private void btnCustomerAdd_Click(object sender, EventArgs e)
 {
     if (TextBoxValidation(txtCustomerName, txtCustomerSurname, txtContactNumber, txtCustomerEmailAddress))
     {
         DialogResult dr = new DialogResult();
         dr = MessageBox.Show("Are you sure you want to add this customer?", "Are you sure", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             int           isValid;
             CCustomer     customer = new CCustomer();
             SqlConnection conn     = new SqlConnection();
             List <int>    iList    = customer.AddCustomer(conn, txtCustomerName.Text.ToString(), txtCustomerSurname.Text, txtCustomerEmailAddress.Text, txtContactNumber.Text);
             isValid = iList[0];
             if (isValid == 1)
             {
                 MessageBox.Show("Customer has successfully been added.");
                 iCustomerId = iList[1];
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Customer was not added.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 private void btnRemoveCustomer_Click(object sender, EventArgs e)
 {
     if (dgvCustomers.Rows.Count < 1 || txtCustomeID.Text == "" || txtCustomeID.Text == "Generated automatically")
     {
         MessageBox.Show("Please select an item to remove.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DialogResult dr = new DialogResult();
         dr = MessageBox.Show("Are you sure you want to remove this customer?", "Are you sure", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             int       isValid;
             CCustomer customer = new CCustomer();
             isValid = customer.RemoveCustomer(conn, Convert.ToInt32(txtCustomeID.Text));
             if (isValid == 1)
             {
                 MessageBox.Show("Customer has successfully been removed.");
                 RefreshDataSource(dgvCustomers, "sp_GetCustomerInfo");
             }
             else
             {
                 MessageBox.Show("Customer was not removed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 private void btnCustomerEdit_Click(object sender, EventArgs e)
 {
     if (TextBoxValidation(txtCustomerName, txtCustomerSurname, txtContactNumber, txtCustomerEmailAddress))
     {
         DialogResult dr = new DialogResult();
         dr = MessageBox.Show("Are you sure you want to edit this customer?", "Are you sure", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             int       isValid;
             CCustomer customer = new CCustomer();
             isValid = customer.EditCustomer(conn, Convert.ToInt32(txtCustomeID.Text), txtCustomerName.Text, txtCustomerSurname.Text, txtContactNumber.Text, txtCustomerEmailAddress.Text);
             if (isValid == 1)
             {
                 MessageBox.Show("Customer has successfully been updated.");
                 RefreshDataSource(dgvCustomers, "sp_GetCustomerInfo");
                 CustomerLayoutChange();
             }
             else
             {
                 MessageBox.Show("Customer was not updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }