Exemplo n.º 1
0
        /// <summary>
        /// 更新职员的密码。
        /// </summary>
        /// <param name="loginId">登录Id。</param>
        /// <param name="password">新的密码。</param>
        public static void UpdatePassword(string loginId, string password)
        {
            Staff s = Db.Session.Load(typeof(Staff), loginId) as Staff;

            s.Password = StringSecurity.StringToSHA1Hash(password);

            Db.TransUpdate(s);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新用户的密码。
        /// </summary>
        /// <param name="loginId">登录Id。</param>
        /// <param name="password">新的密码。</param>
        public static void UpdatePassword(string loginId, string password)
        {
            Db.SessionFactory.EvictQueries("User");

            User u = Db.Session.Load(typeof(User), loginId) as User;

            u.Password = StringSecurity.StringToSHA1Hash(password);

            Db.TransUpdate(u);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增职员。
        /// </summary>
        /// <param name="dto">待新增职员的信息。</param>
        /// <returns>新增是否成功的标示。(1:成功;-2:登录Id重复)</returns>
        public static string InsertStaff(StaffDTO dto)
        {
            //判断登录Id是否重复。
            string hql = "select count(*) from Staff s where s.LoginId = :loginId";
            IQuery q   = Db.Session.CreateQuery(hql);

            q.SetString("loginId", dto.LoginId);
            object o = q.UniqueResult();

            if (int.Parse(o.ToString()) > 0)
            {
                return("-2");
            }

            //职员基本信息。
            Staff s = new Staff();

            s.LoginId                = dto.LoginId;
            s.Password               = StringSecurity.StringToSHA1Hash(dto.Password);
            s.Name                   = dto.Name;
            s.Disabled               = dto.Disabled;
            s.OrderId                = dto.OrderId;
            s.IdCard                 = dto.IdCard;
            s.Code                   = dto.Code;
            s.OfficePhone            = dto.OfficePhone;
            s.ExtNumber              = dto.ExtNumber;
            s.CellPhone              = dto.CellPhone;
            s.FamilyPhone            = dto.FamilyPhone;
            s.Email                  = dto.Email;
            s.ZipCode                = dto.ZipCode;
            s.Remark                 = dto.Remark;
            s.Address                = dto.Address;
            s.DegreeTag              = dto.DegreeTag;
            s.Sex                    = dto.Sex;
            s.PoliticalAppearanceTag = dto.PoliticalAppearanceTag;
            s.Married                = dto.Married;
            s.Birthday               = dto.Birthday;
            s.CountryTag             = dto.CountryTag;
            s.EntersDay              = dto.EntersDay;
            s.NationTag              = dto.NationTag;
            s.LeavesDay              = dto.LeavesDay;
            s.PositionTag            = dto.PositionTag;
            s.TitleTag               = dto.TitleTag;

            //所有通过程序加入的职员都不是内部用户。
            s.IsInnerUser = 0;

            //所属部门。
            Department d = Db.Session.Load(typeof(Department), dto.DepartmentId) as Department;

            d.AddStaff(s);

            Db.TransInsert(s);
            return("1");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 通过登录ID和密码获取职员。
        /// </summary>
        /// <param name="LoginId">登录ID。</param>
        /// <param name="Password">密码。</param>
        /// <returns>职员。</returns>
        public static Staff GetStaffByLoginIdAndPassword(string LoginId, string Password)
        {
            string hql = "from Staff s where s.LoginId = :loginId and s.Password = :Password";
            IQuery q   = Db.Session.CreateQuery(hql);

            q.SetString("loginId", LoginId);
            q.SetString("Password", StringSecurity.StringToSHA1Hash(Password));
            object o = q.UniqueResult();

            return(o == null ? null : o as Staff);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 通过登录ID和密码获取用户。
        /// <remarks>
        /// 前台用户在前台登录时使用。
        /// </remarks>
        /// </summary>
        /// <param name="LoginId">登录ID。</param>
        /// <param name="Password">密码。</param>
        /// <returns>用户。</returns>
        public static User GetUserByLoginIdAndPassword(string loginId, string password)
        {
            string hql = "from User u where u.LoginId = :loginId and u.Password = :Password";
            IQuery q   = Db.Session.CreateQuery(hql);

            q.SetString("loginId", loginId);
            q.SetString("Password", StringSecurity.StringToSHA1Hash(password));
            object o = q.UniqueResult();

            return(o == null ? null : o as User);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新职员的密码。
        /// </summary>
        /// <param name="loginId">登录Id。</param>
        /// <param name="oldPassword">原密码。</param>
        /// <param name="newPassword">新密码。</param>
        /// <returns>返回true表示更新密码成功;false表示原密码错误。</returns>
        public static bool UpdatePassword(string loginId, string oldPassword, string newPassword)
        {
            Staff s = Db.Session.Load(typeof(Staff), loginId) as Staff;

            if (s.Password == StringSecurity.StringToSHA1Hash(oldPassword))
            {
                s.Password = StringSecurity.StringToSHA1Hash(newPassword);
                Db.TransUpdate(s);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 更新用户的密码。
        /// </summary>
        /// <remarks>
        /// 前台用户在前台页面调用。
        /// </remarks>
        /// <param name="loginId">登录Id。</param>
        /// <param name="oldPassword">原密码。</param>
        /// <param name="newPassword">新密码。</param>
        /// <returns>true:更新密码成功;false:原密码错误。</returns>
        public static bool UpdatePassword(string loginId, string oldPassword, string newPassword)
        {
            User u = Db.Session.Load(typeof(User), loginId) as User;

            if (u.Password == StringSecurity.StringToSHA1Hash(oldPassword))
            {
                Db.SessionFactory.EvictQueries("User");

                u.Password = StringSecurity.StringToSHA1Hash(newPassword);
                Db.TransUpdate(u);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 新增用户。
        /// </summary>
        /// <param name="dto">待新增用户的信息。</param>
        /// <returns>新增是否成功的标示。(1:成功;-2:登录Id重复。)</returns>
        public static string InsertUser(UserDTO dto)
        {
            //判断登录Id是否重复。
            string hql = "select count(*) from User u where u.LoginId = :loginId";
            IQuery q   = Db.Session.CreateQuery(hql);

            q.SetString("loginId", dto.LoginId);
            object o = q.UniqueResult();

            if (int.Parse(o.ToString()) > 0)
            {
                return("-2");
            }

            Db.SessionFactory.EvictQueries("User");

            User u = new User();

            u.LoginId      = dto.LoginId;
            u.Password     = StringSecurity.StringToSHA1Hash(dto.Password);
            u.Name         = dto.Name;
            u.Disabled     = dto.Disabled;
            u.IdCard       = dto.IdCard;
            u.Sex          = dto.Sex;
            u.Birthday     = dto.Birthday;
            u.OfficePhone  = dto.OfficePhone;
            u.CellPhone    = dto.CellPhone;
            u.FamilyPhone  = dto.FamilyPhone;
            u.Email        = dto.Email;
            u.ZipCode      = dto.ZipCode;
            u.Remark       = dto.Remark;
            u.Address      = dto.Address;
            u.RegisterDate = DateTime.Now;

            Db.TransInsert(u);
            return("1");
        }