コード例 #1
0
        private void tsbDeleteBankBranch_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgBranches.SelectedRows.Count != 0)
                {
                    DAL.BankBranch bankbranch = (DAL.BankBranch)bsBranches.Current;

                    var _employeeswithBanksortcodequery = from em in rep.GetAllActiveEmployees()
                                                          join bb in db.BankBranches on em.BankCode equals bb.BankSortCode
                                                          where bb.BranchCode == bankbranch.BranchCode
                                                          select em;

                    List <Employee> _employees = _employeeswithBanksortcodequery.ToList();

                    if (_employees.Count > 0)
                    {
                        MessageBox.Show("There is an Employee Associated with this Branch.\n Delete the Employee First!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete Branch\n" + bankbranch.BranchName.ToString().Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                        {
                            db.BankBranches.DeleteObject(bankbranch);
                            db.SaveChanges();
                            RefreshBankGrid();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
コード例 #2
0
 private void dgBranches_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgBranches.SelectedRows.Count != 0)
     {
         try
         {
             DAL.Bank             bank       = (DAL.Bank)bsBanks.Current;
             DAL.BankBranch       bankbranch = (DAL.BankBranch)bsBranches.Current;
             Forms.EditBankBranch ebb        = new Forms.EditBankBranch(bankbranch, bank, connection)
             {
                 Owner = this
             };
             ebb.Text = bankbranch.BranchName.ToString().Trim().ToUpper();
             ebb.ShowDialog();
         }
         catch (Exception ex)
         {
             Utils.ShowError(ex);
         }
     }
 }