dotNetDummi 0 Junior Poster in Training

Hi all,

Is it possible to insert a SQL statement where I specify the time, and not the date. I do need the date, but I want it to be the current date when I run the insert statement. The time got to be fixed.

For example,
Insert into xxx
Values(current_date + '12:00:00');

Anyone have any idea if SQL allows this?

I look forward to your reply.
Thanks in advance.

dotNetDummi 0 Junior Poster in Training

Hi all,
I'm working on a multimedia player with VB6 now.
I have reached to a stage where my media player can play and stop music that I have selected, but path and file name are english characters.
how can I play files that have chinese characters for their file name and path?

Please advise.

Thanks.

dotNetDummi 0 Junior Poster in Training

I did it!

I used two loops and managed to product the results in ascending order.

dotNetDummi 0 Junior Poster in Training

This is something that I can think of, but I know it will be tedious and not good if I continue.

Dim temp As Integer
    
    If (a2 < a1) Then 'if a2 is smaller than a1
        temp = a2   'store a2 into temp
        a2 = a1     'a2 change to a1
        a1 = temp   'a1 replace with a2(first number) = temp
    End If

    'continue to compare other variables with a1 
    'restart comparison then move on to a2 till a7.
dotNetDummi 0 Junior Poster in Training

Hi all, I'm new to VB and I am doing a lottery program.

I managed to produce 7 random numbers but I am stuck with the sorting. All I can think of is to use if statements to do comparsion, but that will be a long way to do it and is very stupid if I do that .

I understand that there are bubble sorting, but I am not sure how to implement it.
I have another one which is to store the 7 numbers into 7 labels. And it's similar as below (just that a1 replace with Labal1.Caption and etc)

I will appreciate if you can help. Thanks.

Dim a1, a2, a3, a4, a5, a6, a7 As Integer


Private Sub cmdClick_Click()

    cmdClick.Caption = "Please wait.."
    cmdClick.Enabled = False
    Sleep 2000 ' wait for 2 seconds.
        
    a1 = Random(1, 45)
    
    a2 = Random(1, 45)
        If (a2 = a1) Then
            a2 = Random(1, 45)
        End If
        
    a3 = Random(1, 45)
        If (a3 = a2) Or (a3 = a1) Then
            a3 = Random(1, 45)
        End If
        
    a4 = Random(1, 45)
        If (a4 = a2) Or (a4 = a1) Or (a4 = a3) Then
            a4 = Random(1, 45)
        End If
        
    a5 = Random(1, 45)
        If (a5 = a4) Or (a5 = a3) Or (a5 = a2) Or (a5 = a1) Then
            a5 = Random(1, 45)
        End If
        
    a6 = Random(1, 45)
        If (a6 = a5) Or (a6 = a4) Or (a6 = a3) Or (a6 = a2) …
dotNetDummi 0 Junior Poster in Training

I found the error. it's about my stored procedure.

dotNetDummi 0 Junior Poster in Training

Hi experts,
I have a project working on C# and ASP.Net.
There's a function for my users to delete a project by the project name, which is the primary key.

However, it is not functioning perfectly.
When the project name is two word(second word more than 4 characters), it could not be deleted.

For example, "Mini Cooper"
I've tested, if the second word is within 4 characters such as "Honda City", it can be deleted.

May I know what is wrong?

dotNetDummi 0 Junior Poster in Training

Erm, Sorry what is the id for that button ?
I mean the top right corner "X" button.

dotNetDummi 0 Junior Poster in Training

Hi experts,

I used Window.showModalDialog to open comment.aspx.

I need to disable the X button(top right button of IE) in my comment.aspx as entering comments is compulsory.

I've done several days of research but to no avail.

I'm guessing that it's not possible even if I use javascript.

Any ideas how can I do that?

dotNetDummi 0 Junior Poster in Training

Thanks for your prompt reply.
I will try that and get back to you if I have any questions. Is that all right?

dotNetDummi 0 Junior Poster in Training

