示例#1
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            ClientBll   clientBll;
            EmployeeBll employeeBll;
            SupplierBll supplierBll;

            try
            {
                if (MessageBox.Show("هل أنت متأكد من حذف الحساب؟") == 1)
                {
                    int num1   = Convert.ToInt32(this.dgvAccounts.SelectedRows[0].Cells[0].Value);
                    int parent = this.accounts.getParent(num1);
                    int num2   = parent;
                    if (num2 != 0)
                    {
                        switch (num2)
                        {
                        case 0:
                        {
                            this.accounts.DeleteBankAccount(num1);
                            break;
                        }

                        case 1:
                        {
                            clientBll = new ClientBll();
                            clientBll.deleteClient(num1);
                            break;
                        }

                        case 2:
                        {
                            employeeBll = new EmployeeBll();
                            employeeBll.deleteEmployee(num1);
                            break;
                        }

                        case 32:
                        {
                            supplierBll = new SupplierBll();
                            supplierBll.deleteSupplier(num1);
                        }
                        }
                    }
                    else
                    {
                        this.accounts.DeleteAccount(num1);
                    }
                    MessageBox.Show("تم الحذف");
                    AccountsViewDataTable accountsView = this.accounts.GetAccountsView();
                    accountsView.BalanceColumn.ColumnName       = "الرصيد";
                    accountsView.Category_NameColumn.ColumnName = "نوع الحساب";
                    accountsView.GL_IDColumn.ColumnName         = "رقم الحساب";
                    accountsView.GL_Name_VCColumn.ColumnName    = "اسم الحساب";
                    accountsView.ParentColumn.ColumnName        = "تابع لحساب";
                    accountsView.Status_BTColumn.ColumnName     = "مفعل";
                    this.dgvAccounts.DataSource = accountsView;
                    this.dgvAccounts.Columns["BS_Category_VC"].Visible = false;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }