private void frmCreateObject_FormClosing(object sender, FormClosingEventArgs e) { //Create a new principal panel form frmPrincipalPanel pP = new frmPrincipalPanel(); pP.Activate(); pP.Show(); //Collect disposed form info System.GC.Collect(); this.Hide(); }
private void bttn_NewStudent_Click(object sender, EventArgs e) { switch (formGoodText()) { // if case 1 case 1: // shows message box saying something was left blank MessageBox.Show("You left a textbox blank", "Invalid Information Supplied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; // if case 2 case 2: // shows message boxing saying a textbox was not entered with numbers MessageBox.Show("A required text field was not entered in numbers", "Invalid Information Supplied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; // if case 0 case 0: // creates array for courses for student string[,] sCourses = new string[Config.MAX_STUDENT_YEARS, Config.MAX_STUDENT_COURSES]; // creates array for comments for student string[,] sComments = new string[Config.MAX_STUDENT_YEARS, Config.MAX_STUDENT_COMMENTS]; // for loop which goes through the student years for (int i = 0; i < Config.MAX_STUDENT_YEARS; i++) { // for loop which goes through the student courses for (int z = 0; z < Config.MAX_STUDENT_COURSES; z++) { // sets value to none since there are no courses yet sCourses[i, z] = "none"; } // for loop which goes through the student comments for (int z = 0; z < Config.MAX_STUDENT_COMMENTS; z++) { // sets comments to none since there are no comments yet sComments[i, z] = "none"; } } // Adds information to database DatabaseConnection.insertStudent(Convert.ToInt32(txt_sNumber.Text), txt_sPass.Text, txt_sFirstName.Text, txt_sLastName.Text, txt_sDateOfBirth.Text, Convert.ToInt32(txt_sGrade.Text), txt_sEmailAddress.Text, txt_sParentName.Text, txt_sPNumber.Text, txt_sAddressHome.Text, sCourses, sComments); // if none of the entries equal null if (DatabaseConnection.loadStudent(txt_sNumber.Text) != null) { // message box showing successfully registered MessageBox.Show("Student Successfully Registered"); } else { // message box showing failure to register MessageBox.Show("FAILURE To Register"); } // principal panel is loaded frmPrincipalPanel fPP = new frmPrincipalPanel(); // principal panel is activated fPP.Activate(); // principal panel is shown fPP.Show(); // principal panel is closed this.Close(); break; } }
private void btnSubmit_Click(object sender, EventArgs e) { // Role depending on teacher, principal or student int userRole = 0; // Adds one to try added to log on tries++; // try parses to check if input is integer if (Config.TryToParse(txt_Username.Text)) { // if student radio button is checked if (rdb_student.Checked == true) { // user role 1 is selected userRole = 1; } // if teacher radio button is checked if (rdb_teacher.Checked == true) { // user role 2 is selected for teacher userRole = 2; } // if principal radio button is checked if (rdb_principal.Checked == true) { // user role 3 is selected for principal userRole = 3; } } else { // Message box is shown telling about incorrect login MessageBox.Show("Please enter your username in the correct format!", "Invalid Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Resetting text box for user name txt_Username.Text = ""; // Resetting text box for password txt_Password.Text = ""; } // Switch case for user role switch (userRole) { // if case 1 case 1: prgbarLoadingLogin.Value = 0; prgbarLoadingLogin.Value += 2; // progress bar increased by 1 // if user input is correct if (DatabaseConnection.checkUser(txt_Username.Text, txt_Password.Text, 0)) { // progress bar increased by 1 prgbarLoadingLogin.Value += 2; // Student profile is loaded frmStudentProfile sForm = new frmStudentProfile(); prgbarLoadingLogin.Value += 2; // Activates student profile form sForm.Activate(); // Progress bar increased by 1 prgbarLoadingLogin.Value += 2; // Temporarily sets the config file as this student so it can be shared between the classes Config.setStudent(DatabaseConnection.loadStudent(txt_Username.Text)); // Progress bar increased by 1 prgbarLoadingLogin.Value += 2; // Message box showing successful logon MessageBox.Show("Successfully Logged In"); // Student Profile form shown sForm.Show(); // Hides logon on form this.Hide(); Config.userRole = 1; // user role is set to 1 } else { // Message box is shown login failed MessageBox.Show("Login Failed"); // If login tries is above 3 if (tries > 3) { // Application is exited Application.Exit(); } } // leaves case break; // if case 2 case 2: prgbarLoadingLogin.Value = 0; prgbarLoadingLogin.Value += 2; // if user input is correct if (DatabaseConnection.checkUser(txt_Username.Text, txt_Password.Text, 1)) { // gets teacher information Teacher getTeacher = DatabaseConnection.getTeacher(Convert.ToInt32(txt_Username.Text)); prgbarLoadingLogin.Value += 2; // Sets teacher info Config.setTTeacher(getTeacher); prgbarLoadingLogin.Value += 2; // teacher profile is loaded frmTeacherProfile fTP = new frmTeacherProfile(); prgbarLoadingLogin.Value += 2; // teacher profile is activated fTP.Activate(); prgbarLoadingLogin.Value += 2; // login screen is hidden this.Hide(); // shows teacher profile fTP.Show(); Config.userRole = 2; // user role is set to 2 } else { // if login fails shows message box showing so MessageBox.Show("Login Failed"); // if tries to login exceeds 3 if (tries > 3) { // program is exitted Application.Exit(); } } break; // if case 3 case 3: prgbarLoadingLogin.Value = 0; prgbarLoadingLogin.Value += 4; // checks to see if user input for principal is correct if (DatabaseConnection.checkUser(txt_Username.Text, txt_Password.Text, 2)) { // principal panel is loaded prgbarLoadingLogin.Value += 2; frmPrincipalPanel pP = new frmPrincipalPanel(); prgbarLoadingLogin.Value += 2; // principal panel is activated pP.Activate(); prgbarLoadingLogin.Value += 2; // principal panel is shown pP.Show(); // login screen is hidden this.Hide(); Config.userRole = 3; // Eser role 3 is set } else { // if login fails shows message box saying so MessageBox.Show("Login Failed"); // if tries to login exceeds 3 if (tries > 3) { // program is exitted Application.Exit(); } } break; } }