예제 #1
0
        private void displayAlertList()
        {
            //Clear List
            alertListView.Items.Clear();

            List<Alert> alerts = new List<Alert>();
            EventEntity eve = new EventEntity();
            ActiveUser au = new ActiveUser(currentUser);
            alerts = au.getListOfAlerts();
            int currentEventID;

            if (alerts.Count != 0)
            {
                for (int i = 0; i < alerts.Count; i++)
                {
                    ListViewItem newAlert = new ListViewItem((i + 1).ToString());
                    newAlert.SubItems.Add(alerts[i].getAlertedEventName()); // Name of Event
                    newAlert.SubItems.Add(alerts[i].getAlert()); // Alert String
                    alertListView.Items.Add(newAlert);

                    // Clear Alert Flag
                    currentEventID = eve.getEventIDFromEventName(alerts[i].getAlertedEventName());
                    eve.clearEventUpdatedFlag(currentEventID);
                    eve.clearEventFullFlag(currentEventID);
                    eve.clearEventStartFlag(currentEventID);
                }
            }

            alerts.Clear(); // Erase off OLD alerts
            alertListView.Show();
        }
예제 #2
0
        // Check For Starting Events For This Curent User
        public void checkForStartingEvent()
        {
            Organiser o = new Organiser(this);
            Participant p = new Participant(this);
            Facilitator f = new Facilitator(this);
            List<EventEntity> listOfOrganizedEvents = o.getOrganisedEvents();
            List<EventEntity> listOfRegisteredEvents = p.getRegisteredEvents();
            List<EventEntity> listOfFacilitatingEvents = f.getFacilitatedEvents();
            EventEntity eve = new EventEntity();
            TimeSpan difference = new TimeSpan(1, 0, 0, 0);

            foreach (EventEntity events in listOfOrganizedEvents)
            {
                if ((events.getEventStartTime().Subtract(System.DateTime.Now)) <= difference)
                    events.setEventStartFlag(events.getEventId());
            }

            foreach (EventEntity events in listOfRegisteredEvents)
            {
                if ((events.getEventStartTime().Subtract(System.DateTime.Now)) <= difference)
                    events.setEventStartFlag(events.getEventId());
            }

            foreach (EventEntity events in listOfFacilitatingEvents)
            {
                if ((events.getEventStartTime().Subtract(System.DateTime.Now)) <= difference)
                    events.setEventStartFlag(events.getEventId());
            }
        }
예제 #3
0
        public static EventEntity getEventEntity(int eventID)
        {
            Database db = Database.CreateDatabase(DatabaseToken);

            List<EventEntity> listOfEventEntity = db.getListOfEvents();
            EventEntity returnEve = new EventEntity();
            foreach (EventEntity eve in listOfEventEntity)
            {
                if (eventID == eve.getEventId())
                {
                    returnEve = eve;
                }
            }
            return returnEve;
        }
예제 #4
0
 public DateTime getStartTimeFromEventID(int currentEventID)
 {
     Database db = Database.CreateDatabase(DatabaseToken);
     List<EventEntity> listOfEvent = db.getListOfEvents();
     EventEntity eve = new EventEntity();
     foreach (EventEntity events in listOfEvent)
     {
         if (events.getEventId() == currentEventID)
             eve = events;
     }
     return eve.startTime;
 }
예제 #5
0
        public bool getEventUpdatedFlag(int currentEventID)
        {
            List<EventEntity> listOfEvent = db.getListOfEvents();
            EventEntity eve = new EventEntity();

            foreach (EventEntity events in listOfEvent)
            {
                if (events.eventId == currentEventID)
                    eve = events;
            }
            return eve.eventUpdatedFlag;
        }
예제 #6
0
 public int getEventIDFromEventName(string name)
 {
     Database db = Database.CreateDatabase(DatabaseToken);
     List<EventEntity> listOfEvent = db.getListOfEvents();
     EventEntity eve = new EventEntity();
     foreach (EventEntity events in listOfEvent)
     {
         if (events.getEventName() == name)
             eve = events;
     }
     return eve.getEventId();
 }
