private void btnNew_Click(object sender, EventArgs e) { fExpenditure frm = new fExpenditure(); frm.ItemChanged = RefreshList; frm.ShowDlg(new Expenditure()); }
private void btnEdit_Click(object sender, EventArgs e) { try { int[] selRows = ((GridView)grdExpenditures.MainView).GetSelectedRows(); DataRowView oExpenditureID = (DataRowView)(((GridView)grdExpenditures.MainView).GetRow(selRows[0])); DataRowView oExpenseDate = (DataRowView)(((GridView)grdExpenditures.MainView).GetRow(selRows[0])); int nExpenditureID = Convert.ToInt32(oExpenditureID["ID"]); DateTime ExpenseDate = Convert.ToDateTime(oExpenseDate["ExpenseDate"]); Expenditure oExpenditure = db.Expenditures.FirstOrDefault(p => p.ExpenditureID == nExpenditureID); if (oExpenditure == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Global.CurrentUser.ISEditable == 1) { if (ExpenseDate < DateTime.Today) { MessageBox.Show("This Item can't be editable, Please contact BD Team.", "Unauthorized Access", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } fExpenditure frm = new fExpenditure(); frm.ItemChanged = RefreshList; frm.ShowDlg(oExpenditure); } catch (Exception ex) { MessageBox.Show(ex.Message); } }