Пример #1
0
        private void dgvCustomerList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 13)
                {
                    //DeleteForCustomer
                    if (!CheckingRoleManagementFeature("CustomerEditOrDelete"))
                    {
                        MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    DialogResult result = MessageBox.Show(this, "Are you sure you want to delete?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.OK))
                    {
                        DataGridViewRow row = dgvCustomerList.Rows[e.RowIndex];
                        customerID = Convert.ToString(row.Cells[0].Value);

                        dgvCustomerList.DataSource = "";
                        Customer customer = (from c in mbsEntities.Customers where c.CustomerID == customerID select c).FirstOrDefault();
                        customer.Active        = false;
                        customer.DeletedUserID = UserID;
                        customer.DeletedDate   = DateTime.Now;
                        customerController.DeleteCustomer(customer);
                        dgvCustomerList.DataSource = (from c in mbsEntities.Customers where c.Active == true orderby c.CustomerCode descending select c).ToList();
                        MessageBox.Show(this, "Successfully Deleted!", "Delete Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        FormRefresh();
                    }
                }
                else if (e.ColumnIndex == 11)
                {
                    if (!CheckingRoleManagementFeature("CustomerView"))
                    {
                        MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    DetailCustomerfrm detailCustomerForm = new DetailCustomerfrm();
                    detailCustomerForm.customerID = Convert.ToString(dgvCustomerList.Rows[e.RowIndex].Cells[0].Value);
                    detailCustomerForm.ShowDialog();
                }
                else if (e.ColumnIndex == 12)
                {
                    //EditCustomer
                    if (!CheckingRoleManagementFeature("CustomerEditOrDelete"))
                    {
                        MessageBox.Show("Access Denied for this function.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    Customerfrm customerForm = new Customerfrm();
                    customerForm.isEdit     = true;
                    customerForm.Text       = "Edit Customer";
                    customerForm.customerID = Convert.ToString(dgvCustomerList.Rows[e.RowIndex].Cells[0].Value);
                    customerForm.UserID     = UserID;
                    customerForm.ShowDialog();
                    this.Close();
                }
            }
        }
Пример #2
0
 private void dgvCustomerList_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         if (e.ColumnIndex == 11)
         {
             DetailCustomerfrm detailCustomerForm = new DetailCustomerfrm();
             detailCustomerForm.customerID = Convert.ToString(dgvCustomerList.Rows[e.RowIndex].Cells[0].Value);
             detailCustomerForm.ShowDialog();
         }
     }
 }