Esempio n. 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     AreaCodeValidatorRef.AreaCodeValidatorWebService ac = new AreaCodeValidatorRef.AreaCodeValidatorWebService();
     if (ac.IsValid(DropDownListAreaCode.SelectedValue, DropDownListState.SelectedValue))
     {
         lblAreaCodeError.Text = "";
         if (CheckBoxRemind.Checked)
         {
             //add Date of Birth in a Cookie
             HttpCookie DOBCookie = new HttpCookie("DOBCookie", DropDownListDay.SelectedValue + "/" + DropDownListMonth.SelectedValue);
             // Set the cookie expiration date.
             DOBCookie.Expires = DateTime.Now.AddMonths(1);
             // Add the cookie.
             Response.Cookies.Add(DOBCookie);
             //Response.Write("<p> The cookie has been written.");
         }
         else
         {
             //Delete Date of Birth in a Cookie
             HttpCookie DOBCookie = new HttpCookie("DOBCookie");
             // Set the cookie expiration date.
             DOBCookie.Expires = DateTime.Now.AddMonths(-1);
             // Add the cookie.
             Response.Cookies.Add(DOBCookie);
             //Response.Write("<p> The cookie has been written.");
         }
         //save in file
         AddSearchRef.AddSearchWebService a = new AddSearchRef.AddSearchWebService();
         a.AddContact(txtboxFirstname.Text, txtboxLastname.Text, DropDownListAreaCode.SelectedValue, txtboxPhoneNO.Text, txtboxAddr.Text, DropDownListState.SelectedValue, txtboxEmail.Text, DropDownListDay.SelectedValue + "/" + DropDownListMonth.SelectedValue + "/" + DropDownListYear.SelectedValue);
         //
         Response.Redirect("SearchPage.aspx", true);
     }
     else
         lblAreaCodeError.Text = "The selected area code is not valid in the selected state!";
 }
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     PanelResult.Visible = true;
     AddSearchRef.AddSearchWebService s = new AddSearchRef.AddSearchWebService();
     switch (DropDownList1.SelectedValue)
     {
         case "Phone Number":
             {
                 if (s.SearchByPhone(txtboxSearchPhoneNO.Text) != "")
                     lblResultFN.Text = s.SearchByPhone(txtboxSearchPhoneNO.Text);
                 else
                     lblResultFN.Text = "Not Found!";
                 lblResultPhN.Text = txtboxSearchPhoneNO.Text;
                 break;
             }
         case "Last name":
             {
                 if (s.SearchByName(txtboxSearchLastname.Text) != "")
                     lblResultPhN.Text = s.SearchByName(txtboxSearchLastname.Text);
                 else
                     lblResultPhN.Text = "Not Found!";
                 lblResultFN.Text = txtboxSearchLastname.Text;
                 break;
             }
     }
 }