Exemplo n.º 1
0
        private static void SetElementView(List <ScheduleLesson> LessonsByView, string nameElementProjection,
                                           ScheduleClasses.View view, ScheduleWeeks Shedule, DataGridView table, Employments Employments, bool watchAll)
        {
            for (int Hour = 1; Hour <= Shedule.Setting.CountLessonsOfDay; Hour++)
            {
                DataGridViewRow row = CreateNewRow(table, nameElementProjection, ScheduleTime.GetHourDiscription(Hour));

                for (int Week = 1, CellIndex = 2; Week <= Shedule.Setting.CountWeeksShedule; Week++)
                {
                    for (int Day = 1; Day <= Shedule.Setting.CountDaysEducationWeek; Day++, CellIndex++)
                    {
                        //время занятия на 1-2 недели
                        ScheduleTime Time1 = new ScheduleTime((Week)Week, (ScheduleClasses.Day)Day, Hour);
                        //время занятия на 3-4 недели
                        ScheduleTime Time2 = GetTimeAfterTwoWeek(Time1);

                        //занятие на 1-2 недели
                        ScheduleLesson item1 = Shedule.FindLessonInList(LessonsByView, Time1);
                        //занятие на 3-4 недели
                        ScheduleLesson item2 = Shedule.FindLessonInList(LessonsByView, Time2);

                        string Room1 = item1 != null ? item1.Room : String.Empty;
                        string Room2 = item2 != null ? item2.Room : String.Empty;

                        Employment employmentCell = FindEmployment(view, Employments, nameElementProjection, Time1);

                        string cellContent = item1 == null && item2 == null ? String.Empty : IsLessonsEqualAndNonEmpty(item1, item2) ?
                                             GetCellContentIdenticalLessons(view, item1) : GetCellContentDiffrentLessons(view, item1, item2);

                        // задать значения ячейки в
                        DataGridViewCell cell = row.Cells[CellIndex];
                        cell.Value = cellContent;
                        cell.Tag   = new SchedulePointer(Time1, Time2, Room1, Room2);
                        // задать цвет и стиль ячейке
                        if (cellContent != String.Empty)
                        {
                            cell.Style.BackColor = IsLessonsEqualAndNonEmpty(item1, item2) ? Color.LightGreen : Color.LightGreen;
                        }

                        if (employmentCell != null && employmentCell.Reason == ReasonEmployment.UserBlocked)
                        {
                            SetCellBlockedStyle(cell);
                        }
                    }
                }

                if (watchAll || (!watchAll && Shedule.Lessons.Where(x => x.Hour == Hour && !x.IsEmpty).Count() > 0))
                {
                    table.Rows.Add(row);
                }
            }

            //добавить разделитель
            int index = table.Rows.GetLastRow(DataGridViewElementStates.None);

            if (index >= 0)
            {
                table.Rows[index].DividerHeight = 3;
            }
        }
Exemplo n.º 2
0
        void cmbProjection_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScheduleClasses.View view = (ScheduleClasses.View)Convert.ToInt32(cmbProjection.SelectedValue);
            ChooseView = view;

            List <string> names = new List <string>();

            switch (view)
            {
            case ScheduleClasses.View.Group: names = adapter.NamesGroups; break;

            case ScheduleClasses.View.Discipline: names = adapter.NamesDisciplines; break;

            case ScheduleClasses.View.Room: names = (from r in Rooms select r.Name).Distinct().ToList(); break;

            case ScheduleClasses.View.Teacher: names = adapter.NamesTeachers; break;

            default: names = new List <string>(); break;
            }

            int i = 0;

            ListGroups.Items.Clear();
            foreach (string name in names)
            {
                ListGroups.Items.Add(name);
                ListGroups.SetItemChecked(i, true);
                i++;
            }
        }
Exemplo n.º 3
0
 public XLSExporter(List <string> _nameElements, ScheduleWeeks _shedule, ScheduleClasses.View _view, string _fileName)
 {
     nameElements = _nameElements;
     shedule      = _shedule;
     view         = _view;
     fileName     = _fileName;
 }
Exemplo n.º 4
0
 public DocExporter(List <string> _nameElements, ScheduleWeeks _shedule, ScheduleClasses.View _view, string _fileName, List <string> _stampParams)
 {
     NameElements = _nameElements;
     shedule      = _shedule;
     view         = _view;
     fileName     = _fileName;
     stampParams  = _stampParams;
 }
