Example #1
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());
            }
        }
        public bool Test_registerEvent()
        {
            bool testSuccess = false;
            const string DatabaseToken = "ewknf%32";

            Database db = Database.CreateDatabase(DatabaseToken);
            List<User> userlist = db.getListOfUsers();
            User theuser = userlist[1];
            Participant target = new Participant(theuser);

            db = Database.CreateDatabase(DatabaseToken);
            List<EventEntity> eventlist = db.getListOfEvents();
            EventEntity theEvent = eventlist[1];
            theEvent.setParticipantSize(50);
            if(EventEntity.getParticipantNumber(theEvent.getEventId())==49)
            {
                bool expected = true;
                bool actual;
                actual = target.registerEvent(theEvent);
                //assert
                if (expected == actual)
                    testSuccess = true;
                return testSuccess;
            }
            else
            {
                if (EventEntity.getParticipantNumber(theEvent.getEventId()) == 50)
                {
                    bool expected = false;
                    bool actual;
                    actual = target.registerEvent(theEvent);
                    //assert
                    if (expected == actual)
                        testSuccess = true;
                    return testSuccess;
                }
            }

            return testSuccess;
        }
Example #3
0
        public bool removeParticipantFromEvent(Participant unInterestedParticipant)
        {
            bool successRemoved = true;

            try
            {
                for (int i = 0; i < participantList.Count; i++)
                {
                    if (participantList[i].getUserId().Equals(unInterestedParticipant.getUserId()))
                    {
                        participantList.RemoveAt(i);
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                successRemoved = false;
            }

            return successRemoved;
        }
Example #4
0
        public bool addParticipantToEvent(Participant newParticipant)
        {
            bool successAdded = false;
            try
            {
                participantList.Add(newParticipant);
                successAdded = true;
            }
            catch (Exception ex)
            {
                successAdded = false;
            }

            return successAdded;
        }
Example #5
0
        private void cancelEditButton_MouseDown(object sender, MouseEventArgs e)
        {
            //Participant cancel event
            int participantCancellingEventId = -1;

            try
            {

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

                Participant participant = new Participant(currentUser);

                if (participantCancellingEventId != -1)
                {
                    if (Participant_Cancel_SideBar_Dialog())
                    {
                        participant.cancelEventRegistration(participantCancellingEventId);
                    }
                }
            }
            catch (ArgumentOutOfRangeException null_ex)
            {
                AdviseUserToMakeASelection();
            }

            //Refresh the Side Bar
            initSideEventBar();
        }
Example #6
0
        public void initSideEventBar()
        {
            this.listSideEventView.Hide();

            this.listSideEventView.Alignment = ListViewAlignment.Top;

            //Clear Side ListBox Columns and Items
            this.listSideEventView.Columns.Clear();
            this.listSideEventView.Items.Clear();

            //Insert Date and EventId Column
            this.listSideEventView.Columns.Insert(0, "Id", 0, HorizontalAlignment.Left);
            this.listSideEventView.Columns.Insert(1, "Date", 80, HorizontalAlignment.Center);
            this.listSideEventView.Columns.Insert(2, "Event", 200, HorizontalAlignment.Left);

            List<EventEntity> sideBarEventListing;

            //Get the value of the DDL selected value
            switch (eventCatComboBox.SelectedIndex)
            {
                case 0:
                    //Participant Action
                    Participant currentParticipant = new Participant(currentUser);
                    sideBarEventListing = currentParticipant.getRegisteredEvents();
                    break;
                case 1:
                    Organiser currentOrganiser = new Organiser(currentUser);
                    sideBarEventListing = currentOrganiser.getOrganisedEvents();
                    break;
                case 2:
                    Facilitator currentFacilitator = new Facilitator(currentUser);
                    sideBarEventListing = currentFacilitator.getFacilitatedEvents();
                    break;
                default:
                    sideBarEventListing = new List<EventEntity>(0);
                    break;
            }

            for (int i = 0; i < sideBarEventListing.Count; i++)
            {
                EventEntity outputEvent = sideBarEventListing[i];

                ListViewItem newEvent = new ListViewItem(outputEvent.getEventId().ToString());
                newEvent.SubItems.Add(outputEvent.getEventDate().ToString("dd/MM/yy"));
                newEvent.SubItems.Add(outputEvent.getEventName());

                listSideEventView.Items.Add(newEvent);
            }

            this.listSideEventView.Show();
        }
Example #7
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;
        }
Example #8
0
        private void registerEventBtn_Click(object sender, EventArgs e)
        {
            Participant registeringParticipant = new Participant(currentUser);

            EventEntity registeringEvent = EventEntity.getEventFromEventId(currentEventID);

            if (Participant_Register_Dialog(registeringEvent.getEventName()))
            {
                registeringParticipant.registerEvent(registeringEvent);
                MessageBox.Show("You have successfully registered this event. Thank you.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //Highlight change in state
            state = determineState(currentEventID);
            displayAppropriateBtn(state);

            this.Close();
        }
Example #9
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;
        }