private void button1_Click(object sender, EventArgs e) { this.Hide(); STUDENT s = new STUDENT(); s.ShowDialog(); }
private void button2_Click(object sender, EventArgs e) { if (comboBox1.Text == "Administrator") { if (textBox1.Text == "Admin" && textBox2.Text == "admin") { this.Hide(); Form ADMIN = new ADMIN(); ADMIN.ShowDialog(); } else { MessageBox.Show("Wrong username or password"); } } else if (comboBox1.Text == "Staff") { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Enter Username and Password"); } else { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Enter Username and Password"); } else { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\ACER\Documents\SMS.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand cmd = new SqlCommand("select count(*) from StaffRegistration where Username ='******' and Password ='******'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); this.Hide(); Form TEACHER = new TEACHER(); TEACHER.ShowDialog(); } } } else if (comboBox1.Text == "Staff") { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Enter Username and Password"); } else { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\ACER\Documents\SMS.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand cmd = new SqlCommand("select count(*) from StudentRegistration where Username ='******' and Password ='******'", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); this.Hide(); Form STUDENT = new STUDENT(); STUDENT.ShowDialog(); } } else { } }