/// <summary> /// Take the user back to the main menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBackPro_Click(object sender, EventArgs e) { this.Hide(); mainMenu main = new mainMenu(); main.ShowDialog(); }
/// <summary> /// Compare the username and password to those in the database /// if they esist they can enter the application displays the main menu. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=F:\vs\Debugger\BugDatabase.mdf;Integrated Security=True;Connect Timeout=30"); SqlDataAdapter sel = new SqlDataAdapter("select count(*) from login where UserName = '******' and Password = '******'", con); DataTable dt = new DataTable(); sel.Fill(dt); if (dt.Rows[0][0].ToString() == "1") //If username and password exists in the table notify the user { this.Hide(); // Display the main menu mainMenu main = new mainMenu(); main.Show(); } else { MessageBox.Show("Please enter the correct username and password", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } }