diff --git a/StudentProgressRecord/Forms/FormsEntity/FormStatement.Designer.cs b/StudentProgressRecord/Forms/FormsEntity/FormStatement.Designer.cs index 305fd83..3cdd1f2 100644 --- a/StudentProgressRecord/Forms/FormsEntity/FormStatement.Designer.cs +++ b/StudentProgressRecord/Forms/FormsEntity/FormStatement.Designer.cs @@ -61,6 +61,7 @@ // // dateTimePicker // + dateTimePicker.Enabled = false; dateTimePicker.Location = new Point(13, 163); dateTimePicker.Name = "dateTimePicker"; dateTimePicker.Size = new Size(250, 27); diff --git a/StudentProgressRecord/Forms/FormsEntity/FormStatement.cs b/StudentProgressRecord/Forms/FormsEntity/FormStatement.cs index e52dd98..9ed164a 100644 --- a/StudentProgressRecord/Forms/FormsEntity/FormStatement.cs +++ b/StudentProgressRecord/Forms/FormsEntity/FormStatement.cs @@ -47,7 +47,7 @@ namespace StudentProgressRecord.Forms { try { - if (dataGridView.RowCount < 1 || comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0) + if (dataGridView.RowCount < 2 || comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0) { throw new Exception("Имеются незаполненые поля"); } diff --git a/StudentProgressRecord/RepositoryImp/SubjectRepository.cs b/StudentProgressRecord/RepositoryImp/SubjectRepository.cs index 399e127..b7487a9 100644 --- a/StudentProgressRecord/RepositoryImp/SubjectRepository.cs +++ b/StudentProgressRecord/RepositoryImp/SubjectRepository.cs @@ -61,7 +61,24 @@ namespace StudentProgressRecord.RepositoryImp public Subject ReadSubjectById(long id) { - return Subject.CreateEntity(0, string.Empty, Direction.None); + _logger.LogInformation("Получение объекта по идентификатору"); + _logger.LogDebug("Объект: {id}", id); + try + { + using var connection = new NpgsqlConnection(_connectionString.GetConnectionString()); + var querySelect = @" + SELECT * FROM Subject + WHERE Id=@id"; + var obj = connection.QueryFirst(querySelect, new { id }); + _logger.LogDebug("Найденный объект: {json}", + JsonConvert.SerializeObject(obj)); + return obj; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при поиске объекта"); + throw; + } } public IEnumerable ReadSubjects()