コード例 #1
0
 private void BtnRegister_Click(object sender, EventArgs e)
 {
     if (securitycode.Check(SecCodeText.Text) == false)//验证码错误
     {
         MessageBoxEx.Show("验证码错误,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         securitycode.UpdateVerifyCode();
         SecCodeText.Text = "";
         SecCodePic.Image = securitycode.getImage();
         return;
     }
     if (TextId.SkinTxt.Text.Length == 0 || TextPwd.SkinTxt.Text.Length == 0)//用户名或密码为空
     {
         MessageBoxEx.Show("用户名或密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (CmoBoxForQue.Text.Length == 0 || CmoBoxForAns.Text.Length == 0)//用户名或密码为空
     {
         MessageBoxEx.Show("密保问题或密保答案不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (Agree.Checked == false)
     {
         MessageBoxEx.Show("请阅读用户协议!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (user.Exists(TextId.SkinTxt.Text.ToString()) == true)//用户已经存在
     {
         MessageBoxEx.Show("用户已存在,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         securitycode.UpdateVerifyCode();
         SecCodeText.Text = "";
         TextId.Text      = "";
         TextPwd.Text     = "";
         SecCodePic.Image = securitycode.getImage();
         return;
     }
     Model.User newuser = new Model.User()
     {
         UserName  = TextId.Text,
         PassWord  = TextId.Text,
         ForgetQue = CmoBoxForQue.Text,
         ForgetAns = CmoBoxForAns.Text,
         School    = CmoBoxSchool.Text,
         Tel       = TextTel.Text,
         Email     = TextEmail.Text,
         Sex       = CmoBoxSex.Text
     };
     user.Add(newuser);
     MessageBoxEx.Show("注册成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.None);
     this.Close();
 }
コード例 #2
0
 private void Btnlogin_Click(object sender, EventArgs e)
 {
     if (securitycode.Check(SecCodeText.Text) == false)//验证码错误
     {
         MessageBoxEx.Show("验证码错误,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         securitycode.UpdateVerifyCode();
         SecCodeText.Text = "";
         SecCodePic.Image = securitycode.getImage();
         return;
     }
     if (TextId.SkinTxt.Text.Length == 0 || TextPwd.SkinTxt.Text.Length == 0)//用户名或密码为空
     {
         MessageBoxEx.Show("用户名或密码不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (user.Exists(TextId.SkinTxt.Text.ToString()) == false)//用户不存在
     {
         MessageBoxEx.Show("用户不存在,请重新输入!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         securitycode.UpdateVerifyCode();
         SecCodeText.Text = "";
         TextId.Text      = "";
         TextPwd.Text     = "";
         SecCodePic.Image = securitycode.getImage();
         return;
     }
     if (user.Check(TextId.Text, TextPwd.Text) == true)//密码正确
     {
         Model.User u = user.GetModel(TextId.Text);
         this.Hide();
         new MainForm(u).Show();
         notifyIcon.ShowBalloonTip(500, "登录成功!", "欢迎你!\n来自" + u.School + "的用户!", ToolTipIcon.Info);
         return;
     }
     else//密码错误
     {
         ForgetPassword.Visible = true;
         ForgetPassword.Show();
         TextId.SkinTxt.Text  = "";
         TextPwd.SkinTxt.Text = "";
         SecCodeText.Text     = "";
         securitycode.UpdateVerifyCode();
         SecCodePic.Image = securitycode.getImage();
     }
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: ZhaoQi99/EasyLife
 public MainForm(Model.User u)
 {
     InitializeComponent();
     SelectItem = SkinTool0;
     this.u     = u;
 }