Exemple #1
0
        private void BtnAddCustomers_Click(object sender, EventArgs e)
        {
            AdminAddCustomer cust = new AdminAddCustomer(this);

            cust.PopulateRouteCombobox();
            cust.BtnSave.Visible   = true;
            cust.BtnSave.Location  = new System.Drawing.Point(118, 641);
            cust.BtnUpdate.Visible = false;
            cust.Show();
        }
Exemple #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                AdminAddCustomer c = new AdminAddCustomer(this);

                c.lblID.Text           = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                c.txtCustomerName.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                c.txtOwnerName.Text    = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                c.txtAddress.Text      = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                c.txtRoute.Text        = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                c.txtPhone.Text        = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                c.txtTelephone.Text    = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
                c.txtEmail.Text        = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
                c.cbxActive.Text       = dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();

                //Hide the Save Button
                c.BtnSave.Visible = false;

                //Show Only the Update Button
                c.BtnUpdate.Visible = true;
                c.lbl1.Text         = "Update Customer Information";
                c.PopulateRouteCombobox();
                c.Show();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete the Customer Information?", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("DELETE FROM tblCustomer WHERE id like '" + dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Customer Information has been successfully Deleted", "Customer Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ShowCustomersInformation();
                }
            }
        }