private void bunifuThinButton21_Click(object sender, EventArgs e) { try { SqlConnection conn2 = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True"); SqlDataAdapter sda2 = new SqlDataAdapter("Select Usertype From Admins where Username='******'and Password='******'", conn2); DataTable dt2 = new DataTable(); conn2.Open(); sda2.Fill(dt2); string s2 = dt2.Rows[0][0].ToString(); if (s2 == "admin") { SqlConnection conn3 = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True"); SqlDataAdapter sda3 = new SqlDataAdapter("Select Count(*) From Admins where Username='******'and Password='******'", conn3); DataTable dt3 = new DataTable(); conn3.Open(); sda3.Fill(dt3); if (dt3.Rows[0][0].ToString() == "1") { Form11 f11 = new Form11(); //f1.catchuser(textUserName.Text); this.Hide(); f11.Show(); f11.admin(textUserName.Text); f11.suser(); } } } catch { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Signup where Username='******'and Password='******'", conn); DataTable dt = new DataTable(); conn.Open(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { SqlConnection conn1 = new SqlConnection("Data Source=DESKTOP-CU4B5J7;Initial Catalog=projectsmartassistant;Integrated Security=True"); SqlDataAdapter sda1 = new SqlDataAdapter("Select isvalid From Signup where Username='******'", conn1); DataTable dt1 = new DataTable(); conn1.Open(); sda1.Fill(dt1); string s = dt1.Rows[0][0].ToString(); int i = int.Parse(s); if (i == 2) { Form5 f1 = new Form5(); f1.catchuser(textUserName.Text); this.Hide(); f1.Show(); } else { MessageBox.Show("Your account is not valid\nPlease try again later!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); textUserName.Text = ""; textPassword.Text = ""; textUserName.Focus(); } } else { MessageBox.Show("Wrong credentials !!\nPlease Check Your User Name and Password !!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); textUserName.Text = ""; textPassword.Text = ""; textUserName.Focus(); } } }