public ActionResult _ItemCategoryDropDownList(string controlName, string controlId, string selectedValue, bool? includeBlankOption, string blankOptionDescription, string blankOptionValue, bool? enable) { ViewBag.ControlName = controlName; ViewBag.ControlId = controlId; //ViewBag.SelectedValue = selectedValue; ViewBag.Enable = enable; IList<ItemCategory> itemCategoryList = base.genericMgr.FindAll<ItemCategory>("from ItemCategory as i"); if (itemCategoryList == null) { itemCategoryList = new List<ItemCategory>(); } if (includeBlankOption.HasValue && includeBlankOption.Value) { ItemCategory blankitemCategory = new ItemCategory(); blankitemCategory.Code = blankOptionValue; blankitemCategory.Description = blankOptionDescription; itemCategoryList.Insert(0, blankitemCategory); } return PartialView(new SelectList(itemCategoryList, "Code", "Description", selectedValue)); }
public ActionResult New(ItemCategory itemCategory) { if (ModelState.IsValid) { if (base.genericMgr.FindAll<long>(duiplicateVerifyStatement, new object[] { itemCategory.Code })[0] > 0) { SaveErrorMessage(Resources.ErrorMessage.Errors_Existing_Code, itemCategory.Code); } else { base.genericMgr.Create(itemCategory); SaveSuccessMessage(Resources.MD.ItemCategory.ItemCategory_Added); return RedirectToAction("Edit/" + itemCategory.Code); } } return View(itemCategory); }
public ActionResult _ItemCategoryDropDownList(string controlName, string controlId, string selectedValue, bool? includeBlankOption, string blankOptionDescription, string blankOptionValue, bool? enable, string SubCategory) { ViewBag.ControlName = controlName; ViewBag.ControlId = controlId; //ViewBag.SelectedValue = selectedValue; ViewBag.Enable = enable; IList<ItemCategory> itemCategoryList = null; if (!string.IsNullOrWhiteSpace(SubCategory)) { itemCategoryList = queryMgr.FindAll<ItemCategory>("from ItemCategory as i where i.SubCategory=?", SubCategory); } else { itemCategoryList = queryMgr.FindAll<ItemCategory>("from ItemCategory as i where i.SubCategory=0"); } if (itemCategoryList == null) { itemCategoryList = new List<ItemCategory>(); } if (includeBlankOption.HasValue && includeBlankOption.Value) { ItemCategory blankitemCategory = new ItemCategory(); blankitemCategory.Code = blankOptionValue; blankitemCategory.Description = blankOptionDescription; itemCategoryList.Insert(0, blankitemCategory); } return PartialView(new SelectList(itemCategoryList.OrderBy(p => p.Code), "Code", "CodeDescription", selectedValue)); }
public ActionResult Edit(ItemCategory itemCategory) { if (ModelState.IsValid) { bool isExist = false; bool isDiffrent = false; IList<ItemCategory> itemCategoryList = base.genericMgr.FindAll<ItemCategory>("from ItemCategory as i where i.ParentCategory = ?", itemCategory.Code); for (int i = 0; i < itemCategoryList.Count; i++) { if (itemCategoryList[i].Code == itemCategory.ParentCategory) { isExist = true; break; } } if (itemCategory.ParentCategory == itemCategory.Code) { isDiffrent = true; } if (isExist) { SaveErrorMessage(Resources.MD.ItemCategory.ItemCategoryErrors_IsParent); } else if (isDiffrent) { SaveErrorMessage(Resources.MD.ItemCategory.ItemCategoryErrors_IsDiffrent); } else { base.genericMgr.Update(itemCategory); SaveSuccessMessage(Resources.MD.ItemCategory.ItemCategory_Updated); } } return View(itemCategory); }