Example #1
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);
                }
            }
        }
Example #2
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string userName = tbxUserName.Text;
            string password = pdxPassword.Password;

            Operator op = OperatorDAL.GetByUserName(userName);

            if (op == null)
            {
                MessageBox.Show("用户名或密码错误");
                return;
            }
            else if (op.Password == password)
            {
                T_OperationLogDAL.Insert(op.Id, op.RealName + "登录成功!");
                Application.Current.Properties["OperatorID"] = op.Id;
                // MessageBox.Show("登录成功!");
                //DialogResult = true;
                MainWindow mainWin = new MainWindow();
                mainWin.Login = this;
                this.Hide();
                mainWin.Show();
            }
            else
            {
                T_OperationLogDAL.Insert(op.Id, op.RealName + "登录失败!");

                MessageBox.Show("用户名或密码错误");
            }
            //  DialogResult = false;
        }
Example #3
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);
            }
        }