Exemplo n.º 1
0
        public EditClass(StudentWorker selectedStudentWorker, int eventDetailsID)
        {
            InitializeComponent();
            deleteButton.Visible = true;

            checkBoxes    = new CheckBox[] { mondayCheckBox, tuesdayCheckBox, wednesdayCheckBox, thursdayCheckBox, fridayCheckBox };
            studentWorker = selectedStudentWorker;
            studentWorkerNameLabel.Text = selectedStudentWorker.Name;
            isNewClass     = false;
            EventDetailsID = eventDetailsID;

            // add class meeting times for the class to edit
            oldClass = DatabaseManager.GetClass(EventDetailsID);
            DatabaseManager.RemoveClass(EventDetailsID);                // remove the class from database while editing so new times will not conflict with times of the same class
            if (oldClass.Count > 0)
            {
                classNameTextBox.Text = oldClass[0].EventName;
            }
            foreach (CalendarEvent classEvent in oldClass)
            {
                newClassSchedule.AddEvent(classEvent);
                ClassMeetingTimePanel newTimePanel = new ClassMeetingTimePanel();
                classTimePanel.Controls.Add(newTimePanel);
            }
            LayoutTimePanels();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Refresh the layout of ClassMeetingTimePanels in the classTimePanel
        /// </summary>
        private void LayoutTimePanels()
        {
            classTimePanel.SuspendLayout();
            studentWorker.GetClassSchedule();
            classTimePanel.Controls.Clear();
            foreach (CalendarEvent classEvent in newClassSchedule.Events)
            {
                ClassMeetingTimePanel newTimePanel = new ClassMeetingTimePanel();
                newTimePanel.SetMeetingTime(classEvent.StartTime, classEvent.EndTime, new int[] { classEvent.Day });
                classTimePanel.Controls.Add(newTimePanel);
            }
            classTimePanel.AutoScrollPosition = new Point(0, 0);
            int top = 3;

            foreach (ClassMeetingTimePanel newTimePanel in classTimePanel.Controls)
            {
                newTimePanel.BorderStyle = BorderStyle.FixedSingle;
                newTimePanel.Location    = new Point(3, top);
                newTimePanel.Size        = new Size(classTimePanel.ClientRectangle.Width - newTimePanel.Margin.Left - newTimePanel.Margin.Right, 37);
                newTimePanel.Anchor      = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);

                // update the top position for the next time to be added
                top += newTimePanel.Height + 6;
            }
            classTimePanel.ResumeLayout();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Put the information for the specified class meeting time into the user input controls and then delete
        /// the ClassMeetingTimePanel so the information can be updated by the user and then saved again.
        /// </summary>
        /// <param name="timePanel">The ClassMeetingTimePanel to edit and remove from the classTimePanel</param>
        /// <param name="startTime">The startTime of the selected time to update</param>
        /// <param name="endTime">The endTime of the selected time to update</param>
        /// <param name="days">The days of the selected time to update</param>
        public void EditTimePanel(ClassMeetingTimePanel timePanel, Time startTime, Time endTime, int[] days)
        {
            startTimePicker.Value = new DateTime(2019, 9, 15, startTime.hours, startTime.minutes, 0);
            endTimePicker.Value   = new DateTime(2019, 9, 15, endTime.hours, endTime.minutes, 0);

            foreach (CheckBox box in checkBoxes)
            {
                box.Checked = false;
            }
            foreach (int day in days)
            {
                checkBoxes[day].Checked = true;
            }

            RemoveTimePanel(timePanel);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Remove the specified ClassMeetingTimePanel from the classTimePanel
 /// </summary>
 /// <param name="timePanel">The ClassMeetingTimePanel to be removed</param>
 public void RemoveTimePanel(ClassMeetingTimePanel timePanel)
 {
     // TODO - remove the CalendarEvent from the database so if you try to change the time where it overlaps with the old time it will not cause a time conflict
     newClassSchedule.Events.RemoveAt(classTimePanel.Controls.IndexOf(timePanel));
     LayoutTimePanels();
 }