private void backButton_Click_1(object sender, EventArgs e) { this.Hide(); UserHome form = new UserHome(); form.Show(); this.Close(); }
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(); } }
private void longinButton_Click(object sender, EventArgs e) { var username = usernameTextbox.Text; //获取用户名 var password = passwordTextbox.Text; //获取密码 username = "******"; password = "******"; if (username == "") { usernameTip.Visible = true; } else if (password == "") { pwdTip.Visible = true; } else { MySqlConnection connection = new MySqlConnection(); connection.ConnectionString = PublicMethod._connectionString; connection.Open(); string findUserSql = "select * from t_user where username='******'and password='******'";//定义查询语句 MySqlCommand sqlCom = new MySqlCommand(findUserSql, connection); MySqlDataReader sdr = sqlCom.ExecuteReader(); sdr.Read(); if (sdr.HasRows) { PublicMethod.user_id = sdr[0].ToString();//把获取的用户id存到全局变量 this.Hide(); UserHome form = new UserHome(); form.Show(); PublicMethod.loginFlag = 1; //用户是否登录标志量,0为未登录,1为登录 PublicMethod.username = sdr[1].ToString(); //把获取的用户名存到全局变量 } else { loginTip.Visible = true; } connection.Close(); } }