Pibd-22_Lyakhov_T_I_Lab2_Simple #3

Open
funa4i wants to merge 7 commits from LabWork2 into LabWrk01
3 changed files with 20 additions and 2 deletions
Showing only changes of commit a8247cf8f7 - Show all commits

View File

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

View File

@ -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("Имеются незаполненые поля");
}

View File

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