private void button8_Click(object sender, EventArgs e) { this.Hide(); ActThree a3 = new ActThree(MyVal); a3.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text == "User") { data = usernameTextBox.Text.ToString(); ActThreePacman pac = new ActThreePacman(data); ActThree act3 = new ActThree(data); Form2 f2 = new Form2(data); WheelForm wh = new WheelForm(data); Form5 f5 = new Form5(data); ActFourMatchTheCards mat = new ActFourMatchTheCards(data); MySqlConnection sqlcon = new MySqlConnection(@"server=localhost;user id=root;database=seproject;password=rootpassword"); try { sqlcon.Open(); String username = usernameTextBox.Text; String password = passwordTextBox.Text; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM seproject.user WHERE username = '******' and password = '******'", sqlcon); adapter.Fill(table); //check if the username exists or not if (table.Rows.Count > 0) { if (checkBox1.Checked == true) { MessageBox.Show("Successfully logged in!"); this.Hide(); Form2 f22 = new Form2(data); f22.ShowDialog(); } else { MessageBox.Show("Incorrect captcha!"); } } else { MessageBox.Show("Incorrect username/password"); usernameTextBox.Text = ""; passwordTextBox.Text = ""; } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Connection error"); } } else if (comboBox1.Text == "Moderator") { MySqlConnection sqlcon = new MySqlConnection(@"server=localhost;user id=root;database=seproject;password=rootpassword"); try { sqlcon.Open(); String username = usernameTextBox.Text; String password = passwordTextBox.Text; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM seproject.moderator WHERE username = '******' and password = '******'", sqlcon); adapter.Fill(table); //check if the username exists or not if (table.Rows.Count > 0) { if (checkBox1.Checked == true) { MessageBox.Show("Admin successfully logged in!"); this.Hide(); Moderator md = new Moderator(); md.ShowDialog(); } else { MessageBox.Show("Incorrect captcha!"); } } else { MessageBox.Show("Incorrect username/password"); usernameTextBox.Text = ""; passwordTextBox.Text = ""; } sqlcon.Close(); } catch (Exception ex) { MessageBox.Show("Connection error"); } } }