// On click listener for managing user accounts private void manageUserAccounts_Click(object sender, EventArgs e) { this.Visible = false; ManageUserAccounts_Form manageForm = new ManageUserAccounts_Form(); manageForm.ShowDialog(this); this.Visible = true; this.Close(); }
//When Save Changes is clicked private void SaveChanges_Click(object sender, EventArgs e) { //a boolean flag so that the error message boxes are only displayed once. bool formats = checkFormats(); user.setEmail(EmailBox.Text); user.setPassword(PassBox.Text); user.setPhoneNumber(PhoneNumberBox.Text); user.setFirstName(FirstNameBox.Text); user.setLastName(LastNameBox.Text); //if the user has the authourity to edit account types, change the account type, if not, display an error if (facList.ElementAt(currentUser).getAccountType() == 3) { user.setAccountType(int.Parse(AccountPermissionsBox.Text)); } else { MessageBox.Show("You do not have permission to change the Account type, changes to it will not be saved."); } //file output system //Binary writer for encoding data using (BinaryWriter w = new BinaryWriter(new FileStream(@"../../../tf.dat", FileMode.OpenOrCreate))) { //loop that writes information for (int i = 0; i < facList.Count; i++) { w.Write(facList.ElementAt(i).ToString()); } w.Close(); } //if the user is an admin and the email and phone have correct formats, go back to the manage user accounts form if (manageAcc && formats) { this.Visible = false; ManageUserAccounts_Form manageForm = new ManageUserAccounts_Form(ref facList, currentUser); manageForm.ShowDialog(this); this.Visible = true; //closes the current window this.Close(); } //If the user is not an admin editing the account, and the phonenumber and email have correct formats, save and go back to the main menu if (!manageAcc && formats) { this.Visible = false; Main_Form mainMenu = new Main_Form(facList, currentUser); mainMenu.ShowDialog(this); this.Close(); } }
// On click listener for managing user accounts private void manageUserAccounts_Click(object sender, EventArgs e) { if (facList.ElementAt(currentUser).getAccountType() == 3) { this.Visible = false; ManageUserAccounts_Form manageForm = new ManageUserAccounts_Form(ref facList, currentUser); manageForm.ShowDialog(this); this.Visible = true; this.Close(); } else { MessageBox.Show("You do not have permission to edit other user accounts.\nIf you think this is an error please contact your Admin."); } }