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();
            }
        }
        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(); //刷新验证码
        }
示例#3
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);
     }
 }
        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);
     }
 }