public static int AddUpdateSubCategory(sub_category ob) { int _Categoryid = 0; using (InventoryEntities db = new InventoryEntities()) { if (ob.id > 0) { sub_category temp = db.sub_category.Where(u => u.id == ob.id).FirstOrDefault(); if (temp != null) { temp.id = ob.id; temp.subcategory_name = ob.subcategory_name; temp.category = ob.category; } } else { db.sub_category.Add(ob); } int x = db.SaveChanges(); if (x > 0) { _Categoryid = ob.id; } } return _Categoryid; }
public static int AddUpdateSubCategory(sub_category ob) { int _Categoryid = 0; using (InventoryEntities db = new InventoryEntities()) { if (ob.id > 0) { sub_category temp = db.sub_category.Where(u => u.id == ob.id).FirstOrDefault(); if (temp != null) { temp.id = ob.id; temp.subcategory_name = ob.subcategory_name; temp.category = ob.category; } } else { db.sub_category.Add(ob); } int x = db.SaveChanges(); if (x > 0) { _Categoryid = ob.id; } } return(_Categoryid); }
public static bool DeleteSubCategory(int Category_id) { bool flag = false; using (InventoryEntities db = new InventoryEntities()) { sub_category temp = db.sub_category.Where(u => u.id == Category_id).FirstOrDefault(); if (temp != null) { db.sub_category.Remove(temp); db.SaveChanges(); flag = true; } } return(flag); }
protected void AddSubCatagory(object parameter) { string sub_category_name; TextBox tb = (TextBox)parameter; sub_category_name = tb.Text; if ((sub_category_name != "") && (SelectedCategory != null)) { List<sub_category> temp_list = SubCategoryServices.GetAllSubCategoryByName(sub_category_name.Trim(), SelectedCategory.id); if (temp_list.Count == 0) { sub_category ct = new sub_category(); ct.id = 0; ct.subcategory_name = sub_category_name; ct.category = SelectedCategory.id; int temp_SubCategory_id = SubCategoryServices.AddUpdateSubCategory(ct); if (temp_SubCategory_id != 0) { // MessageBox.Show("Category " + sub_category_name + " is Created"); InventoryHelper.SuccessAlert("Success", "Category " + sub_category_name + " is Created"); BindGrid(); } } } }
public static int AddUpdateSubCategory(sub_category ob) { return SubCategoryProvider.AddUpdateSubCategory(ob); }