コード例 #1
0
 protected void btSave_Click(object sender, EventArgs e)
 {
     lblAreaError.Text = "";
     ValidityAreaCode v = new ValidityAreaCode();
     if (v.IsValid(ddlState.SelectedItem.Value, ddlAreaCode.SelectedItem.Value) == false)
     {
         lblAreaError.Text = "The selected area code is not valid in the selected state!";
     }
     else
     { 
         PhoneService ac = new PhoneService();
         int date, month, year;
         int.TryParse(ddlDate.SelectedItem.Value, out date);
         month = getValue(ddlMonth.SelectedItem.Value);
         int.TryParse(ddlYear.SelectedItem.Value, out year);
         bool saveStatus = ac.addContact(txtFirstName.Text, txtLastname.Text, ddlTitle.SelectedItem.Value, 
                                         ddlAreaCode.SelectedItem.Value, txtPhoneNumber.Text, txtAddress.Text, 
                                         ddlState.SelectedItem.Value, txtEmail.Text, txtComment.Text,
                                         chkRemember.Checked,  new DateTime(year, month, date), (int)this.Session["login"]);
         if (saveStatus)
         {
             lblResult.Text = "Contact Saved";
         }
         else
         {
             lblResult.Text = "Unable to save contact information. Same name or number exists";
         }
     }
 }
コード例 #2
0
 protected void btSearch_Click(object sender, EventArgs e)
 {
     PhoneService ps = new PhoneService();
     List<string> result;
     if (ddlSearchBy.Text == "Full Name")
     {
         string []words = txtSearchCriteria.Text.Split(' ');
         if (words.Length != 2)
             lblResult.Text = "Please enter full Name";
         else
         {
             result = ps.searchByFullName(words[0], words[1]);
             if (result == null)
             {
                 lblResult.Text = "No result found";
                 PanelResult.Visible = false;
             }
             else
             {
                 lblResult.Text = "";
                 btEdit.Visible = true;
                 PanelResult.Enabled = false;
                 panelResult(result);
             }
         }
     }
     else
     {
         if (txtSearchCriteria.Text.Length != 8)
             lblResult.Text = "Phone Number Length Invalid";
         else
         {
             result = ps.searchByPhone(txtSearchCriteria.Text);
             if (result == null)
             {
                 lblResult.Text = "No result found";
                 PanelResult.Visible = false;
             }
             else
             {
                 lblResult.Text = "";
                 btEdit.Visible = true;
                 PanelResult.Enabled = false;
                 panelResult(result);
             }
         }
     }
 }
コード例 #3
0
 protected void btSave_Click(object sender, EventArgs e)
 {
     lblAreaError.Text = "";
     ValidityAreaCode v = new ValidityAreaCode();
     if (v.IsValid(ddlState.SelectedItem.Value, ddlAreaCode.SelectedItem.Value) == false)
     {
         lblAreaError.Text = "The selected area code is not valid in the selected state!";
     }
     else
     {
         PhoneService ac = new PhoneService();
         List<string> content = new List<string> { txtFirstName.Text, txtLastname.Text, ddlTitle.SelectedItem.Value, ddlAreaCode.SelectedItem.Value, txtPhoneNumber.Text, txtAddress.Text, ddlState.SelectedItem.Value, txtEmail.Text, ddlYear.Text+"-"+ddlMonth.Text+"-"+ddlDate.Text, chkRemember.Checked.ToString(), txtComment.Text };               
         bool saveStatus = ac.addContact(content);
         if (saveStatus)
         {
             lblResult.Text = "Contact Saved";
         }
         else
         {
             lblResult.Text = "Unable to save contact information. Same name or number exists";
         }
     }
 }
コード例 #4
0
        protected void btUpdate_Click(object sender, EventArgs e)
        {
            ValidityAreaCode v = new ValidityAreaCode();
            if (v.IsValid(ddlState.SelectedItem.Value, ddlAreaCode.SelectedItem.Value) == false)
            {
                lblResult.Text = "The selected area code is not valid in the selected state!";

            }
            else
            {
                PhoneService ac = new PhoneService();
                List<string> content = new List<string> { txtFirstName.Text, txtLastname.Text, ddlAreaCode.SelectedItem.Value, txtPhoneNumber.Text, txtAddress.Text, ddlState.SelectedItem.Value, txtEmail.Text, ddlYear.Text + "-" + ddlMonth.Text + "-" + ddlDate.Text, lblID.Text };
  

                bool updateStatus = ac.updateContact(content);
                if (updateStatus)
                {
                    lblResult.Text = "Contact Updated";
                }
                else
                {
                    lblResult.Text = "Unable to update contact information. Same name or number exists";
                }
            }
        }