Hi experts, I have a problem with downloading file.
Okay, my project is setup in IIS (pointing to the folder in my desktop) and my users are able to login, upload a file into the folder.

However, they are not able to download the file (except me).
How can I do that?

Please help. The following is my codes for uploading and downloading

//uploading
String projectID = (String)Session["projId"];
        //change the file name
        if (!FileUpload.FileName.Equals(""))
        {           
            // Create a new folder in Docs folder (folder name = projectID)
            System.IO.Directory.CreateDirectory(Server.MapPath("Docs/") + projectID + "/EP");

            // Save the file into the new folder.
            FileUpload.PostedFile.SaveAs(Server.MapPath("Docs/" + projectID + "/EP/" + FileUpload.FileName));
            lblFile.Text = FileUpload.FileName + " is uploaded!";
            lblFile.Visible = true;

        }
//downloading 
DirectoryInfo diSource = new DirectoryInfo(Server.MapPath("Docs/" + pid + "/" + shortForm + "/"));
            string ExactFilename = string.Empty;

            try
            {
                foreach (FileInfo file in diSource.GetFiles(@"*.*"))
                {
                    ExactFilename = file.FullName;
                    System.Diagnostics.Process.Start(ExactFilename);
                }
            }

I understand that this is not "totally downloading a file".
I don't know the file format of each file my user has uploaded.

dotNetDummi 0 Junior Poster in Training

Hi, I need to create two tables in a Ms Word because I have two gridviews.
But the output became "table in table".
How can I "separate" them ?

Word.Table wt1 = oWordApp.Selection.Tables.Add(oWordApp.Selection.Range, GridView1.Rows.Count + 1, 2, ref missing, ref missing);
  Word.Table wt2 = oWordApp.Selection.Tables.Add(oWordApp.Selection.Range, GridView2.Rows.Count + 1, 7, ref missing, ref missing);
dotNetDummi 0 Junior Poster in Training

Hi , thanks for your reply.
Yes. It went into the loop once, which is correct because I have only one record.

dotNetDummi 0 Junior Poster in Training

Hi experts, I have a task to print some data into a word document .I need to set the word document to readOnly.

It's working but user still can edit. Is there any thing I can do whereby user cannot edit the document?

//        Word.ApplicationClass oWordApp = new Word.ApplicationClass();
            //        object missing = System.Reflection.Missing.Value;
            //        object readOnly = true;
            //        object fileName = Server.MapPath("worddoc.doc");
            //        object isVisible = true;
            //        object password =System.Reflection.Missing.Value;
            //        Word.Document oWordDoc = oWordApp.Documents.Add(ref missing, ref missing,
            //        ref missing, ref isVisible);
            //        oWordDoc.Activate();
            //        oWordApp.Selection.TypeText(form);
                    
            //        oWordApp.Selection.TypeParagraph();
            //        oWordDoc.SaveAs(ref fileName,ref missing, ref missing, ref password, ref
            //missing, ref missing,
            //        ref readOnly, ref missing, ref missing, ref missing, ref missing, ref
            //missing, ref missing,
            //        ref missing, ref missing, ref missing);
            //        oWordApp.Application.Quit(ref missing, ref missing, ref missing);

This is another method that I've done but the word document is not read only.

Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=form1.doc");
        Response.Charset = "";
 
        Response.ContentType = "application/vnd.word";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        htmlWrite.Write("<center>"+form+"</center>");
        htmlWrite.WriteBreak(); htmlWrite.WriteBreak();
        
        GridView1.RenderControl(htmlWrite);
        htmlWrite.WriteBreak();
        gv_retrieve_status.RenderControl(htmlWrite);
 
        System.IO.Directory.CreateDirectory(Server.MapPath  ("Docs/") + projectID + "/EP/");
        //(Server.MapPath("Docs/" + projectID + "/Form1/") + projectID + "_form1.doc");
        Response.Write(stringWrite.ToString());
        Response.End();

Please help. Thanks

dotNetDummi 0 Junior Poster in Training

