예제 #1
0
        public int CountNumberOfLessonsBetweenTimes(PotentialDay pd)
        {
            int timeOS     = ConvertStringTimeToMinutes(pd.TimeOfStart);
            int timeOE     = ConvertStringTimeToMinutes(pd.TimeOfEnding);
            int difference = 0;

            if (timeOS > LastMorningLesson && timeOE < EndFirstANLesson)
            {
                return(0);
            }
            if (timeOS <= LastMorningLesson && timeOE >= FirstANLesson)
            {
                difference  = 660 - timeOS; //660=11:00 //60 min s utra
                difference += (timeOE - FirstANLesson);
            }
            else if ((timeOS > LastMorningLesson && timeOS <= FirstANLesson) && timeOE >= FirstANLesson)
            {
                timeOS     = FirstANLesson;
                difference = timeOE - timeOS;
            }
            else
            {
                difference = timeOE - timeOS;
            }
            int countLessons = difference / DurationOfLesson; //50 минут длится урок

            return(countLessons);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            PotentialDay bd = (PotentialDay)obj;

            return((DayOfWeek == bd.DayOfWeek) && (TimeOfStart == bd.TimeOfStart) && (TimeOfEnding == bd.TimeOfEnding));
        }
예제 #3
0
        public int FindEarliestTimeOfLesson(PotentialDay pd)
        {
            int timeOS      = ConvertStringTimeToMinutes(pd.TimeOfStart);
            int closestTime = Math.Abs(timeOS - TimesOfLessons[0]);
            int index       = 0;

            for (int i = 0; i < TimesOfLessons.Count; i++)
            {
                if (Math.Abs(timeOS - TimesOfLessons[i]) < closestTime && TimesOfLessons[i] >= timeOS)
                {
                    closestTime = Math.Abs(timeOS - TimesOfLessons[i]);
                    index       = i;
                }
            }
            return(index);
        }
예제 #4
0
        public int CheckDayOfWeek(PotentialDay pd)
        {
            int day = 7;

            switch (pd.DayOfWeek)
            {
            case DayOfWeek.Monday:
            {
                day = (int)DayOfWeek.Monday - 1;
                break;
            }

            case DayOfWeek.Tuesday:
            {
                day = (int)DayOfWeek.Tuesday - 1;
                break;
            }

            case DayOfWeek.Wednesday:
            {
                day = (int)DayOfWeek.Wednesday - 1;
                break;
            }

            case DayOfWeek.Thursday:
            {
                day = (int)DayOfWeek.Thursday - 1;
                break;
            }

            case DayOfWeek.Friday:
            {
                day = (int)DayOfWeek.Friday - 1;
                break;
            }

            case DayOfWeek.Saturday:
            {
                day = (int)DayOfWeek.Saturday - 1;
                break;
            }
            }
            return(day);
        }
예제 #5
0
 public void AddPotentialDay(PotentialDay bd)
 {
     PotentialDays.Add(bd);
 }
예제 #6
0
        public void AddPotentialDay(DayOfWeek dow, string timeofstart, string timeofending)
        {
            PotentialDay bd = new PotentialDay(dow, timeofstart, timeofending);

            PotentialDays.Add(bd);
        }
예제 #7
0
        private void buttonAcceptBusy_Click_1(object sender, EventArgs e)
        {
            var selectedStudent = students.ListOfStudents.Find(x => x.FIO.Contains(Convert.ToString(comboBoxStudent.SelectedItem)));

            var potentialDay          = comboBoxDayOfWeek.SelectedItem;
            var potentialTimeOfStart  = inputTimeOfStart.Text;
            var potentialTimeOfEnding = inputTimeOfEnding.Text;

            switch (potentialDay)
            {
            case "Понедельник":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Monday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            case "Вторник":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Tuesday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            case "Среда":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Wednesday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            case "Четверг":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Thursday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            case "Пятница":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Friday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            case "Суббота":
            {
                PotentialDay bd = new PotentialDay(DayOfWeek.Saturday, potentialTimeOfStart, potentialTimeOfEnding);
                selectedStudent.AddPotentialDay(bd);
                break;
            }

            default:
            {
                break;
            }
            }
            var dgr = new DataGridViewRow();
            var bdS = selectedStudent.PotentialDays; //Занятые дни выбранного студента

            if (bdS.Count != 0)
            {
                switch (bdS[bdS.Count - 1].DayOfWeek)
                {
                case DayOfWeek.Monday:
                {
                    dataGridView1.Rows.Add("Понедельник", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }

                case DayOfWeek.Tuesday:
                {
                    dataGridView1.Rows.Add("Вторник", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }

                case DayOfWeek.Wednesday:
                {
                    dataGridView1.Rows.Add("Среда", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }

                case DayOfWeek.Thursday:
                {
                    dataGridView1.Rows.Add("Четверг", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }

                case DayOfWeek.Friday:
                {
                    dataGridView1.Rows.Add("Пятница", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }

                case DayOfWeek.Saturday:
                {
                    dataGridView1.Rows.Add("Суббота", bdS[bdS.Count - 1].TimeOfStart, bdS[bdS.Count - 1].TimeOfEnding);
                    break;
                }
                }
            }
            SerializeXml();
        }