From 478a3e42642ee461d8c1e7a787af8b1672330c09 Mon Sep 17 00:00:00 2001 From: kisame Date: Sat, 30 Nov 2024 00:29:17 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs | 2 +- .../ProjectPolyclinic/Forms/FormDoctorPayments.Designer.cs | 2 +- ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs | 2 +- ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.Designer.cs | 2 +- .../ProjectPolyclinic/Forms/FormMedicalHistories.Designer.cs | 2 +- .../ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs | 2 +- .../ProjectPolyclinic/Forms/FormPatients.Designer.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs index 4919b10..f6e663d 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs @@ -140,7 +140,7 @@ Controls.Add(labelDoctor); Name = "FormDoctorPayment"; StartPosition = FormStartPosition.CenterScreen; - Text = "FormDoctorPayment"; + Text = "Оплата врачу"; groupBox.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridViewPay).EndInit(); ResumeLayout(false); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayments.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayments.Designer.cs index b17af66..350334d 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayments.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayments.Designer.cs @@ -79,7 +79,7 @@ Controls.Add(panel1); Name = "FormDoctorPayments"; StartPosition = FormStartPosition.CenterScreen; - Text = " "; + Text = " Оплаты врачам"; Load += FormDoctorPayments_Load; panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs index 269e8b4..6512edc 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs @@ -121,7 +121,7 @@ Controls.Add(buttonSave); Name = "FormDrug"; StartPosition = FormStartPosition.CenterScreen; - Text = "FormDrug"; + Text = "Лекарство"; ResumeLayout(false); PerformLayout(); } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.Designer.cs index 39a0189..6f1dd1c 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.Designer.cs @@ -105,7 +105,7 @@ Controls.Add(panel1); Name = "FormDrugs"; StartPosition = FormStartPosition.CenterScreen; - Text = " "; + Text = "Лекарства"; Load += FormDrugs_Load; panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistories.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistories.Designer.cs index 0b6fccb..7f0be03 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistories.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistories.Designer.cs @@ -92,7 +92,7 @@ Controls.Add(panel1); Name = "FormMedicalHistories"; StartPosition = FormStartPosition.CenterScreen; - Text = " "; + Text = " Медицинские истории"; Load += FormMedicalHistories_Load; panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs index 20cca49..3f1b72a 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs @@ -171,7 +171,7 @@ Controls.Add(labelPacientName); Name = "FormMedicalHistory"; StartPosition = FormStartPosition.CenterScreen; - Text = "FormMedicalHistory"; + Text = "Медицинская история"; groupBox.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs index 982d84b..ebf376b 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs @@ -105,7 +105,7 @@ Controls.Add(panel1); Name = "FormPatients"; StartPosition = FormStartPosition.CenterScreen; - Text = " "; + Text = " Пациенты"; Load += FormDoctors_Load; panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); -- 2.25.1 From 4c9a5d26aef05b5c15948b1bba6fb9c6c89e8c48 Mon Sep 17 00:00:00 2001 From: kisame Date: Sun, 1 Dec 2024 15:51:37 +0400 Subject: [PATCH 2/4] =?UTF-8?q?2=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectPolyclinic/Forms/FormDoctor.cs | 19 ++- .../Forms/FormDoctorPayment.Designer.cs | 50 +++++- .../Forms/FormDoctorPayment.cs | 22 +-- .../ProjectPolyclinic/Forms/FormDoctors.cs | 9 +- .../ProjectPolyclinic/Forms/FormDrugs.cs | 2 +- .../Forms/FormMedicalHistory.Designer.cs | 36 ++--- .../Forms/FormMedicalHistory.cs | 3 +- .../Forms/FormMedicalHistory.resx | 8 +- .../ProjectPolyclinic/Forms/FormPatients.cs | 4 +- .../ProjectPolyclinic/Program.cs | 20 ++- .../ProjectPolyclinic.csproj | 17 ++ .../Repositories/IConnectionString.cs | 12 ++ .../Repositories/IDoctorPayRepository.cs | 6 - .../Implementations/ConnectionString.cs | 9 ++ .../Implementations/DoctorPayRepository.cs | 69 ++++++-- .../Implementations/DoctorRepository.cs | 149 ++++++++++++++++-- .../Implementations/DrugRepository.cs | 110 ++++++++++++- .../MedicalHistoryRepository.cs | 96 ++++++++++- .../Implementations/PatientRepository.cs | 132 +++++++++++++++- .../ProjectPolyclinic/appsettings.json | 15 ++ 20 files changed, 682 insertions(+), 106 deletions(-) create mode 100644 ProjectPolyclinic/ProjectPolyclinic/Repositories/IConnectionString.cs create mode 100644 ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ConnectionString.cs create mode 100644 ProjectPolyclinic/ProjectPolyclinic/appsettings.json diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs index b655e81..3f0d647 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs @@ -30,25 +30,23 @@ namespace ProjectPolyclinic.Forms } - - private readonly IDoctorRepository _doctorRepository; private int? _doctorId; - - public int Id { set { try { + _doctorId = value; var doctor = _doctorRepository.ReadDoctorById(value); if (doctor == null) { throw new InvalidDataException(nameof(doctor)); } + textBoxFirstName.Text = doctor.First_Name; textBoxLastName.Text = doctor.Last_Name; numericUpDownRoom.Value = doctor.Room; @@ -58,20 +56,20 @@ namespace ProjectPolyclinic.Forms catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; } } } - + private void buttonSave_Click(object sender, EventArgs e) { try { - if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || - numericUpDownRoom.Value < 1 || - comboBoxSpecialization.SelectedItem == null || - comboBoxSpecializationLevel.SelectedItem == null) + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || + string.IsNullOrWhiteSpace(textBoxLastName.Text) || + numericUpDownRoom.Value < 1 || + comboBoxSpecialization.SelectedItem == null || + comboBoxSpecializationLevel.SelectedItem == null) { throw new Exception("Имеются незаполненные поля"); } @@ -94,6 +92,7 @@ namespace ProjectPolyclinic.Forms } + private void buttonCancel_Click(object sender, EventArgs e) => Close(); private Doctor CreateDoctor(int id) => diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs index f3ae38e..b608e54 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs @@ -34,6 +34,10 @@ comboBoxDoctor = new ComboBox(); label4 = new Label(); dateTimePicker = new DateTimePicker(); + label1 = new Label(); + label2 = new Label(); + textBoxCount = new TextBox(); + textBoxPay = new TextBox(); SuspendLayout(); // // labelDoctor @@ -47,7 +51,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(240, 143); + buttonCancel.Location = new Point(240, 304); buttonCancel.Margin = new Padding(3, 4, 3, 4); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(106, 39); @@ -57,7 +61,7 @@ // // buttonSave // - buttonSave.Location = new Point(35, 143); + buttonSave.Location = new Point(35, 304); buttonSave.Margin = new Padding(3, 4, 3, 4); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(106, 39); @@ -94,11 +98,47 @@ dateTimePicker.Size = new Size(153, 27); dateTimePicker.TabIndex = 22; // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(35, 155); + label1.Name = "label1"; + label1.Size = new Size(142, 20); + label1.TabIndex = 23; + label1.Text = "Кол-во посещений"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(35, 204); + label2.Name = "label2"; + label2.Size = new Size(59, 20); + label2.TabIndex = 24; + label2.Text = "Оплата"; + // + // textBoxCount + // + textBoxCount.Location = new Point(193, 152); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(153, 27); + textBoxCount.TabIndex = 25; + // + // textBoxPay + // + textBoxPay.Location = new Point(193, 201); + textBoxPay.Name = "textBoxPay"; + textBoxPay.Size = new Size(153, 27); + textBoxPay.TabIndex = 26; + // // FormDoctorPayment // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(370, 207); + ClientSize = new Size(370, 363); + Controls.Add(textBoxPay); + Controls.Add(textBoxCount); + Controls.Add(label2); + Controls.Add(label1); Controls.Add(dateTimePicker); Controls.Add(label4); Controls.Add(comboBoxDoctor); @@ -121,5 +161,9 @@ private ComboBox comboBoxDoctor; private Label label4; private DateTimePicker dateTimePicker; + private Label label1; + private Label label2; + private TextBox textBoxCount; + private TextBox textBoxPay; } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs index 1ff837c..c17daf4 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs @@ -17,14 +17,16 @@ public partial class FormDoctorPayment : Form { private readonly IDoctorPayRepository _doctorPayRepository; - public FormDoctorPayment(IDoctorPayRepository doctorPayRepository, IDoctorRepository doctorRepository) + + public FormDoctorPayment(IDoctorPayRepository doctorPayRepository, + IDoctorRepository doctorRepository) { InitializeComponent(); _doctorPayRepository = doctorPayRepository ?? throw new ArgumentNullException(nameof(doctorPayRepository)); comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); - comboBoxDoctor.DisplayMember = "Firts_Name"; + comboBoxDoctor.DisplayMember = "Last_Name"; comboBoxDoctor.ValueMember = "Id"; } @@ -32,18 +34,20 @@ public partial class FormDoctorPayment : Form { try { - if (comboBoxDoctor.SelectedIndex < 0) + if (comboBoxDoctor.SelectedIndex < 0 || + string.IsNullOrWhiteSpace(textBoxCount.Text) || + string.IsNullOrWhiteSpace(textBoxPay.Text)) { throw new Exception("Имеются незаполненные поля."); } - string month = dateTimePicker.Value.ToString(); - - //сделать запрос на счет пациентов у каждого врача в medicalhis - - _doctorPayRepository.CreateDoctorPayments(DoctorPay.CreateElement(0, (int)comboBoxDoctor.SelectedValue!, month, 0, 0)); - + int doctorId = (int)comboBoxDoctor.SelectedValue!; + string month = dateTimePicker.Value.ToString("yyyy-MM"); + int patientCount = Convert.ToInt32(textBoxCount.Text); + int payment = Convert.ToInt32(textBoxPay.Text); + var doctorPay = DoctorPay.CreateElement(0, doctorId, month, patientCount, payment); + _doctorPayRepository.CreateDoctorPayments(doctorPay); Close(); } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs index 0e433ef..32cb1ef 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs @@ -103,11 +103,11 @@ public partial class FormDoctors : Form private void buttonUpdate_Click(object sender, EventArgs e) { + if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; } - try { var form = _container.Resolve(); @@ -117,7 +117,12 @@ public partial class FormDoctors : Form } catch (Exception ex) { - MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); } + } + + + } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.cs index c678db3..de5fc98 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrugs.cs @@ -95,7 +95,7 @@ public partial class FormDrugs : Form try { - var form = _container.Resolve(); + var form = _container.Resolve(); form.Id = findId; form.ShowDialog(); LoadList(); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs index 639e905..524e9ef 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.Designer.cs @@ -34,12 +34,12 @@ comboBoxDoctor = new ComboBox(); groupBox = new GroupBox(); dataGridView = new DataGridView(); - ColumnDrug = new DataGridViewComboBoxColumn(); - DrugCount = new DataGridViewTextBoxColumn(); label = new Label(); comboBoxStatus = new ComboBox(); buttonCancel = new Button(); buttonSave = new Button(); + ColumnDrug = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); groupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -99,7 +99,7 @@ dataGridView.AllowUserToResizeColumns = false; dataGridView.AllowUserToResizeRows = false; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnDrug, DrugCount }); + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnDrug, ColumnCount }); dataGridView.Dock = DockStyle.Fill; dataGridView.Location = new Point(3, 24); dataGridView.Margin = new Padding(3, 4, 3, 4); @@ -111,20 +111,6 @@ dataGridView.Size = new Size(263, 301); dataGridView.TabIndex = 0; // - // ColumnDrug - // - ColumnDrug.HeaderText = "Лекарство"; - ColumnDrug.MinimumWidth = 6; - ColumnDrug.Name = "ColumnDrug"; - ColumnDrug.Width = 125; - // - // DrugCount - // - DrugCount.HeaderText = "Количество"; - DrugCount.MinimumWidth = 6; - DrugCount.Name = "DrugCount"; - DrugCount.Width = 125; - // // label // label.AutoSize = true; @@ -165,6 +151,20 @@ buttonSave.UseVisualStyleBackColor = true; buttonSave.Click += buttonSave_Click; // + // ColumnDrug + // + ColumnDrug.HeaderText = "Лекарство"; + ColumnDrug.MinimumWidth = 6; + ColumnDrug.Name = "ColumnDrug"; + ColumnDrug.Width = 125; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.Width = 125; + // // FormMedicalHistory // AutoScaleDimensions = new SizeF(8F, 20F); @@ -202,6 +202,6 @@ private Button buttonCancel; private Button buttonSave; private DataGridViewComboBoxColumn ColumnDrug; - private DataGridViewTextBoxColumn DrugCount; + private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.cs index d0b724d..bedca58 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.cs @@ -37,7 +37,7 @@ public partial class FormMedicalHistory : Form comboBoxPacient.ValueMember = "Id"; comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); - comboBoxDoctor.DisplayMember = "First_Name"; + comboBoxDoctor.DisplayMember = "Last_Name"; comboBoxDoctor.ValueMember = "Id"; ColumnDrug.DataSource = drugRepository.ReadDrug(); @@ -67,7 +67,6 @@ public partial class FormMedicalHistory : Form ); _medicalHistoryRepository.CreateMedicalHistory(medicalHistory); - MessageBox.Show("История болезни сохранена.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } catch (Exception ex) diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.resx index 1414a31..bde7a4b 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.resx +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicalHistory.resx @@ -120,13 +120,7 @@ True - - True - - - True - - + True \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs index 8ca5b05..4e8e9e6 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs @@ -93,7 +93,6 @@ public partial class FormPatients : Form { return; } - try { var form = _container.Resolve(); @@ -103,7 +102,8 @@ public partial class FormPatients : Form } catch (Exception ex) { - MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Program.cs b/ProjectPolyclinic/ProjectPolyclinic/Program.cs index e3447c2..a32671d 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Program.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Program.cs @@ -1,6 +1,10 @@ using ProjectPolyclinic.Repositories.Implementations; using ProjectPolyclinic.Repositories; using Unity; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Serilog; +using Unity.Microsoft.Logging; namespace ProjectPolyclinic { @@ -22,7 +26,7 @@ namespace ProjectPolyclinic { var container = new UnityContainer(); - // + container.AddExtension(new LoggingExtension(CreateLoggerFactory())); container.RegisterType(); container.RegisterType(); @@ -30,10 +34,22 @@ namespace ProjectPolyclinic container.RegisterType(); container.RegisterType(); + container.RegisterType(); + return container; } - + private static LoggerFactory CreateLoggerFactory() + { + var loggerFactory = new LoggerFactory(); + loggerFactory.AddSerilog(new LoggerConfiguration() + .ReadFrom.Configuration(new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build()) + .CreateLogger()); + return loggerFactory; + } } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj b/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj index df6540b..a33b2a1 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj +++ b/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj @@ -9,7 +9,18 @@ + + + + + + + + + + + @@ -39,4 +50,10 @@ + + + PreserveNewest + + + \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IConnectionString.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IConnectionString.cs new file mode 100644 index 0000000..5c245ab --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IConnectionString.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories; + +public interface IConnectionString +{ + public string ConnectionString { get; } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorPayRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorPayRepository.cs index 756579a..a92bbfd 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorPayRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorPayRepository.cs @@ -11,11 +11,5 @@ public interface IDoctorPayRepository { IEnumerable ReadDoctorPayments(); - DoctorPay ReadDoctorPaymentsById(int id); - void CreateDoctorPayments(DoctorPay doctorPayments); - - void UpdateDoctorPayments(DoctorPay doctorPayments); - - void DeleteDoctorPayments(int id); } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ConnectionString.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ConnectionString.cs new file mode 100644 index 0000000..cd6e0af --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ConnectionString.cs @@ -0,0 +1,9 @@ +namespace ProjectPolyclinic.Repositories.Implementations; + +public class ConnectionString : IConnectionString +{ + + string IConnectionString.ConnectionString => + "Server=localhost, Port=5432;Database=polyclinicotp;User Id=postgres;Password=postgres;"; + +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs index 68a452f..aade652 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs @@ -1,4 +1,8 @@ -using ProjectPolyclinic.Entities; +using Dapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npgsql; +using ProjectPolyclinic.Entities; using System; using System.Collections.Generic; using System.Linq; @@ -9,28 +13,65 @@ namespace ProjectPolyclinic.Repositories.Implementations; public class DoctorPayRepository : IDoctorPayRepository { - public void CreateDoctorPayments(DoctorPay doctorPayments) - { + + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + + public DoctorPayRepository(IConnectionString connectionString, ILogger logger) + { + _connectionString = connectionString; + _logger = logger; } - public void DeleteDoctorPayments(int id) - { + + public void CreateDoctorPayments(DoctorPay doctorPayments) + { + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + + + var query = @" + INSERT INTO doctor_pay (IdDoctor, Month, Count_Patient, Payment) + VALUES (@DoctorId, @Month, @CountPatient, @Payment)"; + + connection.Execute(query, new + { + DoctorId = doctorPayments.IdDoctor, + Month = doctorPayments.Month, + CountPatient = doctorPayments.Count_Patient, + Payment = doctorPayments.Payment + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при создании записи о платеже врачу"); + throw; + } } public IEnumerable ReadDoctorPayments() { - return []; - } - public DoctorPay ReadDoctorPaymentsById(int id) - { - return DoctorPay.CreateElement(0, 0, string.Empty, 0, 0); - } + _logger.LogInformation("Получение всех объектов"); + try + { + using var connection = new + NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = "SELECT * FROM doctor_pay"; + var professionalDevelopments = + connection.Query(querySelect); + _logger.LogDebug("Полученные объекты: {json}", + JsonConvert.SerializeObject(professionalDevelopments)); + return professionalDevelopments; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при чтении объектов"); + throw; + } - public void UpdateDoctorPayments(DoctorPay doctorPayments) - { - throw new NotImplementedException(); } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs index 319b3df..a28ef45 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs @@ -1,4 +1,8 @@ -using ProjectPolyclinic.Entities; +using Dapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npgsql; +using ProjectPolyclinic.Entities; using ProjectPolyclinic.Entities.Enums; using System; using System.Collections.Generic; @@ -10,28 +14,141 @@ namespace ProjectPolyclinic.Repositories.Implementations; public class DoctorRepository : IDoctorRepository { + + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + + public DoctorRepository(IConnectionString connectionString, ILogger logger) + { + _connectionString = connectionString; + _logger = logger; + } + public void CreateDoctor(Doctor doctor) { - - } + _logger.LogInformation("Добавление объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(doctor)); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryInsert = @" + INSERT INTO Doctors (first_name, last_name, room, specialization, specializationlevel) + VALUES (@First_Name, @Last_Name, @Room, @Specialization, @SpecializationLevel)"; - public void DeleteDoctor(int id) - { - - } + connection.Execute(queryInsert, doctor); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении объекта"); + throw; + } - public Doctor ReadDoctorById(int id) - { - return Doctor.CreateEntity(0, string.Empty, string.Empty, 0, Specialization.None, SpecializationLevel.None); - } - - public IEnumerable ReadDoctors() - { - return []; } public void UpdateDoctor(Doctor doctor) { - + _logger.LogInformation("Редактирование объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(doctor)); + + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + + // Проверяем, существует ли запись + var existingDoctor = connection.QueryFirstOrDefault("SELECT * FROM Doctors WHERE id = @Id", new { doctor.Id }); + if (existingDoctor == null) + { + _logger.LogWarning("Запись с Id={Id} не найдена.", doctor.Id); + return; + } + + var queryUpdate = @" + UPDATE Doctors + SET first_name = @First_Name, + last_name = @Last_Name, + room = @Room, + specialization = @Specialization, + specializationlevel = @SpecializationLevel + WHERE id = @Id"; + + var affectedRows = connection.Execute(queryUpdate, doctor); + + if (affectedRows == 0) + { + _logger.LogWarning("Обновление не выполнено. Id={Id}.", doctor.Id); + } + else + { + _logger.LogInformation("Запись успешно обновлена."); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при обновлении объекта"); + throw; + } + } + + + public void DeleteDoctor(int id) + { + _logger.LogInformation("Удаление объекта"); + _logger.LogDebug("Объект: {id}", id); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryDelete = @"DELETE FROM Doctors WHERE ID=@id"; + connection.Execute(queryDelete, new { id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при удалении объекта"); + throw; + } + } + + public Doctor ReadDoctorById(int id) + { + + _logger.LogInformation("Получение объекта по идентификатору"); + _logger.LogDebug("Объект: {id}", id); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = @"SELECT * FROM Doctors WHERE Id=@id"; + var doctor = connection.QueryFirst(querySelect, new + { + id + }); + _logger.LogDebug("Найденный объект: {json}", + JsonConvert.SerializeObject(doctor)); + return doctor; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при поиске объекта"); + throw; + } + } + + public IEnumerable ReadDoctors() + { + + _logger.LogInformation("Получение всех объектов"); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = "SELECT * FROM Doctors"; + var doctors = connection.Query(querySelect); + _logger.LogDebug("Полученные объекты: {json}", + JsonConvert.SerializeObject(doctors)); + return doctors; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при чтении объектов"); + throw; + } + } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DrugRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DrugRepository.cs index 3e352cc..edf44ab 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DrugRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DrugRepository.cs @@ -1,37 +1,131 @@ -using ProjectPolyclinic.Entities; +using Dapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npgsql; +using ProjectPolyclinic.Entities; using ProjectPolyclinic.Entities.Enums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Unity; namespace ProjectPolyclinic.Repositories.Implementations; public class DrugRepository : IDrugRepository { - public void CreateDrug(Drug drag) + + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + + + public DrugRepository(IConnectionString connectionString, ILogger logger) { - + _connectionString = connectionString; + _logger = logger; + } + + + public void CreateDrug(Drug drug) + { + _logger.LogInformation("Добавление объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(drug)); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryInsert = @" + INSERT INTO drugs (DrugsNames, grams, Description) + VALUES (@DrugsNames, @Grams, @Description)"; + + connection.Execute(queryInsert, drug); + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении объекта"); + throw; + } } public void DeleteDrug(int id) { - + _logger.LogInformation("Удаление объекта"); + _logger.LogDebug("Объект: {id}", id); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryDelete = @"DELETE FROM drugs WHERE ID=@id"; + connection.Execute(queryDelete, new { id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при удалении объекта"); + throw; + } } public IEnumerable ReadDrug() { - return []; + _logger.LogInformation("Получение всех объектов"); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = "SELECT * FROM drugs"; + var drugs = connection.Query(querySelect); + _logger.LogDebug("Полученные объекты: {json}", + JsonConvert.SerializeObject(drugs)); + return drugs; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при чтении объектов"); + throw; + } } public Drug ReadDrugById(int id) { - return Drug.CreateElement(0, DrugsNames.None, 0, string.Empty); + _logger.LogInformation("Получение объекта по идентификатору"); + _logger.LogDebug("Объект: {id}", id); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = @"SELECT * FROM drugs WHERE Id=@id"; + var drug = connection.QueryFirst(querySelect, new + { + id + }); + _logger.LogDebug("Найденный объект: {json}", + JsonConvert.SerializeObject(drug)); + return drug; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при поиске объекта"); + throw; + } + } - public void UpdateDrug(Drug drag) + public void UpdateDrug(Drug drug) { - + _logger.LogInformation("Редактирование объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(drug)); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryUpdate = @"UPDATE drugs SET + DrugsNames = @DrugsNames, + grams = @Grams, + Description= @Description + WHERE Id=@id"; + connection.Execute(queryUpdate, drug); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении объекта"); + throw; + } } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs index 97719b1..9ffc129 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs @@ -1,4 +1,8 @@ -using ProjectPolyclinic.Entities; +using Dapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npgsql; +using ProjectPolyclinic.Entities; using ProjectPolyclinic.Entities.Enums; using System; using System.Collections.Generic; @@ -10,19 +14,105 @@ namespace ProjectPolyclinic.Repositories.Implementations; public class MedicalHistoryRepository : IMedicalHistoryRepository { + + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + + public MedicalHistoryRepository(IConnectionString connectionString, ILogger logger) + { + _connectionString = connectionString; + _logger = logger; + } + public void CreateMedicalHistory(MedicalHistory medicalHistory) { + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + connection.Open(); + using var transaction = connection.BeginTransaction(); + + try + { + var queryInsertHistory = @" + INSERT INTO medical_history (PatientId, DoctorId, VisitDate, Status) + VALUES (@PatientId, @DoctorId, @VisitDate, @Status) + RETURNING id;"; + var historyId = connection.ExecuteScalar(queryInsertHistory, new + { + medicalHistory.PatientId, + medicalHistory.DoctorId, + medicalHistory.VisitDate, + Status = (int)medicalHistory.Status + }, transaction); + + var queryInsertDrugs = @" + INSERT INTO drug_med_history (medical_history_id, drug_id, count) + VALUES (@MedicalHistoryId, @DrugId, @Count);"; + + foreach (var drug in medicalHistory.DrugMedHistory) + { + connection.Execute(queryInsertDrugs, new + { + MedicalHistoryId = historyId, + DrugId = drug.DrugId, + drug.Count + }, transaction); + } + + transaction.Commit(); + } + catch (Exception) + { + transaction.Rollback(); + throw; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении медицинской истории"); + throw; + } } public void DeletemedicalHistory(int id) { - + _logger.LogInformation("Удаление объекта"); + _logger.LogDebug("Объект: {id}", id); + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryDelete = @"DELETE FROM medical_history WHERE ID=@id"; + connection.Execute(queryDelete, new { id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при удалении объекта"); + throw; + } } public IEnumerable ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null) { - return []; + _logger.LogInformation("Получение всех объектов"); + try + { + using var connection = new + NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = @"SELECT * FROM medical_history"; + var visitings = + connection.Query(querySelect); + _logger.LogDebug("Полученные объекты: {json}", + JsonConvert.SerializeObject(visitings)); + return visitings; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при чтении объектов"); + throw; + } } + } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs index 133fa5c..0d5c0d4 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs @@ -1,7 +1,12 @@ -using ProjectPolyclinic.Entities; +using Dapper; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Npgsql; +using ProjectPolyclinic.Entities; using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Text; using System.Threading.Tasks; @@ -9,25 +14,146 @@ namespace ProjectPolyclinic.Repositories.Implementations; public class PatientRepository : IPatientRepository { + + + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + + + public PatientRepository(IConnectionString connectionString, ILogger logger) + { + _connectionString = connectionString; + _logger = logger; + } + + public void CreatPatient(Patient patient) { + _logger.LogInformation("Добавление объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(patient)); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + + //var queryInsert = @""; + + var queryInsert = @" + INSERT INTO patients (first_name, last_name, address, contactnumber) + VALUES (@First_Name, @Last_Name, @Address, @ContactNumber)"; + + connection.Execute(queryInsert, patient); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при добавлении объекта"); + throw; + } + } public void DeletePatient(int id) { + + _logger.LogInformation("Удаление объекта"); + _logger.LogDebug("Объект: {id}", id); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var queryDelete = @"DELETE FROM Patients WHERE ID=@id"; + connection.Execute(queryDelete, new { id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при удалении объекта"); + throw; + } + } public IEnumerable ReadPatient() { - return []; + //return []; + _logger.LogInformation("Получение всех объектов пациентов"); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = "SELECT * FROM Patients"; + var patients = connection.Query(querySelect); + _logger.LogDebug("Полученные пациенты: {json}", JsonConvert.SerializeObject(patients)); + return patients; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при чтении объектов пациентов"); + throw; + } } public Patient ReadPatientById(int id) { - return Patient.CreateEntity(0, string.Empty, string.Empty, string.Empty, string.Empty); + _logger.LogInformation("Получение объекта по идентификатору"); + _logger.LogDebug("Объект: {id}", id); + try + { + var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = @"SELECT * FROM Patients WHERE Id=@id"; + var patient = connection.QueryFirst(querySelect, new + { + id + }); + _logger.LogDebug("Найденный объект: {json}", + JsonConvert.SerializeObject(patient)); + return patient; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при поиске объекта"); + throw; + } } public void UpdatePatient(Patient patient) { + + _logger.LogInformation("Редактирование объекта"); + _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(patient)); + + try + { + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + + // Проверяем, существует ли запись + var existingDoctor = connection.QueryFirstOrDefault("SELECT * FROM Patients WHERE id = @Id", new { patient.Id }); + if (existingDoctor == null) + { + _logger.LogWarning("Запись с Id={Id} не найдена.", patient.Id); + return; + } + + var queryUpdate = @" + UPDATE patients + SET first_name = @First_Name, + last_name = @Last_Name, + address = @Address, + contactnumber = @Contactnumber + WHERE id = @Id"; + + var affectedRows = connection.Execute(queryUpdate, patient); + + if (affectedRows == 0) + { + _logger.LogWarning("Обновление не выполнено. Id={Id}.", patient.Id); + } + else + { + _logger.LogInformation("Запись успешно обновлена."); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при обновлении объекта"); + throw; + } + } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/appsettings.json b/ProjectPolyclinic/ProjectPolyclinic/appsettings.json new file mode 100644 index 0000000..83b31f5 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/appsettings.json @@ -0,0 +1,15 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/Polyclinic_log.txt", + "rollingInterval": "Day" + } + } + ] + } +} \ No newline at end of file -- 2.25.1 From 80e7462e84354fe4ce0155a7e43267a2a92a7bc4 Mon Sep 17 00:00:00 2001 From: kisame Date: Mon, 2 Dec 2024 14:34:01 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B2?= =?UTF-8?q?=D1=81=D1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Forms/FormDoctorPayment.Designer.cs | 79 ++++++++++--------- .../Forms/FormDoctorPayment.cs | 8 +- .../ProjectPolyclinic/Forms/FormDoctors.cs | 2 +- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs index b608e54..ea1c119 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.Designer.cs @@ -36,35 +36,35 @@ dateTimePicker = new DateTimePicker(); label1 = new Label(); label2 = new Label(); - textBoxCount = new TextBox(); - textBoxPay = new TextBox(); + numericCount = new NumericUpDown(); + numericPay = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericCount).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericPay).BeginInit(); SuspendLayout(); // // labelDoctor // labelDoctor.AutoSize = true; - labelDoctor.Location = new Point(35, 43); + labelDoctor.Location = new Point(31, 32); labelDoctor.Name = "labelDoctor"; - labelDoctor.Size = new Size(43, 20); + labelDoctor.Size = new Size(34, 15); labelDoctor.TabIndex = 0; labelDoctor.Text = "Врач"; // // buttonCancel // - buttonCancel.Location = new Point(240, 304); - buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Location = new Point(210, 228); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(106, 39); + buttonCancel.Size = new Size(93, 29); buttonCancel.TabIndex = 11; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; // // buttonSave // - buttonSave.Location = new Point(35, 304); - buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Location = new Point(31, 228); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(106, 39); + buttonSave.Size = new Size(93, 29); buttonSave.TabIndex = 10; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -74,18 +74,17 @@ // comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxDoctor.FormattingEnabled = true; - comboBoxDoctor.Location = new Point(193, 40); - comboBoxDoctor.Margin = new Padding(3, 4, 3, 4); + comboBoxDoctor.Location = new Point(169, 30); comboBoxDoctor.Name = "comboBoxDoctor"; - comboBoxDoctor.Size = new Size(153, 28); + comboBoxDoctor.Size = new Size(134, 23); comboBoxDoctor.TabIndex = 12; // // label4 // label4.AutoSize = true; - label4.Location = new Point(35, 99); + label4.Location = new Point(31, 74); label4.Name = "label4"; - label4.Size = new Size(54, 20); + label4.Size = new Size(43, 15); label4.TabIndex = 17; label4.Text = "Месяц"; // @@ -93,50 +92,53 @@ // dateTimePicker.CustomFormat = "MMMM yyyy"; dateTimePicker.Format = DateTimePickerFormat.Custom; - dateTimePicker.Location = new Point(193, 94); + dateTimePicker.Location = new Point(169, 70); + dateTimePicker.Margin = new Padding(3, 2, 3, 2); dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(153, 27); + dateTimePicker.Size = new Size(134, 23); dateTimePicker.TabIndex = 22; // // label1 // label1.AutoSize = true; - label1.Location = new Point(35, 155); + label1.Location = new Point(31, 116); label1.Name = "label1"; - label1.Size = new Size(142, 20); + label1.Size = new Size(113, 15); label1.TabIndex = 23; label1.Text = "Кол-во посещений"; // // label2 // label2.AutoSize = true; - label2.Location = new Point(35, 204); + label2.Location = new Point(31, 153); label2.Name = "label2"; - label2.Size = new Size(59, 20); + label2.Size = new Size(47, 15); label2.TabIndex = 24; label2.Text = "Оплата"; // - // textBoxCount + // numericCount // - textBoxCount.Location = new Point(193, 152); - textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(153, 27); - textBoxCount.TabIndex = 25; + numericCount.Location = new Point(169, 114); + numericCount.Maximum = new decimal(new int[] { 999999, 0, 0, 0 }); + numericCount.Name = "numericCount"; + numericCount.Size = new Size(134, 23); + numericCount.TabIndex = 27; // - // textBoxPay + // numericPay // - textBoxPay.Location = new Point(193, 201); - textBoxPay.Name = "textBoxPay"; - textBoxPay.Size = new Size(153, 27); - textBoxPay.TabIndex = 26; + numericPay.Location = new Point(169, 151); + numericPay.Maximum = new decimal(new int[] { 999999, 0, 0, 0 }); + numericPay.Name = "numericPay"; + numericPay.Size = new Size(134, 23); + numericPay.TabIndex = 28; // // FormDoctorPayment // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(370, 363); - Controls.Add(textBoxPay); - Controls.Add(textBoxCount); + ClientSize = new Size(324, 272); + Controls.Add(numericPay); + Controls.Add(numericCount); Controls.Add(label2); Controls.Add(label1); Controls.Add(dateTimePicker); @@ -145,10 +147,11 @@ Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(labelDoctor); - Margin = new Padding(3, 4, 3, 4); Name = "FormDoctorPayment"; StartPosition = FormStartPosition.CenterScreen; Text = "Оплата врачу"; + ((System.ComponentModel.ISupportInitialize)numericCount).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericPay).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -163,7 +166,7 @@ private DateTimePicker dateTimePicker; private Label label1; private Label label2; - private TextBox textBoxCount; - private TextBox textBoxPay; + private NumericUpDown numericCount; + private NumericUpDown numericPay; } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs index c17daf4..47440f8 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctorPayment.cs @@ -34,17 +34,15 @@ public partial class FormDoctorPayment : Form { try { - if (comboBoxDoctor.SelectedIndex < 0 || - string.IsNullOrWhiteSpace(textBoxCount.Text) || - string.IsNullOrWhiteSpace(textBoxPay.Text)) + if (comboBoxDoctor.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля."); } int doctorId = (int)comboBoxDoctor.SelectedValue!; string month = dateTimePicker.Value.ToString("yyyy-MM"); - int patientCount = Convert.ToInt32(textBoxCount.Text); - int payment = Convert.ToInt32(textBoxPay.Text); + int patientCount = (int)numericCount.Value; + int payment = (int)numericPay.Value; var doctorPay = DoctorPay.CreateElement(0, doctorId, month, patientCount, payment); _doctorPayRepository.CreateDoctorPayments(doctorPay); diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs index 32cb1ef..d24a4bc 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs @@ -34,7 +34,7 @@ public partial class FormDoctors : Form _doctorRepository = doctorRepository ?? throw new ArgumentNullException(nameof(doctorRepository)); } - + private void FormDoctors_Load(object sender, EventArgs e) { -- 2.25.1 From 35e3cd66a42f8509b46748749f46c3f5aa7f7b7c Mon Sep 17 00:00:00 2001 From: kisame Date: Mon, 2 Dec 2024 16:56:13 +0400 Subject: [PATCH 4/4] =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Enums/DrugsNames.cs | 12 ++-- .../Forms/FormDrug.Designer.cs | 62 +++++++++++-------- .../ProjectPolyclinic/Forms/FormDrug.cs | 6 +- .../Implementations/DoctorPayRepository.cs | 2 +- .../Implementations/DoctorRepository.cs | 2 +- .../Implementations/PatientRepository.cs | 1 - 6 files changed, 47 insertions(+), 38 deletions(-) diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DrugsNames.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DrugsNames.cs index f5aed2b..1602f46 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DrugsNames.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DrugsNames.cs @@ -12,14 +12,14 @@ public enum DrugsNames None = 0, Paracetamol = 1, - + Ibuprofen = 2, - + Aspirin = 4, - + Antibiotic = 8, - + Antihistamine = 16, - + Insulin = 32, -} +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs index 6512edc..38efbd2 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.Designer.cs @@ -34,24 +34,27 @@ labelGrams = new Label(); labelDescription = new Label(); checkedListBoxName = new CheckedListBox(); - textBoxGrams = new TextBox(); textBoxDescription = new TextBox(); + numericGrams = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericGrams).BeginInit(); SuspendLayout(); // // buttonCancel // - buttonCancel.Location = new Point(177, 302); + buttonCancel.Location = new Point(202, 403); + buttonCancel.Margin = new Padding(3, 4, 3, 4); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(93, 29); + buttonCancel.Size = new Size(106, 39); buttonCancel.TabIndex = 8; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; // // buttonSave // - buttonSave.Location = new Point(38, 302); + buttonSave.Location = new Point(43, 403); + buttonSave.Margin = new Padding(3, 4, 3, 4); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(93, 29); + buttonSave.Size = new Size(106, 39); buttonSave.TabIndex = 7; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -60,68 +63,75 @@ // labelName // labelName.AutoSize = true; - labelName.Location = new Point(38, 44); + labelName.Location = new Point(43, 59); labelName.Name = "labelName"; - labelName.Size = new Size(59, 15); + labelName.Size = new Size(77, 20); labelName.TabIndex = 9; labelName.Text = "Название"; // // labelGrams // labelGrams.AutoSize = true; - labelGrams.Location = new Point(38, 188); + labelGrams.Location = new Point(43, 251); labelGrams.Name = "labelGrams"; - labelGrams.Size = new Size(60, 15); + labelGrams.Size = new Size(76, 20); labelGrams.TabIndex = 10; labelGrams.Text = "Грамовка"; // // labelDescription // labelDescription.AutoSize = true; - labelDescription.Location = new Point(38, 236); + labelDescription.Location = new Point(43, 315); labelDescription.Name = "labelDescription"; - labelDescription.Size = new Size(45, 15); + labelDescription.Size = new Size(57, 20); labelDescription.TabIndex = 11; labelDescription.Text = "Рецепт"; // // checkedListBoxName // checkedListBoxName.FormattingEnabled = true; - checkedListBoxName.Location = new Point(136, 44); + checkedListBoxName.Location = new Point(155, 59); + checkedListBoxName.Margin = new Padding(3, 4, 3, 4); checkedListBoxName.Name = "checkedListBoxName"; - checkedListBoxName.Size = new Size(161, 94); + checkedListBoxName.Size = new Size(183, 114); checkedListBoxName.TabIndex = 12; // - // textBoxGrams - // - textBoxGrams.Location = new Point(136, 185); - textBoxGrams.Name = "textBoxGrams"; - textBoxGrams.Size = new Size(161, 23); - textBoxGrams.TabIndex = 13; - // // textBoxDescription // - textBoxDescription.Location = new Point(136, 233); + textBoxDescription.Location = new Point(155, 311); + textBoxDescription.Margin = new Padding(3, 4, 3, 4); textBoxDescription.Name = "textBoxDescription"; - textBoxDescription.Size = new Size(161, 23); + textBoxDescription.Size = new Size(183, 27); textBoxDescription.TabIndex = 14; // + // numericGrams + // + numericGrams.Location = new Point(155, 249); + numericGrams.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); + numericGrams.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericGrams.Name = "numericGrams"; + numericGrams.Size = new Size(183, 27); + numericGrams.TabIndex = 15; + numericGrams.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // // FormDrug // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(309, 357); + ClientSize = new Size(353, 476); + Controls.Add(numericGrams); Controls.Add(textBoxDescription); - Controls.Add(textBoxGrams); Controls.Add(checkedListBoxName); Controls.Add(labelDescription); Controls.Add(labelGrams); Controls.Add(labelName); Controls.Add(buttonCancel); Controls.Add(buttonSave); + Margin = new Padding(3, 4, 3, 4); Name = "FormDrug"; StartPosition = FormStartPosition.CenterScreen; Text = "Лекарство"; + ((System.ComponentModel.ISupportInitialize)numericGrams).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -134,7 +144,7 @@ private Label labelGrams; private Label labelDescription; private CheckedListBox checkedListBoxName; - private TextBox textBoxGrams; private TextBox textBoxDescription; + private NumericUpDown numericGrams; } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.cs index 3205513..5969e59 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDrug.cs @@ -39,7 +39,7 @@ public partial class FormDrug : Form checkedListBoxName.SetItemChecked(checkedListBoxName.Items.IndexOf(elem), true); } } - textBoxGrams.Text = drag.Grams.ToString(); + numericGrams.Text = drag.Grams.ToString(); textBoxDescription.Text = drag.Description; _dragId = value; @@ -69,7 +69,7 @@ public partial class FormDrug : Form { try { - if (string.IsNullOrWhiteSpace(textBoxGrams.Text) || string.IsNullOrWhiteSpace(textBoxDescription.Text) || + if (string.IsNullOrWhiteSpace(textBoxDescription.Text) || checkedListBoxName.CheckedItems.Count == 0) { throw new Exception("Имеется незаполненные поля"); @@ -104,7 +104,7 @@ public partial class FormDrug : Form drugName |= (DrugsNames)elem; } - return Drug.CreateElement(id, drugName, Convert.ToInt32(textBoxGrams.Text), textBoxDescription.Text); + return Drug.CreateElement(id, drugName, (int)numericGrams.Value, textBoxDescription.Text); } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs index aade652..de94e97 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorPayRepository.cs @@ -74,4 +74,4 @@ public class DoctorPayRepository : IDoctorPayRepository } } -} +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs index a28ef45..caf33a8 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs @@ -151,4 +151,4 @@ public class DoctorRepository : IDoctorRepository } } -} +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs index 0d5c0d4..9f05da6 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs @@ -72,7 +72,6 @@ public class PatientRepository : IPatientRepository public IEnumerable ReadPatient() { - //return []; _logger.LogInformation("Получение всех объектов пациентов"); try { -- 2.25.1