Example #1
0
 public Activity(int i_activityId, DateTime i_datetime, string i_description, Venue i_hostingVenue)
 {
     activityId = i_activityId;
     time = i_datetime;
     description = i_description;
     hostingVenue = i_hostingVenue;
 }
Example #2
0
 public static Venue getVenueFromActivityID(int incomingActivityID)
 {
     Database db = Database.CreateDatabase(DatabaseToken);
     List<Activity> listOfActDb = db.getListOfActivities();
     Venue newVen = new Venue();
     foreach (Activity act in listOfActDb)
     {
         if (act.getActivityId() == incomingActivityID)
             newVen = act.getVenue();
     }
     return newVen;
 }
Example #3
0
 public bool requestActivityDetails(ref int o_activityId,ref DateTime sending_datetime,ref string sending_description,ref Venue sending_hostingVenue, string purpose)
 {
     if (purpose.Equals("databaseRequest"))
     {
         o_activityId = activityId;
         sending_datetime = time;
         sending_description = description;
         sending_hostingVenue = new Venue(hostingVenue);
         return true;
     }
     else
         return false;
 }
Example #4
0
 //Copy Constructor
 public Venue(Venue oldVenue)
 {
     venueId = oldVenue.venueId;
     location = oldVenue.location;
     capacity = oldVenue.capacity;
 }
Example #5
0
        private void dateCombobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Activity currentActivity;
            for (int i = 0; i < listOfActivity.Count; i++)
            {
                currentActivity = listOfActivity[i];
                if (Convert.ToDateTime(dateCombobox.Text).Year == previousScheudleDate.Year && Convert.ToDateTime(dateCombobox.Text).Month == previousScheudleDate.Month && Convert.ToDateTime(dateCombobox.Text).Day == previousScheudleDate.Day)
                    previousScheudleDate = Convert.ToDateTime(dateCombobox.Text);
                if (currentActivity.getDate().Year == previousScheudleDate.Year && currentActivity.getDate().Month == previousScheudleDate.Month && currentActivity.getDate().Day == previousScheudleDate.Day)
                {
                    listOfActivity.Remove(currentActivity);
                    i--;
                }
            }

            DateTime time;
            Activity newAct;
            Organiser org = new Organiser(currentUser);
            Venue ven;

            for (int i = 0; i < scheduleEventView.Items.Count; i++)
            {
                time = returnTime(scheduleEventView.Items[i].SubItems[0].Text, previousScheudleDate);
                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);
                newAct = new Activity(newActivityID, time, scheduleEventView.Items[i].SubItems[1].Text, ven);
                listOfActivity.Add(newAct);
            }
            scheduleEventView.Clear();
            initMainEventList();

            foreach (Activity currAct in listOfActivity)
            {
                DateTime currTime = currAct.getDate();
                if (currAct.getDate().Year == Convert.ToDateTime(dateCombobox.SelectedItem.ToString()).Year && currAct.getDate().Month == Convert.ToDateTime(dateCombobox.SelectedItem.ToString()).Month && currAct.getDate().Day == Convert.ToDateTime(dateCombobox.SelectedItem.ToString()).Day)
                {
                    if (listOfActivity.Count != 0)
                    {
                        ListViewItem newevent = new ListViewItem(String.Format("{0:t}", currAct.getDate()));
                        newevent.SubItems.Add(currAct.getDescription().ToString());
                        newevent.SubItems.Add(currAct.getVenue().getlocation());
                        scheduleEventView.Items.Add(newevent);
                    }
                }
            }
        }
Example #6
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();
            }
        }
Example #7
0
 public void setVenue(Venue incomingVenue)
 {
     hostingVenue = incomingVenue;
 }
