private void btnNew_Click(object sender, EventArgs e) { try { fCashDelivery frm = new fCashDelivery(); frm.ItemChanged = RefreshList; frm.ShowDlg(new CashCollection(), false); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnEdit_Click(object sender, EventArgs e) { try { int[] selRows = ((GridView)grdCashCollections.MainView).GetSelectedRows(); DataRowView oCashCollectionID = (DataRowView)(((GridView)grdCashCollections.MainView).GetRow(selRows[0])); DataRowView oCollDate = (DataRowView)(((GridView)grdCashCollections.MainView).GetRow(selRows[0])); int nCashCollectionID = Convert.ToInt32(oCashCollectionID["CashCollectionID"]); DateTime CollDate = Convert.ToDateTime(oCollDate["EntryDate"]); CashCollection oCashCollection = db.CashCollections.FirstOrDefault(p => p.CashCollectionID == nCashCollectionID); if (oCashCollection == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Global.CurrentUser.ISEditable == 1) { if (CollDate < DateTime.Today) { MessageBox.Show("This Item can't be editable, Please contact BD Team", "Unauthorized Access", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } fCashDelivery frm = new fCashDelivery(); frm.ItemChanged = RefreshList; frm.ShowDlg(oCashCollection, true); } catch (Exception ex) { MessageBox.Show(ex.Message); } }