private void Login_Click(object sender, EventArgs e) { try { if (checkcode.Text == check.Text) { string Account = account.Text.Trim(); string Password = psw.Text.Trim(); LoginBLL BLL = new LoginBLL(); //扔给BLL处理 var Result = BLL.Validate(Account, Password); MessageBox.Show("登录成功,欢迎" + Result.Nickname + "用户使用"); Acc = Account; this.DialogResult = DialogResult.OK; //告知Program.cs 启动主窗体 } else { MessageBox.Show("验证码错误"); checkcode.Text = ""; checkcode.Focus(); check.Text = CheckCode.Code(); } } catch (Exception ex) { MessageBox.Show("登录失败,错误信息:\n" + ex.Message); } finally { account.Text = ""; psw.Text = ""; checkcode.Text = ""; account.Focus(); check.Text = CheckCode.Code(); } }
private void Button1_Click(object sender, EventArgs e) { try { if (sure.Text.Trim() != newpwd.Text.Trim()) { MessageBox.Show("确认密码和新密码不一致"); checkpic.Text = CheckCode.Code(); return; } if (checkcode.Text.Trim() != checkpic.Text) { MessageBox.Show("验证码错误"); checkpic.Text = CheckCode.Code(); return; } if (acc.Text.Trim() == "" || oldpwd.Text.Trim() == "" || newpwd.Text.Trim() == "" || sure.Text.Trim() == "" || checkcode.Text.Trim() == "") { MessageBox.Show("信息不完整"); checkpic.Text = CheckCode.Code(); return; } var BLL = new UpdatePwdBLL(); switch (BLL.Access(acc.Text.Trim(), oldpwd.Text.Trim(), newpwd.Text.Trim())) { case 0: MessageBox.Show("修改成功"); this.Dispose(); this.Close(); break; case 1: MessageBox.Show("修改失败"); break; case 2: MessageBox.Show("用户名或原密码错误"); break; } checkpic.Text = CheckCode.Code(); } catch (Exception ex) { MessageBox.Show("修改失败,错误信息:\n" + ex); } }
private void Regist_Click(object sender, EventArgs e) { try { if (surepwd.Text != pwd.Text) { MessageBox.Show("确认密码和密码不一致"); checkpic.Text = CheckCode.Code(); return; } if (checkcode.Text != checkpic.Text) { MessageBox.Show("验证码错误"); checkpic.Text = CheckCode.Code(); return; } if (acc.Text.Trim() == "" || pwd.Text.Trim() == "" || nick.Text.Trim() == "" || surepwd.Text == "" || checkcode.Text == "") { MessageBox.Show("信息不完整"); checkpic.Text = CheckCode.Code(); return; } var BLL = new RegisterBLL(); switch (BLL.Access(acc.Text.Trim(), pwd.Text.Trim(), nick.Text.Trim())) { case 0: MessageBox.Show("注册成功"); this.Dispose(); this.Close(); break; case 2: MessageBox.Show("用户名存在"); break; } } catch (Exception ex) { MessageBox.Show("注册失败,错误信息:\n" + ex); } }
private void Check_Click(object sender, EventArgs e) { check.Text = CheckCode.Code(); }
public LoginForm() { InitializeComponent(); check.Text = CheckCode.Code(); //生成验证码 }
public RegisterForm() { InitializeComponent(); checkpic.Text = CheckCode.Code(); }
public UpdatePwd() { InitializeComponent(); checkpic.Text = CheckCode.Code(); }