Yes. It does return a row. which is correct.

dotNetDummi 0 Junior Poster in Training

Hi all, I want to retrieve some data from the database and return as a datatable.
However, it does not work. I tried both methods that I could find in the Internet, but it's not working. May I know what have I done wrong? The datatable is returned as null {} .

public static DataTable retrieveView2(string pID)
    {
        SqlConnection conn = new SqlConnection(connString);       
             
        SqlCommand comm = new SqlCommand(
            "Select apname, designation, email, watcherEmail, e.status, reason, responsedate "
            + "from aparty ap, estatus e, endpack ep "
            + "where ap.projectid = ep.projectid "
            + "and e.apid = ap.apid "
            + "and ap.ep = 't' "
            + "and e.status !='Pending' "
            + "and ep.status ='Completed' "
            + "and e.projectID = @pID");


        comm.Connection = conn;
        conn.Open();

        comm.Parameters.AddWithValue("@pID", pID);

        SqlDataReader dr = comm.ExecuteReader();
        DataTable dt = new DataTable();
      
        //method 1 
        dt.load(dr);

        //method 2
        //while (dr.Read())
        //{
        //    DataRow row = dt.NewRow();
        //    row["apname"] = dr["apname"].ToString();
              //continue other rows.
        //    dt.Rows.Add(row);
        //}
        
        conn.Close();
        return dt;
    }

By the way, I will prefer to present the data similiar like SQLServer.
Something like that
column/row | apname | designation | email | watcherEmail | status | reason | responsedate
row 1 | name1 | designation1 | email1 | watcherEmail1 | status1 | reason1 | responsedate1
row 2 | name2 | designation2 | email2 | watcherEmail2 | status2 | reason2 | responsedate2


Please help thanks!

dotNetDummi 0 Junior Poster in Training

Sorry sorry~~ I managed to do it already! it's my careless mistake. but then,
now the problem is i have to click twice at my button then the value in the textbox will be added.

is it i have to add something in page_load()?

below is my code.

protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dropDown = sender as DropDownList;
        int selectedIndex = dropDown.SelectedIndex;
        GridViewRow gvr = dropDown.NamingContainer as GridViewRow;
              
        DropDownList ddl = gvr.FindControl("ddlName") as DropDownList;
        if (ddl.SelectedValue == "others")
        {
            gvr.FindControl("tbxName").Visible = true;
            gvr.FindControl("btnAddName").Visible = true;
        }
        else
        {
            gvr.FindControl("tbxName").Visible = false;
            gvr.FindControl("btnAddName").Visible = false;
        }
    }

protected void gv_retrieve_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //add name
        if (e.CommandName == "addName")
        {
            int index = Convert.ToInt32(e.CommandArgument);           
            GridViewRow gvr = (GridViewRow)gv_retrieve.Rows[index];

            if (gvr.RowType == DataControlRowType.DataRow)
            {
                if (DataControlRowState.Edit > 0 && gvr.RowState > 0)
                {
                    DropDownList ddl = gvr.FindControl("ddlName") as DropDownList;
                    TextBox tbx = (TextBox)gvr.FindControl("tbxName") as TextBox;

                    if (ddl != null)
                    {
                        if (tbx.Text != "")
                        {
                            //check if name exist
                            if (shareDAO.isNameExist(tbx.Text) == false)
                            {
                                ddl.Items.Add(tbx.Text);
                                shareDAO.insertName(tbx.Text);
                                ddl.SelectedValue = tbx.Text;
                                gvr.FindControl("tbxName").Visible = false;
                                gvr.FindControl("btnAddName").Visible = false;
                            }
                            else
                            {
                                Response.Write("<Script language=javascript>alert('Approval Party Name already exist!')</Script>");
                            }
                        }
                    }

                }
            }
        } // end of adding name
}

and this is my aspx.

