Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetRole2(HttpContext context)
        {
            var userolesbll = new UseRolesBll();
            var empid       = context.Request.Params["empid"];
            var jss         = new JavaScriptSerializer();

            var useroles = new UseRoles
            {
                LoginName = empid
            };

            string str;

            try
            {
                var dt   = userolesbll.Query(useroles);
                var list = ConvertHelper <Role> .ConvertToList(dt);

                str  = jss.Serialize(list);
                str += "|";
            }
            catch (Exception e)
            {
                Log.Error(e);
                str = "0|false";
                return(str);
            }
            return(str);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public StringBuilder DelRole(HttpContext context)
        {
            var menuPowerBll   = new MenuPowerBll();
            var roleBll        = new RoleBll();
            var userrolebll    = new UseRolesBll();
            var messageRespose = new MessageRespose();
            var sb             = new StringBuilder();
            var roleId         = context.Request.Params["nodeid"];
            var role           = new Role
            {
                RoleId = roleId
            };
            var userrole = new UseRoles
            {
                RoleId = roleId
            };
            var menuPowerDel = new MenuPower
            {
                PowerId = roleId
            };

            try
            {
                if (roleId == "role_admin")
                {
                    return(sb.Append(messageRespose.Success = "3"));
                }
                //联动删除
                roleBll.Del(role);
                userrolebll.Del2(userrole);
                menuPowerBll.Del(menuPowerDel);
                //操作日志
                if (null == context.Session[Constant.LoginUser])
                {
                    return(sb.Append(messageRespose.Success = "2"));
                }
                var oprlog = new OprLog
                {
                    Operator   = ((Employer)(context.Session[Constant.LoginUser])).Name,
                    OperResult = "成功",
                    OprSrc     = "删除角色",
                    LogDate    = DateTime.Now
                };
                _oprLogBll.Add(oprlog);
                return(sb.Append(messageRespose.Success = "删除成功!"));
            }
            catch (Exception e)
            {
                Log.Error("保存角色出错", e);
                throw;
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public StringBuilder GetRole(HttpContext context)
        {
            var userolebll = new UseRolesBll();
            var str        = new StringBuilder();
            var empid      = context.Request.Params["Id"];
            var jss        = new JavaScriptSerializer();

            try
            {
                var dt   = userolebll.FindBy(empid);
                var list = ConvertHelper <UseRoles> .ConvertToList(dt);

                str.Append(jss.Serialize(list));
                //str = str.Substring(1, str.Length - 2);
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
            return(str);
        }
Example #4
0
        /// <summary>
        /// 编辑员工数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string EditEmployee(HttpContext context)
        {
            var employeeBll = new EmployerBll();
            var useRolesBll = new UseRolesBll();
            var id          = context.Request.Params["empid"];
            var worknum     = context.Request.Params["worknum"];
            var empname     = context.Request.Params["empname"];
            var phonenum    = context.Request.Params["phonenum"];
            var parid       = context.Request.Params["parid"];
            var empmail     = context.Request.Params["empmail"];
            var roleid      = context.Request.Params["roleid"].Split('—');
            var employee    = new Employer
            {
                Id       = id,
                DeptId   = parid,
                WorkNum  = worknum,
                Name     = empname,
                PhoneNum = phonenum,
                Email    = empmail
            };

            try
            {
                var userolesdel = new UseRoles
                {
                    LoginName = id
                };
                useRolesBll.Del(userolesdel);
                foreach (var s in roleid)
                {
                    var useroles = new UseRoles
                    {
                        RoleId    = s,
                        LoginName = id
                    };
                    useRolesBll.Add(useroles);
                }

                var bdata = employeeBll.Exist5(employee);
                switch (bdata)
                {
                case "1":
                    return("exist");

                case "0":
                    employeeBll.UpdateEmployee(employee);
                    break;
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                return("false");
            }
            //操作日志
            if (null == context.Session[Constant.LoginUser])
            {
                return("2");
            }
            var oprlog = new OprLog
            {
                Operator   = ((Employer)(context.Session[Constant.LoginUser])).Name,
                OperResult = "成功",
                OprSrc     = "编辑人员",
                LogDate    = DateTime.Now
            };

            _oprLogBll.Add(oprlog);
            return("true");
        }