public ActionResult Edit(tblInfoCriteria tblcriteria, int id, FormCollection collection) { if (ModelState.IsValid) { int idcate = int.Parse(collection["drMenu"]); tblcriteria.idCri = idcate; db.Entry(tblcriteria).State = EntityState.Modified; db.SaveChanges(); #region [Updatehistory] Updatehistoty.UpdateHistory("Edit tblcriteria", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã sửa thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/InfoCriteria/Index?id=" + idcate + "")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/InfoCriteria/Create?id=" + idcate + "")); } } return(View(tblcriteria)); }
public ActionResult Edit(int id = 0) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(6, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { tblInfoCriteria tblcriteria = db.tblInfoCriterias.Find(id); var menuModel = db.tblCriterias.OrderBy(m => m.id).ToList(); List <SelectListItem> carlist = new List <SelectListItem>(); foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); } ViewBag.drMenu = new SelectList(carlist, "Value", "Text", tblcriteria.idCri); if (tblcriteria == null) { return(HttpNotFound()); } return(View(tblcriteria)); } else { return(Redirect("/Users/Erro")); } }
public ActionResult DeleteCriteria(int id) { if (ClsCheckRole.CheckQuyen(6, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { tblInfoCriteria tblcriteria = db.tblInfoCriterias.Find(id); var result = string.Empty; db.tblInfoCriterias.Remove(tblcriteria); db.SaveChanges(); result = "Bạn đã xóa thành công."; return(Json(new { result = result })); } else { var result = string.Empty; result = "Bạn không có quyền thay đổi tính năng này"; return(Json(new { result = result })); } }
public ActionResult Create(tblInfoCriteria tblcriteria, FormCollection collection) { int idcate = int.Parse(collection["drMenu"]); tblcriteria.idCri = idcate; db.tblInfoCriterias.Add(tblcriteria); db.SaveChanges(); Updatehistoty.UpdateHistory("Add tblcriteria", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); if (collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/InfoCriteria/Index?id=" + idcate + "")); } if (collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm tiêu trí mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/InfoCriteria/Create?id=" + idcate + "")); } return(Redirect("Index")); }
// GET: InfoCriteria public ActionResult Index(string id, FormCollection collection) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(6, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { var ListCriteria = db.tblInfoCriterias.OrderBy(m => m.Ord).ToList(); var menuModel = db.tblGroupProducts.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlists.Clear(); string strReturn = "---"; foreach (var item in menuModel) { carlists.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListFor(item.id, carlists, strReturn); strReturn = "---"; } if (id != "") { ViewBag.drMenu = carlists; ViewBag.idCate = id; ViewBag.idMenu = id; } else { ViewBag.drMenu = carlists; } if (collection["btnDelete"] != null) { foreach (string key in Request.Form.Keys) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { if (ClsCheckRole.CheckQuyen(6, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { int ids = Convert.ToInt32(key.Remove(0, 4)); tblInfoCriteria tblcriteria = db.tblInfoCriterias.Find(ids); db.tblInfoCriterias.Remove(tblcriteria); db.SaveChanges(); } else { return(Redirect("/Users/Erro")); } } } } //dsd } if (Session["Thongbao"] != null && Session["Thongbao"] != "") { ViewBag.thongbao = Session["Thongbao"].ToString(); Session["Thongbao"] = ""; } return(View()); } else { return(Redirect("/Users/Erro")); } }