private void btnEdit_Click(object sender, EventArgs e) { try { int[] selRows = ((GridView)grdExpenditures.MainView).GetSelectedRows(); DataRowView oBankTransID = (DataRowView)(((GridView)grdExpenditures.MainView).GetRow(selRows[0])); DataRowView TranDate = (DataRowView)(((GridView)grdExpenditures.MainView).GetRow(selRows[0])); int noBankTransID = Convert.ToInt32(oBankTransID["ID"]); DateTime dTranDate = Convert.ToDateTime(TranDate["TranDate"]); BankTransaction oBankTran = db.BankTransactions.FirstOrDefault(p => p.BankTranID == noBankTransID); if (oBankTran == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //if (Global.CurrentUser.IsEditable == 1) //{ // if (dTranDate < DateTime.Today) // { // MessageBox.Show("This transaction can't be editable, Please contact BD Team", "Unauthorized Access", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } //} fBankTransaction frm = new fBankTransaction(); frm.ItemChanged = RefreshList; frm.ShowDlg(oBankTran, true); } catch (Exception ex) { MessageBox.Show(ex.Message); } //try //{ // if (lsvCashTran.SelectedItems.Count <= 0) // { // MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } // CashTransaction oCashTransaction = null; // fCashTransaction frm = new fCashTransaction(); // if (lsvCashTran.SelectedItems != null && lsvCashTran.SelectedItems.Count > 0) // { // oCashTransaction = (CashTransaction)lsvCashTran.SelectedItems[0].Tag; // } // frm.ItemChanged = RefreshList; // frm.ShowDlg(oCashTransaction, true); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }
private void btnNew_Click(object sender, EventArgs e) { try { fBankTransaction frm = new fBankTransaction(); frm.ItemChanged = RefreshList; frm.ShowDlg(new BankTransaction(), false); } catch (Exception ex) { MessageBox.Show(ex.Message); } }