Exemplo n.º 1
0
 /// <summary>
 /// 验证数据字典分类属性--标题和编码不可重复
 /// </summary>
 /// <returns></returns>
 public static string DPValDicCategoryAttribute(SYS_DicCategory Model)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             string flag = string.Empty;
             IQueryable <SYS_DicCategory> _name = context.SYS_DicCategory;
             _name = _name.Where(c => c.Title == Model.Title || c.Code == Model.Code);
             if (Model.DicCategory_Code != "0")
             {
                 _name = _name.Where(c => c.DicCategory_Code != Model.DicCategory_Code);
             }
             if (_name.Count() > 0)
             {
                 flag = "0";
             }
             return(flag);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 验证菜单属性
 /// </summary>
 /// <returns></returns>
 public static string DPValMenuAttribute(SYS_FunctionTree Btn)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             string flag = string.Empty;
             IQueryable <SYS_FunctionTree> _valbBtn = context.SYS_FunctionTree;
             if (Btn.FT_Id != 0)
             {
                 _valbBtn = _valbBtn.Where(c => c.FT_Id != Btn.FT_Id);
             }
             var _valName = _valbBtn.Where(c => c.FT_Name == Btn.FT_Name);
             if (_valName.Count() > 0)
             {
                 flag = "0";
             }
             return(flag);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 通用查询
        /// </summary>
        /// <param name="BtnG"></param>
        /// <param name="rp"></param>
        /// <param name="pageIndex"></param>
        /// <param name="allRows"></param>
        /// <param name="allPages"></param>
        /// <returns></returns>
        public static List <dynamic> DPGetQueryLst(SearchMod <T> aa, dynamic expression)
        {
            using (NERPEntities contex = new NERPEntities())
            {
                int skipCount = ((aa.page - 1) * aa.rp);
                var bb        = aa.ret; //匿名对象,用于显示输出
                //List<dynamic> list = contex.Set<T>().Select(c => aa).ToList<dynamic>();
                IQueryable <dynamic> query = aa.query;
                var custom = new SYS_ButtonGroup {
                    BG_Name = "BG_Name", BG_Name_En = "BG_Name_En"
                };
                //aa.where.Compile()(custom);
                //query.Where(aa.where);
                //query = aa.query;

                // var custom = expression.Compile()(expression);

                // var ww = expression.Compile()(custom);
                //表中有无法转换的字段,所以用动态类型进行转换
                List <dynamic> list = query.ToList <dynamic>();
                aa.total = list.Count();
                aa.total = aa.total / aa.rp + aa.total % aa.rp == 0 ? 0 : 1;
                List <dynamic> ret = aa.page == 0 ? list : list.Skip(skipCount).Take(aa.rp).ToList();
                return(ret);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 获取按钮组
 /// </summary>
 /// <returns></returns>
 public static List <dynamic> DPGetButtonGroup(string BG_Name, string BG_Name_En, int pageSize, int pageIndex, out int allRows, out int allPages)
 {
     using (NERPEntities contex = new NERPEntities())
     {
         int skipCount = ((pageIndex - 1) * pageSize);
         IQueryable <SYS_ButtonGroup> query = contex.SYS_ButtonGroup;
         if (!string.IsNullOrEmpty(BG_Name))
         {
             query = query.Where(c => c.BG_Name == BG_Name);
         }
         if (!string.IsNullOrEmpty(BG_Name_En))
         {
             query = query.Where(c => c.BG_Name_En == BG_Name_En);
         }
         //表中有无法转换的字段,所以用动态类型进行转换
         List <dynamic> list = query.Select(c => new { BG_Name = c.BG_Name, BG_Name_En = c.BG_Name_En, BG_OrderIndex = c.BG_OrderIndex, BG_Desc = c.BG_Desc }).ToList <dynamic>();
         //List<SYS_ButtonGroup> list = query.OrderByDescending(c => c.BG_CreatedOn).ToList();
         //foreach (var item in list)
         //{
         //    item.BG_RowVersion = null;
         //}
         allRows  = list.Count();
         allPages = allRows / pageSize + allRows % pageSize == 0 ? 0 : 1;
         return(pageIndex == 0 ? list : list.Skip(skipCount).Take(pageSize).ToList());
     }
 }
Exemplo n.º 5
0
        public string Allocate(JObject json)
        {
            try
            {
                int AR_AccountId = Convert.ToInt32(json["ACC_ID"].ToString());
                using (NERPEntities context = new NERPEntities())
                {
                    //删除已有的数据集合
                    List <SYS_AccountRole> tempList = context.SYS_AccountRole.Where(c => c.AR_AccountId == AR_AccountId).ToList();
                    context.SYS_AccountRole.RemoveRange(tempList);
                    context.SaveChanges();

                    //循环添加
                    for (int i = 0; i < json["RoleValueArray"].Count(); i++)
                    {
                        string          tempRoleName = json["RoleValueArray"][i].ToString();
                        SYS_AccountRole _role        = new SYS_AccountRole();
                        _role.AR_AccountId = AR_AccountId;
                        int AR_SystemRoleId = context.SYS_SystemRole.Where(c => c.ROLE_Name == tempRoleName).FirstOrDefault().ROLE_Id;
                        _role.AR_SystemRoleId = AR_SystemRoleId;
                        DPBase.Add(_role);
                    }
                    return("保存成功!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "转换的过程中发生了错误!");
            }
        }
Exemplo n.º 6
0
 public string GetComboxJson()
 {
     using (NERPEntities db = new NERPEntities())
     {
         var d = db.SYS_Button.OrderBy(c => c.BTN_OrderIndex).Select(c => new { name = c.BTN_Name, code = c.BTN_Id }).ToList();
         return(JsonConvert.SerializeObject(d));
     }
 }
Exemplo n.º 7
0
 public string GetCategoryJson()
 {
     using (NERPEntities db = new NERPEntities())
     {
         var d = db.SYS_DicCategory.OrderBy(c => c.Sortnum).ToList();
         return(JsonConvert.SerializeObject(d));
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 获取所有手机端菜单-调用存储过程sp_AuthorityWap实现-20150402
 /// </summary>
 /// <param name="staffId">工号</param>
 /// <returns></returns>
 public static IList <Menu> GetFunctionMenuWap(string staffId)
 {
     using (NERPEntities context = new NERPEntities())
     {
         var query = context.sp_AuthorityWap(staffId).ToList();
         var menus = GetChildMenu(query, 0);
         return(menus);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 实体查询
 /// </summary>
 public List <dynamic> getList(System.Linq.Expressions.Expression <Func <T, bool> > where)
 {
     using (NERPEntities contex = new NERPEntities())
     {
         var            aa   = new { BG_Name = "123", BG_Name_En = "456", BG_OrderIndex = "678", BG_Desc = "789" };
         List <dynamic> list = contex.Set <T>().Where(where).Select(c => aa).ToList <dynamic>();
         return(list);
     }
 }
Exemplo n.º 10
0
        public SYS_DicCategory CategoryGet(JObject json)
        {
            var model = JsonToObject <SYS_DicCategory>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var d = db.SYS_DicCategory.Where(c => c.DicCategory_Code == model.DicCategory_Code).ToList().FirstOrDefault();
                return(d);
            }
        }
Exemplo n.º 11
0
        public string CategoryUpdate(JObject json)
        {
            var model = JsonToObject <SYS_DicCategory>(json);

            using (NERPEntities db = new NERPEntities())
            {
                db.SYS_DicCategory.Attach(model);
                db.Entry(model).State = EntityState.Modified;
                return((db.SaveChanges() > 0) ? "修改成功!" : "修改失败");
            }
        }
Exemplo n.º 12
0
        public string CategoryAdd(JObject json)
        {
            var model = JsonToObject <SYS_DicCategory>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var d = db.SYS_DicCategory.Select(c => c.DicCategory_Code).ToList().LastOrDefault(); //查询id最大值
                model.DicCategory_Code = (int.Parse(d) + 1).ToString();                              //新的id为最大值id++
                db.SYS_DicCategory.Add(model);
                return((db.SaveChanges() > 0) ? "新增成功!" : "新增失败");
            }
        }
Exemplo n.º 13
0
        public int Update(JObject json)
        {
            var model = JsonToObject <SYS_FunctionItem>(json);

            model.FI_CreatedOn = DateTime.Now;
            using (NERPEntities db = new NERPEntities())
            {
                db.SYS_FunctionItem.Attach(model);
                db.Entry(model).State = EntityState.Modified;
                return((db.SaveChanges() > 0) ? 1 : -2);  //成功1,失败-2
            }
        }
Exemplo n.º 14
0
        public string Delete(JObject json)
        {
            var model = JsonToObject <SYS_Dics>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var d = db.SYS_Dics.Where(c => c.Dics_Code == model.Dics_Code).FirstOrDefault();
                db.SYS_Dics.Remove(d);

                return((db.SaveChanges() > 0) ? "删除成功!" : "删除失败");
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 更改密码
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static int ChangePassWord(string userName, string password)
        {
            var newPassWord = StringHelper.CreateMD5(password);//md5加密

            using (NERPEntities context = new NERPEntities())
            {
                var result = context.SYS_Account.First(c => c.ACC_Account == userName);
                result.ACC_Password = newPassWord;
                var d = context.SaveChanges();
                return(d);
            }
        }
Exemplo n.º 16
0
        public string GetButtonJson(JObject json)
        {
            var model = JsonToObject <vw_FunctionItem>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var d = db.vw_FunctionItem.OrderBy(c => c.FI_Id).
                        OrderBy(c => c.FI_ButtonGroupOrderIndex).
                        Where(c => c.FI_TreeId == model.FI_TreeId && c.FI_ButtonGroupId == model.FI_ButtonGroupId).
                        Select(c => new { name = c.BTN_Name, code = c.FI_ButtonId, OrderIndex = c.FI_ButtonOrderIndex, TreeId = c.FI_TreeId, FI_Id = c.FI_Id }).ToList();
                return(JsonConvert.SerializeObject(d));
            }
        }
Exemplo n.º 17
0
 public static void SaveAlltheRights()
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转化的过程中发生了错误!");
     }
 }
Exemplo n.º 18
0
        public int Delete(JObject json)
        {
            var model = JsonToObject <SYS_FunctionItem>(json);

            using (NERPEntities db = new NERPEntities())
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                var d = db.SYS_FunctionItem.Where(c => c.FI_TreeId == model.FI_TreeId && c.FI_ButtonGroupId == model.FI_ButtonGroupId && c.FI_ButtonId == model.FI_ButtonId).FirstOrDefault();
                db.SYS_FunctionItem.Remove(d);

                return((db.SaveChanges() > 0) ? 1 : -2);  //成功1,失败-2
            }
        }
Exemplo n.º 19
0
        public string Add(JObject json)
        {
            SetDefaultValue(json);
            var model = JsonToObject <SYS_FunctionTree>(json);

            //model.FT_IsSuspended = false;   //默认为false
            model.FT_CreatedBy = UserSession.username;  //当前用户
            model.FT_CreatedOn = DateTime.Now;
            using (NERPEntities db = new NERPEntities())
            {
                db.SYS_FunctionTree.Add(model);
                return((db.SaveChanges() > 0)? "新增成功!" : "新增失败");
            }
        }
Exemplo n.º 20
0
        public string GetJson(JObject json)
        {
            var model = JsonToObject <vw_FunctionItem>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var d = db.vw_FunctionItem.
                        OrderBy(c => c.FI_ButtonGroupOrderIndex).
                        Where(c => c.FI_TreeId == model.FI_TreeId).
                        Select(c => new { name = c.BG_Name, code = c.FI_ButtonGroupId, OrderIndex = c.FI_ButtonGroupOrderIndex, TreeId = c.FI_TreeId, FI_Id = c.FI_Id }).
                        DistinctBy(p => new { p.code }); //过滤重复字段
                return(JsonConvert.SerializeObject(d));
            }
        }
Exemplo n.º 21
0
        public string ValACCAttribute(JObject json)
        {
            SYS_Account model = JsonToObject <SYS_Account>(json);

            using (NERPEntities context = new NERPEntities())
            {
                IQueryable <SYS_Account> _Account = context.SYS_Account.Where(c => c.ACC_Account == model.ACC_Account);
                if (_Account.Count() > 0)
                {
                    return("1");
                }
                return("0");
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// 验证按钮组属性
 /// </summary>
 /// <returns></returns>
 public static string DPValBtnGroupAttribute(SYS_ButtonGroup bGroup)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             string flag = string.Empty;
             IQueryable <SYS_ButtonGroup> _valbGroup = context.SYS_ButtonGroup;
             if (bGroup.BG_Id != 0)
             {
                 _valbGroup = _valbGroup.Where(c => c.BG_Id != bGroup.BG_Id);
             }
             IQueryable <SYS_ButtonGroup> _valName = _valbGroup.Where(c => c.BG_Name == bGroup.BG_Name);
             if (_valName.Count() != 0)
             {
                 flag = "0";
             }
             else
             {
                 IQueryable <SYS_ButtonGroup> _valName_En = _valbGroup.Where(c => c.BG_Name_En == bGroup.BG_Name_En);
                 if (_valName_En.Count() != 0)
                 {
                     flag = "1";
                 }
                 else
                 {
                     //_valbGroup = context.SYS_ButtonGroup.Where(c => c.BG_OrderIndex == bGroup.BG_OrderIndex);
                     //if (_valbGroup.Count() != 0)
                     //{
                     //     flag = "2";
                     //}
                     //else
                     //{
                     IQueryable <SYS_ButtonGroup> _valMark = _valbGroup.Where(c => c.BG_Mark == bGroup.BG_Mark);
                     if (_valMark.Count() != 0)
                     {
                         flag = "3";
                     }
                     //}
                 }
             }
             return(flag);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// 获取按钮组
 /// </summary>
 /// <returns></returns>
 public static SYS_ButtonGroup DPGetBtnInformation(SYS_ButtonGroup bGroup)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             SYS_ButtonGroup btnGroup = context.SYS_ButtonGroup.Where(c => c.BG_Name_En == bGroup.BG_Name_En).FirstOrDefault();
             return(btnGroup);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// 登陆
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public static List <SYS_Account> Login(string userName, string password)
 {
     try
     {
         var newPassWord = StringHelper.CreateMD5(password);//md5加密
         using (NERPEntities context = new NERPEntities())
         {
             var result = context.SYS_Account.Where(c => c.ACC_Account == userName && c.ACC_Password == newPassWord).ToList();
             return(result);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 25
0
 public Array GetRoleChecked(string accout)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             //    var _list = context.vw_AccountRole.Where(c => c.staffid == accout).Select(o => new { ROLE_Name = o.ROLE_Name }).ToArray();
             var _list = context.vw_AccountRole.Where(c => c.staffid == accout).Select(o => o.ROLE_Name).ToArray();
             //return JsonConvert.SerializeObject(_list);
             return(_list);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 26
0
        public string CategoryDelete(JObject json)
        {
            var model = JsonToObject <SYS_DicCategory>(json);

            using (NERPEntities db = new NERPEntities())
            {
                var count = db.SYS_Dics.Count(c => c.CategoryId.ToString() == model.DicCategory_Code);
                if (count > 0)
                {
                    return("删除失败,因为该分类下有数据字典,请先删除数据字典!");
                }
                var d = db.SYS_DicCategory.Where(c => c.DicCategory_Code == model.DicCategory_Code).FirstOrDefault();
                db.SYS_DicCategory.Remove(d);

                return((db.SaveChanges() > 0) ? "删除成功!" : "删除失败");
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// 保存按钮组
 /// </summary>
 /// <returns></returns>
 public static void DPSaveButtonModel(SYS_ButtonGroup bGroup)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             bGroup.BG_IsSuspended = false;
             bGroup.BG_CreatedOn   = DateTime.Now;
             bGroup.BG_CreatedBy   = "SYS";
             context.SYS_ButtonGroup.Add(bGroup);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 28
0
        public string ValRolAttribute(JObject json)
        {
            if (string.IsNullOrEmpty(json["ROLE_Level"].ToString()) || string.IsNullOrEmpty(json["ROLE_OrderIndex"].ToString()))
            {
                json["ROLE_Level"]      = 0;
                json["ROLE_OrderIndex"] = 0;
            }
            SYS_SystemRole model = JsonToObject <SYS_SystemRole>(json);

            using (NERPEntities context = new NERPEntities())
            {
                IQueryable <SYS_SystemRole> _role = context.SYS_SystemRole.Where(c => c.ROLE_Name == model.ROLE_Name);
                if (_role.Count() > 0)
                {
                    return("1");
                }
                return("0");
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// 验证按钮属性
 /// </summary>
 /// <returns></returns>
 public static string DPValBtnAttribute(SYS_Button Btn)
 {
     try
     {
         using (NERPEntities context = new NERPEntities())
         {
             string flag = string.Empty;
             IQueryable <SYS_Button> _valbBtn = context.SYS_Button;
             if (Btn.BTN_Id != 0)
             {
                 _valbBtn = _valbBtn.Where(c => c.BTN_Id != Btn.BTN_Id);
             }
             var _valName = _valbBtn.Where(c => c.BTN_Name == Btn.BTN_Name);
             if (_valName.Count() != 0)
             {
                 flag = "0";
             }
             else
             {
                 var _valName_En = _valbBtn.Where(c => c.BTN_Name_En == Btn.BTN_Name_En);
                 if (_valName_En.Count() != 0)
                 {
                     flag = "1";
                 }
                 else
                 {
                     var _valMark = _valbBtn.Where(c => c.BTN_Mark == Btn.BTN_Mark);
                     if (_valMark.Count() != 0)
                     {
                         flag = "3";
                     }
                     //}
                 }
             }
             return(flag);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "转换的过程中发生了错误!");
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// 通用查询
        /// </summary>
        /// <param name="BtnG"></param>
        /// <param name="rp"></param>
        /// <param name="page"></param>
        /// <param name="allRows"></param>
        /// <param name="allPages"></param>
        /// <returns></returns>
        public static List <dynamic> DPGetQueryLst <T>(SearchMod <T> aa)
        {
            using (NERPEntities contex = new NERPEntities())
            {
                int            skipCount = ((aa.page - 1) * aa.rp);
                string         afg       = typeof(T).ToString();
                IQueryable <T> query     = null;

                ParameterExpression  left             = Expression.Parameter(typeof(T), "c");       //c=>
                ConstantExpression   _constExp        = Expression.Constant("aaa", typeof(string)); //一个常量
                MethodCallExpression _methodCallexp   = Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), _constExp);
                Expression <Action>  consoleLambdaExp = Expression.Lambda <Action>(_methodCallexp);

                //表中有无法转换的字段,所以用动态类型进行转换
                List <dynamic> list = query.Select(c => new { BG_Name = "123", BG_Name_En = "456", BG_OrderIndex = "678", BG_Desc = "789" }).ToList <dynamic>();
                aa.total = list.Count();
                aa.total = aa.total / aa.rp + aa.total % aa.rp == 0 ? 0 : 1;
                return(aa.page == 0 ? list : list.Skip(skipCount).Take(aa.rp).ToList());
            }
        }