/// <summary> /// /// CREATOR: Steve Coonrod /// CREATED: 3\15\2020 /// APPROVER: Ryan Morganti /// /// This is a helper method to Set up the EventApprovalForm as a View only Page /// /// </summary> /// <remarks> /// /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> /// <param name="eventApprovalVM"></param> private void SetUpViewMode(EventApprovalVM eventApprovalVM) { txtVolunteersNeeded.IsReadOnly = true; btnApprove.Visibility = Visibility.Hidden; btnDisapprove.Visibility = Visibility.Hidden; lblAutogen.Visibility = Visibility.Hidden; chkAutoGenVolunteerTask.Visibility = Visibility.Hidden; //Currently, the reviewer name being returned is actually the reviewers ID //Therefore, this checks to see if the value is parsable to an int and != 0 //If so it tries to find the matching ID for a user in the DB //All just to get the info needed for the reviewer attached to this request if (Int32.TryParse(eventApprovalVM.ReviewerName, out int reviewerID) && reviewerID != 0) { //Not Ideal, waiting for a retrieveUserByID method IUserManager _tempUserManager = new UserManager(); foreach (var user in _tempUserManager.RetrieveAllActivePetUniverseUsers()) { if (user.PUUserID == reviewerID) { lblReviewerName.Content = user.FirstName + " " + user.LastName; } } } else//this is the case for pending events { lblReviewerName.Content = "Not Applicable"; txtVolunteersNeeded.Visibility = Visibility.Hidden; lblNeededVolunteers.Visibility = Visibility.Hidden; } txtEventDisapprovalReason.Visibility = Visibility.Hidden; lblEventStatus.Content += _event.Status; lblEventStatus.Visibility = Visibility.Visible; }
/// <summary> /// /// CREATOR: Steve Coonrod /// CREATED: 3\08\2020 /// APPROVER: Ryan Morganti /// /// This is a helper method which fills the forms fields with the Event's data /// /// </summary> /// <remarks> /// /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> /// <param name="eventApprovalVM"></param> private void FillFieldData(EventApprovalVM eventApprovalVM) { lblBannerPath.Content = eventApprovalVM.BannerPath; lblDateRequested.Content = eventApprovalVM.DateCreated.ToString(); lblEventAddressLineOne.Content = eventApprovalVM.Address; lblEventAddressLineTwo.Content = eventApprovalVM.City + ", " + eventApprovalVM.State + " " + eventApprovalVM.Zipcode; lblEventDescription.Text = eventApprovalVM.Description; txtEventDisapprovalReason.Text = eventApprovalVM.DisapprovalReason; lblEventName.Content = eventApprovalVM.EventName; lblEventTime.Content = eventApprovalVM.EventDateTime.ToString(); lblEventType.Content = eventApprovalVM.EventTypeID; try { Uri uri = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + @"..\..\images\" + _event.BannerPath, UriKind.RelativeOrAbsolute); picEventPicture.Source = new BitmapImage(uri); } catch (Exception ex) { } lblRequestedByName.Content = eventApprovalVM.RequestedByName; txtVolunteersNeeded.Text = eventApprovalVM.DesiredVolunteers.ToString(); }
/// <summary> /// /// CREATOR: Steve Coonrod /// CREATED: 3\08\2020 /// APPROVER: Ryan Morganti /// /// This is the event handler for when this page loads /// Gets the Event's View Model through the Event Manager /// /// </summary> /// <remarks> /// /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Loaded(object sender, RoutedEventArgs e) { //EventID = 0 on EventMgmt startup, which loads the empty constructor //This block is bypassed on startup, only occurs when called from the eventMgmt button if (_event.EventID != 0) { try { EventApprovalVM eventApprovalVM = _eventManager.GetEventApprovalVM(_event.EventID, _event.CreatedByID); if (eventApprovalVM != null) { FillFieldData(eventApprovalVM); if (_approveMode == true) { lblReviewerName.Content = _user.FirstName + " " + _user.LastName; txtEventDisapprovalReason.Text = "Reason for disapproval"; } else //If in View Mode { SetUpViewMode(eventApprovalVM); }//End View Mode } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.InnerException.Message); } } }
}// End SelectAllEvents() /// <summary> /// /// CREATOR: Steve Coonrod /// CREATED: 3/15/2020 /// APPROVER: Ryan Morganti /// /// The data accessor method for Selecting an Event View Model /// /// </summary> /// <remarks> /// /// Updater: NA /// Updated: NA /// Update: NA /// /// </remarks> /// <param name="eventID"></param> /// <param name="createdByID"></param> /// <returns></returns> public EventApprovalVM SelectEventApprovalVM(int eventID, int createdByID) { EventApprovalVM retrievedEventApprovalVM = new EventApprovalVM(); var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_select_event_approval_request_by_eventID", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EventID", eventID); cmd.Parameters.AddWithValue("@CreatedByID", createdByID); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { retrievedEventApprovalVM.RequestedByName = reader.GetString(0); retrievedEventApprovalVM.DateCreated = reader.GetDateTime(1); retrievedEventApprovalVM.EventName = reader.GetString(2); retrievedEventApprovalVM.EventTypeID = reader.GetString(3); retrievedEventApprovalVM.EventDateTime = reader.GetDateTime(4); retrievedEventApprovalVM.Address = reader.GetString(5); retrievedEventApprovalVM.City = reader.GetString(6); retrievedEventApprovalVM.State = reader.GetString(7); retrievedEventApprovalVM.Zipcode = reader.GetString(8); retrievedEventApprovalVM.BannerPath = reader.GetString(9); retrievedEventApprovalVM.Status = reader.GetString(10); retrievedEventApprovalVM.Description = reader.GetString(11); if (!reader.IsDBNull(12)) { retrievedEventApprovalVM.ReviewerName = reader.GetInt32(12).ToString(); } else { retrievedEventApprovalVM.ReviewerName = "0"; } if (!reader.IsDBNull(13)) { retrievedEventApprovalVM.DisapprovalReason = reader.GetString(13); } retrievedEventApprovalVM.DesiredVolunteers = reader.GetInt32(14); } } reader.Close(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(retrievedEventApprovalVM); }
/// <summary> /// Creator: Steve Coonrod /// Created: 02/06/2020 /// Approver: Ryan Morganti /// /// No arg constructor /// /// </summary> /// <remarks> /// /// Updater: NA /// Updated: NA /// Update: NA /// /// </remarks> public FakeEventAccessor() { //A fake repository containing 4 events puEvents = new List <PUEvent>() { new PUEvent() { EventID = 1000000, CreatedByID = 1000000, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), EventName = "Billy's Animal Parade", EventTypeID = "Fundraiser", EventDateTime = DateTime.Parse("04/20/2020 05:15 PM"), Address = "202 First Street", City = "Cedar Rapids", State = "IA", Zipcode = "52402", BannerPath = "billysParade.jpg", Status = "PendingApproval", Description = "Billy Little is hosting a childrens animal parade." }, new PUEvent() { EventID = 1000001, CreatedByID = 1000010, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), EventName = "Fun at the Lake", EventTypeID = "Adoption", EventDateTime = DateTime.Parse("07/06/2020 06:30 PM"), Address = "202 Fawn Lake Drive", City = "Estes Park", State = "CO", Zipcode = "88233", BannerPath = "FawnLake.jpg", Status = "PendingApproval", Description = "Come spend some time with our animals out at Fawn Lake Animal Shelter." }, new PUEvent() { EventID = 1000023, CreatedByID = 1000142, DateCreated = DateTime.Parse("01/24/2020 05:15 PM"), EventName = "Animal Cruelty Awareness Rally", EventTypeID = "Awareness", EventDateTime = DateTime.Parse("10/31/2020 05:15 PM"), Address = "1187 Arbor Lane", City = "Millbrook", State = "WI", Zipcode = "67421", BannerPath = "ACAR.jpg", Status = "PendingApproval", Description = "Animals are cruel and you need to know about it." }, new PUEvent() { EventID = 1000418, CreatedByID = 1000055, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), EventName = "Lets All Monkey Around", EventTypeID = "Fundraiser", EventDateTime = DateTime.Parse("01/24/2020 05:15 PM"), Address = "9391 Amazing Place", City = "Coolsville", State = "MI", Zipcode = "11697", BannerPath = "monkeys.jpg", Status = "Approved", Description = "Come join us at the Amazing Place and go bananas with our monkeys." }, }; //A fake repository containing 4 requests requests = new List <Request>() { new Request() { RequestID = 1000000, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), RequestTypeID = "Event", Open = true }, new Request() { RequestID = 1000001, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), RequestTypeID = "Event", Open = true }, new Request() { RequestID = 1000002, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), RequestTypeID = "Event", Open = true }, new Request() { RequestID = 1000003, DateCreated = DateTime.Parse("01/24/2019 05:15 PM"), RequestTypeID = "Event", Open = false }, }; // A fake repository of 4 event requests puEventRequests = new List <EventRequest>() { new EventRequest() { EventID = 1000000, RequestID = 1000000, ReviewerID = 1000027, DisapprovalReason = null, DesiredVolunteers = 5, Active = true }, new EventRequest() { EventID = 1000001, RequestID = 1000001, ReviewerID = 1000247, DisapprovalReason = null, DesiredVolunteers = 6, Active = true }, new EventRequest() { EventID = 1000023, RequestID = 1000002, ReviewerID = 1000332, DisapprovalReason = null, DesiredVolunteers = 4, Active = true }, new EventRequest() { EventID = 1000418, RequestID = 1000003, ReviewerID = 1001027, DisapprovalReason = null, DesiredVolunteers = 3, Active = true } }; eventTypes = new List <EventType>() { new EventType() { EventTypeID = "Adoption", Description = "An Adoption Event" }, new EventType() { EventTypeID = "Awareness", Description = "An Awareness Event" }, new EventType() { EventTypeID = "Fundraiser", Description = "A Fundraising Event" }, new EventType() { EventTypeID = "Recruiting", Description = "A Recruiting Event" } }; eventApprovalVM = new EventApprovalVM() { DateCreated = DateTime.Parse("01/24/2020 05:15 PM"), EventName = "Animal Cruelty Awareness Rally", EventTypeID = "Awareness", EventDateTime = DateTime.Parse("10/31/2020 05:15 PM"), Address = "1187 Arbor Lane", City = "Millbrook", State = "WI", Zipcode = "67421", BannerPath = "ACAR.jpg", Status = "PendingApproval", Description = "Animals are cruel and you need to know about it.", RequestedByName = "Billy Anderson", DesiredVolunteers = 0, DisapprovalReason = null, ReviewerName = null }; }