<asp:TemplateField HeaderText="Name">
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlName" runat="server"
                                Width="172px" DataSourceID="names" AppendDataBoundItems = "true" DataTextField="names" OnSelectedIndexChanged="ddlName_SelectedIndexChanged" AutoPostBack="True">
                            <asp:ListItem Text = "------------"></asp:ListItem>
                            <asp:ListItem Text = "Others" Value ="others" ></asp:ListItem>
                            </asp:DropDownList><br />
                            <asp:TextBox ID="tbxName" runat="server" Visible = "false" AutoPostBack="True">
                            </asp:TextBox>&nbsp;
                            <asp:Button ID="btnAddName" runat="server" Text="Add" Visible="false" CommandName="addName"  CommandArgument="<%# Container.DataItemIndex %>" …
dotNetDummi 0 Junior Poster in Training

Hi all, I have a gridview in my project.

There is a cell that contains a dropdownlist, textbox and button.
My task is when the use clicks "others" in the dropdownlist, the textbox and button should show so that they can add new value into the dropdownlist.

But I got an exception.
"Object reference not set to an instance of an object. " at tbxName.Visible = true

How can I show that?
Please help.

protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dropDown = sender as DropDownList;
        int selectedIndex = dropDown.SelectedIndex;
        GridViewRow gvr = dropDown.NamingContainer as GridViewRow;

       // GridViewRow gvr = (GridViewRow)gv_retrieve.Rows[index];

        DropDownList ddl = gvr.FindControl("ddlName") as DropDownList;
        if (ddl.SelectedValue == "others")
        {
            TextBox tbxName = (TextBox)gv_retrieve.FindControl("tbxName") as TextBox;            
            tbxName.Visible = true;
        }
    }
dotNetDummi 0 Junior Poster in Training

erm, just to clarify, it will be similer like some music web sites right?

I can also do this in gridview, with different links to the uploaded file, am I right?

dotNetDummi 0 Junior Poster in Training

wow~~ That's cool.

So I get the file names and append to the link . aha! I need this method for my search function.
But I have to research on iFrame first.

I know it in Java but not too sure if it refers to internal frame. lol.

Thanks !!! I will try this.

dotNetDummi 0 Junior Poster in Training

First, Thanks for your reply.

oh oh(I have to convince my client to buy the software)...

