コード例 #1
0
        private void GoUpdatePW_Click(object sender, EventArgs e)
        {
            string user        = UserBox.Text.Trim();
            string name        = MyNameBox.Text.Trim();
            string email_Phone = EmailPhoneBox.Text.Trim();
            string code        = VcBox.Text.Trim();
            string s;//s有两种值,电子邮箱,手机号码

            if (EmailRadio.Checked)
            {
                s = "电子邮箱";
            }
            else
            {
                s = "手机号码";
            }
            if (!CheckUtil.CheckSring(user, name, email_Phone, code))//验证所有文本框均不空且不为默认值,为空则返回false,注意,取反
            {
                MessageBox.Show("用户名丶姓名丶手机号码丶验证码均为必填项", "必填项", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (code != Code)
            {
                MessageBox.Show("验证码不匹配,请检查" + s + "接收的6位验证码", "验证码错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!new UserInfoHelp().RetrievePassword(user, name, email_Phone))
            {
                MessageBox.Show("您填写的用户名,姓名," + s + ",三者信息不匹配,请修改后再尝试", "验证失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                UIUtil.CloseForm(this);
                Close();
                new updatePassword().Show();
            }
        }
コード例 #2
0
 /// <summary>
 /// 初始化学生信息,成功返回true,失败返回false
 /// </summary>
 /// <returns></returns>
 private bool Sinit()
 {
     id   = Sid.Text.Trim();                                                 //学号
     name = Sname.Text.Trim();                                               //姓名
     date = Convert.ToDateTime(Sdatetime.Text.Trim());                       //生日
     dept = Sdept.SelectedItem == null ? "" : Sdept.SelectedItem.ToString(); //系别
     sex  = Sman.Checked ? "男" : "女";                                        //性别
     text = Stext.Text;                                                      //备注
     if (!CheckUtil.CheckSring(id, name, date.ToString(), dept, sex))
     {
         MessageBox.Show("以下是必要的信息,请确保已填写!" + '\n'
                         + "学号:" + id + '\n'
                         + "姓名:" + name + '\n'
                         + "性别:" + sex + '\n'
                         + "生日:" + date + '\n'
                         + "系别:" + dept);
         return(false);
     }
     else if (DateTime.Now.Year - date.Year < 15)//限制年龄不应小于15岁
     {
         MessageBox.Show("该学生未满15岁,未满足入学要求");
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #3
0
        private void GoLogin_Click(object sender, EventArgs e)
        {
            //登录检查
            //1,检查文本框不为空
            //2,检查验证码是否正确
            //3,检查用户名和密码是否匹配
            string user = User.Text.Trim();
            string pw   = PasswordBox.Text.Trim();
            string code = VerificationBox.Text.Trim();

            if (!CheckUtil.CheckSring(user, pw, code))
            {
                MessageBox.Show("请将用户名,密码,验证码填写完");
            }
            else if (code != v.Z.ToString())
            {
                MessageBox.Show("加载失败,正确答案为:" + v.Z.ToString());
            }
            else if (!new UserInfoHelp().Login(user, pw))
            {
                MessageBox.Show("用户名和密码错误!");
            }
            else
            {
                string time = "今天是" + DateTime.Now.ToString("yyyy-MM-dd") + "," + DateTime.Now.ToString("dddd");
                MessageBox.Show("您好," + UserInfo.UserName + "\n" + "先生/女士,您好,欢迎登录本系统" + "\n" + time);
                UIUtil.CloseForm(this);                     //将本窗体淡出
                new Home().Show();                          //主界面显示出来
            }
            PasswordBox.Text     = "";                      //清空密码
            VerificationBox.Text = "";                      //清空答案
            Verification.Text    = v.SetVerificationCode(); //刷新验证码
        }
コード例 #4
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            string user  = User.Text.Trim();                               //用户名
            string pw    = Password.Text.Trim();                           //密码
            string okpw  = OKPassword.Text.Trim();                         //确认密码
            string phone = Phone.Text.Trim();                              //手机号码
            string name  = MyName.Text.Trim();                             //名字
            string email = Email.Text.Trim();                              //邮箱

            if (!CheckUtil.CheckSring(user, pw, okpw, phone, name, email)) //检测到各个文本框为空
            {
                MessageBox.Show("请填写注册信息,不要留空");
            }
            else if (user.Length < 4 || pw.Length < 4 || okpw.Length < 4)//如果用户名,密码,确认密码文本框输入长度小于4
            {
                MessageBox.Show("用户名和密码的长度应在4~6位");
            }
            else if (pw != okpw)//检测到密码和确认密码不一致
            {
                MessageBox.Show("两次密码不一致,请修改并牢记您的密码");
            }
            else if (!CheckUtil.IsPhone(phone))//检测到不是手机号码
            {
                MessageBox.Show("该号码不是中国大陆手机号码,暂不支持注册");
            }
            else if (!CheckUtil.IsName(name))//检测到不是真实姓名
            {
                MessageBox.Show("请输入真实姓名!");
            }
            else if (!CheckUtil.IsEmail(email))//检测到不是邮箱
            {
                MessageBox.Show("请输入正确的电子文档");
            }
            else if (new UserInfoHelp().SelectUserID(user))
            {
                MessageBox.Show("该用户名已被注册,请更换后重试");
            }
            else if (new UserInfoHelp().SelectPhone(phone))
            {
                MessageBox.Show("该手机号码已被使用");
            }
            else if (new UserInfoHelp().SelectEmail(email))
            {
                MessageBox.Show("该电子邮箱已被使用");
            }
            else if (new UserInfoHelp().Register(user, pw, name, phone, email))
            {
                MessageBox.Show("注册失败,原因未知,请检查网络和您填写的信息,请稍后再试");
            }
            else
            {
                MessageBox.Show(name + "先生/女士,您的账号" + user + "注册成功!" + '\n' + "注册成功!" + '\n' + "请牢记您的账号和密码,如若遗忘,请通过找回密码功能重置密码");
                MessageBox.Show("接下来将带您返回到登录界面");
                Owner.Tag = user;
                Exit_Click(sender, e);
            }
        }
コード例 #5
0
 /// <summary>
 /// 初始化课程信息,成功返回true,失败返回false
 /// </summary>
 /// <returns></returns>
 private bool Cinit()
 {
     Clid    = Cid.Text.Trim();   //学号
     Clname  = Cname.Text.Trim(); //姓名
     Clredit = Convert.ToInt32(Credit.Text);
     if (!CheckUtil.CheckSring(Clid, Clname, Clredit.ToString()))
     {
         MessageBox.Show("以下是必要的信息,请确保已填写!" + '\n'
                         + "课程号:" + Clid + '\n'
                         + "课程名:" + Clname + '\n'
                         + "学分:" + Clredit.ToString());
         return(false);
     }
     else if (Clredit < 0)//学分小于0
     {
         MessageBox.Show("学分格式错误,请检查!");
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #6
0
 private void VcButton_Click(object sender, EventArgs e)
 {
     if (CheckTextBox(EmailPhoneBox))//检查是否填写数据
     {
         string s = EmailPhoneBox.Text;
         if (EmailRadio.Checked)       //如果为true,则说明选择的是邮箱
         {
             if (CheckUtil.IsEmail(s)) //判断是否为真实邮箱,为true则是
             {
                 //if()验证是否为该用户注册时绑定的邮箱地址
                 //{
                 MailUtil mailUtil = new MailUtil();//创建邮件工具类的对象
                 if (mailUtil.QQ(s))
                 {
                     VcButton.Enabled = false; //禁用按钮
                     timer1.Enabled   = true;  //开启一分钟计时器
                     MessageBox.Show("发送成功");
                     Code = mailUtil.Code;
                 }
                 else
                 {
                     MessageBox.Show("发送失败");
                 }
                 //}
                 //else MessageBox.Show("用户名 与 邮箱地址 不匹配");
             }
             else
             {
                 MessageBox.Show("此邮箱地址不正确,请重新填写!", "邮箱地址有误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else //否则,选择的是手机
         {
             if (CheckUtil.IsPhone(s))//是否为中国大陆号码,为true则是
             {
                 if (true)                         //验证是否为该用户注册时绑定的
                 {
                     if (SMSAPI.GoSMS(s))          //发送验证码到手机
                     {
                         VcButton.Enabled = false; //禁用按钮
                         timer1.Enabled   = true;  //开启一分钟计时器
                         MessageBox.Show("发送成功!");
                         Code = SMSAPI.Code;
                     }
                     else
                     {
                         MessageBox.Show(SMSAPI.Code); //发送失败,给出错误信息
                     }
                 }
                 else
                 {
                     MessageBox.Show("用户名与手机号码不匹配!");
                 }
             }
             else
             {
                 MessageBox.Show("此手机号码不是中国大陆手机号码,请重新填写!");
             }
         }
     }
 }