private void loginDoctor() { //Query database for credentials SqlConnection sqlConn = new SqlConnection(ConnectionString); SqlCommand sqlCmd = new SqlCommand("SELECT PASSWORD from DoctorTable where USER_ID='" + txtUsername.Text + "'", sqlConn); sqlCmd.Parameters.AddWithValue("@USER_ID", txtUsername.Text); sqlConn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(); reader.Read(); if (reader.HasRows == true) { if (reader[0].ToString() == txtPassword.Text) { //Redirtect user to the doctor menu this.Hide(); DoctorMenu DocMenu = new DoctorMenu(); DocMenu.Show(); } else { MessageBox.Show("Password is incorrect", "Incorrect Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("User does not exist", "Invalid Credentials!", MessageBoxButtons.OK, MessageBoxIcon.Error); } sqlConn.Close(); }
private void buttonCancel_Click(object sender, EventArgs e) { this.Hide(); DoctorMenu docMenu = new DoctorMenu(); docMenu.Show(); }