Erm, is there any other methods to convert these web widgets into some format that is not editable, (I can't use ms word etc)

dotNetDummi 0 Junior Poster in Training

Hi experts,

I've been researching about convert an aspx to pdf but nothing seems to help me.
I found crystal reports but my layout is not just gridview only.

In my aspx, it includes textboxes, labels, tables, gridview. I need to print them to a pdf format automatically.

Due to the limited resources, I can't download the softwares available.

I saw codes like
PdfConverter pdfConverter = new PdfConverter();

(link is http://www.html-to-pdf.net/Support.aspx#csharp)

I tried them but it don't work. What are some other ways I can do?

Thanks in advance.

dotNetDummi 0 Junior Poster in Training

I got it . I used another method found online.

DirectoryInfo diSource = new DirectoryInfo(Server.MapPath("Docs/" + pid + "/EP/"));
        string ExactFilename = string.Empty;

        foreach (FileInfo file in diSource.GetFiles(@"*.*"))
        {
            ExactFilename = file.FullName;
        }      
        System.Diagnostics.Process.Start(ExactFilename);

Just that it opened the application immediately without the filedialog box.

dotNetDummi 0 Junior Poster in Training

okay, I pass a filename already. It works.

Now I have to solve the problem.
To download the files which is "unknown" to my clients' users.

dotNetDummi 0 Junior Poster in Training

Thanks for your reply.
You're fast.

Actually the thing is I wouldn't know what are the files that are being uploaded in the first place.

dotNetDummi 0 Junior Poster in Training

Thanks for your reply.

Nope, I realised that variable ''file'' is empty.
But I thought that's the way to get the filename and extension in a directory path?

May I know how to do that?

dotNetDummi 0 Junior Poster in Training

Hi. Thanks for your reply.
I'm trying to download files. By the way, I'm using C# so doesn't really quite understand the VB code.

I tried this .

protected void btnLink_OnClientClick(object sender, EventArgs e)
    {
        String pid = Convert.ToString(Session["pid"]);
        String file = System.IO.Path.GetFileName(Server.MapPath("Docs/" + pid + "/EP/"));

        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + file);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = "application/octet-stream";
        Response.WriteFile(file);
        Response.End();
    }

But it doesn't work .

Error msg : Access to the path 'C:\Documents and Settings\[machineName]\My Documents\[projectName]' is denied.

Is it because I upload at my documents?
What should I do? Please help. Thanks

dotNetDummi 0 Junior Poster in Training

Hi experts,
I need a linkbutton/button to download the files which my clients have uploaded.

Below is my upload method and it works.

protected void uploadFile()
    {
        String projectID = (String)Session["projId"];
        //change the file name
        if (!FileUpload.FileName.Equals(""))
        {
            // Create a new folder in Docs folder (folder name = projectID)
            System.IO.Directory.CreateDirectory(Server.MapPath("Docs/") + projectID);

            // Save the file into the new folder.
            FileUpload.PostedFile.SaveAs(Server.MapPath("Docs/" + projectID + "/" + FileUpload.FileName));
            lblFile.Text = FileUpload.FileName + " is uploaded!";
            lblFile.Visible = true;

        }
    }//end of method

However, it's not working for downloading of file (in another asp)
May I know how can I do that?

protected void btnLink_OnClientClick(object sender, EventArgs e)
{
   String projectID = (String)Session["projId"];
   String file1 = System.IO.Path.GetFileName(Server.MapPath("Docs/" + pid + "/"));
}

The files format that are uploaded are not consistent. Usually it's excel, word or pdf format.

Please help. Thanks!

dotNetDummi 0 Junior Poster in Training

Thanks! that method worked for me!

dotNetDummi 0 Junior Poster in Training

Thanks

dotNetDummi 0 Junior Poster in Training

Hi experts,

I need a validator in my gridview.
When the user update a field in the gridview, I need to check if the email is valid.
How can I do that?

Below is my gridview.
Please help. Thanks!

<asp:GridView ID="gv_retrieve" runat="server" AutoGenerateColumns="False" CellPadding="3"
        ForeColor="Black" GridLines="Vertical" Width="751px" OnRowEditing="gv_retrieve_RowEditing" 
        OnRowUpdating="gv_retrieve_RowUpdating" onRowCancelingEdit = "gv_retrieve_RowCancelingEdit" 
        OnRowDeleting = "gv_retrieve_RowDeleting" OnRowDataBound = "gv_retrieve_RowDataBound"
        BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" Font-Bold="False">
        <FooterStyle BackColor="#CCCCCC" />
        
        <Columns>
            
            <asp:BoundField DataField="Name" HeaderText="Name" />
            <asp:BoundField DataField="Designation" HeaderText="Designation" />
            <asp:BoundField DataField="Email" HeaderText="Email Address" />
            <asp:BoundField DataField="WatcherEmail" HeaderText="Watcher Email" />
            <asp:CommandField ShowEditButton="True" >
                <ItemStyle Width="35px" />
            </asp:CommandField>
            <asp:CommandField ShowDeleteButton="True" />
            <asp:BoundField DataField="apid">
                <ItemStyle CssClass="hiddencol" />
            </asp:BoundField>
        </Columns>
        <EmptyDataTemplate>
            <table width="100%">
                <tr style="font-weight:bold; text-decoration:underline" align="center">
                    <td>
                        Name
                    </td>
                    <td>
                        Designation
                    </td>
                    <td>
                        Email
                    </td>
                    <td>
                        WatcherEmail
                    </td>
                </tr>                                                                                  
            </table>                        
             <br />
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>
dotNetDummi 0 Junior Poster in Training

Thanks for your reply.

actually I didn't use SQL server to send the email.

I need a function whereby i retrieve the email address if there is no response from the users' clients after 3 days.

My Console Application contained the sql statements and the Stmp mail..

It's working if I run.. But still, I'm not too sure if this is the method I should use.

Sorry to trouble you.

dotNetDummi 0 Junior Poster in Training

Hi.. I've developed the console application already.

Now I have a question.
In the end, the database which is attached to my web application will be deployed in a web server.

Will this console application (install in one of my user's PC) connect to that database?

The connection string is the same.

Is there anything I've to do or I can just install the exe file to my user's PC and it will be link to the database in the web server?

dotNetDummi 0 Junior Poster in Training

Thanks!

dotNetDummi 0 Junior Poster in Training

Hi, thanks for your reply.
I am not able to install that to my clients' computer so I think I'll go for method two.

Erm, I need to ask you something.
My database is using MS SQL Server.
So if my users don't have to login to the system and the database is able to trigger the method (sending email accordingly) itself?

Sorry, I don't understand about database mail.

Thanks for your reply.

dotNetDummi 0 Junior Poster in Training

Hi, Thanks for your reply.
Erm, if I deploy this website app to the web-server,
I should be using method two. am I correct?

hi,
there are different options to send email automatically
1) you can use windows schedular in u r computer to send them
the following urls will help u :
http://blogs.msdn.com/dditweb/archive/2006/10/09/Windows-Services-Or-Task-Scheduler_3F00_-_2D00_-Part-I.aspx
http://www.gridviewguy.com/ArticleDetails.aspx?articleID=32

2)u can achieve the same functionality using sql server,if u are using that in u r project.
first u need to configure the sql to send emails the procedure and requirements for a computer to send email are given below,hope it helps

