private void button4_Click(object sender, EventArgs e) { Form22 Form22 = new Form22(); Form22.Show(); this.Hide(); }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = DBConnection.getConnection(); string username = txtuname.Text.Trim(); string password = txtpass.Text.Trim(); string acctype = cmbacctype.Text; try { if (cmbacctype.SelectedItem == "Admin") { SqlCommand cmd = new SqlCommand("SELECT * FROM users WHERE username='******' AND password='******'", conn); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { Form23 ap = new Form23(); ap.Show(); } else { MessageBox.Show("Invalid username or password"); } } else if (cmbacctype.SelectedItem == "Manager") { SqlCommand cmd = new SqlCommand("SELECT username, password FROM users WHERE username='******' AND password='******'", conn); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { Form20 mm = new Form20(); mm.Show(); } else { MessageBox.Show("Invalid username or password"); } } else if (cmbacctype.SelectedItem == "FrontOffice") { SqlCommand cmd = new SqlCommand("SELECT username, password FROM users WHERE username='******' AND password='******'", conn); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { Form18 cm = new Form18(); cm.Show(); } else { MessageBox.Show("Invalid username or password"); } } else if (cmbacctype.SelectedItem == "Doctor") { SqlCommand cmd = new SqlCommand("SELECT username, password FROM users WHERE username='******' AND password='******'", conn); SqlDataAdapter adapt = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapt.Fill(ds); int count = ds.Tables[0].Rows.Count; if (count == 1) { MessageBox.Show("Login Successful!"); this.Hide(); Form22 dm = new Form22(); dm.Show(); } else { MessageBox.Show("Invalid username or password"); } } else { MessageBox.Show("Login Failed"); this.txtuname.Text = ""; this.txtpass.Text = ""; } } catch (SqlException ex) { MessageBox.Show(ex.Message); } }