Пример #1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            frmAddModifyCustomer modifyCustomerForm = new frmAddModifyCustomer();

            modifyCustomerForm.addCustomer = false;
            modifyCustomerForm.customer    = customer;
            DialogResult result = modifyCustomerForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                customer = modifyCustomerForm.customer;
                this.DisplayCustomer();
            }
            else if (result == DialogResult.Retry)
            {
                this.GetCustomer(customer.CustomerID);
                if (customer != null)
                {
                    this.DisplayCustomer();
                }
                else
                {
                    this.ClearControls();
                }
            }
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     frmAddModifyCustomer addCustomerForm = new frmAddModifyCustomer();
     addCustomerForm.addCustomer = true;
     DialogResult result = addCustomerForm.ShowDialog();
     if (result == DialogResult.OK)
     {
         customer = addCustomerForm.customer;
         txtCustomerID.Text = customer.CustomerID.ToString();
         this.DisplayCustomer();
     }
 }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddModifyCustomer addCustomerForm = new frmAddModifyCustomer();

            addCustomerForm.addCustomer = true;
            DialogResult result = addCustomerForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                customer           = addCustomerForm.customer;
                txtCustomerID.Text = customer.CustomerID.ToString();
                this.DisplayCustomer();
            }
        }
Пример #4
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            frmAddModifyCustomer addModifyCustomerForm = new frmAddModifyCustomer();

            addModifyCustomerForm.addCustomer = false;
            addModifyCustomerForm.customer    = selectedCustomer;
            DialogResult result = addModifyCustomerForm.ShowDialog();

            if (result == DialogResult.OK || result == DialogResult.Retry)
            {
                try
                {
                    selectedCustomer = addModifyCustomerForm.customer;
                    this.DisplayCustomer();
                    entities.SaveChanges();
                }
                // Add concurrency error handling.
                // Place the catch block before the one for a generic exception.
                catch (DbUpdateConcurrencyException ex)
                {
                    ex.Entries.Single().Reload();
                    if (entities.Entry(selectedCustomer).State
                        == EntityState.Detached)
                    {
                        MessageBox.Show("Another user has deleted that customer.",
                                        "Concurrency Error");
                        txtCustomerID.Text = "";
                        this.ClearControls();
                    }
                    else
                    {
                        MessageBox.Show("Another user has updated that customer.",
                                        "Concurrency Error");
                        this.DisplayCustomer();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
            else
            {
                txtCustomerID.Text = "";
                this.ClearControls();
            }
        }
        private void btnModify_Click(object sender, EventArgs e)
        {
            frmAddModifyCustomer addModifyCustomerForm = new frmAddModifyCustomer();

            addModifyCustomerForm.addCustomer = false;
            addModifyCustomerForm.customer    = selectedCustomer;
            DialogResult result = addModifyCustomerForm.ShowDialog();

            if (result == DialogResult.OK || result == DialogResult.Retry)
            {
                selectedCustomer = addModifyCustomerForm.customer;
                this.DisplayCustomer();
            }
            else
            {
                txtCustomerID.Text = "";
                this.ClearControls();
            }
        }
 private void btnModify_Click(object sender, EventArgs e)
 {
     frmAddModifyCustomer modifyCustomerForm = new frmAddModifyCustomer();
     modifyCustomerForm.addCustomer = false;
     modifyCustomerForm.customer = customer;
     DialogResult result = modifyCustomerForm.ShowDialog();
     if (result == DialogResult.OK)
     {
         customer = modifyCustomerForm.customer;
         this.DisplayCustomer();
     }
     else if (result == DialogResult.Retry)
     {
         this.GetCustomer(customer.CustomerID);
         if (customer != null)
             this.DisplayCustomer();
         else
             this.ClearControls();
     }
 }