Requirements for Domain User Account


All domain user accounts must have permission to:
Access and change the SQL Server directory (\Program Files\Microsoft SQL Server\Mssql).-->the server account we r using should be db owner.
Access and change the .mdf, .ndf, and .ldf database files.
Log on as a service.-->go to control panel->administrator tools->services->local security settings->local policies->user rights assignment->double click we will get logon as service->check whether the account is included in the list displayed otherwise add
Read and write registry keys at and under:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer.
-or- for any named instance: HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server.
start->run>regedit>HKEY_LOCAL_MACHINE>Software>
Microsoft>mssqlserver>right click and check for permisions and check whether u r account is listed or not
HKEY_LOCAL_MACHINE\System\CurrentControlset\Services\MSSQLServer.
-or- for any named instance: HKEY_LOCAL_MACHINE\System\CurrentControlset\Services\MSSQL$Instancename. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Perflib. start>run>regedit>HKEY_LOCAL_MACHINE>System>
currentcontrolset>services>mssqlserver>right click and check for permisions and check whether u …

dotNetDummi 0 Junior Poster in Training

I am working on a web-based app, and I need to implement a function whereby it checks the dates daily, and send reminder email automatically.

May I know how can I do that? I saw some websites that mentioned about Console Application and Windows Scheduler.
Is that what I need? If so, how can I link to my app?
Otherwise, what are the methods that are available?

I'm new to C# and asp.net, please help.
Thanks.

dotNetDummi 0 Junior Poster in Training

I've two tables where their composite keys are foreign keys that references each other.

table1 (projId, userId, name, add)
table2 (projId, userId, status, responseDate, reason)

I need to retrieve table1(name,add) and table2( status, responseDate, reason) with projId only..

my query is

Select ap.name, ap.add, p.status,
p.responseDate, p.reason 
from table1 ap, table2 p
where p.projID = ap.projID 
and ap.userId = p.userId
and p.projectID = 'test1'

but the output is like this:

Name Add Status responseDate Reason
name1 123 Pending 21-11-2007
name1 123 Approved 21-11-2007
name1 123 Rejected 21-11-2007 Invalid name provided


The last three columns are correct but name and add is not.
I need my result to be like

Name Add Status responseDate Reason
name1 123 Pending 21-11-2007
name2 456 Approved 21-11-2007
name3 789 Rejected 21-11-2007 Invalid name provided

What have I do wrong? Please help. Thanks
table2 is the parent table.


