конечная лаба

This commit is contained in:
funa4i 2024-11-19 16:02:24 +04:00
parent aa5c773d5a
commit a8247cf8f7
3 changed files with 20 additions and 2 deletions

View File

@ -61,6 +61,7 @@
// //
// dateTimePicker // dateTimePicker
// //
dateTimePicker.Enabled = false;
dateTimePicker.Location = new Point(13, 163); dateTimePicker.Location = new Point(13, 163);
dateTimePicker.Name = "dateTimePicker"; dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(250, 27); dateTimePicker.Size = new Size(250, 27);

View File

@ -47,7 +47,7 @@ namespace StudentProgressRecord.Forms
{ {
try try
{ {
if (dataGridView.RowCount < 1 || comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0) if (dataGridView.RowCount < 2 || comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0)
{ {
throw new Exception("Имеются незаполненые поля"); throw new Exception("Имеются незаполненые поля");
} }

View File

@ -61,7 +61,24 @@ namespace StudentProgressRecord.RepositoryImp
public Subject ReadSubjectById(long id) 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<Subject>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(obj));
return obj;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
} }
public IEnumerable<Subject> ReadSubjects() public IEnumerable<Subject> ReadSubjects()