private void tsbAddBankBranch_Click(object sender, EventArgs e) { if (dgBanks.SelectedRows.Count != 0) { try { DAL.Bank bank = (DAL.Bank)bsBanks.Current; Forms.AddBankBranch abb = new Forms.AddBankBranch(bank, connection) { Owner = this }; abb.ShowDialog(); } catch (Exception ex) { Utils.ShowError(ex); } } }
private void dgBanks_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (dgBanks.SelectedRows.Count != 0) { try { DAL.Bank bank = (DAL.Bank)bsBanks.Current; Forms.EditBank eb = new Forms.EditBank(bank, connection) { Owner = this }; eb.Text = bank.BankName.ToString().Trim().ToUpper(); eb.ShowDialog(); } catch (Exception ex) { Utils.ShowError(ex); } } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dataGridView1.SelectedRows.Count != 0) { DAL.Bank bank = (DAL.Bank)bindingSource1.Current; if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete ", "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { de.DeleteBank(bank.BankCode); RefreshGrid(); } } } catch (Exception ex) { Utils.ShowError(ex); } }
private void tsbEditBankBranch_Click(object sender, EventArgs 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); } } }
private void dgBanks_SelectionChanged(object sender, EventArgs e) { try { if (dgBanks.SelectedRows.Count != 0) { DAL.Bank bank = (DAL.Bank)bsBanks.Current; bsBranches.DataSource = bank.BankBranches; groupBox2.Text = bsBranches.Count.ToString(); foreach (DataGridViewRow row in dgBranches.Rows) { dgBranches.Rows[dgBranches.Rows.Count - 1].Selected = true; int nRowIndex = dgBranches.Rows.Count - 1; bsBranches.Position = nRowIndex; } } } catch (Exception ex) { Utils.ShowError(ex); } }
public void RefreshBranchGrid() { try { db = new SBPayrollDBEntities(connection); bsBanks.DataSource = null; bsBranches.DataSource = null; var bankquery = db.Banks.Include("BankBranches"); banksList = bankquery.ToList(); bsBanks.DataSource = banksList; groupBox1.Text = bsBanks.Count.ToString(); DAL.Bank bank = (DAL.Bank)bsBanks.Current; foreach (DataGridViewRow row in dgBanks.Rows) { dgBanks.Rows[dgBanks.Rows.Count - 1].Selected = true; int nRowIndex = dgBanks.Rows.Count - 1; bsBanks.Position = nRowIndex; } if (dgBanks.SelectedRows.Count != 0) { DAL.Bank _bank = (DAL.Bank)bsBanks.Current; bsBranches.DataSource = _bank.BankBranches; groupBox2.Text = bsBranches.Count.ToString(); foreach (DataGridViewRow row in dgBranches.Rows) { dgBranches.Rows[dgBranches.Rows.Count - 1].Selected = true; int nRowIndex = dgBranches.Rows.Count - 1; bsBranches.Position = nRowIndex; } } } catch (Exception ex) { Utils.ShowError(ex); } }