public ActionResult ItemUpdate(int id) { ModelState.Clear(); CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); ItemBL bl = new ItemBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); ItemsDTO dto = new ItemsDTO(); bl.SearchID(id, out dto); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ViewData["tool"] = dto.manufacture_tool.ToString().ToLower(); ViewData["make"] = dto.manufacture_make.ToString().ToLower(); ViewData["dangerous"] = dto.dangerous.ToString().ToLower(); ViewData["good"] = dto.manufacture_finished_goods.ToString().ToLower(); ViewData["category"] = dto.category_id; ViewData["inventorymeasure"] = dto.inventory_measure_id; ViewData["sizemeasure"] = dto.manufacture_size_measure_id; ViewData["weightmeasure"] = dto.manufacture_weight_measure_id; return(View(dto)); }
public ActionResult MeasureDelete(int id) { MeasureBL bl = new MeasureBL(); List <MeasureDTO> dtResult = new List <MeasureDTO>(); MeasureDTO measureDTO = new MeasureDTO(); measureDTO.id = id; bl.SearchData(measureDTO, out dtResult); if (dtResult.Count() <= 0) { Response.StatusCode = 404; return(null); } else { int result = bl.DeleteData(id); if (result == 1) { TempData["Error"] = "Delete fail"; TempData["Success"] = ""; } else { TempData["Error"] = ""; TempData["Success"] = "Delete sucessfully"; } } return(RedirectToAction("MeasureSearch")); }
public ActionResult MeasureSearch(string Page, MeasureSearch model) { MeasureDTO dto = new MeasureDTO(); ModelState.Clear(); if (!string.IsNullOrEmpty(model.SearchButton) || Page.IsNotNullOrEmpty()) { if (Page != null) { dto.page = int.Parse(Page); model.Page = dto.page; } MeasureBL bl = new MeasureBL(); List <MeasureDTO> result = new List <MeasureDTO>(); if (model.MeasureCode.IsNotNullOrEmpty()) { dto.code = model.MeasureCode; } if (model.MeasureName.IsNotNullOrEmpty()) { dto.name = model.MeasureName; } bl.SearchData(dto, out result); model.PageCount = bl.PageCount(dto); model.SearchResults = new StaticPagedList <MeasureDTO>(result, model.Page, 20, model.PageCount); } return(View(model)); }
public ActionResult UpdateMeasure(MeasureDTO measure) { MeasureBL mesureBL = new MeasureBL(); try { if (ModelState.IsValid) { measure.created_by = 123; measure.updated_by = 123; mesureBL.UpdateData(measure); return(RedirectToAction("Measure")); } } catch (DataException dex) { ModelState.AddModelError("", "Unable to perform action. Please contact us."); return(RedirectToAction("SubmissionFailed", measure)); } measure = new MeasureDTO() { id = measure.id }; return(View("Update")); }
public ActionResult MeasureAdd(MeasureDTO measure) { if (ModelState.IsValid) { MeasureBL bl = new MeasureBL(); if (bl.CheckCode(measure) > 0) { TempData["Error"] = "Code already exsit"; TempData["Success"] = ""; } else { measure.created_by = 0; measure.updated_by = 0; int result = bl.InsertData(measure); if (result == 1) { TempData["Error"] = "Insert fail"; TempData["Success"] = ""; } else { TempData["Error"] = ""; TempData["Success"] = "Insert successfully"; return(RedirectToAction("MeasureAdd")); } } } return(View(measure)); }
// GET: Measure public ActionResult MeasureSearch(MeasureDTO measure) { MeasureBL bl = new MeasureBL(); MeasureList model = new MeasureList(); DataTable dt; bl.SearchData(measure, out dt); model.Measures = CommonMethod.DataTableToList <MeasureDTO>(dt); return(View(model)); }
public ActionResult MeasureUpdate(int id) { ModelState.Clear(); MeasureBL bl = new MeasureBL(); List <MeasureDTO> dtResult = new List <MeasureDTO>(); MeasureDTO measure = new MeasureDTO(); measure.id = id; bl.SearchData(measure, out dtResult); measure = dtResult[0]; return(View(measure)); }
public ActionResult ItemAdd(ItemsDTO model) { CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; ItemBL bl = new ItemBL(); if (ModelState.IsValid) { int count = bl.CheckCode(model); if (count > 0) { TempData["Error"] = "Code already exists"; TempData["Success"] = ""; return(View(model)); } else { if (model.discontinued_datetime.IsNotNullOrEmpty() == true) { string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss"); model.discontinued_datetime = datetime; } model.created_by = 0; model.updated_by = 0; int equal = bl.InsertData(model); if (equal == 1) { TempData["Error"] = "Insert badly"; TempData["Success"] = ""; return(View(model)); } else { TempData["Error"] = ""; TempData["Success"] = "Insert successfully"; return(RedirectToAction("ItemAdd")); } } } else { return(View(model)); } }
public ActionResult ItemAdd() { ModelState.Clear(); CategoryBL category = new CategoryBL(); MeasureBL measure = new MeasureBL(); List <CategoryDTO> categorydt = new List <CategoryDTO>(); List <MeasureDTO> measuredt = new List <MeasureDTO>(); category.SearchList(out categorydt); measure.SearchList(out measuredt); ViewBag.CategoryList = categorydt; ViewBag.MeasureList = measuredt; return(View()); }
public ActionResult DeleteMeasure(string id) { try { MeasureBL categoryBL = new MeasureBL(); categoryBL.DeleteData(id.ParseInt32()); return(RedirectToAction("Measure")); } catch (DataException dex) { ModelState.AddModelError("", "Unable to perform action. Please contact us."); return(RedirectToAction("SubmissionFailed")); } }
public ActionResult ItemAdd() { CategoryBL catelogy = new CategoryBL(); MeasureBL measure = new MeasureBL(); DataTable catelogydt; DataTable measuredt; catelogy.SearchList(out catelogydt); measure.SearchList(out measuredt); ViewBag.CatelogyList = CommonMethod.DataTableToList <CategoryDTO>(catelogydt); ViewBag.MeasureList = CommonMethod.DataTableToList <MeasureDTO>(measuredt); ItemsDTO model = new ItemsDTO(); return(View(model)); }
private Item LoadItemAddForm(Item item) { if (item == null) { item = new Item(); } SelectList listCategory = new SelectList(new CategoryBL().SelectDropdownData(), "id", "name"); ViewBag.ListCategory = listCategory; MeasureBL measureBL = new MeasureBL(); SelectList listMeasure = new SelectList(new MeasureBL().SelectDropdownData(), "id", "name"); ViewBag.listMeasure = listMeasure; return(item); }
public ActionResult Update(string id) { MeasureDTO dto = new MeasureDTO(); if (id.IsNumber()) { List <MeasureDTO> list; MeasureBL bl = new MeasureBL(); dto.id = int.Parse(id); bl.SearchData(dto, out list); if (list.Count > 0) { dto = list[0]; } else { TempData["Success"] = "0 row(s) has found."; return(RedirectToAction("Measure")); } } return(View(dto)); }
public ActionResult MeasureUpdate(MeasureDTO measure) { if (ModelState.IsValid) { MeasureBL bl = new MeasureBL(); measure.created_by = 0; measure.updated_by = 0; int result = bl.UpdateData(measure); if (result == 1) { TempData["Error"] = "Update fail"; TempData["Success"] = ""; } else { TempData["Error"] = ""; TempData["Success"] = "Update successfully"; } return(RedirectToAction("MeasureSearch")); } return(View(measure)); }
public ActionResult AddMeasure(MeasureDTO mesure) { try { if (ModelState.IsValid) { mesure.created_by = 113; MeasureBL categorybl = new MeasureBL(); if (mesure.code.Contains(" ")) { TempData["Error"] = "Don't input Space in Measure Code"; return(View("Add")); } int count = categorybl.CountData(new MeasureDTO() { code = mesure.code }); if (count == 0) { categorybl.InsertData(mesure); } else { TempData["Error"] = "The Code already is exister!"; return(View("Add")); } return(RedirectToAction("Measure")); } } catch (DataException dex) { ModelState.AddModelError("", "Unable to perform action. Please contact us."); return(RedirectToAction("SubmissionFailed", mesure)); } return(View("Add")); }
public ActionResult Measure(string page, ResearchMeasureModel model) { ModelState.Clear(); MeasureBL bl = new MeasureBL(); if (model == null) { model = new ResearchMeasureModel(); model.measure = new MeasureDTO(); model.listMeasure = new List <MeasureDTO>(); } else { if (model.measure == null) { model.measure = new MeasureDTO(); } if (model.listMeasure == null) { model.listMeasure = new List <MeasureDTO>(); } } if (page == null) { page = "1"; } model.page_count = bl.CountData(model.measure); List <MeasureDTO> list; model.measure.page = int.Parse(page); bl.SearchData(model.measure, out list); model.listMeasure = list; TempData["Success"] = model.page_count + " row(s) has found."; return(View(model)); }
public ActionResult MeasureDeleteMulti(FormCollection frm) { string[] ids = frm["MeasureID"].Split(new char[] { ',' }); MeasureBL bl = new MeasureBL(); foreach (string item in ids) { MeasureDTO measureDTO = new MeasureDTO(); int id = item.ParseInt32(); measureDTO.id = id; List <MeasureDTO> dtos = new List <MeasureDTO>(); int returncode = bl.SearchData(measureDTO, out dtos); if (returncode == 1) { Response.StatusCode = 404; return(null); } else { bl.DeleteData(id); } } return(RedirectToAction("MeasureSearch")); }