public void Fill(Group group, TimeCategory.TimeTableClass <TimeTable> row) { this.Period = row.Period; if (row.Saturday != null) { this.Saturday = row.Saturday.ToString(); } if (row.Sunday != null) { this.Sunday = row.Sunday.ToString(); } if (row.Monday != null) { this.Monday = row.Monday.ToString(); } if (row.Tuesday != null) { this.Tuesday = row.Tuesday.ToString(); } if (row.Wednesday != null) { this.Wednesday = row.Wednesday.ToString(); } if (row.Thursday != null) { this.Thursday = row.Thursday.ToString(); } this.Group = group.Title; }
private void initializeGridView() { if (this.holdingTimes == null || this.holdingTimes.Count <= 0) { return; } this.holdingTable = new List <TimeTableClass <bool> >(); var times = from t in this.holdingTimes where t.Possible group t by new { t.StartTime, t.EndTime }; foreach (var time in times) { TimeTableClass <bool> ttc = new TimeTableClass <bool>(time.Key.StartTime, time.Key.EndTime); foreach (var ht in time) { ttc.Fill(false, ht.HoldingDay); } this.holdingTable.Add(ttc); } this.timeDataGridView.DataSource = this.holdingTable; }
private void btnMake_Click(object sender, EventArgs e) { if (!this.boxStartUniversityMasked.ValidateAll()) { return; } if (!this.boxEndUniversityMasked.ValidateAll()) { return; } if (!this.boxClassPeriodMasked.ValidateAll()) { return; } if (!this.boxRestTimeMasked.ValidateAll()) { return; } this.uniBeginning = this.boxStartUniversityMasked.GetTime(); this.uniEnd = this.boxEndUniversityMasked.GetTime(); this.periodTime = this.boxClassPeriodMasked.GetTime(); int minutes = (int)(this.periodTime.TotalMinutes / 2); int hours = (minutes / 60); minutes -= hours * 60; this.halfPeriod = new TimeSpan(hours, minutes, 0); this.restPeriod = this.boxRestTimeMasked.GetTime(); this.holdingTable = new List <TimeTableClass <bool> >(); TimeSpan previousStart = this.uniBeginning; for (TimeSpan start = this.uniBeginning; start.Add(this.halfPeriod) <= this.uniEnd;) { TimeSpan end = start.Add(this.halfPeriod); TimeTableClass <bool> ttc = new TimeTableClass <bool>(start, end); ttc.Fill(true, new Shamsi.ShamsiDay(0).Name, new Shamsi.ShamsiDay(1).Name, new Shamsi.ShamsiDay(2).Name, new Shamsi.ShamsiDay(3).Name, new Shamsi.ShamsiDay(4).Name, new Shamsi.ShamsiDay(5).Name); this.holdingTable.Add(ttc); start = end; if (end - previousStart == this.periodTime) { start = start.Add(this.restPeriod); previousStart = start; } } this.holdingTable = this.holdingTable.OrderBy(ht => ht.StartTime).ToList(); this.timeDataGridView.DataSource = this.holdingTable; }
private void readFromDb() { if (this.holdingTimes == null || this.holdingTimes.Count <= 0) { return; } this.holdingTable = new List <TimeTableClass <bool> >(); var times = from t in this.holdingTimes where t.Possible group t by new { t.StartTime, t.EndTime }; foreach (var time in times) { TimeTableClass <bool> ttc = new TimeTableClass <bool>(time.Key.StartTime, time.Key.EndTime); foreach (var ht in time) { ttc.Fill(ht.Enabled, ht.HoldingDay); } this.holdingTable.Add(ttc); } this.uniBeginning = times.Min(t => t.Key.StartTime); this.boxStartUniversityMasked.Text = this.uniBeginning.ToString().Remove(5); this.uniEnd = times.Max(t => t.Key.EndTime); this.boxEndUniversityMasked.Text = this.uniEnd.ToString().Remove(5); var h = times.OrderBy(t => t.Key.StartTime).Take(2); this.periodTime = h.Last().Key.EndTime - h.First().Key.StartTime; this.boxClassPeriodMasked.Text = this.periodTime.ToString().Remove(5); this.restPeriod = times.OrderBy(t => t.Key.StartTime).Take(3).Last().Key.StartTime - h.Last().Key.EndTime; this.boxRestTimeMasked.Text = this.restPeriod.ToString().Remove(5); }