/// <summary>
        /// Adds checkboxes for users to select their available times.
        /// </summary>
        /// <param name="dTime">The datetime to add a checkbox for.</param>
        private AvailabilityCheckBox AddCheckbox(DateTime dTime)
        {
            AvailabilityCheckBox cB = new AvailabilityCheckBox();

            cB.associatedDateTime = dTime;
            if (yourAttendance != null)
            {
                if (yourAttendance.Item2.Contains(dTime))
                {
                    cB.Checked = true;
                }
            }
            if (!use24Hour)
            {
                cB.Text = dTime.ToShortTimeString();
            }
            else
            {
                String dateFormat = "HH:mm";
                cB.Text = dTime.ToString(dateFormat);
            }

            checkboxList.Add(cB);
            cB.CheckedChanged += preventHostDelisting;
            return(cB);
        }
예제 #2
0
        public AvailabilityCheckBox AvailabilityBoxFull()
        {
            AvailabilityCheckBox ABox = new AvailabilityCheckBox();

            //ABox.BookingDate = button;
            //ABox.FacilityID = button;
            //ABox.Timeslot = button;
            //ABox.TransactionID = button;
            return(ABox);
        }
        /// <summary>
        /// CheckedChanged behavior for the checkboxes.
        /// Prevent the host from delisting himself from all time slots
        /// </summary>
        /// <param name="sender">The sending winforms object.</param>
        /// <param name="e">Winforms event arguments.</param>
        private void preventHostDelisting(object sender, EventArgs e)
        {
            AvailabilityCheckBox send = (AvailabilityCheckBox)sender;

            if (userName == hostBox.Text && send.Checked == false)
            {
                int checkedCount = 0;
                foreach (AvailabilityCheckBox cb in checkboxList)
                {
                    if (cb.Checked)
                    {
                        checkedCount++;
                    }
                }
                if (checkedCount == 0)
                {
                    send.Checked = true;
                    MessageBox.Show("You are the host of this event and cannot completely remove your attendance.");
                }
            }
        }
        /// <summary>
        /// SelectedIndexChanged behavior for the event combo box.
        /// Changes displayed event info.
        /// </summary>
        private void eventComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            flowPanel.Controls.Clear();
            Console.Write(eventComboBox.DataSource);

            ComboBox comBox        = (ComboBox)sender;
            Event    selectedEvent = (Event)comBox.SelectedItem;

            hostBox.Text     = selectedEvent.getHost() ?? "";
            locationBox.Text = selectedEvent.getLocation() ?? "";
            briefBox.Text    = selectedEvent.getBrief() ?? "";
            capacityBox.Text = selectedEvent.getCapacity().ToString();
            if (yourAttendance != null)
            {
                yourAttendance.Item2.Clear();
            }
            updateAttendees(selectedEvent);
            unAvailableTimes.Clear();
            possibleTimes.Clear();
            attendeesPerTime.Clear();
            checkboxList.Clear();

            //gives me list of date time tuples
            for (int i = 0; i < selectedEvent.dateTimes.Count; i++)
            {
                TimeSpan timeDifference = selectedEvent.dateTimes[i].Item2 - selectedEvent.dateTimes[i].Item1;

                int minuteIntervals = (int)timeDifference.TotalMinutes / 30;

                DateTime startTimeBox = selectedEvent.dateTimes[i].Item1;

                CheckUnavailableTimes(minuteIntervals, startTimeBox, selectedEvent);

                for (int j = 0; j < minuteIntervals; j++)
                {
                    bool noCheckBox = false;

                    if (unAvailableTimes != null && unAvailableTimes.Count > 0)
                    {
                        for (int k = 0; k < unAvailableTimes.Count; k++)
                        {
                            if (unAvailableTimes[k] == startTimeBox)
                            {
                                unAvailableTimes.RemoveAt(k);
                                noCheckBox = true;
                                break;
                            }
                        }
                    }
                    AvailabilityCheckBox cB = AddCheckbox(startTimeBox);
                    flowPanel.Controls.Add(cB);
                    if (noCheckBox && !cB.Checked)
                    {
                        cB.Enabled = false;
                    }


                    startTimeBox = startTimeBox.AddMinutes(30);
                }
            }
        }
        /// <summary>
        /// SelectedIndexChanged behavior for the event combo box.
        /// Changes displayed event info.
        /// </summary>
        private void eventComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //clear control panels for a refreshed view
            flowPanel.Controls.Clear();
            taskPanel.Controls.Clear();
            Console.Write(eventComboBox.DataSource);

            //declare variables affiliated with knowing which event is being accessed
            ComboBox comBox        = (ComboBox)sender;
            Event    selectedEvent = (Event)comBox.SelectedItem;

            hostBox.Text     = selectedEvent.getHost() ?? "";
            locationBox.Text = selectedEvent.getLocation() ?? "";
            briefBox.Text    = selectedEvent.getBrief() ?? "";
            capacityBox.Text = selectedEvent.getCapacity().ToString();
            if (yourAttendance != null)
            {
                yourAttendance.Item2.Clear();
            }
            updateAttendees(selectedEvent);
            unAvailableTimes.Clear();
            possibleTimes.Clear();
            attendeesPerTime.Clear();
            checkboxList.Clear();

            //gives me list of date time tuples
            //for every tuple, create a timespan for the user.
            //Add availability checkboxes for times that are affiliated with the user's profile.
            for (int i = 0; i < selectedEvent.dateTimes.Count; i++)
            {
                TimeSpan timeDifference = selectedEvent.dateTimes[i].Item2 - selectedEvent.dateTimes[i].Item1;

                int minuteIntervals = (int)timeDifference.TotalMinutes / 30;

                DateTime startTimeBox = selectedEvent.dateTimes[i].Item1;

                CheckUnavailableTimes(minuteIntervals, startTimeBox, selectedEvent);

                for (int j = 0; j < minuteIntervals; j++)
                {
                    bool noCheckBox = false;

                    if (unAvailableTimes != null && unAvailableTimes.Count > 0)
                    {
                        for (int k = 0; k < unAvailableTimes.Count; k++)
                        {
                            if (unAvailableTimes[k] == startTimeBox)
                            {
                                unAvailableTimes.RemoveAt(k);
                                noCheckBox = true;
                                break;
                            }
                        }
                    }
                    AvailabilityCheckBox cB = AddCheckbox(startTimeBox);
                    flowPanel.Controls.Add(cB);
                    if (noCheckBox && !cB.Checked)
                    {
                        cB.Enabled = false;
                    }

                    startTimeBox = startTimeBox.AddMinutes(30);
                }

                //For Each Task in the event's Task List
                //Grab the name of the task and create a textbox affiliated with that task name
                //Users will be able to input that they are completing the task when they are added to the taskPanel
                for (int k = 0; k < selectedEvent.ThisEventTaskList.Count; k++)
                {
                    //"task" refers to the name of the given task
                    String task = selectedEvent.ThisEventTaskList[k].Item2;
                    //"name" refers to the user who has signer up for that given task
                    String name = selectedEvent.ThisEventTaskList[k].Item1;

                    //Error checking, not essential to program but nice to have.
                    Console.WriteLine("This task currently assigned to: " + name);
                    //if the name value is unassigned, add a new chekbox to the task control panel
                    //otherwise, do nothing.
                    //this ensures that tasks can only be signed up for by a single attendee
                    if (name == "")
                    {
                        CheckBox taskBox = AddTaskBox(task);
                        taskPanel.Controls.Add(taskBox);
                    }
                }
            }
        }