Ejemplo n.º 1
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 + "转换的过程中发生了错误!");
            }
        }
Ejemplo n.º 2
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) ? "修改成功!" : "修改失败");
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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) ? "新增成功!" : "新增失败");
            }
        }
Ejemplo n.º 5
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) ? "删除成功!" : "删除失败");
            }
        }
Ejemplo n.º 6
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
            }
        }
Ejemplo n.º 7
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
            }
        }
Ejemplo n.º 8
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)? "新增成功!" : "新增失败");
            }
        }
Ejemplo n.º 9
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) ? "删除成功!" : "删除失败");
            }
        }
Ejemplo n.º 10
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 + "转换的过程中发生了错误!");
     }
 }
Ejemplo n.º 11
0
        public string Add(JObject json)
        {
            var model = JsonToObject <SYS_FunctionItem>(json);

            model.FI_CreatedOn = DateTime.Now;
            using (NERPEntities db = new NERPEntities())
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                db.SYS_FunctionItem.Add(model);
                if (db.SaveChanges() > 0)//成功1,失败-2
                {
                    var d = new { id = model.FI_Id, ordexindex = model.FI_ButtonOrderIndex, treeid = model.FI_TreeId, result = 1 };
                    return(JsonConvert.SerializeObject(d));
                }
                else
                {
                    var d = new { result = -2 };
                    return(JsonConvert.SerializeObject(d));
                }
            }
        }