Ejemplo n.º 1
0
        /// <summary>
        /// 登录提交
        /// </summary>
        /// <returns></returns>
        public string Login()
        {
            string uid = Request.Form["uid"];
            string pwd = Request.Form["pwd"];

            pwd = SecurityEncrypt.EncryptMD5(pwd);
            string code = Request.Form["checkcode"];

            if (string.IsNullOrEmpty(code) || (Session["vCode"] == null) || (code.Trim() != Session["vCode"].ToString())) //校验验证码是否正确
            {
                return("4");                                                                                              //验证码错误
            }
            DBModel.User user = UserService.LoadEntities(u => u.UserCode == uid).FirstOrDefault();
            //验证用户名密码判断
            if (user == null)
            {
                return("1");
            }
            if (user.UserPassword != pwd)
            {
                return("2");
            }
            //保存Session
            Session["UserCode"] = user.UserCode;
            Session["UserName"] = user.UserName;
            //获取权限
            List <UserFramework> list = UserFrameworkService.LoadEntities(u => u.UserCode == user.UserCode).ToList();
            string powerStr           = "";

            for (int i = 0; i < list.Count; i++)
            {
                powerStr += list[i].DeptCode + ",";
            }
            Session["Power"] = list.Count > 0 ? powerStr.Substring(0, powerStr.Length - 1) : powerStr;
            //获取按钮权限
            var buttons = MenuService.GetButtonPower(user.UserCode).ToList();

            if (buttons.Count == 0)
            {
                Session["btnPower"] = "[]";
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < buttons.Count; i++)
                {
                    sb.Append(buttons[i]);
                    sb.Append(",");
                }
                string temp = sb.ToString();
                temp = "[" + temp.Substring(0, temp.Length - 1) + "]";
                Session["btnPower"] = temp;
            }
            return("0");//登录成功
        }
Ejemplo n.º 2
0
 public ActionResult GetBaseInfo(string inoutType)
 {
     if (Session["Power"] == null || Session["UserCode"] == null)
     {
         return(null);
     }
     else
     {
         string UserCode = Session["UserCode"].ToString();                                     //员工编号
         string Power    = Session["Power"].ToString();                                        //权限字符串
         var    list     = WarehouseService.LoadEntities(a => Power.Contains(a.DepartmentId)); //仓库 货位
         var    list1    = GoodItemService.LoadEntities(a => Power.Contains(a.DepartmentId));  //物料档案
         var    temp     = UserFrameworkService.LoadEntities(u => Power.Contains(u.DeptCode));
         var    list2    = (from a in temp
                            select new
         {
             a.UserCode,
             a.UserName
         }).Distinct();                                                                      //人员信息
         var list3 = LoadGoodsTypeService.LoadEntities(a => Power.Contains(a.DepartmentId)); //装卸类型
         var list4 = BusinessTypeService.LoadEntities(a => Power.Contains(a.DepartmentId));  //业务类型
         //出入库类别
         IQueryable <DBModel.InOutType> list5;
         if (inoutType == "in")
         {
             list5 = InOutTypeService.LoadEntities(a => Power.Contains(a.DepartmentId) && a.InoutType == "入库");
         }
         else if (inoutType == "out")
         {
             list5 = InOutTypeService.LoadEntities(a => Power.Contains(a.DepartmentId) && a.InoutType == "出库");
         }
         else
         {
             list5 = InOutTypeService.LoadEntities(a => Power.Contains(a.DepartmentId));
         }
         var list6 = UserFrameworkService.LoadEntities(u => u.UserCode == UserCode);//公司部门信息
         var res   = new
         {
             Warehouse     = list.Select(a => new { a.Id, a.Name, a.Department, a.Location }),
             GoodItem      = list1.Select(a => new { a.ItemCode, a.ItemLine, a.ItemName, a.ItemSpecifications, a.ItemUnit, a.UnitWeight, a.IsBatch }),
             UserFramework = list2.Select(a => new { a.UserCode, a.UserName }),
             LoadGoodsType = list3.Select(a => a.Name),
             BusinessType  = list4.Select(a => a.Name),
             InOutType     = list5.Select(a => new { a.Id, a.Name, a.InoutType }),
             Departent     = list6.Select(a => new { a.DeptCode, a.DeptName, a.CmopanyCode, a.CompanyAbbr })
         };
         return(Json(res));
     }
 }
Ejemplo n.º 3
0
 //获取基础数据:部门、费用项目
 public ActionResult GetDepartmentAndCostItems()
 {
     if (Session["Power"] == null || Session["UserCode"] == null)
     {
         return(null);
     }
     else
     {
         string UserCode = Session["UserCode"].ToString();                                    //员工编号
         string Power    = Session["Power"].ToString();                                       //权限字符串
         var    list1    = UserFrameworkService.LoadEntities(u => u.UserCode == UserCode);    //部门
         var    list2    = CostItemService.LoadEntities(u => Power.Contains(u.DepartmentId)); //费用项目
         var    res      = new
         {
             Departent = list1,
             CostItem  = list2,
         };
         return(Json(res));
     }
 }
Ejemplo n.º 4
0
 public ActionResult GetBaseInfo()
 {
     //测试用Session
     Session["UserName"] = "******";
     Session["UserCode"] = "HR1406";
     Session["Power"]    = "LH6220,BM0067";
     if (Session["Power"] == null || Session["UserCode"] == null)
     {
         return(null);
     }
     else
     {
         string UserCode = Session["UserCode"].ToString();                                     //员工编号
         string Power    = Session["Power"].ToString();                                        //权限字符串
         var    list     = WarehouseService.LoadEntities(a => Power.Contains(a.DepartmentId)); //仓库 货位
         var    list1    = GoodItemService.LoadEntities(a => Power.Contains(a.DepartmentId));  //物料档案
         var    temp     = UserFrameworkService.LoadEntities(u => Power.Contains(u.DeptCode));
         var    list2    = (from a in temp
                            select new
         {
             a.UserCode,
             a.UserName
         }).Distinct();                                                                      //人员信息
         var list3 = LoadGoodsTypeService.LoadEntities(a => Power.Contains(a.DepartmentId)); //装卸类型
         var list4 = BusinessTypeService.LoadEntities(a => Power.Contains(a.DepartmentId));  //业务类型
         var list5 = InOutTypeService.LoadEntities(a => Power.Contains(a.DepartmentId));     //出入库类别
         var list6 = UserFrameworkService.LoadEntities(u => u.UserCode == UserCode);         //公司部门信息
         var res   = new
         {
             Warehouse     = list.Select(a => new { a.Id, a.Name, a.Department, a.Location }),
             GoodItem      = list1.Select(a => new { a.ItemCode, a.ItemLine, a.ItemName, a.ItemSpecifications, a.ItemUnit, a.UnitWeight }),
             UserFramework = list2.Select(a => new { a.UserCode, a.UserName }),
             LoadGoodsType = list3.Select(a => a.Name),
             BusinessType  = list4.Select(a => a.Name),
             InOutType     = list5.Select(a => a.Name),
             Departent     = list6.Select(a => new { a.DeptCode, a.DeptName, a.CmopanyCode, a.CompanyAbbr })
         };
         return(Json(res));
     }
 }