private void btnSaveChanges_Click(object sender, EventArgs e) { try { for (int i = 0; i < gridJournal.Rows.Count; i++) { decimal?mark; if (string.IsNullOrEmpty(gridJournal.Rows[i].Cells["Mark"].Value.ToString())) { mark = null; } else { mark = (decimal)gridJournal.Rows[i].Cells["Mark"].Value; } LessonDAL.PlaceMark(newLesson.LessonID, this.studentsOnTheLesson[i].StudentID, mark, (bool)((DataGridViewCheckBoxCell)gridJournal.Rows[i].Cells["IsPresent"]).Value); } this.toolStripIsSaved.Text = "Saved."; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnCreateLesson_Click(object sender, EventArgs e) { string txtLessonTheme = this.txtLessonTheme.Text, txtNumberOfHours = this.comboBoxNHours.SelectedItem.ToString(), txtHomeTask = this.txtHomeTask.Text; if (string.IsNullOrEmpty(txtLessonTheme)) { ShowExceptionMessage("Lesson theme cannot be empty!"); return; } if (string.IsNullOrEmpty(txtNumberOfHours)) { ShowExceptionMessage("Number of hours cannot be empty!"); return; } int numberOfHours = 0; if (!int.TryParse(txtNumberOfHours, out numberOfHours)) { ShowExceptionMessage("Incorrect hours number format!"); return; } int studentsInGradeCount = StudentDAL.GetStudentCountByGradeName(comboGrade.SelectedItem.ToString()); if (studentsInGradeCount == 0) { MessageBox.Show(string.Format("No students in grade {0}!\nAsk administrator to add some!", comboGrade.SelectedItem.ToString()), "Impossible to create lesson!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ILessonInfo newLesson = LessonDAL.StartNewLesson(comboBoxSubject.SelectedItem.ToString(), txtLessonTheme, numberOfHours, comboGrade.SelectedItem.ToString(), txtHomeTask, this.TeacherID); NewLessonWindow nlWindow = new NewLessonWindow(this.TeacherID, newLesson); nlWindow.Owner = this.Owner; nlWindow.Show(); this.Close(); } catch (Exception ex) { ShowExceptionMessage(ex.Message); return; } }
public LessonBLL() { _Dal = new LessonDAL(); }