public JsonResult Delete(int id) { var isUsed = new MenuTypeDao().CheckMenuIsUsed(id); if (!isUsed) { var res = new MenuTypeDao().Delete(id); if (res) { return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { status = false, message = "Có menu đang dùng. Vui lòng kiểm tra lại" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult LoadData(int type, string keyword, int pageIndex, int pageSize) { string str = NonUnicode.RemoveUnicode(keyword).ToLower(); var model = new MenuTypeDao().ListAll(); switch (type) { case 0: model = model.Where(x => NonUnicode.RemoveUnicode(x.Name.ToLower()).Contains(str)); break; } int totalRow = model.Count(); model = model.OrderByDescending(x => x.ID) .Skip((pageIndex - 1) * pageSize) .Take(pageSize); int totalRowCurent = model.Count(); return(Json(new { data = model, total = totalRow, totalCurent = totalRowCurent, status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(MenuType collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuTypeDao bdDao = new MenuTypeDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; // collection.CreatedBy = us.UserName; // collection.CreatedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); if (bdDao.Update(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public JsonResult GetDetail(int id) { var model = new MenuTypeDao().GetByID(id); return(Json(new { data = model, status = true }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveData(string strMenuType) { JavaScriptSerializer serializer = new JavaScriptSerializer(); MenuType menuType = serializer.Deserialize <MenuType>(strMenuType); bool status = false; string action = string.Empty; string message = string.Empty; bool res = new MenuTypeDao().CheckIDExist(menuType.ID); if (res) { var model = new MenuTypeDao(); try { model.Insert(menuType); status = true; action = "insert"; } catch (Exception ex) { status = false; message = ex.Message; } } else { //update existing DB //save db try { var model = new MenuTypeDao().Update(menuType); status = true; action = "update"; } catch (Exception ex) { status = false; message = ex.Message; } } return(Json(new { status = status, message = message, action = action })); }
// GET: Admin/Menu/Edit/5 public ActionResult Edit(long id) { MenuDao dbMenu = new MenuDao(); MenuTypeDao dbMenuType = new MenuTypeDao(); Menu menu = null; try { menu = dbMenu.FindByID(id); var items = GetClientMenuViewModel(); ViewBag.ParentID = new SelectList(items, "ID", "Text", menu.ParentID); ViewBag.GroupID = new SelectList(dbMenuType.ToList(), "ID", "Name"); } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View(menu)); }
public ActionResult Create(MenuType collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuTypeDao bdDao = new MenuTypeDao(); if (bdDao.FindByID(collection.ID) == null) { UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreatedBy = us.UserName; collection.CreatedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } else { ModelState.AddModelError("", "Mã nhóm menu đã tồn tại"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Delete(string id) { try { // TODO: Add delete logic here MenuTypeDao bdDao = new MenuTypeDao(); MenuDao mnDao = new MenuDao(); if (mnDao.FindByMenuType(id).Count > 0) { SetAlert("Đang sử dụng không được phép xóa", SystemConsts.ALERT_DANGER); return(RedirectToAction("Index")); } bdDao.Delete(id); // SetAlert("Xóa thành công", "success"); return(RedirectToAction("Index")); } catch { // SetAlert("Không xóa được", "danger"); return(View()); } }
public ActionResult Edit(Menu collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuDao bdDao = new MenuDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.UpdatedBy = us.UserName; collection.UpdatedDate = Hepper.GetDateServer(); MenuDao dbMenu = new MenuDao(); MenuTypeDao dbMenuType = new MenuTypeDao(); var items = GetClientMenuViewModel(); ViewBag.ParentID = new SelectList(items, "ID", "Text"); ViewBag.GroupID = new SelectList(dbMenuType.ToList(), "ID", "Name"); if (bdDao.Update(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không cập nhật được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
// GET: Admin/MenuType/Edit/5 public ActionResult Edit(string id) { MenuTypeDao bdDao = new MenuTypeDao(); return(View(bdDao.FindByID(id))); }
// GET: Admin/MenuType public ActionResult Index() { MenuTypeDao bdDao = new MenuTypeDao(); return(View(bdDao.ToList())); }
private void PopulateGroupIDDropDownList(object selectedParent = null) { MenuTypeDao dbDao = new MenuTypeDao(); ViewBag.Groups = new SelectList(dbDao.ToList(), "ID", "Name", selectedParent); }
/// <summary> /// /// </summary> public MenuTypeBll() { _menuTypeDao = new MenuTypeDao(); }
// GET: Admin/MenuTypes public ActionResult Index() { var model = new MenuTypeDao().ListAll(); return(View(model)); }
public void SetDropdownList(string selectedId = null) { var dao = new MenuTypeDao(); ViewBag.MenuTypeID = new SelectList(dao.ListAll(), "ID", "Name", selectedId); }