This is my create statements

create table table1 (
projectid varchar(10),
userid int identity(1,1),
name varchar(50),
add varchar(20),
email varchar(80),
primary key (projectid, apid)
);

create table table2(
projectid varchar(10),
userid int,
status varchar(15),
reason varchar(100),
responseDate varchar(15),
primary key (projectid,userid),
constraint fk_table1 foreign key (projectid, apid) references table2(projectid, apid)
);
dotNetDummi 0 Junior Poster in Training

I've found something.
Is it console application , windows scheduler?

Erm, then I would have two applications?
Sorry, I'm really confused and have no idea.

Appreciate your help.
Thanks in advance.

dotNetDummi 0 Junior Poster in Training

In short, it's like automatic send reminder emails.

Sorry if I am confusing anyone...

dotNetDummi 0 Junior Poster in Training

Hey, Hihi,
The verification code is done!
It's working perfectly.
Thanks for your help.

Now I have another problem.

I need to send reminder emails to approval parties if they do not respond within 3 days upon submission. How can I do that? I know the methods.. But I don't know how to call the methods, like running "live" 24/7.

I thought of calling the methods when the admins login into the system, but I don't think they will login daily ... So is there any method to let it run daily?

Erm, any advices?
Thanks.

dotNetDummi 0 Junior Poster in Training

Yeah, Thanks for your help all this while

dotNetDummi 0 Junior Poster in Training

I see. Thanks.
I think I will not edit about that anymore.

dotNetDummi 0 Junior Poster in Training

Hi, I'm working on Switch right now.
I saw switch statements online.

Switch (variable)
{
   case 1: //do something
   case 2: //do something else
   break;
}

but I don't know what variable I need for my case. Er can you please help?
I'm trying to use switch instead of if-else...

if (!txtEmail1.Text.Equals("")) 
        {
            msgMail1.From = new MailAddress(txtPCEmail.Text);
            if (!txtBackupEmail.Text.Equals(""))
            {
                msgMail1.CC.Add(new MailAddress(txtBackupEmail.Text));
            }

            msgMail1.Subject = "TEST EMAIL for VR Documents (EndPack) - " + projectID;

            msgMail1.IsBodyHtml = true;

            String v_code = generateVCode();
            vc = new VerCode(v_code,"1",projectID);            
            VerCodeDAO.addVCode(vc);

            msgMail1.Body = body + v_code + footer;

            MailAddress to1 = new MailAddress(txtEmail1.Text);

            if (!txtWatcherEmail1.Text.Equals(""))
            {
                MailAddress cc1 = new MailAddress(txtWatcherEmail1.Text);
                msgMail1.CC.Add(cc1);
            }
            msgMail1.To.Add(to1);
          
            
        }

        if (!txtEmail2.Text.Equals(""))
        {
            msgMail2.From = new MailAddress(txtPCEmail.Text);
            if (!txtBackupEmail.Text.Equals(""))
            {
                msgMail2.CC.Add(new MailAddress(txtBackupEmail.Text));
            }

            msgMail2.Subject = "TEST EMAIL for VR Documents (EndPack) - " + projectID;

            msgMail2.IsBodyHtml = true;

            String v_code = generateVCode();
            vc = new VerCode(v_code, "2", projectID);
            VerCodeDAO.addVCode(vc);

            MailAddress to2 = new MailAddress(txtEmail2.Text);

            if (!txtWatcherEmail2.Text.Equals(""))
            {
                MailAddress cc2 = new MailAddress(txtWatcherEmail2.Text);
                msgMail2.CC.Add(cc2);
            }
            msgMail2.To.Add(to2);
            msgMail2.Body = body + v_code + footer;
          
        }
dotNetDummi 0 Junior Poster in Training

Thanks for your help... =)
I will keep you update... Hopefully, I don't need to trouble you so much anymore... =)

dotNetDummi 0 Junior Poster in Training

Cool. I got it already. It's working perfectly. Thanks man~
So now I can use the v_code, from here it's similar with login right?

