예제 #1
0
        private void AddRecordButton_Click(object sender, EventArgs e)
        {
            var recordRepository  = new RecordRepository();
            var subjectRepository = new SubjectRepository();

            var mark       = (int)subjectsNumeric.Value;
            var studentId  = _inspectingList.Last();
            var expression = $"SubjectName = \'{subjectsComboBox.SelectedItem}\'";
            var subjectId  = (int)subjectRepository.FindAll().Select(expression)[0]["SubjectID"];

            var record = new Record(mark, studentId, subjectId);

            recordRepository.Create(record);
            RefreshRecordsList(_inspectingList.Last());
        }
예제 #2
0
        private void SetTeacherSubjectButton_Click(object sender, EventArgs e)
        {
            var subjectRepository = new SubjectRepository();
            var expression        = $"SubjectName = \'{selectSubjectComboBox.SelectedItem}\'";
            var subjectId         = subjectRepository.FindAll().Select(expression)[0]["SubjectID"];

            var teacherRepository = new TeacherRepository();
            var initials          = selectTeacherComboBox.SelectedItem.ToString().Split();

            expression = $"TeacherName = \'{initials[0]}\' and TeacherSurname = \'{initials[1]}\'";
            var teacherId = teacherRepository.FindAll().Select(expression)[0]["TeacherID"];

            _dataProvider.ExecuteNonQuery($"UPDATE Subjects SET TeacherID = {teacherId} WHERE SubjectID = {subjectId};");
            _dataProvider.ExecuteNonQuery($"UPDATE Teachers SET SubjectID = {subjectId} WHERE TeacherID = {teacherId};");

            selectSubjectComboBox.Text = string.Empty;
            selectTeacherComboBox.Text = string.Empty;
            RefreshForm();
        }