// GET api/menuapi public IEnumerable <CMenuCategory> Get() { var user = (CSign)HttpContext.Current.Session[ConfigurationManager.AppSettings["AuthSaveKey"]]; if (user == null) { throw new HttpResponseException(new SiginFailureMessage()); } using (var dal = DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0)) { try { dal.Open(); } catch (Exception ex) { LogBll.Write(dal, new CLog { LogUser = string.Format("{0}-{1}", user.UserCode, user.UserName), LogContent = string.Format("{0}#{1}", "Menu.List", ex.Message), LogType = LogType.系统异常 }); throw new HttpResponseException(new SystemExceptionMessage()); } var menus = FunctionBll.LoadMenu(dal, user.GroupCode); if (menus == null) { throw new HttpResponseException(new DataNotFoundMessage()); } return(menus); } }
public ActionResult LeftMenu() { FunctionBll funBll = new FunctionBll(); var adminLayoutViewModel = funBll.GetAllMenuFunction(); return(View(adminLayoutViewModel)); }
public ActionResult Edit(Function fun) { FunctionBll funBll = new FunctionBll(); funBll.UpdateFunction(fun); return(Redirect("Index")); }
// GET: Function public ActionResult Index() { FunctionBll funBll = new FunctionBll(); var funList = funBll.GetAllAdminFunction(); return(View(funList)); }
public ActionResult Edit(int id) { ViewBag.FunctionFather = CreateFunctionFather().AsEnumerable();; FunctionBll funBll = new FunctionBll(); Function fun = funBll.GetFunction(id); fun.function_id = id; return(View(fun)); }
public ActionResult Add(Function f) { f.function_sort = 0; f.kuser = Session["callid"].ToString(); f.kdate = DateTime.Now; ViewBag.FunctionFather = CreateFunctionFather().AsEnumerable(); FunctionBll functionBll = new FunctionBll(); functionBll.AddFunction(f); return(Redirect("index")); }
private SelectList CreateFunctionFather(int selectValue = 0) { var funBll = new FunctionBll(); //List<SelectListItem> ddlDPList = new List<SelectListItem>(); SelectList ddlDPList; var dpList = funBll.GetAllAdminFatherFunction(); if (selectValue == 0) { ddlDPList = new SelectList(dpList, "function_id", "function_name"); } else { ddlDPList = new SelectList(dpList, "function_id", "function_name", selectValue); } return(ddlDPList); }
/// <summary> /// 权限控制 /// </summary> protected void permission() { RoleBll roleBll = new RoleBll(); FunctionBll functionBll = new FunctionBll(); User user = (User)Session["user"]; userName = user.UserName; regionName = user.ReginId.RegionName; Role role = new Role(); role = user.RoleId; int roleId = role.RoleId; dsPer = functionBll.SelectByRoleId(roleId); string userId = user.UserId; DataSet dsRole = roleBll.selectRole(userId); string roleName = dsRole.Tables[0].Rows[0]["roleName"].ToString(); if (roleName == "超级管理员") { isAdmin = true; } for (int i = 0; i < dsPer.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 1) { funcOrg = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 2) { funcRole = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 3) { funcUser = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 4) { funcGoods = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 5) { funcCustom = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 6) { funcLibrary = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 7) { funcBook = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 8) { funcPut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 9) { funcOut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 10) { funcSale = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 11) { funcSaleOff = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 12) { funcReturn = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 13) { funcSupply = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 14) { funcRetail = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 15) { funcBookStock = true; } } }
// GET api/menuapi public IEnumerable <CMenuCategory> Get() { using (var dal = DalBuilder.CreateDal(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString, 0)) { var user = (CSign)HttpContext.Current.Session[ConfigurationManager.AppSettings["AuthSaveKey"]]; try { dal.Open(); if (user == null) { var httpCookie = HttpContext.Current.Request.Cookies["Token"]; if (httpCookie != null) { //存在Token,进行Token登录 if (SignBll.Signin(dal, httpCookie.Values["User"], httpCookie.Values["Value"], user)) { HttpContext.Current.Session.Add(ConfigurationManager.AppSettings["AuthSaveKey"], user); //更新Token var token = Guid.NewGuid().ToString(); HttpContext.Current.Response.Cookies["Token"].Values["User"] = user.UserCode; HttpContext.Current.Response.Cookies["Token"].Values["Value"] = token; HttpContext.Current.Response.Cookies["Token"].Expires = DateTime.Now.AddDays(30); SignBll.UpdateToken(dal, token, user.UserCode); } else { throw new HttpResponseException(new SiginFailureMessage()); } } else { throw new HttpResponseException(new SiginFailureMessage()); } } var menus = FunctionBll.LoadMenu(dal, user.GroupCode); if (menus == null) { throw new HttpResponseException(new DataNotFoundMessage()); } return(menus); } catch (Exception ex) { LogBll.Write(dal, new CLog { LogUser = string.Format("{0}-{1}", user == null?string.Empty:user.UserCode, user == null?string.Empty:user.UserName), LogContent = string.Format("{0}#{1}", "Menu.List", ex.Message), LogType = LogType.系统异常 }); throw new HttpResponseException(new SystemExceptionMessage()); } finally { dal.Close(); } } }
protected void permission() { FunctionBll functionBll = new FunctionBll(); User user = (User)Session["user"]; Role role = new Role(); role = user.RoleId; int roleId = role.RoleId; dsPer = functionBll.SelectByRoleId(roleId); for (int i = 0; i < dsPer.Tables[0].Rows.Count; i++) { if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 1) { funcOrg = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 2) { funcRole = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 3) { funcUser = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 4) { funcGoods = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 5) { funcCustom = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 6) { funcLibrary = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 7) { funcBook = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 8) { funcPut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 9) { funcOut = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 10) { funcSale = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 11) { funcSaleOff = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 12) { funcReturn = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 13) { funcSupply = true; } if (Convert.ToInt32(dsPer.Tables[0].Rows[i]["functionId"]) == 14) { funcRetail = true; } } }