private void btnEdit_Click(object sender, EventArgs e) { try { using (DEWSRMEntities db = new DEWSRMEntities()) { int[] selRows = ((GridView)grdColorInfos.MainView).GetSelectedRows(); DataRowView oColorInfosD = (DataRowView)(((GridView)grdColorInfos.MainView).GetRow(selRows[0])); int nColorInfosID = Convert.ToInt32(oColorInfosD["ColorInfosID"]); INVENTORY.DA.Color oColorInfo = db.Colors.FirstOrDefault(p => p.ColorID == nColorInfosID); if (oColorInfo == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } fColorInfo frm = new fColorInfo(); frm.ItemChanged = RefreshList; frm.ShowDlg(oColorInfo, false); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnNew_Click(object sender, EventArgs e) { fColorInfo frm = new fColorInfo(); frm.ItemChanged = RefreshList; frm.ShowDlg(new INVENTORY.DA.Color(), true); }