Ejemplo n.º 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";
         }
     }
 }
Ejemplo n.º 2
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";
         }
     }
 }
Ejemplo n.º 3
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";
                }
            }
        }