示例#1
0
        public Model.APIResult GetLoginUserInfo(string strUserCode, string strPassward)
        {
            Model.APIResult result = new Model.APIResult();
            try
            {
                //获取用户信息
                List <TSUser> tsUserList = new TSUserDAO().GetList("userCode", strUserCode);
                if (tsUserList.Count != 1)
                {
                    result.Data    = null;
                    result.Message = "没有查询到用户的登录信息!";
                    result.Result  = 101;
                }

                TSUser tsUser = tsUserList[0];
                if (!tsUser.userPwd.Equals(Encrypt.ConvertPwd(tsUser.userId, strPassward)))
                {
                    result.Data    = null;
                    result.Message = "用户名与密码不匹配!";
                    result.Result  = 102;
                }
                else if (!"1".Equals(tsUser.status))
                {
                    result.Data    = null;
                    result.Message = "该用户帐号已停用!";
                    result.Result  = 103;
                }

                //获取部门信息
                TSDept tsDept = new TSDeptDAO().Get(tsUser.deptId);
                if (tsDept == null)
                {
                    result.Data    = null;
                    result.Message = "该用户所属部门不存在!";
                    result.Result  = 104;
                }
                else if (!"1".Equals(tsDept.status))
                {
                    result.Data    = null;
                    result.Message = "该用户所属部门已停用!";
                    result.Result  = 105;
                }

                GetModuleInfo(tsUser);

                result.Data    = tsUser;
                result.Message = "获取用户信息成功!";
                result.Result  = 100;
            }
            catch (Exception ex)
            {
                result.Data    = null;
                result.Message = "获取用户信息失败:" + ex.Message;
                result.Result  = 0;
            }
            return(result);
        }
示例#2
0
        ///<summary>
        ///登录系统
        ///</summary>
        /// <param name="context">HTTP请求上下文</param>
        /// <param name="userCode">用户名称</param>
        /// <param name="userPwd">用户密码</param>
        public void Login(System.Web.HttpContext context, string userCode, string userPwd)
        {
            //获取用户信息
            List <TSUser> tsUserList = new TSUserDAO().GetList("userCode", userCode);

            if (tsUserList.Count != 1)
            {
                Message.error(context, "帐号错误");
                return;
            }

            TSUser tsUser = tsUserList[0];

            if (!tsUser.userPwd.Equals(Encrypt.ConvertPwd(tsUser.userId, userPwd)))
            {
                Message.error(context, "密码错误");
                return;
            }
            else if (!"1".Equals(tsUser.status))
            {
                Message.error(context, "帐号停用");
                return;
            }

            //获取部门信息
            TSDept tsDept = new TSDeptDAO().Get(tsUser.deptId);

            if (tsDept == null)
            {
                Message.error(context, "用户所属部门不存在");
                return;
            }
            else if (!"1".Equals(tsDept.status))
            {
                Message.error(context, "用户所属部门停用");
                return;
            }

            //设置登录信息
            this.userId   = tsUser.userId;
            this.userName = tsUser.userName;
            this.roleIds  = tsUser.roleIds;
            this.deptId   = tsUser.deptId;
            this.deptName = tsDept.deptName;

            //会话保存登录用户信息
            context.Session["clientUser"] = this;
            Message.success(context, "success");//成功返回
        }
示例#3
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="userId"></param>
        public void PwdReset(string userId)
        {
            TSUser tsUser = tsUserDAO.Get(userId);

            try
            {
                string password = Encrypt.ConvertPwd(tsUser.userId, tsUser.userCode);
                tsUserDAO.ChangePwd(tsUser.userId, password);
                Message.success(context, "用户密码重置成功");
                loginSession.Log(tsUser.userName + "[" + tsUser.userId + "]用户密码重置成功");
            }
            catch (Exception e)
            {
                Message.error(context, "用户修改失败");
                loginSession.Log(e.Message);
            }
        }
示例#4
0
        /// <summary>
        /// 重置员工密码
        /// </summary>
        /// <param name="staffId"></param>
        /// <param name="roleType"></param>
        public void PawReset(string staffId, string roleType)
        {
            TSAgentUser    tsAgentUser    = new TSAgentUser();
            string         strSQL         = "select * from tsAgentUser where userId=" + staffId + " and roleId!=001";
            TSAgentUserDAO tsAgentUserDao = new TSAgentUserDAO();
            Param          param          = new Param();

            tsAgentUser = tsAgentUserDao.GetList(strSQL, param)[0];
            try
            {
                string userPwd = Encrypt.ConvertPwd(tsAgentUser.userId, tsAgentUser.userCode);
                tsAgentUserDao.ChangePwd(tsAgentUser.userId, userPwd, roleType);
                Message.success(context, "员工密码重置成功");
                loginSession.Log(staffId + "员工密码重置成功");
            }
            catch (Exception e)
            {
                Message.error(context, "员工密码重置失败 ");
                loginSession.Log(e.Message);
            }
        }
