Exemplo n.º 1
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="name">员工姓名</param>
        /// <param name="sex">员工性别</param>
        /// <param name="age">员工年龄</param>
        /// <param name="nation">员工民族</param>
        /// <param name="phone">员工手机</param>
        /// <param name="email">员工邮箱</param>
        /// <param name="DeptTxt">部门编号</param>
        /// <param name="StateTxt">状态编号</param>
        /// <returns></returns>
        public NewsModel AddStaff(string name, string sex, string age, string nation, string phone, string email, string DeptTxt, string StateTxt)
        {
            StaffManageDAL staffManageDAL = new StaffManageDAL();

            if (staffManageDAL.IsNullStaffByPhone(phone))
            {
                return(new NewsModel(false, "手机号已使用,无法录入!"));
            }
            Staff staff = new Staff();

            staff.Name             = name;
            staff.Sex              = sex.Equals("0") ? false : true;
            staff.Age              = Convert.ToInt32(age);
            staff.Nation           = nation;
            staff.Phone            = phone;
            staff.Email            = email;
            staff.DeptId           = Convert.ToInt32(DeptTxt);
            staff.EstablishDate    = DateTime.Now;
            staff.IsDelete         = false;
            staff.Password         = MD5Tool.MD5Encryption("1");
            staff.Staff_StateId    = Convert.ToInt32(StateTxt);
            staff.Staff_DdentityId = new StaffManageDAL().GetDdentityIdByDeptID(staff.DeptId);

            if (staffManageDAL.AddStaff(staff))
            {
                return(new NewsModel(true, "添加成功"));
            }
            return(new NewsModel(false, "添加失败"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改用户的密码
        /// </summary>
        /// <param name="pwdy">原密码</param>
        /// <param name="pwdx">要修改的密码</param>
        /// <param name="pwdq">修改密码确认</param>
        /// <param name="name">当前用户名字</param>
        /// <returns></returns>
        public NewsModel EditUserPwd(string pwdy, string pwdx, string pwdq, string name)
        {
            if (string.IsNullOrWhiteSpace(pwdy) || string.IsNullOrWhiteSpace(pwdx) || string.IsNullOrWhiteSpace(pwdq))
            {
                return(new NewsModel(false, "请不要留空"));
            }
            if (!pwdx.Equals(pwdq))
            {
                return(new NewsModel(false, "两次密码不一致"));
            }
            PersonalManageDAL personalManageDAL = new PersonalManageDAL();

            if (!personalManageDAL.GetPwdByName(name).Equals(MD5Tool.MD5Encryption(pwdy)))
            {
                return(new NewsModel(false, "原密码不正确"));
            }
            if (personalManageDAL.EditUserPwd(MD5Tool.MD5Encryption(pwdx), name))
            {
                return(new NewsModel(true, "修改完成"));
            }
            return(new NewsModel(false, "用户不存在"));
        }
Exemplo n.º 3
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="loginId">帐号</param>
 /// <param name="loginPwd">密码</param>
 /// <param name="valiCodeInput">输入的验证码</param>
 /// <param name="ValidateCode">生成的验证码</param>
 /// <returns></returns>
 public NewsModel StaffLogin(string loginId, string loginPwd, string valiCodeInput, string ValidateCode)
 {
     if (ValidateCode.Equals(valiCodeInput))
     {
         StaffManageDAL staffManageDAL = new StaffManageDAL();
         Staff          staff          = staffManageDAL.StaffLogin(loginId);
         if (Convert.IsDBNull(staff))
         {
             return(new NewsModel(false, "没有这个帐号"));
         }
         else if (staff.Password.Equals(MD5Tool.MD5Encryption(loginPwd)))
         {
             return(new NewsModel(true, staff.Name + "|" + staff.Staff_DdentityId));
         }
         else
         {
             return(new NewsModel(false, "密码错误"));
         }
     }
     else
     {
         return(new NewsModel(false, "验证码错误"));
     }
 }