Beispiel #1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="roles"></param>
 /// <returns></returns>
 public String Update(Roles roles)
 {
     try
     {
         int result = new BLRoles().Update(roles);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "修改成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "修改失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "修改失败,失败原因:" + ex.Message
         }));
     }
 }
Beispiel #2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="roles"></param>
 /// <returns></returns>
 public String Add(Roles roles)
 {
     try
     {
         roles.RoleId = Guid.NewGuid().ToString();
         int result = new BLRoles().Add(roles);
         if (result > 0)
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = true, msg = "新增成功"
             }));
         }
         else
         {
             return(JsonConvert.JavaScriptSerializer(new ExtResult()
             {
                 success = false, msg = "新增失败"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.JavaScriptSerializer(new ExtResult()
         {
             success = false, msg = "新增失败,失败原因:" + ex.Message
         }));
     }
 }
Beispiel #3
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <returns></returns>
        public String SelectByPage(int limit, int start)
        {
            int          total;
            List <Roles> roless = new BLRoles().Select(limit, start, new HashTableExp(), out total, "and Role_Id<>'-1'");

            return(JsonConvert.JavaScriptSerializer(new ExtGridRecord(roless, total)));
        }
Beispiel #4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids">Id的集合,如1,2,3</param>
        /// <returns></returns>
        public String Delete(String ids)
        {
            int num = new BLRoles().Delete(ids);

            return(JsonConvert.JavaScriptSerializer(new ExtResult()
            {
                success = true, msg = "成功删除" + num + "条数据"
            }));
        }
Beispiel #5
0
        /// <summary>
        /// 查询角色树信息
        /// </summary>
        /// <returns></returns>
        public String Search()
        {
            List <Roles> roless = new BLRoles().Select(new HashTableExp(), "and Role_Id<>'-1'");
            List <ExtTreeNode <Roles> > nodes = new List <ExtTreeNode <Roles> >();

            foreach (var item in roless)
            {
                nodes.Add(new ExtTreeNode <Roles>()
                {
                    id      = item.RoleId,
                    text    = item.RoleName,
                    leaf    = true,
                    Tobject = item
                });
            }
            return(JsonConvert.JavaScriptSerializer(nodes));
        }
Beispiel #6
0
        /// <summary>
        /// 获得所有角色信息
        /// </summary>
        /// <returns></returns>
        public String GetAllRoles()
        {
            List <Roles> roles = new BLRoles().Select(new HashTableExp(), "and Role_Id<>'-1'");

            return(JsonConvert.JavaScriptSerializer(roles));
        }