Пример #1
0
 /// <summary>
 /// Button to get the data from the current selected customer in the data grid view and writes it on the variable "currentSelectedCustomer"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnEditCustomer_Click(object sender, EventArgs e)
 {
     if (this.dgvListCustomer.SelectedCells.Count != 0)
     {
         try
         {
             Customer       currentSelectedCustomer = Customer.GetCustomerWithNumber(Int32.Parse(this.dgvListCustomer.SelectedRows[0].Cells[0].Value.ToString()));
             FrmAddEditCust dialog = new FrmAddEditCust(currentSelectedCustomer);    //Calling the subwindow "FrmAddEditCust" for editing customers
                                                                                     //transfers the current selected customer into the subwindow for editing the E-Mail and the last name
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 UpdateDataList(currentSelectedCustomer);            //the list gets updated again to upload the edited customer in the data grid view.
             }
         }
         catch (IOException ex)
         {
             MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         catch (System.Security.Cryptography.CryptographicException ex)
         {
             MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("There is no customer selected, who can be changed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        /// <summary>
        /// Button "btnAddCustomer" opens the subwindow "FrmAddEditCust"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            FrmAddEditCust dialog = new FrmAddEditCust(); //Calling the subwindow "FrmAddEditCust" for adding customers

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                tbxEntry.Text = string.Empty;
                UpdateDataList(dialog.ACustomer); //the list gets updated again to upload the new customer in the data grid view.
                this.dgvListCustomer.FirstDisplayedScrollingRowIndex = dgvListCustomer.RowCount - 1;
            }
        }