Exemplo n.º 5
0
        private static string GetCellContentDiffrentLessons(ScheduleClasses.View view, ScheduleLesson item1, ScheduleLesson item2)
        {
            string content = String.Empty;

            content += item1 != null?GetLessonInfoFormat2(view, item1) : emptyLesson;

            content += Environment.NewLine + splitLine + Environment.NewLine;
            content += item2 != null?GetLessonInfoFormat2(view, item2) : emptyLesson;

            return(content);
        }
Exemplo n.º 6
0
        private static Employment FindEmployment(ScheduleClasses.View view, Employments items, string name, ScheduleTime time)
        {
            switch (view)
            {
            case ScheduleClasses.View.Teacher: return(items.Teachers.GetItem(name, time));

            case ScheduleClasses.View.Group: return(items.Groups.GetItem(name, time));

            case ScheduleClasses.View.Room: return(items.Rooms.GetItem(name, time));

            default: return(null);
            }
        }
Exemplo n.º 7
0
        private static IEnumerable <string> GetNamesItemsView(ScheduleClasses.View view, EducationLoadAdapter adapter, IEnumerable <ScheduleRoom> rooms)
        {
            switch (view)
            {
            case ScheduleClasses.View.Teacher: return(adapter.NamesTeachers);

            case ScheduleClasses.View.Discipline: return(adapter.NamesDisciplines);

            case ScheduleClasses.View.Group: return(adapter.NamesGroups);

            case ScheduleClasses.View.Room: return((from r in rooms select r.Name).Distinct().ToList());

            default: return(new List <string>());
            }
        }
Exemplo n.º 8
0
        private static string GetLessonInfoFormat1(ScheduleClasses.View view, ScheduleLesson lesson)
        {
            string format = "{0} \n {1} \n {2} \n {3}";

            switch (view)
            {
            case ScheduleClasses.View.Teacher: return(String.Format(format, lesson.Discipline, ScheduleLessonType.Description(lesson.Type), lesson.GroupsDescription, lesson.Room));

            case ScheduleClasses.View.Discipline: return(String.Format(format, lesson.GroupsDescription, ScheduleLessonType.Description(lesson.Type), lesson.Teacher, lesson.Room));

            case ScheduleClasses.View.Group: return(String.Format(format, lesson.Discipline, ScheduleLessonType.Description(lesson.Type), lesson.Teacher, lesson.Room));

            case ScheduleClasses.View.Room: return(String.Format(format, lesson.Discipline, ScheduleLessonType.Description(lesson.Type), lesson.Teacher, lesson.GroupsDescription));

            default: return(String.Empty);
            }
        }
Exemplo n.º 9
0
 public static DataGridView FillDataGrid(ScheduleWeeks Shedule, DataGridView table,
                                         ScheduleClasses.View view, EducationLoadAdapter adapter, IEnumerable <ScheduleRoom> Rooms, bool WatchAll)
 {
     table.Rows.Clear();
     //задать значение заколовку с именами элементов проекции
     table.Columns["name"].HeaderText = new ScheduleView(view).Name.ToUpper();
     //добавить в таблицу все занятия всех элементов проекции расписания
     foreach (string elementView in GetNamesItemsView(view, adapter, Rooms).ToList())
     {
         //получить все занятия определенного элемента проекции расписания
         List <ScheduleLesson> LessonsByView = Shedule.GetLessonsByView(view, elementView).ToList();
         //добавить в таблицу все занятия элемента
         SetElementView(LessonsByView, elementView, view, Shedule, table, Shedule.Employments, WatchAll);
     }
     //проставить даты в заголовки столбцов таблицы
     SetDatesColumns(table, Shedule);
     return(table);
 }
Exemplo n.º 10
0
        private void ChooseGroupsForm_Load(object sender, EventArgs e)
        {
            int i = 0;

            ListGroups.Items.Clear();
            foreach (string group in adapter.NamesGroups)
            {
                ListGroups.Items.Add(group);
                ListGroups.SetItemChecked(i, true);
                i++;
            }

            BindingSource bs = new BindingSource();

            bs.DataSource = ScheduleView.BasicViews;
            cmbProjection.DisplayMember = "Description";
            cmbProjection.ValueMember   = "TypeCode";
            cmbProjection.DataSource    = bs;

            ChooseView = (ScheduleClasses.View)Convert.ToInt32(cmbProjection.SelectedValue);

            this.cmbProjection.SelectedIndexChanged += new EventHandler(cmbProjection_SelectedIndexChanged);
        }
Exemplo n.º 11
0
 private static string GetCellContentIdenticalLessons(ScheduleClasses.View view, ScheduleLesson item)
 {
     return(GetLessonInfoFormat1(view, item));
 }