Exemplo n.º 1
0
        public override void btn_Delete_Click(object sender, EventArgs e)
        {
            int?customerID = 0;

            if (dgrid_Result.Rows[dgrid_Result.SelectedCells[0].RowIndex].Cells["CustomerID"].Value != null)
            {
                if (MessageBox.Show("هل نت متأكد من حذف العميل؟", "تحذير", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    customerID = Convert.ToInt32(dgrid_Result.Rows[dgrid_Result.SelectedCells[0].RowIndex].Cells["CustomerID"].Value);
                    BDCustomerPrimaryKey customerPK = new BDCustomerPrimaryKey();
                    customerPK.CustomerID = customerID;
                    try
                    {
                        _bDCustomerWrapper.Delete(customerPK);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("لا يمكن مسح هذا العميل .. حيث انه مرتبط بفواتير");
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("لابد من اختيار عميل");
            }
            Search();
        }