Beispiel #1
0
        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetRoleInfo(string id)
        {
            ResultInfo <object> result = new ResultInfo <object>();
            DataTable           dt     = new BLL.sys_roleinfo().GetList("rolecode='" + id + "'").Tables[0];

            result.IsSucceed = true;
            result.Message   = "GetData!";
            result.Entity    = JsonHelper.DataTableToList(dt);
            return(JsonConvert.SerializeObject(result));
        }
Beispiel #2
0
        /// <summary>
        /// 新增、修改角色保存
        /// </summary>
        /// <returns></returns>
        public string RoleSave(string json)
        {
            ResultInfo result   = new ResultInfo(false);
            JObject    jo       = JObject.Parse(json);
            LoginInfo  userInfo = SessionHelper.ReadSession <LoginInfo>(SessionKeys.LoginInfoKey);

            BLL.sys_roleinfo bll = new BLL.sys_roleinfo();
            //新增
            if (jo["id"].ToString() == "-1")
            {
                MultiColorPen.Model.sys_roleinfo model = new MultiColorPen.Model.sys_roleinfo
                {
                    rolecode   = bll.GetMaxNo(),
                    rolename   = jo["rolename"].ToString(),
                    isenable   = 1,
                    remark     = jo["remark"].ToString(),
                    createtime = DateTime.Now,
                    createman  = userInfo.UserName
                };
                if (!string.IsNullOrEmpty(jo["rolesort"].ToString()))
                {
                    model.rolesort = int.Parse(jo["rolesort"].ToString());
                }
                else
                {
                    model.rolesort = 99;
                }
                if (bll.Add(model) > 0)
                {
                    result.IsSucceed = true;
                    result.Message   = "Save Successful!";
                    PublicClass.AddLog("Operating", "Add Role" + model.rolename + "!");
                }
                else
                {
                    result.IsSucceed = false;
                    result.Message   = "Save Failed!";
                }
            }
            else//修改
            {
                string id     = jo["id"].ToString();
                var    umodel = bll.GetModel(id);
                umodel.rolename = jo["rolename"].ToString();
                if (!string.IsNullOrEmpty(jo["rolesort"].ToString()))
                {
                    umodel.rolesort = int.Parse(jo["rolesort"].ToString());
                }
                else
                {
                    umodel.rolesort = 99;
                }
                umodel.remark     = jo["remark"].ToString();
                umodel.updateman  = userInfo.UserName;
                umodel.updatetime = DateTime.Now;
                if (bll.Update(umodel))
                {
                    result.IsSucceed = true;
                    result.Message   = "Save Successful!";
                    PublicClass.AddLog("Operating", "Edit Role" + umodel.rolename + "!");
                }
                else
                {
                    result.IsSucceed = false;
                    result.Message   = "Save Failed!";
                }
            }
            return(JsonConvert.SerializeObject(result));
        }