private void TilesGenerate() { //Looking for startDate and finishDate Diapazon diapazon = new Diapazon(KeyDate); DateTime startDate = diapazon.startDate; DateTime finishDate = diapazon.finishDate; DateTime date = startDate; int baseLeft = 40; int tileWidth = 49; int betweenTilesV = 1; int betweenTilesH = 7; int baseTop = 60; int tileHeight = 6; tiles.Clear(); for (int day = 0; day < 21; day++) //Three weeks { for (int unit = 0; unit < 24 * 4; unit++) { //for possible lesson unit per hour Tile tile = new Tile(); tile.left = baseLeft + day * (tileWidth + betweenTilesH); tile.width = tileWidth; tile.top = baseTop + unit * (tileHeight + betweenTilesV); tile.height = tileHeight; //tile.text = "Tile" bool isEvenHour = unit / 4 % 2 == 0; if (isEvenHour) { tile.color = Color.LightSeaGreen; } tiles.Add(tile); } } LessonsListManager lessonsListManager = new LessonsListManager(dbPath); List <LessonInfo> lessonInfos = lessonsListManager.getLessonsList(startDate, finishDate); for (int i = 0; i < lessonInfos.Count; i++) { LessonInfo lessonInfo = lessonInfos[i]; int tileNum = 0; DateTime lessonDateTime = startDate; while (lessonDateTime < lessonInfo.DateAndTime) { lessonDateTime = lessonDateTime.AddMinutes(15); //*** tileNum++; } tiles[tileNum].height = lessonInfo.duration * tileHeight + (lessonInfo.duration - 1) * betweenTilesV; tiles[tileNum].text = lessonInfo.studentInfo.name; tiles[tileNum].color = Color.LightGreen; tiles[tileNum].free = false; } }
private void RefreshAllInfo() { studentsListManager = new StudentsListManager(dbPath); studentInfos = studentsListManager.getAllStudentsInfo(); List <string> stulentsNames = studentsListManager.getStudentsNames(); comboBoxStudentsNames.Items.Clear(); comboBoxStudentsNames.Text = ""; comboBoxStudentsNames.Items.AddRange(stulentsNames.ToArray()); //------------------------------------------------------------- stubjectListManager = new SubjectsListManager(dbPath); subjectInfos = stubjectListManager.getAllSubjectInfo(); List <string> subjectsNames = stubjectListManager.getSubjectsNames(); comboBoxSubjects.Items.Clear(); comboBoxSubjects.Text = ""; comboBoxSubjects.Items.AddRange(subjectsNames.ToArray()); //------------------------------------------------------------- lessonInfos = lessonsListManager.getLessonsList(); listBox1.Items.Clear(); foreach (var lesInfo in lessonInfos) { string dateTime = lesInfo.DateAndTime.ToString(); string studentName = lesInfo.studentInfo.name; string subjectName = lesInfo.subjectInfo.name; listBox1.Items.Add(dateTime + " " + studentName + " " + subjectName + " " + lesInfo.done); } //------------------------------------------------------------- dateTimePicker.Value = DateTime.Now; numericUpDownDuration.Value = 4; comboBoxStudentsNames.SelectedIndex = -1; comboBoxSubjects.SelectedIndex = -1; textBoxTopic.Text = ""; checkBoxPaid.Checked = false; checkBoxDone.Checked = false; numericUpDownPrice.Value = 80; textBoxRemark.Text = ""; }