private void btnLogOut_Click(object sender, EventArgs e) { string error_messages_folder = Application.StartupPath + "/error images/"; string incorrect_images_folder = Application.StartupPath + "/Incorrect Answer/"; try { if (Directory.Exists(error_messages_folder) == true) { var err_messages_dir = new DirectoryInfo(Application.StartupPath + "\\error images\\"); err_messages_dir.Delete(true); } } catch (IOException ex1) { MessageBox.Show(ex1.Message); } try { if (Directory.Exists(incorrect_images_folder) == true) { var incorrect_images_dir = new DirectoryInfo(Application.StartupPath + "\\Incorrect Answer\\"); incorrect_images_dir.Delete(true); } } catch (IOException ex2) { MessageBox.Show(ex2.Message); } DirectoryInfo di = new DirectoryInfo(Application.StartupPath); List <FileInfo> files = GetFiles(Application.StartupPath, ".yml", ".pickle"); foreach (FileInfo file in files) { try { file.Attributes = FileAttributes.Normal; File.Delete(file.FullName); } catch { } } DirectoryInfo di2 = new DirectoryInfo(Application.StartupPath); FileInfo[] files2 = di2.GetFiles("*.clf") .Where(p => p.Extension == ".clf").ToArray(); foreach (FileInfo the_file in files2) { try { the_file.Attributes = FileAttributes.Normal; File.Delete(the_file.FullName); } catch { } } FrmAdministratorMainPage frmAMP = new FrmAdministratorMainPage(); frmAMP.Show(); this.Hide(); }
private void btnExit_Click(object sender, EventArgs e) { btnTurnOffCamera.PerformClick(); FrmAdministratorMainPage frm_am = new FrmAdministratorMainPage(); frm_am.Show(); this.Hide(); }
private void btnlogin_Click(object sender, EventArgs e) { the_user_name = txtUserName.Text; //If the checkbox is ticked if (chkRememberMe.Checked) { Properties.Settings.Default.textbox = txtUserName.Text; Properties.Settings.Default.textbox2 = txtPassword.Text; Properties.Settings.Default.combobox = comboUserType.Text; Properties.Settings.Default.checkbox = chkRememberMe.Checked; Properties.Settings.Default.Save(); } //If the checkbox is not ticked else { Properties.Settings.Default.textbox = ""; Properties.Settings.Default.textbox2 = ""; Properties.Settings.Default.combobox = ""; Properties.Settings.Default.checkbox = (chkRememberMe.Checked = false); Properties.Settings.Default.Save(); } if (txtUserName.Text == "9999999999") { MessageBox.Show("Please key in your User Name", "User Name field is empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txtPassword.Text == "9999999999") { MessageBox.Show("Please key in your Password", "Password field is empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (comboUserType.Text == "Select User Type") { MessageBox.Show("Please select your User Type", "User Type is not selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { //Sql Adapter to run the Sql Query //If it is correct, the count will be 1, otherwise the count will be 0 /*SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From [dbo].[Login] Where UserName='******' and Password='******'and UserType='" + comboUserType.Text + "'", con); * DataTable dt = new DataTable(); * sda.Fill(dt);*/ // if (dt.Rows[0][0].ToString() == "1") // { if (comboUserType.Text == "Student") { FrmMainForm frmp = new FrmMainForm(); frmp.Show(); if (chkRememberMe.Checked == false) { txtPassword.Text = ""; txtUserName.Text = ""; comboUserType.Text = ""; } this.Hide(); } else if (comboUserType.Text == "Teacher") { FrmAttendanceRecords frar = new FrmAttendanceRecords(); frar.Show(); if (chkRememberMe.Checked == false) { txtPassword.Text = ""; txtUserName.Text = ""; comboUserType.Text = ""; } this.Hide(); } else if (comboUserType.Text == "Admin") { FrmAdministratorMainPage FrmAdmin = new FrmAdministratorMainPage(); FrmAdmin.Show(); if (chkRememberMe.Checked == false) { txtPassword.Text = ""; txtUserName.Text = ""; comboUserType.Text = ""; } this.Hide(); } // } /* else * { * MessageBox.Show("Please Check Your UserName and Password", "Invalid username or password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * }*/ } }