Ejemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string errMsg = ValidateForm();

                if (errMsg != string.Empty)
                {
                    MessageBox.Show(errMsg);
                }
                else
                {
                    ContactsBL contactsBL = new ContactsBL();
                    populateContact();

                    if (contactsBL.UpdateContact(contact) == true)
                    {
                        PopulateDGV();
                        MessageBox.Show("Contact update successful");
                    }
                    else
                    {
                        MessageBox.Show("Contact update failed");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
    protected void ContactDataView_CustomCallback(object sender, CallbackEventArgsBase e)
    {
        if (string.IsNullOrEmpty(e.Parameter))
        {
            return;
        }
        var args = e.Parameter.Split('|');

        if (args[0] == "Delete" && args.Length == 2)
        {
            int id;
            if (!int.TryParse(args[1], out id))
            {
                return;
            }
            ContactsBL bl = new ContactsBL();
            bl.DeleteContact(id);
            BindDataView();
        }
        if (args[0] == "SaveContact")
        {
            var name     = ContactNameEditor.Text;
            var email    = ContactEmailEditor.Text;
            var address  = ContactAddressEditor.Text;
            var country  = ContactCountryEditor.Text;
            var city     = ContactCityEditor.Text;
            var phone    = ContactPhoneEditor.Text;
            var photoUrl = Utils.GetUploadedPhotoUrl(args[2]);
            int id;
            if (args.Length == 4 && args[1] == "Edit" && int.TryParse(args[3], out id))
            {
                ContactsBL bl = new ContactsBL();
                bl.UpdateContact(id, name, email, address, country, city, phone, photoUrl);
            }
            else if (args.Length == 3 && args[1] == "New")
            {
                ContactsBL bl = new ContactsBL();
                bl.AddContact(name, email, address, country, city, photoUrl, photoUrl);
            }

            BindDataView();
        }
    }
Ejemplo n.º 3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string errMsg = ValidateForm();

                if (errMsg != string.Empty)
                {
                    lblMessage.Text = errMsg;
                }
                else
                {
                    ContactsBL contactsBL = new ContactsBL();
                    populateContact();
                    if (Session["Timestamp"] != null)
                    {
                        contact.TimeStamp = (byte[])Session["Timestamp"];
                    }

                    if (contactsBL.UpdateContact(contact) == true)
                    {
                        PopulateDDL();
                        lblMessage.Text = "Contact update successful";
                    }
                    else
                    {
                        lblMessage.Text = "Contact update failed";

                        foreach (ValidationError ve in contactsBL.ValidationErrors)
                        {
                            lblMessage.Text = ve.Description.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }