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; } }
public void FillHours(Worksheet sheet, int row) { for (int counterDay = 1; counterDay <= 6; counterDay++) { int Hour; for (Hour = 1; Hour <= lsnCntMult; Hour++) { string str = ""; str = ScheduleTime.GetHourDiscription(Hour); sheet[7, row + (Hour - 1) * lessonHorizontalMult].Value = str; FontOptionsBase font = (FontOptionsBase)sheet[7, row + (Hour - 1) * lessonHorizontalMult].Font; font.Bold = true; Range range = new Range(sheet[7, row + (Hour - 1) * lessonHorizontalMult], sheet[7, row + (Hour - 1) * lessonHorizontalMult + lessonHorizontalMult - 1]); range.Merge(); BorderOptionsBase brOptC = (BorderOptionsBase)range.Border; brOptC.Color = Color.Black; brOptC.Sides = BorderSides.All; } row += (Hour - 1) * lessonHorizontalMult; } }
private void FillLessons(WordTable table, int monthStart, int row, List <ScheduleLesson> tmp, Week week1, Week week2) { int column = 1; for (int counterDay = 1; counterDay <= 6; counterDay++) { column = 1; for (int counterMonth = monthStart; counterMonth < monthStart + 5; counterMonth++) { List <int> numbers = (from x in tmp from p in x.Dates where x.Day == (ScheduleClasses.Day)counterDay && p.Month == counterMonth && (x.Week == week1 || x.Week == week2) select p.Day).Distinct().OrderBy(e => e).ToList(); foreach (int day in numbers) { table.Cell(row, column).WriteLine(); table.Cell(row, column).Write(day.ToString()); } column++; } List <ScheduleLesson> query1 = (from x in tmp from p in x.Dates where x.Day == (ScheduleClasses.Day)counterDay && (x.Week == week1 || x.Week == week2) select x).ToList(); List <int> Hours = (from x in query1 select x.Hour).Distinct().OrderBy(e => e).ToList(); foreach (int hour in Hours) { string str = ""; str = ScheduleTime.GetHourDiscription(hour); table.Cell(row, 7).Write(str); table.Cell(row, 7).WriteLine(); } for (int i = 0; i < Hours.Count; i++) { List <ScheduleLesson> t1 = query1.Where(x => x.Hour == Hours[i] && x.Week == week1).ToList(); List <ScheduleLesson> t2 = query1.Where(x => x.Hour == Hours[i] && x.Week == week2).ToList(); ScheduleLesson lesson = (t1.Count > 0) ? t1.First() : null; ScheduleLesson lesson2 = (t2.Count > 0) ? t2.First() : null; if (lesson != null && lesson2 != null && lesson.IsEqual(lesson2)) { WriteLesson(table, row, lesson, false); if (i + 1 < Hours.Count) { List <ScheduleLesson> Next1 = query1.Where(x => x.Hour == Hours[i + 1] && x.Week == week1).ToList(); ScheduleLesson next1 = (t1.Count > 0) ? t1.First() : null; List <ScheduleLesson> Next2 = query1.Where(x => x.Hour == Hours[i + 1] && x.Week == week2).ToList(); ScheduleLesson next2 = (t1.Count > 0) ? t1.First() : null; if (next1 != null && next2 != null && next1.IsEqual(next2) && lesson.IsEqual(next1)) { i++; } } } else { if (lesson != null) { if (lesson2 == null) { WriteLesson(table, row, lesson, false); } else { WriteLesson(table, row, lesson, true); } if (i + 1 < Hours.Count) { List <ScheduleLesson> Next = query1.Where(x => x.Hour == Hours[i + 1] && x.Week == week1).ToList(); ScheduleLesson next = (Next.Count > 0) ? Next.First() : null; if (next != null && lesson.IsEqual(next)) { i++; } } } if (lesson2 != null) { if (lesson == null) { WriteLesson(table, row, lesson2, false); } else { WriteLesson(table, row, lesson2, true); } if (i + 1 < Hours.Count) { List <ScheduleLesson> Next = query1.Where(x => x.Hour == Hours[i + 1] && x.Week == week2).ToList(); ScheduleLesson next = (Next.Count > 0) ? Next.First() : null; if (next != null && lesson2.IsEqual(next)) { i++; } } } } } row++; } }