Example #8
0
        public bool saveListOfSchedule(List<Schedule> scheduleListToSave)
        {
            bool savingSuccessFlag = false;

            //Schedule Attributes
            int o_scheduleId = 0;
            List<string> o_listOfItems = new List<string>();
            List<Activity> o_Activities = new List<Activity>();

            //Activity Attributes
            int o_activityId = 0;
            DateTime o_time = DateTime.Now;
            string o_description = "";
            Venue o_venue = new Venue();

            //Venue Attributes
            int o_venueId = 0;
            string o_venueDescription = "";
            int o_capacity = 0;

            int sizeOfList = scheduleListToSave.Count();

            XmlWriterSettings writerSettings = new XmlWriterSettings();
            writerSettings.Indent = true;

            Schedule holdingElement;
            int itemsCounter = 0;
            int activitiesCounter = 0;

            try
            {
                using (XmlWriter writer = XmlTextWriter.Create("schedules.xml", writerSettings))
                {
                    writer.WriteStartDocument();

                    writer.WriteStartElement("SchedulePool");

                    for (int i = 0; i < sizeOfList; i++)
                    {
                        holdingElement = scheduleListToSave[i];
                        holdingElement.requestScheduleDetail(ref o_scheduleId,ref o_listOfItems,ref o_Activities, requestString);

                        //Schedule Details

                        writer.WriteStartElement("Schedule");

                        writer.WriteElementString("scheduleId",o_scheduleId.ToString());

                        //Process List of Items

                        writer.WriteStartElement("listOfItems");
                        while(itemsCounter<o_listOfItems.Count)
                        {
                            writer.WriteElementString("item", o_listOfItems[itemsCounter]);
                            ++itemsCounter;
                        }
                        itemsCounter = 0;
                        writer.WriteEndElement();

                        //Process Activities

                        writer.WriteStartElement("listOfActivities");
                        while (activitiesCounter < o_Activities.Count)
                        {
                            o_Activities[activitiesCounter].requestActivityDetails(ref o_activityId, ref o_time, ref o_description, ref o_venue, requestString);

                            writer.WriteStartElement("Activity");

                            //Activity Details
                            writer.WriteElementString("activityId", o_activityId.ToString());
                            writer.WriteElementString("time", o_time.ToString("s"));
                            writer.WriteElementString("description", o_description);

                            //Contains one Venue class

                            writer.WriteStartElement("hostingVenue");

                            o_venue.requestVenueDetails(ref o_venueId, ref o_venueDescription, ref o_capacity, requestString);

                            writer.WriteStartElement("Venue");
                            writer.WriteElementString("venueId", o_venueId.ToString());
                            writer.WriteElementString("location", o_venueDescription);
                            writer.WriteElementString("capacity", o_capacity.ToString());
                            writer.WriteEndElement();

                            //EndTag hosting Venue
                            writer.WriteEndElement();

                            //EndTag Activity

                            writer.WriteEndElement();

                            ++activitiesCounter;
                        }
                        activitiesCounter = 0;

                        writer.WriteEndElement();

                        //Write End Tag for Schedule

                        writer.WriteEndElement();
                    }

                    savingSuccessFlag = true;

                }
            }
            catch (Exception ex)
            {
                savingSuccessFlag = false;
            }

            return savingSuccessFlag;
        }
