private void btnUpdate_Click(object sender, EventArgs e) { if (is_validate()) { try { if (!string.IsNullOrEmpty(txtBankName.Text)) { _bank.BankName = Utils.ConvertFirstLetterToUpper(txtBankName.Text.Trim()); } rep.UpdateBank(_bank); BanksForm b = (BanksForm)this.Owner; b.RefreshBankGrid(); this.Close(); } catch (Exception ex) { Utils.ShowError(ex); } } }
private void btnOk_Click(object sender, EventArgs e) { if (is_validate()) { try { Bank _Bank = new Bank(); if (!string.IsNullOrEmpty(txtBankCode.Text)) { _Bank.BankCode = txtBankCode.Text.Trim(); } if (!string.IsNullOrEmpty(txtBankName.Text)) { _Bank.BankName = Utils.ConvertFirstLetterToUpper(txtBankName.Text.Trim()); } if (db.Banks.Any(c => c.BankCode == _Bank.BankCode)) { MessageBox.Show("Bank Code Exist!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!db.Banks.Any(c => c.BankCode == _Bank.BankCode)) { db.Banks.AddObject(_Bank); db.SaveChanges(); BanksForm b = (BanksForm)this.Owner; b.RefreshBankGrid(); this.Close(); } } catch (Exception ex) { Utils.ShowError(ex); } } }