Esempio n. 1
0
        /// <summary>
        /// 获取用户所能查看的易诺用户池客户类型
        /// </summary>
        /// <param name="model">系统用户实体</param>
        private EyouSoft.Model.SystemStructure.SystemUser GetSysUserCustomerTypeIds(EyouSoft.Model.SystemStructure.SystemUser model)
        {
            if (model == null || model.ID <= 0)
            {
                return(model);
            }

            IList <int> CustomerTypeIds = new List <int>();
            string      strSql          = " SELECT [CustomerId] FROM [tbl_UserCustomerType] where UserId = @ID; ";
            DbCommand   dc = base.PoolStore.GetSqlStringCommand(strSql);

            base.PoolStore.AddInParameter(dc, "ID", DbType.Int32, model.ID);
            using (IDataReader dr = DbHelper.ExecuteReader(dc, base.PoolStore))
            {
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        CustomerTypeIds.Add(dr.GetInt32(0));
                    }
                }
            }
            model.CustomerTypeIds = CustomerTypeIds;
            return(model);
        }
Esempio n. 2
0
        protected void LoadUserInfo(int userId)
        {
            EyouSoft.Model.SystemStructure.SystemUser userModel = userBll.GetSystemUserModel(userId);
            us_txtFax.Value       = userModel.ContactFax;
            us_txtMoible.Value    = userModel.ContactMobile;
            us_txtRealName.Value  = userModel.ContactName;
            us_txtTel.Value       = userModel.ContactTel;
            us_txtUserName1.Value = userModel.UserName;
            us_txtUserName1.Attributes.Add("readonly", "readonly");
            userPermitList = userModel.PermissionList;//账户权限
            userTypes      = userModel.CustomerTypeIds;
            //获取账户负责区域列表
            EyouSoft.IBLL.SystemStructure.ISysCity cityBll = EyouSoft.BLL.SystemStructure.SysCity.CreateInstance();

            StringBuilder areaBuilder = new StringBuilder();

            if (userModel.AreaId != null)
            {
                foreach (int areaId in userModel.AreaId)
                {
                    EyouSoft.Model.SystemStructure.SysCity cityModel = cityBll.GetSysCityModel(areaId);
                    areaBuilder.Append(string.Format("<input type='checkbox' checked='checked' id='ckSale_{0}' name='ckSellCity' value='{0}' /><label for='ckSale_{0}'>{1}</label>", areaId.ToString(), cityModel != null ? cityModel.CityName : "暂无"));
                }
            }
            areaHTML = areaBuilder.ToString();
            //绑定类别
        }
