private void button1_Click(object sender, EventArgs e) { main_screen open_screen = new main_screen(mCurrentUser); open_screen.Show(); this.Close(); }
private void addNewMeetingBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save this meeting?", "Save Meeting", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { try { meeting newMeeting = new meeting(); newMeeting.Location = meetingPlaceTxtBx.Text; newMeeting.meetingDesc = meetingDescTxtBx.Text; newMeeting.DateTime = meetingDatePicker.Value.ToString(); newMeeting.meetingTitle = meetingTitleTxtBx.Text; meeting.addNewMeeting(newMeeting, currentGroup); main_screen open_screen = new main_screen(currentUser); open_screen.Show(); this.Close(); } catch { MessageBox.Show("Meeting could not be saved."); } } }
private void loginBtn_Click(object sender, EventArgs e) { string username; string password; username = usernameTxtBx.Text; password = passwordTxtBx.Text; user user = new user(username, password); bool loginSuccess = user.checkLogin(user); if (loginSuccess == true) { using (var context = new SALAHContext()) { var query = from data in context.Users where data.Name == username select new { data.Name, data.groupIDs, data.ID }; foreach (var result in query) { user.ID = result.ID; user.groupIDs = result.groupIDs; } MessageBox.Show("Login successful! Welcome: " + username); main_screen openScreen = new main_screen(user); openScreen.Show(); Visible = false; } } if (loginSuccess == false) { MessageBox.Show("Login unsuccessful. Please ensure the username and password are entered correctly."); } }
private void cancelNewLocationBtn_Click(object sender, EventArgs e) { main_screen open_screen = new main_screen(currentUser); open_screen.Show(); this.Close(); }
private void addNewScoutBtn_Click(object sender, EventArgs e) { string firstName = ""; string secondName = ""; string dateOfBirth = ""; string pEmail = ""; string pFName = ""; string pSName = ""; string pNumb = ""; string healthInfo = ""; address Address = new address(); string groupName = ""; bool groupChosen = false; bool scoutAdded = false; scout Scout = getPersonalDetails(firstName, secondName, dateOfBirth, Address, pEmail, pFName, pSName, pNumb, healthInfo); try { groupName = getGroupName(); groupChosen = true; } catch (Exception e2) { MessageBox.Show("New scout could not be created: Please select a group to add the scout to."); scoutAdded = false; } try { if (groupChosen) { scout.addNewScout(Scout); MessageBox.Show("New scout was created."); scoutAdded = true; } } catch (Exception e1) { MessageBox.Show("New scout could not be created. Please try again."); scoutAdded = false; } try { int groupID = group.getGroupID(groupName); if (groupChosen && scoutAdded == true) { group.addScoutToGroup(groupID, Scout.scoutID); main_screen open_screen = new main_screen(currentUser); open_screen.Show(); this.Close(); } } catch (Exception e2) { MessageBox.Show("New scout created, but not added to group"); scoutAdded = false; } }
/// <summary> /// new user button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void newUserBtn_Click_1(object sender, EventArgs e) { string newUsername; string password = null; string salt = null; string newUserValid = passwordManager.passwordValidation(password1TxtBx.Text, password2TxtBx.Text); bool usernameUsed = user.checkUsername(usernameTxtBx.Text); if (usernameUsed == true) { newUserValid = "usernameUsed"; } switch (newUserValid) //switch provides the user with detailed error messages when trying to create a new user { case "valid": password = password1TxtBx.Text; newUsername = usernameTxtBx.Text; password = passwordManager.HashSaltManager.GeneratePasswordHash(password, out salt); user User = new user(newUsername, password, salt); MessageBox.Show("New user was created successfully."); if (user.AddNewUser(user: User)) { main_screen openMainScreen = new main_screen(User); openMainScreen.Show(); Visible = false; } break; case "nonAlphaChar": MessageBox.Show("New user could not be created: special character used in password"); break; case "nonMatch": MessageBox.Show("New user could not be created: passwords did not match"); break; case "noCaps": MessageBox.Show("New user could not be created: no capital letters included in password"); break; case "noNums": MessageBox.Show("New user could not be created: no numbers included in password"); break; case "tooShort": MessageBox.Show("New user could not be created: password incorrect length"); break; case "usernameUsed": MessageBox.Show("New user could not be created: username already in use on this system; please choose a new one."); break; } }
private void addNewLocationBtn_Click(object sender, EventArgs e) { newlocation.locationName = locationNameTxtBx.Text; newlocation.Address = createAddress(); newlocation.venueNotes = venueNotesTxtBx.Text; location.addLocation(newlocation); group.changeLocationOfGroup(currentGroup.groupID, newlocation.locationID); main_screen open_screen = new main_screen(currentUser); open_screen.Show(); this.Close(); }
private void cancelNewScoutBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to cancel?", "Cancel adding new scout", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } }
private void discardChangesBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to discard your changes?", "Discard changes", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } }
private void editGroupBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save your changes?", "Save changes", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { int groupId = groupToBeEdited.groupID; using (var ctx = new SALAHContext()) { var result = ctx.Groups.SingleOrDefault(g => g.groupID == groupId); if (result != null) { result.group_name = groupNameTxtbx.Text; bool locationExists = location.checkLocationExists(meetingPlaceTxtBx.Text); if (locationExists == true) { location location = location.getLocationWName(meetingPlaceTxtBx.Text); group.changeLocationOfGroup(groupId, location.locationID); string locationIDString = location.locationID.ToString(); result.location_ID = locationIDString; } else { location location = new location(meetingPlaceTxtBx.Text); location.addLocation(location); group.changeLocationOfGroup(groupId, location.locationID); } result.group_type = ageGroupCBox.SelectedItem.ToString(); } ctx.SaveChanges(); ctx.Dispose(); } main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } return; }
private void deleteLocationBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to delete this location: " + currentLocation.locationName + "?", "Delete " + currentLocation.locationName, MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { try { location.DeleteLocation(currentLocation, currentGroup); main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } catch { MessageBox.Show("Location could not be deleted. Please check the details and try again."); } } }
private void deleteMeetingBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to delete this scout? This action cannot be undone.", "Delete Meeting: " + currentMeeting.meetingTitle, MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { try { group.RemoveMeetingFromGroup(currentGroup, currentMeeting); meeting.deleteMeeting(currentMeeting.meetingID); main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } catch { MessageBox.Show("Scout could not be deleted. Please check the details and try again."); } } }
private void addNewResourceBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save this new resource?", "Save New Resource", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { bool resourceAdded = true; try { newResource = new resource(); newResource.name = resourceNameTxtBx.Text; newResource.notes = resourceNotesTxtBx.Text; newResource.quantity = int.Parse(quantityUpDown.Text); if (!resource.addNewResource(newResource)) { resourceAdded = false; } if (!location.addResourceToLocation(currentLocation.locationID, newResource.resourceID)) { resourceAdded = false; } } catch { resourceAdded = false; } if (resourceAdded == false) { MessageBox.Show("This resource could not be saved, try again please"); } else if (resourceAdded == true) { main_screen open_screen = new main_screen(currentUser); open_screen.Show(); this.Close(); } } }
private void deleteLocationBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to delete this resource? This action cannot be undone.", "Delete Meeting: " + currentResource.name, MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { try { location.RemoveResourceFromLocation(currentLocation, currentResource); resource.DeleteResource(currentResource.resourceID); main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } catch { MessageBox.Show("Resource could not be deleted. Please check the details and try again."); } } }
private void saveChangesBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save your changes?", "Save changes", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { if (newGroup.group_name == currentGroup.group_name) moveGroup = false; group.changeGroupMeeting(currentGroup, newGroup, currentMeeting, moveGroup); int meetingId = currentMeeting.meetingID; using (var ctx = new SALAHContext()) { var result = ctx.Meetings.SingleOrDefault(m => m.meetingID == meetingId); if (result != null) { result.meetingTitle = meetingTitleTxtBx.Text; result.meetingDesc = meetingDescTxtBx.Text; result.Location = meetingPlaceTxtBx.Text; result.DateTime = meetingDatePicker.Value.ToString(); } ctx.SaveChanges(); ctx.Dispose(); } main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } return; }
private void saveChangesBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save the changes you have made?", "Save Changes to " + mCurrentMeeting.meetingTitle, MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { for (int i = 0; i < mNumberOfScoutsInGroup; i++) { if (registerCheckedListBox1.GetItemCheckState(i) == CheckState.Checked) { string nameAndId = registerCheckedListBox1.Items[i].ToString(); string[] nameAndIdArray = nameAndId.Split(')'); int id = int.Parse(nameAndIdArray[0]); if (!meeting.wasScoutAtMeeting(mCurrentMeeting.meetingID, id)) { meeting.addScoutToMeeting(mCurrentMeeting.meetingID, id); } } else if (registerCheckedListBox1.GetItemCheckState(i) == CheckState.Unchecked) { string nameAndId = registerCheckedListBox1.Items[i].ToString(); string[] nameAndIdArray = nameAndId.Split(')'); int id = int.Parse(nameAndIdArray[0]); if (meeting.wasScoutAtMeeting(mCurrentMeeting.meetingID, id)) { meeting.removeScoutsFromMeeting(mCurrentMeeting.meetingID, id); } } } main_screen open_screen = new main_screen(mCurrentUser); open_screen.Show(); this.Close(); } }
private void saveBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save your changes?", "Save changes", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { if (newGroup.group_name == currentGroup.group_name || newGroup.group_name == null) { moveGroup = false; } location.changeLocationsGroup(currentLocation, currentGroup, newGroup, moveGroup); int locationId = currentLocation.locationID; using (var ctx = new SALAHContext()) { var result = ctx.Locations.SingleOrDefault(l => l.locationID == locationId); if (result != null) { result.locationName = locationNameTxtBx.Text; result.venueNotes = venueNotesTxtBx.Text; result.Address = CreateAddress(); } ctx.SaveChanges(); ctx.Dispose(); } main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } }
private void addNewGroupBtn_Click(object sender, EventArgs e) { name = groupNameTxtbx.Text; meetingplace = meetingPlaceTxtBx.Text; type = ageGroupCBox.Text; groupNameValid = true; foreach (string s in group.getGroupNames(user)) { if (name == s) { MessageBox.Show("This group name is already taken."); groupNameValid = false; break; } } if (groupNameValid) { location location = new location(meetingplace); location.addLocation(location); string locationIDString = location.locationID.ToString(); group newGroup = new group(name, locationIDString, type); bool userAdded = group.AddNewGroup(newGroup, user); if (userAdded) { MessageBox.Show("Group was successfully added."); main_screen open_screen = new main_screen(user); this.Close(); open_screen.Show(); } if (!userAdded) { MessageBox.Show("Group was not added. Please try again."); } } }
private void saveBtn_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("Are you sure you want to save your changes to this resource?", "Save Changes", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { if (newLocation.locationID == currentLocation.locationID) { moveLocation = false; } resource.ChangeLocationOfResource(currentResource.resourceID, currentLocation.locationID, newLocation.locationID, moveLocation); int resourceId = currentResource.resourceID; using (var ctx = new SALAHContext()) { var result = ctx.Resources.SingleOrDefault(r => r.resourceID == resourceId); if (result != null) { result.name = resourceNameTxtBx.Text; result.notes = resourceNotesTxtBx.Text; result.quantity = int.Parse(quantityUpDown.Text); } ctx.SaveChanges(); ctx.Dispose(); } main_screen open_screen = new main_screen(currentUser); this.Close(); open_screen.Show(); } }