public ActionResult Create(DIC_TINH model) { if (ModelState.IsValid) { try { model.Cap = model.GetCapById(model.Cap); var result = model.Insert(); if (result == data.enums.SqlResultType.OK) { this.ShowNotification(data.enums.MessageObjectType.Success, "", "Tạo mới tỉnh/thành thành công."); return(RedirectToAction("Index")); } else { this.GetMessageFromSqlState(result, "Mã tỉnh"); return(View(model)); } } catch (Exception ex) { this.HanderException(ex); return(View(model)); } } else { return(View(model)); } }
// GET: tinhthanh public ActionResult Index(string text, string cap, bool status = true, int page = 1, int pagesize = 20) { this.SetPageInfo(page, pagesize); ViewBag.text = text; ViewBag.cap = cap; ViewBag.status = status; using (DIC_TINH dic_tinhthanh = new DIC_TINH()) { string _cap = dic_tinhthanh.GetCapById(cap); var dic_tinhthanhs = dic_tinhthanh.GetFilter(text, _cap == "" ? null : _cap, status ? "1" : "0").ToPagedList(page, pagesize); return(View(dic_tinhthanhs)); } }
public ActionResult Edit(string id, DIC_TINH model) { if (ModelState.IsValid) { try { model.Cap = model.GetCapById(model.Cap); var entityUpdate = model.Get(DataConverter.StringToInt(id)); if (entityUpdate != null) { entityUpdate.MaTinh = model.MaTinh; entityUpdate.TenTinh = model.TenTinh; entityUpdate.Cap = model.Cap; entityUpdate.Status = model.Status; var result = entityUpdate.Update(); if (result == data.enums.SqlResultType.OK) { this.ShowNotification(data.enums.MessageObjectType.Success, "", "Chỉnh sửa thành công."); return(RedirectToAction("Index")); } else { this.GetMessageFromSqlState(result, "Mã tỉnh"); return(View(model)); } } else { this.GetMessageFromSqlState(data.enums.SqlResultType.NotExisted, "Mã tỉnh"); return(View(model)); } } catch (Exception ex) { this.HanderException(ex); return(View(model)); } } else { return(View(model)); } }