Esempio n. 3
0
        /// <summary>
        /// 新增系统管理员用户
        /// </summary>
        /// <param name="model">系统用户实体</param>
        /// <returns>返回新加用户的ID</returns>
        public virtual int AddSystemUser(EyouSoft.Model.SystemStructure.SystemUser model)
        {
            if (model == null)
            {
                return(0);
            }

            DbCommand dc = base.SystemStore.GetSqlStringCommand(Sql_SystemUser_Add);

            #region 参数赋值

            base.SystemStore.AddInParameter(dc, "UserName", DbType.String, model.UserName);
            base.SystemStore.AddInParameter(dc, "PassWord", DbType.String, model.PassWordInfo.NoEncryptPassword);
            base.SystemStore.AddInParameter(dc, "MD5Password", DbType.String, model.PassWordInfo.MD5Password);
            base.SystemStore.AddInParameter(dc, "EncryptPassword", DbType.String, model.PassWordInfo.SHAPassword);
            base.SystemStore.AddInParameter(dc, "ContactName", DbType.String, model.ContactName);
            base.SystemStore.AddInParameter(dc, "ContactTel", DbType.String, model.ContactTel);
            base.SystemStore.AddInParameter(dc, "ContactFax", DbType.String, model.ContactFax);
            base.SystemStore.AddInParameter(dc, "ContactMobile", DbType.String, model.ContactMobile);
            base.SystemStore.AddInParameter(dc, "IsDisable", DbType.String, model.IsDisable ? "1" : "0");
            base.SystemStore.AddInParameter(dc, "PermissionList", DbType.String, model.PermissionList);
            base.SystemStore.AddInParameter(dc, "IssueTime", DbType.DateTime, DateTime.Now);

            #endregion

            object obj = DbHelper.GetSingle(dc, base.SystemStore);
            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="SystemUserId">用户ID</param>
        /// <returns>返回用户实体</returns>
        public virtual EyouSoft.Model.SystemStructure.SystemUser GetSystemUserModel(int SystemUserId)
        {
            Model.SystemStructure.SystemUser model = new EyouSoft.Model.SystemStructure.SystemUser();

            string strWhere = Sql_SystemUser_Select + " where ID = @ID; ";

            strWhere += " select AreaId from tbl_SysUserAreaControl where UserId = @ID; ";
            DbCommand dc = base.SystemStore.GetSqlStringCommand(strWhere);

            base.SystemStore.AddInParameter(dc, "ID", DbType.Int32, SystemUserId);

            using (IDataReader dr = DbHelper.ExecuteReader(dc, base.SystemStore))
            {
                if (dr.Read())
                {
                    if (!string.IsNullOrEmpty(dr[0].ToString()))
                    {
                        model.ID = int.Parse(dr[0].ToString());
                    }
                    model.UserName = dr[1].ToString();
                    model.PassWordInfo.NoEncryptPassword = dr[2].ToString();
                    model.ContactName    = dr[3].ToString();
                    model.ContactTel     = dr[4].ToString();
                    model.ContactFax     = dr[5].ToString();
                    model.ContactMobile  = dr[6].ToString();
                    model.PermissionList = dr[7].ToString();
                    if (!string.IsNullOrEmpty(dr[8].ToString()))
                    {
                        if (dr[8].ToString() == "1")
                        {
                            model.IsDisable = true;
                        }
                        else
                        {
                            model.IsDisable = false;
                        }
                    }
                    if (!string.IsNullOrEmpty(dr[9].ToString()))
                    {
                        model.IssueTime = DateTime.Parse(dr[9].ToString());
                    }
                }

                dr.NextResult();

                IList <int> AreaIds = new List <int>();
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        AreaIds.Add(dr.GetInt32(0));
                    }
                }
                model.AreaId = AreaIds;
            }

            return(GetSysUserCustomerTypeIds(model));
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string method = Utils.GetQueryStringValue("method");

            userName = MasterUserInfo.UserName;
            if (!CheckMasterGrant(YuYingPermission.帐户管理_管理该栏目, YuYingPermission.帐户管理_修改密码))
            {
                Utils.ResponseNoPermit(YuYingPermission.帐户管理_修改密码, true);
                return;
            }
            if (!CheckMasterGrant(YuYingPermission.帐户管理_管理该栏目, YuYingPermission.帐户管理_修改密码))
            {
                haveUpdate = false;
            }

            if (method == "update")
            {
                if (!haveUpdate)
                {
                    Utils.ResponseMeg(false, "对不起,你没有修改密码的权限!");
                    return;
                }
                string oldPass  = Utils.GetQueryStringValue("oldpass");
                string newPass1 = Utils.GetQueryStringValue("newpass1");
                string newPass2 = Utils.GetQueryStringValue("newpass2");
                if (oldPass == "" || newPass1 == "" || newPass2 == "")
                {
                    Utils.ResponseMegNoComplete();
                    return;
                }
                if (newPass1 != newPass2)
                {
                    Utils.ResponseMeg(false, "前后两次密码不匹配!");
                    return;
                }
                EyouSoft.IBLL.SystemStructure.ISystemUser userBll   = EyouSoft.BLL.SystemStructure.SystemUser.CreateInstance();
                EyouSoft.Model.SystemStructure.SystemUser userModel = userBll.GetSystemUserModel(MasterUserInfo.ID);
                if (userModel != null && userModel.PassWordInfo.NoEncryptPassword == oldPass)
                {
                    if (userBll.UpdateUserPassWord(MasterUserInfo.ID, newPass1) > 0)
                    {
                        Utils.ResponseMeg(true, "密码已修改,请妥善保管!");
                    }
                    else
                    {
                        Utils.ResponseMegError();
                    }
                }
                else
                {
                    Utils.ResponseMeg(false, "原密码不正确!");
                }
            }
        }
