using System; using System.Windows.Forms; namespace CSC330_CSharp_Midterm { public partial class AuthorizationForm : Form { public AuthorizationForm() { InitializeComponent(); textBox2.PasswordChar = '$'; } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "") //if all fields are filled { if (Requests.CheckAdmin("SELECT Login From Admin Where Password='" + textBox2.Text + "'", textBox1.Text) == true) //pass to the method login of the administrator and the query finding admin login with the supplied password. If the username and password match, then go to the admin page { MessageBox.Show("Access granted!", "Information", MessageBoxButtons.OK, MessageBoxIcon.None); Close(); //close the authorization form AdminForm af = new AdminForm(); af.Show(); //show admin form } else //If the username and password doesn't match { MessageBox.Show("Wrong login and (or) password!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //if all fields are not filled { MessageBox.Show("Fill in all the fields!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void checkBoxShowPassword_CheckedChanged(object sender, EventArgs e) { textBox2.PasswordChar = checkBoxShowPassword.Checked ? '\0' : '$'; } } }