Example #9
0
        //Activities Database Interaction Implementation
        public List<Activity> getListOfActivities()
        {
            List<Activity> listToPop = new List<Activity>();

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

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

                scanner.ReadToDescendant("Activity");

                do
                {
                    scanner.ReadToDescendant("activityId");

                    int activityId = scanner.ReadElementContentAsInt();

                    DateTime time = scanner.ReadElementContentAsDateTime();

                    string activityDescription = scanner.ReadElementContentAsString("description", "");

                    scanner.ReadToFollowing("venueId");

                    int i_venueId = scanner.ReadElementContentAsInt();

                    string i_location = scanner.ReadElementContentAsString("location", "");

                    int i_capacity = scanner.ReadElementContentAsInt();

                    Venue newVenue = new Venue(i_venueId, i_location, i_capacity);

                    Activity newActivity = new Activity(activityId, time, activityDescription, newVenue);

                    listToPop.Add(newActivity);

                    //Skip end element till /activity end tag
                    scanner.Skip();
                    scanner.Skip();

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

            return listToPop;
        }
Example #10
0
        public bool saveListOfActivities(List<Activity> activityListToSave)
        {
            bool savingSuccessFlag = false;

            //Activity Attributes
            int o_activityId = 0;
            DateTime o_time = DateTime.Now;
            string o_description = "";
            Venue o_venue = new Venue();

            //Venue Attributes
            int o_venueId = 0;
            string o_venueDescription = "";
            int o_capacity = 0;

            int sizeOfList = activityListToSave.Count;

            XmlWriterSettings writerSettings = new XmlWriterSettings();
            writerSettings.Indent = true;

            Activity holdingElement;

            try
            {
                using (XmlWriter writer = XmlTextWriter.Create("activities.xml", writerSettings))
                {
                    writer.WriteStartDocument();

                    writer.WriteStartElement("ActivityPool");

                    for (int i = 0; i < sizeOfList; i++)
                    {
                        holdingElement = activityListToSave[i];

                        holdingElement.requestActivityDetails(ref o_activityId,ref o_time,ref o_description,ref o_venue, requestString);

                        writer.WriteStartElement("Activity");

                        //Activity Details
                        writer.WriteElementString("activityId", o_activityId.ToString());
                        writer.WriteElementString("time", o_time.ToString("s"));
                        writer.WriteElementString("description", o_description);

                        //Contains one Venue class

                        writer.WriteStartElement("hostingVenue");

                        o_venue.requestVenueDetails(ref o_venueId, ref o_venueDescription, ref o_capacity, requestString);

                        writer.WriteStartElement("Venue");
                        writer.WriteElementString("venueId", o_venueId.ToString());
                        writer.WriteElementString("location", o_venueDescription);
                        writer.WriteElementString("capacity",o_capacity.ToString());
                        writer.WriteEndElement();

                        //EndTag hosting Venue
                        writer.WriteEndElement();

                        //EndTag Activity

                        writer.WriteEndElement();
                    }

                    savingSuccessFlag = true;

                }
            }
            catch (Exception ex)
            {
                savingSuccessFlag = false;
            }

            return savingSuccessFlag;
        }
Example #11
0
        //Venue Database Interaction Implementation
        public List<Venue> getListOfVenues()
        {
            List<Venue> listToPop = new List<Venue>();

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

            using (XmlReader scanner = XmlReader.Create("venues.xml", settings))
            {
                //Move scanner to content
                scanner.MoveToContent();

                scanner.ReadToDescendant("Venue");

                do
                {
                    scanner.ReadToDescendant("venueId");

                    int i_venueId = scanner.ReadElementContentAsInt();

                    string i_location = scanner.ReadElementContentAsString("location","");

                    int i_capacity = scanner.ReadElementContentAsInt();

                    Venue newVenue = new Venue(i_venueId, i_location, i_capacity);

                    listToPop.Add(newVenue);

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

            }

            return listToPop;
        }
Example #12
0
        //Schedules Database Interaction Implementation
        public List<Schedule> getListOfSchedule()
        {
            List<Schedule> listToPop = new List<Schedule>();
            List<string> scheduleItems = new List<string>();
            List<Activity> scheduleActivities = new List<Activity>();

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

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

                scanner.ReadToDescendant("Schedule");

                do
                {
                    scanner.ReadToDescendant("scheduleId");

                    int scheduleId = scanner.ReadElementContentAsInt();

                    scanner.ReadToDescendant("item");

                    //GetAllItems
                    while (scanner.Name!="listOfItems")
                    {

                        scheduleItems.Add(scanner.ReadElementContentAsString("item",""));

                    }

                    scanner.Skip();

                    scanner.ReadToDescendant("Activity");

                    do
                    {
                        scanner.ReadToDescendant("activityId");

                        int activityId = scanner.ReadElementContentAsInt();

                        DateTime time = scanner.ReadElementContentAsDateTime();

                        string activityDescription = scanner.ReadElementContentAsString("description", "");

                        scanner.ReadToFollowing("venueId");

                        int i_venueId = scanner.ReadElementContentAsInt();

                        string i_location = scanner.ReadElementContentAsString("location", "");

                        int i_capacity = scanner.ReadElementContentAsInt();

                     //   int i_capacity = scanner.ReadElementContentAsInt();

                        Venue newVenue = new Venue(i_venueId, i_location, i_capacity);

                        Activity newActivity = new Activity(activityId, time, activityDescription, newVenue);

                        scheduleActivities.Add(newActivity);

                        //Skip end element till /activity end tag
                        scanner.Skip();
                        scanner.Skip();

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

                    //Clone Two new list

                    List<string> clonedItemList = new List<string>(scheduleItems);
                    List<Activity> clonedActivityList = new List<Activity>(scheduleActivities);

                    Schedule newSchedule = new Schedule(scheduleId, clonedItemList,clonedActivityList);

                    listToPop.Add(newSchedule);

                    //Skip /activity end tag
                    scanner.Skip();

                    //Clear both list
                    scheduleItems.Clear();
                    scheduleActivities.Clear();

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

            return listToPop;
        }
Example #13
0
        private void updateForm_Load(object sender, EventArgs e)
        {
            EventEntity newEve = Facilitator.getEventEntity(currentEventID);
            titleLabel.Text = newEve.getEventName();
            int organiserID = newEve.getOrganiserID();
            organiserTextBox.Text = User.getNamefromID(organiserID);
            participantTextbox.Text = EventEntity.getParticipantSize(currentEventID).ToString();
            DateTime dateValue = EventEntity.getStartTime(currentEventID);
            dateTextBox.Text = String.Format("{0:f}", dateValue);
            listOfDateTime = EventEntity.getListOfTimeFromEventID(currentEventID);
            listofDescription = EventEntity.getListOfDescriptionFromEventID(currentEventID);
            listOfVenue = EventEntity.getListOfVenueFromEventID(currentEventID);
            venueTextBox.Text = listOfVenue.Peek();
            Activity currentAct; Venue ven;

            Organiser pub = new Organiser(currentUser);
            int newActID = pub.getNewActivityId();
            newActID++;
            while (listOfDateTime.Count != 0)
            {

                string curlocation = listOfVenue.Dequeue();
                ven = new Venue(Venue.getVenueIdfromLocation(curlocation), curlocation, Venue.getVenueCapacityfromID(Venue.getVenueIdfromLocation(curlocation)));
                currentAct = new Activity(newActID, listOfDateTime.Dequeue(), listofDescription.Dequeue(), ven);
                listOfActivity.Add(currentAct);
                newActID++;
            }
            setScheduleDay(dateValue, endTime);
            dateCombobox.Text = dateValue.ToLongDateString();
        }
Example #14
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();
            }
        }