В процессе
This commit is contained in:
parent
09eea654df
commit
578f9735f4
@ -38,8 +38,8 @@ namespace RegistrationPatientsPolyclinic.Forms
|
|||||||
|
|
||||||
// Получаем значение из первой строки колонки ColumnMonth
|
// Получаем значение из первой строки колонки ColumnMonth
|
||||||
string month = dataGridViewPayment.Rows[0].Cells["ColumnMonth"].Value?.ToString();
|
string month = dataGridViewPayment.Rows[0].Cells["ColumnMonth"].Value?.ToString();
|
||||||
int countPatient = int.Parse(dataGridViewPayment.Rows[0].Cells["Column2"].Value?.ToString() ?? "0");
|
int countPatient = int.Parse(dataGridViewPayment.Rows[0].Cells["ColumnCount"].Value?.ToString() ?? "0");
|
||||||
int payment = int.Parse(dataGridViewPayment.Rows[0].Cells["Column3"].Value?.ToString() ?? "0");
|
int payment = int.Parse(dataGridViewPayment.Rows[0].Cells["ColumnPayment"].Value?.ToString() ?? "0");
|
||||||
|
|
||||||
// Проверяем, что месяц не пустой
|
// Проверяем, что месяц не пустой
|
||||||
if (string.IsNullOrEmpty(month))
|
if (string.IsNullOrEmpty(month))
|
||||||
|
@ -75,7 +75,7 @@ namespace RegistrationPatientsPolyclinic.Forms
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var form = _container.Resolve<FormDoctor>();
|
var form = _container.Resolve<FormDrug>();
|
||||||
form.Id = findId;
|
form.Id = findId;
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
LoadList();
|
LoadList();
|
||||||
|
@ -9,13 +9,9 @@ namespace RegistrationPatientsPolyclinic.Repositories;
|
|||||||
|
|
||||||
public interface IDoctorPaymentsRepository
|
public interface IDoctorPaymentsRepository
|
||||||
{
|
{
|
||||||
IEnumerable<IDoctorPaymentsRepository> ReadDoctorPayments();
|
IEnumerable<DoctorPayments> ReadDoctorPayments();
|
||||||
|
|
||||||
DoctorPayments ReadDoctorPaymentsById(int id);
|
|
||||||
|
|
||||||
void CreateDoctorPayments(DoctorPayments doctorPayments);
|
void CreateDoctorPayments(DoctorPayments doctorPayments);
|
||||||
|
|
||||||
void UpdateDoctorPayments(DoctorPayments doctorPayments);
|
|
||||||
|
|
||||||
void DeleteDoctorPayments(int id);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
using RegistrationPatientsPolyclinic.Entities;
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using RegistrationPatientsPolyclinic.Entities;
|
||||||
|
using Serilog.Core;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -9,25 +16,59 @@ namespace RegistrationPatientsPolyclinic.Repositories.Implementations;
|
|||||||
|
|
||||||
public class DoctorPaymentsRepository : IDoctorPaymentsRepository
|
public class DoctorPaymentsRepository : IDoctorPaymentsRepository
|
||||||
{
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<DoctorPaymentsRepository> _logger;
|
||||||
|
|
||||||
|
public DoctorPaymentsRepository(IConnectionString connectionString, ILogger<DoctorPaymentsRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
public void CreateDoctorPayments(DoctorPayments doctorPayments)
|
public void CreateDoctorPayments(DoctorPayments doctorPayments)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(doctorPayments));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO DoctorPayments (IdDoctor, Month, Count_Patient, Payment)
|
||||||
|
VALUES (@IdDoctor, @Month, @Count_Patient, @Payment)";
|
||||||
|
connection.Execute(queryInsert, doctorPayments);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteDoctorPayments(int id)
|
public IEnumerable<DoctorPayments> ReadDoctorPayments()
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM DoctorPayments";
|
||||||
|
var doctorPayments =
|
||||||
|
connection.Query<DoctorPayments>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(doctorPayments));
|
||||||
|
return doctorPayments;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IDoctorPaymentsRepository> ReadDoctorPayments()
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public DoctorPayments ReadDoctorPaymentsById(int id)
|
|
||||||
{
|
|
||||||
return DoctorPayments.CreateElement(0, 0, string.Empty, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateDoctorPayments(DoctorPayments doctorPayments)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
using RegistrationPatientsPolyclinic.Entities;
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using RegistrationPatientsPolyclinic.Entities;
|
||||||
using RegistrationPatientsPolyclinic.Entities.Enums;
|
using RegistrationPatientsPolyclinic.Entities.Enums;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -10,25 +14,123 @@ namespace RegistrationPatientsPolyclinic.Repositories.Implementations;
|
|||||||
|
|
||||||
public class DoctorRepository : IDoctorRepository
|
public class DoctorRepository : IDoctorRepository
|
||||||
{
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<DoctorRepository> _logger;
|
||||||
|
|
||||||
|
public DoctorRepository(IConnectionString connectionString, ILogger<DoctorRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
public void CreateDoctor(Doctor doctor)
|
public void CreateDoctor(Doctor doctor)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(doctor));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Doctor (First_Name, Last_Name, DoctorPost)
|
||||||
|
VALUES (@First_Name, @Last_Name, @DoctorPost)";
|
||||||
|
connection.Execute(queryInsert, doctor);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateDoctor(Doctor doctor)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(doctor));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Doctor
|
||||||
|
SET
|
||||||
|
First_Name=@First_Name,
|
||||||
|
Last_Name=@Last_Name,
|
||||||
|
DoctorPost=@DoctorPost
|
||||||
|
WHERE Id=@Id";
|
||||||
|
connection.Execute(queryUpdate, doctor);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteDoctor(int id)
|
public void DeleteDoctor(int id)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Doctor
|
||||||
|
WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Doctor ReadDoctorById(int id)
|
public Doctor ReadDoctorById(int id)
|
||||||
{
|
{
|
||||||
return Doctor.CreateEntity(0, string.Empty, string.Empty, DoctorPost.None);
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Doctor
|
||||||
|
WHERE Id=@id";
|
||||||
|
var doctor = connection.QueryFirst<Doctor>(querySelect, new
|
||||||
|
{
|
||||||
|
id
|
||||||
|
});
|
||||||
|
_logger.LogDebug("Найденный объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(doctor));
|
||||||
|
return doctor;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Doctor> ReadDoctors()
|
public IEnumerable<Doctor> ReadDoctors()
|
||||||
{
|
{
|
||||||
return [];
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new
|
||||||
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Doctor";
|
||||||
|
var doctor = connection.Query<Doctor>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(doctor));
|
||||||
|
return doctor;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDoctor(Doctor doctor)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,4 @@ public class MedicalHistoryRepository : IMedicalHistoryRepository
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user