Beispiel #1
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();
            }
        }
Beispiel #2
0
 public static bool replaceSchedule(int currentEventID, List<Activity> listOfActivity)
 {
     int scheduleId = 1;
     Database db = Database.CreateDatabase(DatabaseToken);
     List<EventEntity> listOfEvent = db.getListOfEvents();
     foreach (EventEntity events in listOfEvent)
     {
         if (currentEventID == events.getEventId())
             scheduleId = events.getScheduleID();
     }
     List<Schedule> listOfSchedule = db.getListOfSchedule();
     foreach (Schedule sch in listOfSchedule)
     {
         if (scheduleId == sch.getScheduleID())
         {
             listOfSchedule.Remove(sch);
             break;
         }
     }
     List<string> listOfitem = new List<string>();
     int newScheduleID = Organiser.getNewScheduleId();
     Schedule newSchedule = new Schedule(newScheduleID, listOfitem, listOfActivity);
     listOfSchedule.Add(newSchedule);
     db.saveListOfSchedule(listOfSchedule);
     foreach (EventEntity events in listOfEvent)
     {
         if (events.getEventId() == currentEventID)
             events.setScheduleID(newScheduleID);
     }
     db.saveListOfEvents(listOfEvent);
     return true;
 }
Beispiel #3
0
 public bool addSchedule(Schedule newSchedule)
 {
     Database db = Database.CreateDatabase(DatabaseToken);
     List<Schedule> listOfSchedule = db.getListOfSchedule();
     listOfSchedule.Add(newSchedule);
     db.saveListOfSchedule(listOfSchedule);
     return true;
 }
Beispiel #4
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;
        }
Beispiel #5
0
 // Constructor Copy
 public Schedule(Schedule oldSchedule)
 {
     scheduleId = oldSchedule.scheduleId;
     listOfItems = oldSchedule.listOfItems;
     activities = oldSchedule.activities;
 }