예제 #1
0
        private void backButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            HomeForm form = new HomeForm();

            form.Show();
            this.Close();
        }
예제 #2
0
        private void 返回ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PublicMethod.loginFlag = 0;  //全局变量是否登录恢复默认
            PublicMethod.user_id   = ""; //全局变量用户ID恢复默认
            PublicMethod.username  = ""; //全局变量用户名恢复默认

            this.Hide();
            HomeForm form = new HomeForm();

            form.Show();
            this.Close();
        }
예제 #3
0
 private void backButton_Click(object sender, EventArgs e)
 {
     if (PublicMethod.loginFlag == 1)
     {
         this.Hide();
         UserHome form = new UserHome();
         form.Show();
         this.Close();
     }
     else
     {
         this.Hide();
         HomeForm form = new HomeForm();
         form.Show();
         this.Close();
     }
 }
예제 #4
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            var    username = usernameTextBox.Text;//获取注册的用户名
            string sex      = "";

            var password      = passwordTextBox4.Text;  //获取注册的用户密码
            var againPassword = pwdAgainiTextBox5.Text; //获取注册的重复用户密码
            var userNO        = idNumTextBox3.Text;     //获取注册用户的身份证

            bool[] flag = { false, false, false, false };

            //username = "******";
            //sex = "女";
            //password = "******";
            //againPassword = "******";
            //userNO = "111111111111111111";
            userTip.Visible       = false;
            checkUsername.Visible = false;
            sexTip.Visible        = false;
            pwdTip.Visible        = false;
            checkPwd.Visible      = false;
            againPwdTip.Visible   = false;
            checkAgainpwd.Visible = false;
            checkID.Visible       = false;
            IDTip.Visible         = false;
            checkUser.Visible     = false;

            if (sexComboBox1.SelectedItem != null)
            {
                sex     = sexComboBox1.SelectedItem.ToString();//获取注册的用户性别
                flag[1] = true;
            }
            else
            {
                sexTip.Visible = true;
            }

            if (username == "")
            {
                userTip.Visible = true;
            }
            else if (username.Length < 2)
            {
                checkUsername.Visible = true;
            }
            else
            {
                flag[0] = true;
            }
            if (password == "")
            {
                pwdTip.Visible = true;
            }
            else if (password.Length < 6 || password.Length > 10)
            {
                checkPwd.Visible = true;
            }
            else
            {
                if (againPassword == "")
                {
                    againPwdTip.Visible = true;
                }
                else if (password != againPassword)
                {
                    checkAgainpwd.Visible = true;
                }
                else
                {
                    flag[2] = true;
                }
            }
            if (userNO == "")
            {
                IDTip.Visible = true;
            }
            else if (userNO.Length != 18)
            {
                checkID.Visible = true;
            }
            else
            {
                flag[3] = true;
            }
            if (flag[0] && flag[1] && flag[2] && flag[3])
            {
                for (var i = 0; i < 4; i++)
                {
                    flag[i] = false;
                }


                MySqlConnection connection = new MySqlConnection(PublicMethod._connectionString);
                connection.Open();
                string          findIDSql = "select idNum from t_user where idNum='" + userNO + "'";
                MySqlCommand    sqlCom    = new MySqlCommand(findIDSql, connection);
                MySqlDataReader sdr       = sqlCom.ExecuteReader();
                sdr.Read();
                if (sdr.HasRows)
                {
                    checkUser.Visible = true;
                }
                else
                {
                    PublicMethod query  = new PublicMethod();
                    string       strSql = "insert into t_user(user_id,username,password,sex,idNum) values (LEFT(MD5(RAND()), 5),'" +
                                          username + "','" + password + "','" + sex + "','" + userNO + "')";
                    if (query.ExecuteNonQuery(strSql, PublicMethod._connectionString) > 0)
                    {
                        if (MessageBox.Show("注册成功!确定返回登录", "提示", MessageBoxButtons.OK) == DialogResult.OK)
                        {
                            this.Hide();
                            HomeForm form = new HomeForm();
                            form.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("注册失败!", "信息提示");
                    }
                }
                sdr.Close();
                connection.Close();
            }
        }