private void btnNew_Click(object sender, EventArgs e) { fCategory frm = new fCategory(); frm.ItemChanged = RefreshList; frm.ShowDlg(new Category(), true); }
private void btnEdit_Click(object sender, EventArgs e) { try { using (DEWSRMEntities db = new DEWSRMEntities()) { int[] selRows = ((GridView)grdCategorys.MainView).GetSelectedRows(); DataRowView oCategoryD = (DataRowView)(((GridView)grdCategorys.MainView).GetRow(selRows[0])); int nCategoryID = Convert.ToInt32(oCategoryD["CategoryID"]); Category oCategory = db.Categorys.FirstOrDefault(p => p.CategoryID == nCategoryID); if (oCategory == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } fCategory frm = new fCategory(); frm.ItemChanged = RefreshList; frm.ShowDlg(oCategory, false); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCategory_Click(object sender, EventArgs e) { ForNewCategory = true; fCategory frm = new fCategory(); frm.ShowDlg(new Category(), true); if (ForNewCategory) { db = new DEWSRMEntities(); List <Category> oCatList = db.Categorys.ToList(); ctlCategory.SelectedID = oCatList[oCatList.Count - 1].CategoryID; ForNewCategory = false; } }