/// <summary> /// /// NAME: Steve Coonrod /// DATE: 2020-03-04 /// CHECKED BY: /// /// This is the Delete Button click event handler /// /// Updated By: /// Updated On: /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, RoutedEventArgs e) { //Logic to delete the event try { bool successfulDelete = _eventManager.DeleteEvent(_event.EventID); if (successfulDelete == true) { MessageBox.Show(_event.EventName + " was deleted."); this.DialogResult = true; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// CREATOR: Steve Coonrod, Matt Deaton /// CREATED 2/10/2020 /// APPROVER: Ryan Morganti /// /// Main Click Event to submit an Event. Submits Form Data for processing. /// /// </summary> /// <remarks> /// /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> private void BtnSubmitCreate_Click(object sender, RoutedEventArgs e) { int eventID; //Will be returned with the Event int requestID; //Will be returned with the Request //This method will validate the field data and return the values in a string array //The validated field data strings will be assigned to a new Event Object //To be passed to the DB through the eventManager interface string[] validatedFieldData = validateFormData(); if (validatedFieldData != null) { try { //Create an Event object from the validated fields PUEvent newEvent = new PUEvent() { CreatedByID = Int32.Parse(validatedFieldData[0]), DateCreated = DateTime.Parse(validatedFieldData[1]), EventName = validatedFieldData[2], EventTypeID = validatedFieldData[3], EventDateTime = DateTime.Parse(validatedFieldData[4]), Address = validatedFieldData[5], City = validatedFieldData[6], State = validatedFieldData[7], Zipcode = validatedFieldData[8], BannerPath = validatedFieldData[9], Status = validatedFieldData[10], Description = validatedFieldData[11] }; //Check the User's Role //In any case, the event is created... //But a DC will create one with the status Approved, and will not need to create a request if (_user.PURoles.Contains("Donation Coordinator")) { newEvent.Status = (statusOptions.Approved.ToString()); eventID = _eventManager.AddEvent(newEvent); if (eventID != 0) { MessageBox.Show("Event: " + newEvent.EventName + "\n" + "has been created."); } } else // If the user does not have the Donation Coordinator Role... { newEvent.Status = (statusOptions.PendingApproval.ToString()); eventID = _eventManager.AddEvent(newEvent); if (eventID != 0) { //Create A Request Request newRequest = new Request() { DateCreated = DateTime.Now, RequestTypeID = "Event", RequestingUserID = _user.PUUserID, Open = true }; requestID = _eventManager.AddRequest(newRequest); if (requestID != 0) { //Will need to create an eventRequest EventRequest newEventRequest = new EventRequest() { EventID = eventID, RequestID = requestID, DisapprovalReason = "", DesiredVolunteers = 0, ReviewerID = 0, Active = true }; //Verify that all tables were updated int rowsEffectedByAddRequestEvent = _eventManager.AddEventRequest(newEventRequest); if (rowsEffectedByAddRequestEvent == 1 && eventID != 0 && requestID != 0) { MessageBox.Show("Event: " + newEvent.EventName + " has been created. \nA request has been made to review this event."); _eventMgmt.frAllEvents.Content = new ListAllEvents(_eventManager, _eventMgmt); _eventMgmt.frPendingEvents.Content = new ListPendingEvents(_eventManager, _eventMgmt); _eventMgmt.frApprovedEvents.Content = new ListApprovedEvents(_eventManager, _eventMgmt); CloseThisPage(); } else { MessageBox.Show("An unknown error has occurred.\nPlease try again later."); _eventManager.DeleteEvent(eventID); CloseThisPage(); } } } //End if for non-DC member Event creation } //End if-else for role-based implementation } //End try catch (Exception ex) { MessageBox.Show("We're Sorry.\n" + "There was an error with the process.\n" + "Please try again later.\n" + ex.Message); CloseThisPage(); } } //End if(validatedFieldData[] != null) } //End Submit click event