示例#1
0
        /// <summary>
        /// 保存修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtPwd1.Text.Trim() != "" && txtPwd2.Text.Trim() != "")
            {
                if (txtPwd1.Text.Trim() != txtPwd2.Text.Trim())
                {
                    MessageBox.Show("两次输入的密码不一致!");
                    return;
                }
                UIModels.LoginUserInfo _loginfo = LoginManager.Instance.GetThisUserLoginInfo();

                KPS.Model.UserInfo _user = new UserInfo();
                _user.ID       = _loginfo.UserID;
                _user.userName = _loginfo.LoginName;
                _user.userPwd  = txtPwd1.Text.Trim();

                KPS.BLL.UserInfoManager manager = new BLL.UserInfoManager();
                if (manager.Update(_user))
                {
                    MessageBox.Show("修改成功!");
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
            else
            {
                MessageBox.Show("新密码和确认密码都不可为空!");
            }
        }
示例#2
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="_userName"></param>
        /// <param name="_pwd"></param>
        public LoginStateEnum Login(string _userName, string _pwd)
        {
            LoginStateEnum _state = LoginStateEnum.Error;
            //处理内容开始
            KPS.BLL.UserInfoManager manager = new BLL.UserInfoManager();
            DataSet _dt= manager.GetList(string.Format("userName='******'",_userName));
            if (_dt != null && _dt.Tables[0].Rows.Count > 0)
            {
                int thisuserID=0;
                foreach (DataRow _row in _dt.Tables[0].Rows)
                {
                    if (_row["userPwd"].ToString() == _pwd)
                    {
                        thisuserID=Convert.ToInt32(_row["ID"]);
                        _state = LoginStateEnum.Correct;
                        break;
                    }
                }
                if (_state == LoginStateEnum.Correct)
                {
                    userinfo = new LoginUserInfo(_userName);
                    userinfo.UserID = thisuserID;
                    if (_userName == "admin")
                    {
                        userinfo.IsAdministrator = false;
                        userinfo.UserName = "******";
                    }

                    //保存登录记录
                    LoginRecordsManager.Instance.SaveRecord(new LoginRecordsInfo(_userName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                }
            }
            else
            {
                _state = LoginStateEnum.NoExt;
            }

            //处理内容结束
            return _state;
        }