Пример #1
0
 public override void Create(Subject subject)
 {
     if (SubjectValidation.IsValidSubject(subject))
     {
         DataAccessProvider.ExecuteNonQuery($"INSERT INTO Subjects (SubjectName, UniversityID) " +
                                            $"values (\'{subject.SubjectName}\', " +
                                            $"{subject.UniversityId})");
     }
 }
Пример #2
0
 public override void Update(Subject subject)
 {
     if (SubjectValidation.IsValidSubject(subject) &&
         SubjectValidation.IsValidSubjectId(subject.SubjectId))
     {
         DataAccessProvider.ExecuteNonQuery($"UPDATE Subjects SET " +
                                            $"SubjectName = \'{subject.SubjectName}\', " +
                                            $"UniversityID = {subject.UniversityId} " +
                                            $"WHERE SubjectID = {subject.SubjectId}");
     }
 }
Пример #3
0
        private void AddSubjectButton_Click(object sender, EventArgs e)
        {
            var subjectRepository = new SubjectRepository();

            var subjectName = addSubjectNameTextBox.Text;
            var subject     = new Subject(subjectName, _universityId);

            if (!SubjectValidation.IsValidSubject(subject))
            {
                return;
            }

            subjectRepository.Create(subject);
            RefreshForm();
        }