Esempio n. 6
0
        protected void AddUser()
        {
            EyouSoft.Model.SystemStructure.SystemUser userModel = new EyouSoft.Model.SystemStructure.SystemUser();
            userModel.UserName = Utils.GetFormValue(us_txtUserName1.UniqueID, 16);
            string pass1 = Utils.GetFormValue(us_txtPass1.UniqueID);
            string pass2 = Utils.GetFormValue(us_txtPass2.UniqueID);

            userModel.PassWordInfo.NoEncryptPassword = pass1;
            userModel.ContactName = Utils.GetFormValue(us_txtRealName.UniqueID, 16);
            userModel.ContactTel  = Utils.GetFormValue(us_txtTel.UniqueID);
            if (userModel.UserName == "" || pass1 == "" || pass2 == "" || userModel.ContactName == "" || userModel.ContactTel == "")
            {
                MessageBox.Show(this, "数据请填写完整!");
                return;
            }


            if (pass1 != pass2)
            {
                MessageBox.Show(this, "两次密码不一致!");
                return;
            }
            EyouSoft.IBLL.SystemStructure.ISystemUser sysUserBll = EyouSoft.BLL.SystemStructure.SystemUser.CreateInstance();
            if (sysUserBll.ExistsByUserName(userModel.UserName))
            {
                MessageBox.Show(this, "用户名已存在!");
                return;
            }
            string areaIds = Utils.GetFormValue("ckSellCity");

            userModel.ContactMobile  = Utils.GetFormValue(us_txtMoible.UniqueID);
            userModel.ContactFax     = Utils.GetFormValue(us_txtFax.UniqueID, 30);
            userModel.PermissionList = Utils.GetFormValue("chk_Permit");
            if (areaIds != "")
            {
                userModel.AreaId = areaIds.Split(',').Select(i => Utils.GetInt(i)).ToList <int>();
            }
            //获取绑定的用户类型
            IList <int> custTypeList = Utils.GetFormValues("chkCustType").Select(i => int.Parse(i)).ToList();

            userModel.CustomerTypeIds = custTypeList;

            if (EyouSoft.BLL.SystemStructure.SystemUser.CreateInstance().AddSystemUser(userModel) > 0)
            {
                MessageBox.ShowAndRedirect(this, "保存成功!", "UserListManage.aspx");
            }
            else
            {
                MessageBox.Show(this, "保存失败!");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 绑定列表的时候,根据ID编号获取审核人姓名
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetSysUserName(int id)
        {
            string userName = MasterUserInfo.ContactName;

            if (id != 0)
            {
                EyouSoft.Model.SystemStructure.SystemUser userModel = userBll.GetSystemUserModel(id);
                if (userModel != null)
                {
                    userName = userModel.ContactName;
                }
            }
            return(userName);
        }
Esempio n. 8
0
        protected void UpdateUser(int userId)
        {
            string userName = Utils.GetFormValue(us_txtUserName1.UniqueID, 16);
            string pass1    = Utils.GetFormValue(us_txtPass1.UniqueID);
            string pass2    = Utils.GetFormValue(us_txtPass2.UniqueID);
            string realName = Utils.GetFormValue(us_txtRealName.UniqueID, 16);
            string userTel  = Utils.GetFormValue(us_txtTel.UniqueID);

            if (userName == "" || realName == "" || userTel == "")
            {
                MessageBox.Show(this, "数据请填写完整!");
                return;
            }
            if (pass1 != pass2)
            {
                MessageBox.Show(this, "两次密码不一致!");
                return;
            }
            EyouSoft.Model.SystemStructure.SystemUser userModel = userBll.GetSystemUserModel(userId);
            if (userModel != null)
            {
                string areaIds = Utils.GetFormValue("ckSellCity");
                if (areaIds != "")
                {
                    userModel.AreaId = areaIds.Split(',').Select(i => Utils.GetInt(i)).ToList <int>();
                }
                userModel.UserName       = userName;
                userModel.ContactFax     = Utils.GetFormValue(us_txtFax.UniqueID, 30);
                userModel.ContactMobile  = Utils.GetFormValue(us_txtMoible.UniqueID);
                userModel.ContactTel     = userTel;
                userModel.ContactName    = realName;
                userModel.PermissionList = Utils.GetFormValue("chk_Permit");
                //获取绑定的用户类型
                IList <int> custTypeList = Utils.GetFormValues("chkCustType").Select(i => int.Parse(i)).ToList();
                userModel.CustomerTypeIds = custTypeList;

                if (pass1 != "")
                {
                    userBll.UpdateUserPassWord(userModel.ID, pass1);
                }
            }
            if (userBll.UpdateSystemUser(userModel) > 0)
            {
                MessageBox.ShowAndRedirect(this, "保存成功!", "UserListManage.aspx");
            }
            else
            {
                MessageBox.Show(this, "保存失败!");
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 修改系统用户
        /// </summary>
        /// <param name="model">系统用户实体(区域ID集合为null或者count小于等于0不修改用户和区域的关系)</param>
        /// <returns>-3:新增管理员区域失败;-2:删除旧用户和区域关系失败;-1:新增用户失败;0:用户实体为空;1:Success</returns>
        public int UpdateSystemUser(EyouSoft.Model.SystemStructure.SystemUser model)
        {
            if (model == null)
            {
                return(0);
            }

            int Result = 0;

            using (TransactionScope AddTran = new TransactionScope())
            {
                Result = dal.UpdateSystemUser(model);
                if (Result <= 0)
                {
                    return(-1);
                }

                IList <int> Ids = new List <int>();
                Ids.Add(model.ID);
                if (model.AreaId != null && model.AreaId.Count > 0)
                {
                    Result = dal.DeleteSysUserAreaControl(Ids);
                    Result = dal.AddSysUserAreaControl(model.ID, model.AreaId);
                    if (Result <= 0)
                    {
                        return(-3);
                    }
                }
                if (model.CustomerTypeIds != null && model.CustomerTypeIds.Count > 0)
                {
                    Result = dal.DeleteSysUserCustomerType(Ids);
                    Result = dal.AddSysUserCustomerType(model.ID, model.CustomerTypeIds);
                    if (Result <= 0)
                    {
                        return(-4);
                    }
                }
                Ids.Clear();
                Ids = null;

                Result = 1;
                AddTran.Complete();
            }
            return(Result);
        }
Esempio n. 10
0
        /// <summary>
        /// 修改用户信息(只修改联系人、电话、传真、手机、权限)
        /// </summary>
        /// <param name="model">用户实体</param>
        /// <returns>返回受影响行数</returns>
        public virtual int UpdateSystemUser(EyouSoft.Model.SystemStructure.SystemUser model)
        {
            if (model == null)
            {
                return(0);
            }

            DbCommand dc = base.SystemStore.GetSqlStringCommand(Sql_SystemUser_Update);

            base.SystemStore.AddInParameter(dc, "ContactName", DbType.String, model.ContactName);
            base.SystemStore.AddInParameter(dc, "ContactTel", DbType.String, model.ContactTel);
            base.SystemStore.AddInParameter(dc, "ContactFax", DbType.String, model.ContactFax);
            base.SystemStore.AddInParameter(dc, "ContactMobile", DbType.String, model.ContactMobile);
            base.SystemStore.AddInParameter(dc, "PermissionList", DbType.String, model.PermissionList);
            base.SystemStore.AddInParameter(dc, "ID", DbType.Int32, model.ID);

            return(DbHelper.ExecuteSql(dc, base.SystemStore));
        }
Esempio n. 11
0
        /// <summary>
        /// 新增系统用户(管理员区域ID集合为null或者count小于等于0不添加)
        /// </summary>
        /// <param name="model">系统用户实体</param>
        /// <returns>-2:新增管理员区域失败;-1:新增用户失败;0:用户实体为空;1:Success</returns>
        public int AddSystemUser(EyouSoft.Model.SystemStructure.SystemUser model)
        {
            if (model == null)
            {
                return(0);
            }

            //设置所有的密码
            model.PassWordInfo = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance().InitPassWordModel(model.PassWordInfo.NoEncryptPassword);

            int Result = 0;

            using (TransactionScope AddTran = new TransactionScope())
            {
                Result   = dal.AddSystemUser(model);
                model.ID = Result;
                if (Result <= 0)
                {
                    return(-1);
                }
                if (model.AreaId != null && model.AreaId.Count > 0)
                {
                    Result = dal.AddSysUserAreaControl(Result, model.AreaId);
                    if (Result <= 0)
                    {
                        return(-2);
                    }
                }
                if (model.CustomerTypeIds != null && model.CustomerTypeIds.Count > 0)
                {
                    Result = dal.AddSysUserCustomerType(model.ID, model.CustomerTypeIds);
                    if (Result <= 0)
                    {
                        return(-3);
                    }
                }

                Result = 1;
                AddTran.Complete();
            }

            return(Result);
        }
Esempio n. 12
0
        /// <summary>
        /// 验证用户是否存在(存在返回该用户实体,不存在返回null)
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="PassWord">密码</param>
        /// <returns>存在返回该用户实体,不存在返回null</returns>
        public virtual Model.SystemStructure.SystemUser ExistsByUserName(string UserName, string PassWord)
        {
            if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(PassWord))
            {
                return(null);
            }

            Model.SystemStructure.SystemUser model = new EyouSoft.Model.SystemStructure.SystemUser();

            string strWhere = Sql_SystemUser_Select + " where [UserName] = @UserName and [PassWord] = @PassWord; ";

            strWhere += " select [AreaId] from [tbl_SysUserAreaControl] where [UserId] = (select top 1 ID from [tbl_SystemUser] where [UserName] = @UserName and [PassWord] = @PassWord) order by [AreaId] asc ; ";
            DbCommand dc = base.SystemStore.GetSqlStringCommand(strWhere);

            base.SystemStore.AddInParameter(dc, "UserName", DbType.String, UserName);
            base.SystemStore.AddInParameter(dc, "PassWord", DbType.String, PassWord);

            using (IDataReader dr = DbHelper.ExecuteReader(dc, base.SystemStore))
            {
                while (dr.Read())
                {
                    if (!string.IsNullOrEmpty(dr[0].ToString()))
                    {
                        model.ID = int.Parse(dr[0].ToString());
                    }
                    model.UserName = dr[1].ToString();
                    model.PassWordInfo.NoEncryptPassword = dr[2].ToString();
                    model.ContactName    = dr[3].ToString();
                    model.ContactTel     = dr[4].ToString();
                    model.ContactFax     = dr[5].ToString();
                    model.ContactMobile  = dr[6].ToString();
                    model.PermissionList = dr[7].ToString();
                    if (!string.IsNullOrEmpty(dr[8].ToString()))
                    {
                        if (dr[8].ToString() == "1")
                        {
                            model.IsDisable = true;
                        }
                        else
                        {
                            model.IsDisable = false;
                        }
                    }
                    if (!string.IsNullOrEmpty(dr[9].ToString()))
                    {
                        model.IssueTime = DateTime.Parse(dr[9].ToString());
                    }

                    break;
                }

                dr.NextResult();

                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        model.AreaId.Add(dr.GetInt32(0));
                    }
                }
            }
            return(model);
        }
Esempio n. 13
0
        /// <summary>
        /// 获取系统用户列表
        /// </summary>
        /// <param name="PageSize">每页记录数</param>
        /// <param name="PageIndex">当前页数</param>
        /// <param name="RecordCount">总记录数</param>
        /// <param name="OrderIndex">排序索引,0添加时间升序,1添加时间降序</param>
        /// <param name="AreaId">线路区域ID</param>
        /// <param name="UserName">用户名(模糊查询)</param>
        /// <param name="ContactName">联系人(模糊查询)</param>
        /// <returns>系统用户实体集合</returns>
        public virtual IList <EyouSoft.Model.SystemStructure.SystemUser> GetSystemUserList(int PageSize, int PageIndex, ref int RecordCount, int OrderIndex, int AreaId, string UserName, string ContactName)
        {
            IList <EyouSoft.Model.SystemStructure.SystemUser> list = new List <EyouSoft.Model.SystemStructure.SystemUser>();

            bool   IsWhere  = false;
            string strWhere = string.Empty;
            string strFiles = " [ID],[UserName],[PassWord],[ContactName],[ContactTel],[ContactFax],[ContactMobile],[PermissionList],[IsDisable],[IssueTime] ";
            string strOrder = string.Empty;

            if (AreaId > 0)
            {
                strWhere += string.Format(" ID in (select distinct [UserId] from [tbl_SysUserAreaControl] where [AreaId] = {0}) ", AreaId);
                IsWhere   = true;
            }
            if (!string.IsNullOrEmpty(UserName))
            {
                if (IsWhere)
                {
                    strWhere += " and ";
                }

                strWhere += string.Format(" [UserName] like '%{0}%' ", UserName.Replace("'", ""));
                IsWhere   = true;
            }
            if (!string.IsNullOrEmpty(ContactName))
            {
                if (IsWhere)
                {
                    strWhere += " and ";
                }

                strWhere += string.Format(" [ContactName] like '%{0}%' ", ContactName.Replace("'", ""));
                IsWhere   = true;
            }
            switch (OrderIndex)
            {
            case 0: strOrder = " [IssueTime] asc "; break;

            case 1: strOrder = " [IssueTime] desc "; break;

            default: strOrder = " [IssueTime] desc "; break;
            }

            using (IDataReader dr = DbHelper.ExecuteReader(base.SystemStore, PageSize, PageIndex, ref RecordCount, "tbl_SystemUser", "[ID]", strFiles, strWhere, strOrder))
            {
                Model.SystemStructure.SystemUser model = null;
                while (dr.Read())
                {
                    model = new EyouSoft.Model.SystemStructure.SystemUser();
                    if (!string.IsNullOrEmpty(dr[0].ToString()))
                    {
                        model.ID = int.Parse(dr[0].ToString());
                    }
                    model.UserName = dr[1].ToString();
                    model.PassWordInfo.NoEncryptPassword = dr[2].ToString();
                    model.ContactName    = dr[3].ToString();
                    model.ContactTel     = dr[4].ToString();
                    model.ContactFax     = dr[5].ToString();
                    model.ContactMobile  = dr[6].ToString();
                    model.PermissionList = dr[7].ToString();
                    if (!string.IsNullOrEmpty(dr[8].ToString()))
                    {
                        if (dr[8].ToString() == "1")
                        {
                            model.IsDisable = true;
                        }
                        else
                        {
                            model.IsDisable = false;
                        }
                    }
                    if (!string.IsNullOrEmpty(dr[9].ToString()))
                    {
                        model.IssueTime = DateTime.Parse(dr[9].ToString());
                    }

                    list.Add(model);
                }
                model = null;
            }

            return(list);
        }