예제 #7
0
        // Create Appropriate Alerts
        public Alert createAlert(int currentEventID, int alertType)
        {
            Database db = Database.CreateDatabase(DatabaseToken);
            List<EventEntity> listOfEvent = db.getListOfEvents();
            EventEntity eve = new EventEntity();
            Alert alert = new Alert();

            foreach (EventEntity events in listOfEvent)
            {
                if (events.eventId == currentEventID)
                    eve = events;
            }

            switch (alertType)
            {
                case 1:
                    Alert alert1 = new Alert(eve.name, "Event has been updated!");
                    alert = alert1;
                    break;
                case 2:
                    Alert alert2 = new Alert(eve.name, "Event has been deleted!");
                    alert = alert2;
                    break;
                case 3:
                    Alert alert3 = new Alert(eve.name, "Event is starting in 1 day!");
                    alert = alert3;
                    break;
                case 4:
                    Alert alert4 = new Alert(eve.name, "Event is fully registered!");
                    alert = alert4;
                    break;
                default:
                    // Error here
                    break;
            }
            return alert;
        }
예제 #8
0
        private void organiserEditButton_Click(object sender, EventArgs e)
        {
            try
            {
                TimeSpan difference = new TimeSpan(3, 0, 0, 0);
                EventEntity eve = new EventEntity();
                ListViewItem listItem = this.listSideEventView.SelectedItems[0];
                currentEventID = int.Parse(listItem.SubItems[0].Text);

                if ((eve.getStartTimeFromEventID(currentEventID).Subtract(System.DateTime.Now)) <= difference)
                {
                    MessageBox.Show("You cannot edit an event that starts 3 days from now.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    try
                    {
                        updateForm updateNew = new updateForm(currentUser, currentEventID);
                        updateNew.Show();
                    }
                    catch
                    {
                        AdviseUserToMakeASelection();
                    }
                }
            }
            catch
            {
                AdviseUserToMakeASelection();
            }
        }
예제 #9
0
        private void organiserCancel_Click(object sender, EventArgs e)
        {
            int organiserCancellingEventId = -1;

            try
            {

                ListViewItem sideListItem = this.listSideEventView.SelectedItems[0];
                organiserCancellingEventId = int.Parse(sideListItem.SubItems[0].Text);

                Organiser organiser = new Organiser(currentUser);

                if (organiserCancellingEventId != -1)
                {
                    if (Organiser_Cancel_SideBar_Dialog())
                    {
                        organiser.cancelEvent(organiserCancellingEventId);
                    }
                }
            }
            catch (ArgumentOutOfRangeException arg_ex)
            {
                AdviseUserToMakeASelection();
            }

            // Set Event Delete Flag
            EventEntity eve = new EventEntity();
            eve.setEventDeletedFlag(currentEventID);

            //Refresh the Side Bar
            initSideEventBar();
        }
예제 #10
0
        public bool registerEvent(EventEntity interestedEvent)
        {
            bool eventRegistered = false;

            //Establish database linkage
            IDatabase db = Database.CreateDatabase(DatabaseToken);

            List<EventEntity> currentEvents = db.getListOfEvents();

            for(int i=0;i<currentEvents.Count;i++)
            {
                if(interestedEvent.getEventId().Equals(currentEvents[i].getEventId()))
                {
                        currentEvents[i].addParticipantToEvent(this);
                        registeredEvents.Add(interestedEvent);
                        eventRegistered = true;
                }
            }

            //Save all events back into database

            db.saveListOfEvents(currentEvents);

            return eventRegistered;
        }
예제 #11
0
        public List<Participant> viewParticipantList(EventEntity thisEvent)
        {
            List<Participant> allParticipant = new List<Participant>();

            //Establish database linkage
            IDatabase db = Database.CreateDatabase(DatabaseToken);

            List<EventEntity> allEvents = db.getListOfEvents();

            EventEntity abstractedEvent = new EventEntity() ;

            for(int i =0 ; i<allEvents.Count;i++)
            {
                if (thisEvent.getEventId().Equals(allEvents[i].getEventId()))
                {
                    abstractedEvent = allEvents[i];
                    break;
                }
            }

            return abstractedEvent.getParticipantList();
        }
예제 #12
0
        private void displayAppropriateBtn(EventEntity.EventInfoStates fixedState)
        {
            /*All Participants and Organisers can view the facilitator info */

            switch (fixedState)
            {
                case EventEntity.EventInfoStates.unregisteredActiveUser:
                    registerEventBtn.Show();
                    facilitateEventBtn.Show();
                    viewParticipantListBtn.Hide();
                    viewFacilitatorListBtn.Show();
                    break;
                case EventEntity.EventInfoStates.registeredParticipant:
                    registerEventBtn.Hide();
                    facilitateEventBtn.Hide();
                    viewParticipantListBtn.Hide();
                    viewFacilitatorListBtn.Show();
                    viewFacilitatorListBtn.Location = new Point(160, 50);
                    displayStatusLabel("You have already registered for this event");
                    break;
                case EventEntity.EventInfoStates.facilitator:
                    registerEventBtn.Hide();
                    facilitateEventBtn.Hide();
                    viewParticipantListBtn.Show();
                    viewFacilitatorListBtn.Hide();
                    break;
                case EventEntity.EventInfoStates.organiser:
                    registerEventBtn.Hide();
                    facilitateEventBtn.Hide();
                    viewParticipantListBtn.Show();
                    viewFacilitatorListBtn.Show();
                    break;
            }

            returnBtn.Show();
        }
예제 #13
0
        //Events Database Interaction Implementation
        public List<EventEntity> getListOfEvents()
        {
            List<EventEntity> listToPop = new List<EventEntity>();
            List<Participant> participantList = new List<Participant>();

            List<int> budgetList = new List<int>();
            List<int> facilitatorList = new List<int>();

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;

            using (XmlReader scanner = XmlReader.Create("events.xml", settings))
            {
                scanner.MoveToContent();

                scanner.ReadToDescendant("EventEntity");

                do
                {
                    scanner.ReadToDescendant("eventId");

                    int eventId = scanner.ReadElementContentAsInt();

                    string eventDescription = scanner.ReadElementContentAsString("name", "");

                    DateTime startTime = scanner.ReadElementContentAsDateTime();

                    DateTime endTime = scanner.ReadElementContentAsDateTime();

                    int eventScheduleId = scanner.ReadElementContentAsInt();

                    int participantSize = scanner.ReadElementContentAsInt();

                    int organiserId = scanner.ReadElementContentAsInt();

                    double totalBudget = scanner.ReadElementContentAsDouble();

                    bool eventUpdatedFlag = scanner.ReadElementContentAsBoolean();

                    bool eventDeletedFlag = scanner.ReadElementContentAsBoolean();

                    bool eventStartingFlag = scanner.ReadElementContentAsBoolean();

                    bool eventFullFlag = scanner.ReadElementContentAsBoolean();

                    if (scanner.ReadToDescendant("User"))
                    {
                        do
                        {

                            scanner.ReadToDescendant("userId");

                            int userId = scanner.ReadElementContentAsInt();

                            string userName = scanner.ReadElementContentAsString("userName", "");

                            string name = scanner.ReadElementContentAsString("name", "");

                            string matricNo = scanner.ReadElementContentAsString("matricNo", "");

                            string pw = scanner.ReadElementContentAsString("password", "");

                            string em = scanner.ReadElementContentAsString("email", "");

                            int age = scanner.ReadElementContentAsInt();

                            bool loggedIn = scanner.ReadElementContentAsBoolean();

                            double HomeNum = scanner.ReadElementContentAsDouble();

                            double HPContact = scanner.ReadElementContentAsDouble();

                            Participant newParticipant = new Participant(userId, userName, name, matricNo, pw, em, age, loggedIn, HomeNum, HPContact);

                            participantList.Add(newParticipant);

                        } while (scanner.ReadToNextSibling("User"));

                    }

                    scanner.Skip();

                    if (scanner.ReadToDescendant("User"))
                    {
                        do
                        {
                            scanner.ReadToDescendant("userId");

                            int facilitatorId = scanner.ReadElementContentAsInt();

                            facilitatorList.Add(facilitatorId);

                        } while (scanner.ReadToNextSibling("User"));
                    }

                    scanner.Skip();

                    if (scanner.ReadToDescendant("Budget"))
                    {
                        do
                        {
                            scanner.ReadToDescendant("itemId");

                            int budgetId = scanner.ReadElementContentAsInt();

                            budgetList.Add(budgetId);

                        }while(scanner.ReadToNextSibling("Budget"));
                    }

                    scanner.Skip();

                    EventEntity newEvent = new EventEntity(eventId, eventDescription, startTime, endTime, eventScheduleId, participantSize, participantList,facilitatorList,budgetList, totalBudget,organiserId, eventUpdatedFlag,eventDeletedFlag,eventStartingFlag,eventFullFlag);

                    participantList.Clear();
                    facilitatorList.Clear();
                    budgetList.Clear();

                    listToPop.Add(newEvent);

                } while (scanner.ReadToNextSibling("EventEntity"));

            }
            return listToPop;
        }
예제 #14
0
        public List<Facilitator> viewListOfFacilitator(EventEntity thisEvent)
        {
            List<Facilitator> outputFacilitatorList = new List<Facilitator>();

            List<int> listOfFacilitatorId = thisEvent.getListOfFacilitator();

            Database db = Database.CreateDatabase(DatabaseToken);

            List<User> listOfUsers = db.getListOfUsers();

            for (int i = 0; i < listOfUsers.Count; i++)
            {
                if(listOfFacilitatorId.Contains(listOfUsers[i].getUserId()))
                    outputFacilitatorList.Add(new Facilitator(listOfUsers[i]));
            }

            return outputFacilitatorList;
        }
예제 #15
0
        public bool createEvent(EventEntity events)
        {
            Database db = Database.CreateDatabase(DatabaseToken);
            List<EventEntity> eventList = db.getListOfEvents();

            //Add event into the database
            eventList.Add(events);
            db.saveListOfEvents(eventList);

            //Add event into Organiser's own list
            createdEvents.Add(events);

            return true;
        }
예제 #16
0
        private void createButton_Click(object sender, EventArgs e)
        {
            if (eventNameTextBox.Text == "" && sizeTextBox.Text == "")
            {
                MessageBox.Show("Please fill in the event details. Thank you.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (eventNameTextBox.Text == "")
            {
                MessageBox.Show("Please enter an event name. Thank you.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (sizeTextBox.Text == "")
            {
                MessageBox.Show("Please enter the particpatiant size. Thank you.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (startTimePicker.Value > endTimePicker.Value)
            {
                MessageBox.Show("The event's start date cannot be after its end date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (startTimePicker.Value == endTimePicker.Value)
            {
                MessageBox.Show("The event cannot have the same start and end time.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (int.Parse(sizeTextBox.Text) < 1)
            {
                MessageBox.Show("You cannot create an event with 0 participant size.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (listOfActivity.Count == 0 && scheduleEventView.Items.Count == 0)
            {
                MessageBox.Show("Please add your schedule. Thank you.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string path = "events.xml";
                int neweventId = 1;
                int newscheduleId = 1;
                if (File.Exists(path))
                {
                    neweventId = Organiser.getNewEventId();
                    newscheduleId = Organiser.getNewScheduleId();
                }
                List<Participant> participantList = new List<Participant>();
                List<int> facilitatorList = new List<int>();
                Organiser org = new Organiser(currentUser);

                // Delete event
                Activity currentActivity;
                for (int i = 0; i < listOfActivity.Count; i++)
                {
                    currentActivity = listOfActivity[i];
                    if (currentActivity.getDate().Year == Convert.ToDateTime(dateCombobox.Text).Year && currentActivity.getDate().Month == Convert.ToDateTime(dateCombobox.Text).Month && currentActivity.getDate().Day == Convert.ToDateTime(dateCombobox.Text).Day)
                    {
                        listOfActivity.Remove(currentActivity);
                        i--;
                    }
                }

                //Readd the current date event
                Activity currAct; Venue ven; DateTime time;
                for (int i = 0; i < scheduleEventView.Items.Count; i++)
                {
                    time = returnTime(scheduleEventView.Items[i].SubItems[0].Text, Convert.ToDateTime(dateCombobox.Text));
                    int newVenueID = org.getCheckVenueId(scheduleEventView.Items[i].SubItems[2].Text);
                    ven = new Venue(newVenueID, scheduleEventView.Items[i].SubItems[2].Text, Venue.getVenueCapacityfromID(newVenueID));
                    if (listOfActivity.Count == 0)
                        newActivityID = org.getNewActivityId();
                    else
                        newActivityID = getNewActIDFromActList(listOfActivity);
                    currAct = new Activity(newActivityID, time, scheduleEventView.Items[i].SubItems[1].Text, ven);
                    listOfActivity.Add(currAct);
                }
                listOfActivity = sortActivityList(listOfActivity);
                foreach (Activity newAct in listOfActivity)
                {
                    org.addNewActivity(newAct);
                }
                List<string> listOfItems = new List<string>();
                Schedule newSchedule = new Schedule(newscheduleId, listOfItems, listOfActivity);
                int newItemID = 0;
                List<int> listOfBudgetID = new List<int>();
                List<Budget> listOfBudget = new List<Budget>();
                Budget currBudget;
                for (int i = 0; i < budgetListListView.Items.Count; i++)
                {
                    if (i == 0)
                        newItemID = org.getNewItemID();
                    else
                        newItemID++;
                    listOfBudgetID.Add(newItemID);
                    currBudget = new Budget(newItemID, double.Parse(budgetListListView.Items[i].SubItems[1].Text), budgetListListView.Items[i].SubItems[0].Text);
                    listOfBudget.Add(currBudget);
                }
                org.addSchedule(newSchedule);
                org.addBudget(listOfBudget);
                EventEntity events = new EventEntity(neweventId, eventNameTextBox.Text, startTimePicker.Value, endTimePicker.Value, newscheduleId, int.Parse(sizeTextBox.Text), participantList, facilitatorList, listOfBudgetID, double.Parse(totalPriceTextBox.Text), currentUser.getUserId(), false, false, false, false);
                org.createEvent(events);
                if (MessageBox.Show(events.getEventName() + " has been created. Do you want to advertise?", "Registration", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Advertise newAdvForm = new Advertise(this.eventNameTextBox.Text.ToString());
                    newAdvForm.Show();
                }
                this.Close();
            }
        }
예제 #17
0
        // Alert Search
        public int scoutAlert()
        {
            int numOfAlerts = 0;
            userAlerts.Clear();
            Participant p = new Participant(this);
            Facilitator f = new Facilitator(this);
            Organiser o = new Organiser(this);
            List<EventEntity> listOfRegisteredEvents = new List<EventEntity>();
            List<EventEntity> listOfFacilitatingEvents = new List<EventEntity>();
            List<EventEntity> listOfOrganizingEvents = new List<EventEntity>();
            EventEntity eve = new EventEntity();
            listOfFacilitatingEvents = f.getFacilitatedEvents();
            listOfOrganizingEvents = o.getOrganisedEvents();
            listOfRegisteredEvents = p.getRegisteredEvents();

            // Alert if User is PARTICIPANT of this updated event
            foreach (EventEntity e in listOfRegisteredEvents)
            {
                if (e.getEventUpdatedFlag(e.getEventId()) == true)
                {
                    userAlerts.Add(eve.createAlert(e.getEventId(), 1));
                    numOfAlerts++;
                }
            }

            // Alert if User if FACILITATOR of this updated event
            foreach (EventEntity e in listOfFacilitatingEvents)
            {
                if (e.getEventUpdatedFlag(e.getEventId()) == true)
                {
                    userAlerts.Add(eve.createAlert(e.getEventId(), 1));
                    numOfAlerts++;
                }
            }

            // Alert if User is PARTICIPANT of this starting event
            foreach (EventEntity e in listOfRegisteredEvents)
            {
                if (e.getEventStartFlag(e.getEventId()) == true)
                {
                    userAlerts.Add(eve.createAlert(e.getEventId(), 3));
                    numOfAlerts++;
                }
            }

            // Alert if User is FACILITATOR of this starting event
            foreach (EventEntity e in listOfFacilitatingEvents)
            {
                if (e.getEventStartFlag(e.getEventId()) == true)
                {
                    userAlerts.Add(eve.createAlert(e.getEventId(), 3));
                    numOfAlerts++;
                }
            }

            // Alert if User is ORGANIZER of this starting event
            foreach (EventEntity e in listOfOrganizingEvents)
            {
                if (e.getEventStartFlag(e.getEventId()) == true)
                {
                    userAlerts.Add(eve.createAlert(e.getEventId(), 3));
                    numOfAlerts++;
                }
            }

            return numOfAlerts;
        }
예제 #18
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            int numParticipant = int.Parse(participantTextbox.Text);

            if (numParticipant < EventEntity.getParticipantSize(currentEventID))  // Prohibit decrease in participant size
            {
                MessageBox.Show("You are not allowed to decrease the participant size", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (timeListBox.Items.Count != descriptionListBox.Items.Count || timeListBox.Items.Count != venueListBox.Items.Count)
            {
                MessageBox.Show("At least one activity is missing in the schedule!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                EventEntity.setParticipantNumFromEventID(currentEventID, numParticipant);

                // delete schedule
                Activity currentActivity;
                for (int i = 0; i < listOfActivity.Count; i++)
                {
                    currentActivity = listOfActivity[i];
                    if (currentActivity.getDate().Year == Convert.ToDateTime(dateCombobox.Text).Year && currentActivity.getDate().Month == Convert.ToDateTime(dateCombobox.Text).Month && currentActivity.getDate().Day == Convert.ToDateTime(dateCombobox.Text).Day)
                    {
                        listOfActivity.Remove(currentActivity);
                        i--;
                    }
                }

                //set schedule
                Organiser org = new Organiser(currentUser);
                Activity currAct; Venue ven; DateTime time;
                for (int i = 0; i < timeListBox.Items.Count; i++)
                {
                    time = returnTime(timeListBox.Items[i].ToString(), Convert.ToDateTime(dateCombobox.Text));
                    int newVenueID = org.getCheckVenueId(venueListBox.Items[i].ToString());
                    ven = new Venue(newVenueID, venueListBox.Items[i].ToString(), Venue.getVenueCapacityfromID(newVenueID));
                    if (listOfActivity.Count == 0)
                        newActivityID = org.getNewActivityId();
                    else
                        newActivityID = getNewActIDFromActList(listOfActivity);
                    currAct = new Activity(newActivityID, time, descriptionListBox.Items[i].ToString(), ven);
                    listOfActivity.Add(currAct);
                }
                listOfActivity = sortActivityListByID(listOfActivity);

                foreach(Activity act in listOfActivity)
                    org.addNewActivity(act);
                listOfActivity = sortActivityListByTime(listOfActivity);

            //    EventEntity.setSchedule(currentEventID, listOfDateTime, listOfdescription, listOfVenue);
                EventEntity.replaceSchedule(currentEventID, listOfActivity);
                //Set Alert Flag
                EventEntity eve = new EventEntity();
                eve.setEventUpdatedFlag(currentEventID);
                //

                MessageBox.Show("Save successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }