Exemple #1
0
 /// <summary>
 /// 根据用户名获得用户信息
 /// </summary>
 /// <param name="userName"></param>
 /// <returns></returns>
 public Operator GetOperatorByUserName(string userName)
 {
     OperatorDAL dal = new OperatorDAL();
        Operator model = dal.GetByUserName(userName);
        //获得用户登录的Id
        if (model == null)
        {
        return null;
        }
     else
     {
            return model;
     }
 }
Exemple #2
0
        /// <summary>
        /// 用户登录的判断
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public LoginResult UserLoginResult(string userName,string password)
        {
            OperatorDAL dal = new OperatorDAL();
             Operator model = dal.GetByUserName(userName);
               //获得用户登录的Id

              if (model==null)
              {
              return LoginResult.ErrorNameOrPwd;
              }
              else
              {
              //判断密码是否相等
               string dbMd5 = model.Password; //数据库中存储的密码值
                string mymd5 = CommonHelper.GetMD5(password +CommonHelper.GetPasswordSalt());
                if (dbMd5 == mymd5)
                {
                    return LoginResult.LoginSuccessful;
                }
                else
                {
                    //密码不正确,返回ErrorNameOrPwd密码或用户名错误
                    return LoginResult.ErrorNameOrPwd;
                }
              }
        }