示例#5
0
        /// <summary>
        /// 增加系统用户
        /// <param name="tsUser">系统用户</param>
        /// </summary>
        public void Add(TSUser tsUser)
        {
            //判断是否帐号重复
            if (tsUserDAO.Exist("userCode", tsUser.userCode))
            {
                Message.error(context, "帐号重复请重新输入!");
                return;
            }

            try
            {
                tsUser.userId  = commonDao.GetMaxNo("TSUser", "", 6);
                tsUser.userPwd = Encrypt.ConvertPwd(tsUser.userId, tsUser.userPwd);
                tsUser.status  = tsUser.status == null ? "0" : "1";
                tsUserDAO.Add(tsUser);
                Message.success(context, "用户增加成功");
                loginSession.Log(tsUser.userName + "用户增加成功");
            }
            catch (Exception e)
            {
                Message.error(context, "用户增加失败");
                loginSession.Log(e.Message);
            }
        }
示例#6
0
        private DataAccess db = new DataAccess(DataAccess.DBConn);//数据库连接

        /// <summary>
        /// 事务增加快开厅员工
        /// <param name="tbStaff">快开厅员工</param>
        /// </summary>
        public void AddTrans(TBStaff tbStaff, TSAgentUser tsAgentUser)
        {
            ComTransaction trans = null;

            try
            {
                db.Open();
                trans = db.BeginTransaction();
                Add(db, tbStaff);
                tsAgentUser.userId  = tbStaff.staffId;
                tsAgentUser.userPwd = Encrypt.ConvertPwd(tsAgentUser.userId, tsAgentUser.userPwd);
                new TSAgentUserDAO().Add(db, tsAgentUser);
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                throw e;
            }
            finally
            {
                db.Close();
            }
        }
示例#7
0
        /// <summary>
        /// 修改当前用户密码
        /// </summary>
        /// <param name="oldPwd">旧密码</param>
        /// <param name="newPwd">新密码</param>
        public void ChangePwd(string oldPwd, string newPwd)
        {
            TSUserDAO tsUserDao = new TSUserDAO();
            TSUser    user      = tsUserDao.Get(loginUser.UserId);

            if (user.userPwd.Equals(Encrypt.ConvertPwd(user.userId, oldPwd)) == false)
            {
                Message.error(context, "旧密码输入错误");
                return;
            }

            user.userPwd = Encrypt.ConvertPwd(user.userId, newPwd);
            try
            {
                tsUserDao.ChangePwd(user.userId, user.userPwd);
                Message.success(context, "密码修改成功");
                loginUser.Log("密码修改成功");
            }
            catch (Exception e)
            {
                Message.error(context, "密码修改失败");
                loginUser.Log("密码修改失败,错误:" + e.Message);
            }
        }
示例#8
0
        ///<summary>
        ///登录系统
        ///</summary>
        /// <param name="context">HTTP请求上下文</param>
        /// <param name="userCode">用户名称</param>
        /// <param name="userPwd">用户密码</param>
        public void Login(System.Web.HttpContext context, string userCode, string userPwd)
        {
            //获取用户信息
            List <TSAgentUser> tsAgentUserList = new TSAgentUserDAO().GetList("userCode", userCode);

            if (tsAgentUserList.Count != 1)
            {
                Message.error(context, "帐号错误");
                return;
            }

            TSAgentUser tsAgentUser = tsAgentUserList[0];

            if (!tsAgentUser.userPwd.Equals(Encrypt.ConvertPwd(tsAgentUser.userId, userPwd)))
            {
                Message.error(context, "密码错误");
                return;
            }
            //获取代理商和执法文书类型信息
            string roleType = new TSAgentRoleDAO().Get(tsAgentUser.roleId).type;

            if (roleType == "0")
            {
                TBAgent tbAgent = new TBAgentDAO().Get(tsAgentUser.userId);
                if (tbAgent.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "代理商未审核或审核失败");
                    return;
                }
                if (!tbAgent.status.Equals("1"))
                {
                    Message.error(context, "代理商停用");
                    return;
                }
            }
            else
            {
                TBStaff tbStaff = new TBStaffDAO().Get(tsAgentUser.userId);
                TBAgent tbAgent = new TBAgentDAO().Get(tbStaff.agentId);
                if (tbAgent.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "代理商未审核或审核失败");
                    return;
                }
                if (!tbAgent.status.Equals("1"))
                {
                    Message.error(context, "代理商停用");
                    return;
                }
                TBSite tbSite = new TBSiteDAO().Get(tbStaff.siteId);
                if (tbSite.auditStatus != ((int)AuditStauts.AuditSucces).ToString())
                {
                    Message.error(context, "执法文书类型未审核或审核失败");
                    return;
                }
                if (!tbSite.status.Equals("1"))
                {
                    Message.error(context, "执法文书类型停用");
                    return;
                }
            }

            //设置登录信息
            this.userId  = tsAgentUser.userId;
            this.roleIds = tsAgentUser.roleId;
            if (roleType == "0")//代理商
            {
                this.userName = new TBAgentDAO().Get(tsAgentUser.userId).agentName;
            }
            else //员工
            {
                this.userName = new TBStaffDAO().Get(tsAgentUser.userId).staffName;
            }
            //会话保存登录用户信息
            context.Session["clientUser"] = this;
            Message.success(context, "success");//成功返回
        }