private void CmdAdminSignIn_Click(object sender, EventArgs e) { Connect connect = new Connect(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(); string query = "SELECT * FROM `admin` WHERE `username` = @usn AND `password` = @pass "; command.CommandText = query; command.Connection = connect.getConnection(); command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = txtAdminUsername.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = txtAdminPassword.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { label3.Text = "Welcome" + " " + txtAdminUsername.Text; label3.Visible = true; cmdAdminLogOut.Visible = true; label1.Visible = false; label2.Visible = false; txtAdminUsername.Visible = false; txtAdminPassword.Visible = false; cmdAdminSignIn.Visible = false; groupBox1.Visible = true; groupBox2.Visible = true; groupBox3.Visible = true; txtAdminPassword.Clear(); txtAdminUsername.Clear(); MySqlCommand fetchPatientCommand = new MySqlCommand("SELECT * FROM `patientstreat`", connect.getConnection()); MySqlDataAdapter newAdapter = new MySqlDataAdapter(); DataTable dataTable = new DataTable(); newAdapter.SelectCommand = fetchPatientCommand; newAdapter.Fill(dataTable); dataGridView1.DataSource = dataTable; MySqlCommand fetchDoctorCommand = new MySqlCommand("SELECT username, fullName, fullAddress FROM `doctors`", connect.getConnection()); MySqlDataAdapter newAdapter2 = new MySqlDataAdapter(); DataTable dataTable2 = new DataTable(); newAdapter2.SelectCommand = fetchDoctorCommand; newAdapter2.Fill(dataTable2); dataGridView2.DataSource = dataTable2; } else if (txtAdminUsername.Text.Trim().Equals("")) { MessageBox.Show("Enter your username", "Empty username field", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtAdminPassword.Text.Trim().Equals("")) { MessageBox.Show("Enter your password", "Empty password field", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("This username and password was not found! Please recheck or create a new account by clicking on the new button in the Welcome form", "No account found", MessageBoxButtons.OK, MessageBoxIcon.Error); } }