get the v_code from the textbox, check who is the user or valid v_code then show the output?
am i right?

by the way, erm, there's no other options then if-else statements/switch??

sorry.

dotNetDummi 0 Junior Poster in Training

Cool, I understand already. Thanks..
Erm, Now I have an error with my email.

I have 2 recipents, both vercode and apid in the database are different.

however, both the recipents receive the same vercode. the first recipents receive the second recipent's ver_code(different from database).

String body = "<html><body>Hi, <br><br>&nbsp;&nbsp;&nbsp; 
             "<br>&nbsp;&nbsp;&nbsp;<a href='<link>/'> VDAS </a> <br>&nbsp;&nbsp;&nbsp;Your Verification code is : <b>";

        String footer = "</b><br>&nbsp;&nbsp;&nbsp;Thank You!" +
            "<br><br>Regards, <br>Team</body></html>";

        VerCode vc = new VerCode();

        if (!txtEmail1.Text.Equals("")) 
        {
            String v_code = generateVCode();
            vc = new VerCode(v_code,"1",projectID);            
            VerCodeDAO.addVCode(vc);

            msgMail.Body = body + v_code + footer;

            MailAddress to1 = new MailAddress(txtEmail1.Text);

            if (!txtWatcherEmail1.Text.Equals(""))
            {
                MailAddress cc1 = new MailAddress(txtWatcherEmail1.Text);
                msgMail.CC.Add(cc1);
            }
            msgMail.To.Add(to1);


        }

        if (!txtEmail2.Text.Equals(""))
        {
            String v_code = generateVCode();
            vc = new VerCode(v_code, "2", projectID);
            VerCodeDAO.addVCode(vc);

            MailAddress to2 = new MailAddress(txtEmail2.Text);

            if (!txtWatcherEmail2.Text.Equals(""))
            {
                MailAddress cc2 = new MailAddress(txtWatcherEmail2.Text);
                msgMail.CC.Add(cc2);
            }
            msgMail.To.Add(to2);
            msgMail.Body = body + v_code + footer;

        }

       smtp.Send(msgMail);

I tried and put smtp.Send(msgMail); into each if statement but it's worst.

I apologise for troubling you but please advice. Thanks a Million. By the way, I find that it's not good to use if statements for checking of each txtbox (null or not) because I've 5 textboxes.

Other than using switch is there any methods for me to use? I thought of using for loop. is it possible. if so, can you please give me some hints/tips on the coding ...

dotNetDummi 0 Junior Poster in Training

Hi and thanks for your reply,

I found the method of generating numbers. It's working... But how can I improve it so that the code are not repeated as v_code is my primary key in my database.

the method is as follows:

//Generate v_code
private String generateVCode()
{        
    char[] normalChars = "qwertyuiopasdfghjklzxcvbnm1234567890".ToCharArray();

    string code = string.Empty;

    for (int i = 0; i < 20; i++)
    {
        char n = ' ';

        n = normalChars[GetRandomNumber(normalChars.Length - 1)];

        if (i % 2 == 0)
            code += n.ToString().ToUpper();

        else
            code += n;
    }
    return code;
}

//Get Random Number
public static int GetRandomNumber(int maxvalue)
{
    System.Security.Cryptography.RandomNumberGenerator random =

    System.Security.Cryptography.RandomNumberGenerator.Create();

    byte[] r = new byte[1];

    random.GetBytes(r);

    double val = (double)r[0] / byte.MaxValue;

    int i = (int)Math.Round(val * maxvalue, 0);

    return i;
}

Thank you in advance.

dotNetDummi 0 Junior Poster in Training

yeah. But these people don't have a userid , so i actually gave them an id in the table approvalParties.

Erm, then I can use the apid to identify them, am i right to say so?

dotNetDummi 0 Junior Poster in Training

Hi, thanks for your reply, just to clarify something..

approvalParties (APId, projectId, name, designation, email, watcherEmail)

ver_code (v_code, apid)

am I right?