//修改密码
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.tb_originpasswd.Text == "" || this.tb_newpasswd.Text == "" || this.tb_renewpasswd.Text == "")
            {
                MessageBox.Show("请输入所有内容。");
            }
            else
            {
                if (this.tb_originpasswd.Text == this.userModel.Password)
                {
                    if (this.tb_newpasswd.Text == this.tb_renewpasswd.Text)
                    {
                        UserBusiness userBusiness = new UserBusiness();
                        if (userBusiness.changePasswd(userModel.Username, this.tb_newpasswd.Text))
                        {
                            MessageBox.Show("修改成功");
                        }
                        else
                        {
                            MessageBox.Show("修改失败");
                        }
                    }
                    else
                    {
                        MessageBox.Show("两次输入的密码不一致");
                    }

                }
                else
                {
                    MessageBox.Show("原密码不正确。");
                }
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string username = this.textBox1.Text;
            string password = this.textBox2.Text;
            int type = 0 ;
            if (username == "" || password == "")
            {
                MessageBox.Show("请输入用户名或密码");
                this.textBox1.Focus();
            }
            else
            {
                this.button1.Text = "正在登陆...";
                this.button1.Enabled = false;
                this.textBox1.Enabled = false;
                this.textBox2.Enabled = false;

                UserBusiness userBusiness = new UserBusiness();
                type = userBusiness.CheckPasswd(username, password);
                UserModel userModel = new UserModel();
                userModel.Username = username;
                userModel.Password = password;

                //1:学生
                if (type == 1)
                {
                    userModel.Uid = userBusiness.getUidByUsername(username);
                    FmStudentMain fmStudentMain = new FmStudentMain(this, userModel);
                    fmStudentMain.Show();
                }
                //2:老师
                else if (type == 2)
                {
                    userModel.Uid = userBusiness.getUidByUsername(username);
                    FmTeacherMain fmTeacherMain = new FmTeacherMain(this, userModel);
                    fmTeacherMain.Show();
                }
                //3:管理员
                else if (type == 3)
                {
                    userModel.Uid = userBusiness.getUidByUsername(username);
                    FmAdminMain fmAdminMain = new FmAdminMain(this, userModel);
                    fmAdminMain.Show();
                }
                //0:登陆失败
                else if (type == 0)
                {
                    MessageBox.Show("登陆失败,请重试");
                    this.button1.Text = "登陆";
                    this.button1.Enabled = true;
                    this.textBox1.Enabled = true;
                    this.textBox2.Enabled = true;
                }
            }
        }
 public UserController()
 {
     this._unitOfWork = new UnitOfWork(_df);
     this._userBusiness = new UserBusiness(_df, this._unitOfWork);
    
 }