diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Doctor.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Doctor.cs new file mode 100644 index 0000000..574abfc --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Doctor.cs @@ -0,0 +1,16 @@ +namespace RegistrationOfPatients.Entities; + +public class Doctor +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + + public static Doctor CreateEntity(int id, string name) + { + return new Doctor + { + Id = id, + Name = name + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/HealthStatus.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/HealthStatus.cs new file mode 100644 index 0000000..ca07025 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/HealthStatus.cs @@ -0,0 +1,7 @@ +namespace RegistrationOfPatients.Entities.Enums; + +public enum HealthStatus +{ + Ill = 0, + Healthy = 1 +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/MedicineType.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/MedicineType.cs new file mode 100644 index 0000000..a7fcc5f --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Enums/MedicineType.cs @@ -0,0 +1,11 @@ +namespace RegistrationOfPatients.Entities.Enums; + +[Flags] +public enum MedicineType +{ + None = 0, + Aspirin = 1, + Sertraline = 2, + Claritin = 4, + Tylenol = 8 +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Medicine.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Medicine.cs new file mode 100644 index 0000000..ba0d199 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Medicine.cs @@ -0,0 +1,22 @@ +using Microsoft.VisualBasic.FileIO; +using RegistrationOfPatients.Entities.Enums; +using System.Security.Cryptography.Pkcs; + +namespace RegistrationOfPatients.Entities; + +public class Medicine +{ + + public int Id { get; set; } + public MedicineType MedicineType { get; private set; } + public string Description { get; private set; } = string.Empty; + public static Medicine CreateEntity(int id, MedicineType medicineType, string description) + { + return new Medicine + { + Id = id, + MedicineType = medicineType, + Description = description ?? string.Empty + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Patient.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Patient.cs new file mode 100644 index 0000000..315d68e --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Patient.cs @@ -0,0 +1,17 @@ +namespace RegistrationOfPatients.Entities; + +public class Patient +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public string Phone { get; private set; } = string.Empty; + public static Patient CreateEntity(int id, string Name, string Phone) + { + return new Patient + { + Id = id, + Name = Name ?? string.Empty, + Phone = Phone ?? string.Empty + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Payment.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Payment.cs new file mode 100644 index 0000000..f9182ec --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Payment.cs @@ -0,0 +1,23 @@ +namespace RegistrationOfPatients.Entities; + +public class Payment +{ + public int Id { get; private set; } + public int Salary { get; private set; } + public int TotalPatients { get; private set; } + public DateTime Date { get; private set; } + public int PercentageOfRecoveries { get; private set; } + public int DoctorId { get; private set; } + public static Payment CreateOperation(int id, int salary, int totalPatients, DateTime date, int percentageOfRecoveries, int doctorId) + { + return new Payment + { + Id = id, + Salary = salary, + TotalPatients = totalPatients, + Date = DateTime.Now, + PercentageOfRecoveries = percentageOfRecoveries, + DoctorId = doctorId + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/Reception.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/Reception.cs new file mode 100644 index 0000000..2d837f1 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/Reception.cs @@ -0,0 +1,27 @@ +using RegistrationOfPatients.Entities.Enums; + +namespace RegistrationOfPatients.Entities; + +public class Reception +{ + public int Id { get; private set; } + public DateTime Date { get; private set; } + public HealthStatus HealthStatus { get; private set; } + public string Illness { get; private set; } = string.Empty; + public int PatientId { get; private set; } + public int DoctorId { get; private set; } + public IEnumerable ReceptionMedicine { get; private set; } = []; + public static Reception CreateOperation(int id, DateTime date, HealthStatus healthStatus, string illness, int patientId, int doctorId, IEnumerable receptionMedicine) + { + return new Reception + { + Id = id, + Date = DateTime.Now, + HealthStatus = healthStatus, + Illness = illness ?? string.Empty, + PatientId = patientId, + DoctorId = doctorId, + ReceptionMedicine = receptionMedicine + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Entities/ReceptionMedicine.cs b/RegistrationOfPatients/RegistrationOfPatients/Entities/ReceptionMedicine.cs new file mode 100644 index 0000000..af2ab20 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Entities/ReceptionMedicine.cs @@ -0,0 +1,17 @@ +namespace RegistrationOfPatients.Entities; + +public class ReceptionMedicine +{ + public int Id { get; set; } + public int MedicineId { get; private set; } + public int Count { get; private set; } + public static ReceptionMedicine CreateElement(int id, int medicineId, int count) + { + return new ReceptionMedicine + { + Id = id, + MedicineId = medicineId, + Count = count + }; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Form1.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Form1.Designer.cs deleted file mode 100644 index aa4323e..0000000 --- a/RegistrationOfPatients/RegistrationOfPatients/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RegistrationOfPatients -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Form1.cs b/RegistrationOfPatients/RegistrationOfPatients/Form1.cs deleted file mode 100644 index 916617f..0000000 --- a/RegistrationOfPatients/RegistrationOfPatients/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RegistrationOfPatients -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.Designer.cs new file mode 100644 index 0000000..69dbdac --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.Designer.cs @@ -0,0 +1,138 @@ +namespace RegistrationOfPatients +{ + partial class FormRegistration + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + DoctorsToolStripMenuItem = new ToolStripMenuItem(); + PatientsToolStripMenuItem = new ToolStripMenuItem(); + MedicinesToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + ReceptionToolStripMenuItem = new ToolStripMenuItem(); + PaymentToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(571, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DoctorsToolStripMenuItem, PatientsToolStripMenuItem, MedicinesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(117, 24); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // DoctorsToolStripMenuItem + // + DoctorsToolStripMenuItem.Name = "DoctorsToolStripMenuItem"; + DoctorsToolStripMenuItem.Size = new Size(163, 26); + DoctorsToolStripMenuItem.Text = "Доктора"; + DoctorsToolStripMenuItem.Click += DoctorsToolStripMenuItem_Click; + // + // PatientsToolStripMenuItem + // + PatientsToolStripMenuItem.Name = "PatientsToolStripMenuItem"; + PatientsToolStripMenuItem.Size = new Size(163, 26); + PatientsToolStripMenuItem.Text = "Пациенты"; + PatientsToolStripMenuItem.Click += PatientsToolStripMenuItem_Click; + // + // MedicinesToolStripMenuItem + // + MedicinesToolStripMenuItem.Name = "MedicinesToolStripMenuItem"; + MedicinesToolStripMenuItem.Size = new Size(163, 26); + MedicinesToolStripMenuItem.Text = "Лекарства"; + MedicinesToolStripMenuItem.Click += MedicinesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReceptionToolStripMenuItem, PaymentToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(95, 24); + операцииToolStripMenuItem.Text = "Операции"; + // + // ReceptionToolStripMenuItem + // + ReceptionToolStripMenuItem.Name = "ReceptionToolStripMenuItem"; + ReceptionToolStripMenuItem.Size = new Size(224, 26); + ReceptionToolStripMenuItem.Text = "Запись"; + ReceptionToolStripMenuItem.Click += ReceptionToolStripMenuItem_Click; + // + // PaymentToolStripMenuItem + // + PaymentToolStripMenuItem.Name = "PaymentToolStripMenuItem"; + PaymentToolStripMenuItem.Size = new Size(224, 26); + PaymentToolStripMenuItem.Text = "Зарплата"; + PaymentToolStripMenuItem.Click += PaymentToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormRegistration + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.polyclinic; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(571, 738); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormRegistration"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Поликлиника"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem DoctorsToolStripMenuItem; + private ToolStripMenuItem PatientsToolStripMenuItem; + private ToolStripMenuItem ReceptionToolStripMenuItem; + private ToolStripMenuItem PaymentToolStripMenuItem; + private ToolStripMenuItem MedicinesToolStripMenuItem; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.cs b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.cs new file mode 100644 index 0000000..f009aa0 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.cs @@ -0,0 +1,74 @@ +using RegistrationOfPatients.Forms; +using Unity; + +namespace RegistrationOfPatients; + +public partial class FormRegistration : Form +{ + private readonly IUnityContainer _container; + public FormRegistration(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void DoctorsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void PatientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void MedicinesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ReceptionToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void PaymentToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.resx b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/FormRegistration.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.Designer.cs new file mode 100644 index 0000000..21bc36e --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.Designer.cs @@ -0,0 +1,96 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormDoctor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label = new Label(); + TextBoxName = new TextBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + SuspendLayout(); + // + // label + // + label.AutoSize = true; + label.Location = new Point(77, 94); + label.Name = "label"; + label.Size = new Size(45, 20); + label.TabIndex = 0; + label.Text = "ФИО:"; + // + // TextBoxName + // + TextBoxName.Location = new Point(196, 91); + TextBoxName.Name = "TextBoxName"; + TextBoxName.Size = new Size(219, 27); + TextBoxName.TabIndex = 1; + // + // ButtonSave + // + ButtonSave.Location = new Point(77, 278); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 2; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(196, 278); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 3; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // FormDoctor + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(523, 360); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(TextBoxName); + Controls.Add(label); + Name = "FormDoctor"; + StartPosition = FormStartPosition.CenterParent; + Text = "Доктор"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label; + private TextBox TextBoxName; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.cs new file mode 100644 index 0000000..cb3622b --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.cs @@ -0,0 +1,80 @@ +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RegistrationOfPatients.Forms; + +public partial class FormDoctor : Form +{ + private readonly IDoctorRepository _doctorRepository; + private int? _doctorId; + public int Id + { + set + { + try + { + var doctor = _doctorRepository.ReadDoctorById(value); + + if (doctor == null) + { + throw new InvalidDataException(nameof(doctor)); + } + + TextBoxName.Text = doctor.Name; + + _doctorId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormDoctor(IDoctorRepository doctorRepository) + { + InitializeComponent(); + _doctorRepository = doctorRepository ?? throw new ArgumentNullException(nameof(doctorRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(TextBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_doctorId.HasValue) + { + + _doctorRepository.UpdateDoctor(CreateDoctor(_doctorId.Value)); + } + else + { + _doctorRepository.CreateDoctor(CreateDoctor(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Doctor CreateDoctor(int id) => Doctor.CreateEntity(id, TextBoxName.Text); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Form1.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.resx similarity index 92% rename from RegistrationOfPatients/RegistrationOfPatients/Form1.resx rename to RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.resx index 1af7de1..8b2ff64 100644 --- a/RegistrationOfPatients/RegistrationOfPatients/Form1.resx +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctor.resx @@ -1,17 +1,17 @@  - diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.Designer.cs new file mode 100644 index 0000000..5407c35 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormDoctors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(650, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(150, 450); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.minus; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(26, 168); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(94, 60); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.pencil; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(26, 102); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(94, 60); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(26, 36); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(94, 60); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 51; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(650, 450); + dataGridViewData.TabIndex = 1; + // + // FormDoctors + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormDoctors"; + StartPosition = FormStartPosition.CenterParent; + Text = "Доктора"; + Load += FormDoctors_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.cs new file mode 100644 index 0000000..84ebfa7 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.cs @@ -0,0 +1,110 @@ +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace RegistrationOfPatients.Forms; + +public partial class FormDoctors : Form +{ + private readonly IUnityContainer _container; + + private readonly IDoctorRepository _doctorRepository; + + public FormDoctors(IUnityContainer container, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _doctorRepository = doctorRepository ?? throw new ArgumentNullException(nameof(doctorRepository)); + } + + private void FormDoctors_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _doctorRepository.DeleteDoctor(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _doctorRepository.ReadDoctors(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormDoctors.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.Designer.cs new file mode 100644 index 0000000..50c8e8b --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.Designer.cs @@ -0,0 +1,120 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormMedicine + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + checkedListBoxMedicineType = new CheckedListBox(); + label2 = new Label(); + textBoxDescription = new TextBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(56, 45); + label1.Name = "label1"; + label1.Size = new Size(111, 20); + label1.TabIndex = 0; + label1.Text = "Тип лекарства:"; + // + // checkedListBoxMedicineType + // + checkedListBoxMedicineType.FormattingEnabled = true; + checkedListBoxMedicineType.Location = new Point(195, 45); + checkedListBoxMedicineType.Name = "checkedListBoxMedicineType"; + checkedListBoxMedicineType.Size = new Size(247, 114); + checkedListBoxMedicineType.TabIndex = 1; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(65, 190); + label2.Name = "label2"; + label2.Size = new Size(82, 20); + label2.TabIndex = 2; + label2.Text = "Описание:"; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(195, 190); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(247, 72); + textBoxDescription.TabIndex = 3; + // + // ButtonSave + // + ButtonSave.Location = new Point(65, 314); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 4; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(195, 314); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 5; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // FormMedicine + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(593, 421); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(textBoxDescription); + Controls.Add(label2); + Controls.Add(checkedListBoxMedicineType); + Controls.Add(label1); + Name = "FormMedicine"; + StartPosition = FormStartPosition.CenterParent; + Text = "Лекарства"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private CheckedListBox checkedListBoxMedicineType; + private Label label2; + private TextBox textBoxDescription; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.cs new file mode 100644 index 0000000..58fde9e --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.cs @@ -0,0 +1,96 @@ +using Microsoft.VisualBasic.FileIO; +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Entities.Enums; +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RegistrationOfPatients.Forms; + +public partial class FormMedicine : Form +{ + private readonly IMedicineRepository _medicineRepository; + private int? _medicineId; + public int Id + { + set + { + try + { + var medicine = _medicineRepository.ReadMedicineById(value); + if (medicine == null) + { + throw new InvalidDataException(nameof(medicine)); + } + foreach (MedicineType elem in Enum.GetValues(typeof(MedicineType))) + { + if ((elem & medicine.MedicineType) != 0) + { + checkedListBoxMedicineType.SetItemChecked(checkedListBoxMedicineType.Items.IndexOf(elem), true); + } + } + + textBoxDescription.Text = medicine.Description; + _medicineId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormMedicine(IMedicineRepository medicineRepository) + { + InitializeComponent(); + _medicineRepository = medicineRepository ?? throw new ArgumentNullException(nameof(medicineRepository)); + + foreach (var elem in Enum.GetValues(typeof(MedicineType))) + { + checkedListBoxMedicineType.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDescription.Text) || checkedListBoxMedicineType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_medicineId.HasValue) + { + _medicineRepository.UpdateMedicine(CreateMedicine(_medicineId.Value)); + } + else + { + _medicineRepository.CreateMedicine(CreateMedicine(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Medicine CreateMedicine(int id) + { + MedicineType medicineType = MedicineType.None; + foreach (var elem in checkedListBoxMedicineType.CheckedItems) + { + medicineType |= (MedicineType)elem; + } + return Medicine.CreateEntity(id, medicineType, textBoxDescription.Text); + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicine.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.Designer.cs new file mode 100644 index 0000000..dfe0fbe --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormMedicines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(600, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(200, 450); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.minus; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(45, 202); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(94, 69); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.pencil; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(45, 127); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(94, 69); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(45, 52); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(94, 69); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 51; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(600, 450); + dataGridViewData.TabIndex = 1; + // + // FormMedicines + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormMedicines"; + StartPosition = FormStartPosition.CenterParent; + Text = "Лекарства"; + Load += FormMedicines_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.cs new file mode 100644 index 0000000..4743011 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.cs @@ -0,0 +1,107 @@ +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace RegistrationOfPatients.Forms; + +public partial class FormMedicines : Form +{ + private readonly IUnityContainer _container; + + private readonly IMedicineRepository _medicineRepository; + public FormMedicines(IUnityContainer container, IMedicineRepository medicineRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _medicineRepository = medicineRepository ?? throw new ArgumentNullException(nameof(medicineRepository)); + } + + private void FormMedicines_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _medicineRepository.DeleteMedicine(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _medicineRepository.ReadMedicine(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormMedicines.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.Designer.cs new file mode 100644 index 0000000..c905b8a --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.Designer.cs @@ -0,0 +1,118 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormPatient + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + TextBoxName = new TextBox(); + TextBoxNumber = new TextBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(44, 54); + label1.Name = "label1"; + label1.Size = new Size(45, 20); + label1.TabIndex = 0; + label1.Text = "ФИО:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(44, 104); + label2.Name = "label2"; + label2.Size = new Size(130, 20); + label2.TabIndex = 1; + label2.Text = "Номер телефона:"; + // + // TextBoxName + // + TextBoxName.Location = new Point(200, 47); + TextBoxName.Name = "TextBoxName"; + TextBoxName.Size = new Size(191, 27); + TextBoxName.TabIndex = 2; + // + // TextBoxNumber + // + TextBoxNumber.Location = new Point(200, 97); + TextBoxNumber.Name = "TextBoxNumber"; + TextBoxNumber.Size = new Size(191, 27); + TextBoxNumber.TabIndex = 3; + // + // ButtonSave + // + ButtonSave.Location = new Point(44, 190); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 4; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(200, 190); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 5; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // FormPatient + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(422, 334); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(TextBoxNumber); + Controls.Add(TextBoxName); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormPatient"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormPatient"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private TextBox TextBoxName; + private TextBox TextBoxNumber; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.cs new file mode 100644 index 0000000..e47a44a --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.cs @@ -0,0 +1,81 @@ +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RegistrationOfPatients.Forms; + +public partial class FormPatient : Form +{ + private readonly IPatientRepository _patientRepository; + + private int? _patientId; + public int Id + { + set + { + try + { + var patient = _patientRepository.ReadPatientById(value); + if (patient == null) + { + throw new InvalidDataException(nameof(patient)); + } + + TextBoxName.Text = patient.Name; + TextBoxNumber.Text = patient.Phone; + _patientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormPatient(IPatientRepository patientRepository) + { + InitializeComponent(); + _patientRepository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(TextBoxName.Text) || string.IsNullOrWhiteSpace(TextBoxNumber.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_patientId.HasValue) + { + + _patientRepository.UpdatePatient(CreatePatient(_patientId.Value)); + } + else + { + + _patientRepository.CreatePatient(CreatePatient(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Patient CreatePatient(int id) => Patient.CreateEntity(id, TextBoxName.Text, TextBoxNumber.Text); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatient.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.Designer.cs new file mode 100644 index 0000000..11c3efb --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormPatients + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(625, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(175, 450); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.minus; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(40, 173); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(94, 62); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.pencil; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(40, 105); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(94, 62); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(40, 37); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(94, 62); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 51; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(625, 450); + dataGridViewData.TabIndex = 1; + // + // FormPatients + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormPatients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Пациенты"; + Load += FormPatients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.cs new file mode 100644 index 0000000..5a445be --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.cs @@ -0,0 +1,109 @@ +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace RegistrationOfPatients.Forms; + +public partial class FormPatients : Form +{ + private readonly IUnityContainer _container; + + private readonly IPatientRepository _patientRepository; + public FormPatients(IUnityContainer container, IPatientRepository patientRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _patientRepository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); + } + + private void FormPatients_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _patientRepository.DeletePatient(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _patientRepository.ReadPatients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPatients.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.Designer.cs new file mode 100644 index 0000000..8f873ac --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.Designer.cs @@ -0,0 +1,192 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormPayment + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + comboBoxDoctor = new ComboBox(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + dateTimePickerPayment = new DateTimePicker(); + label5 = new Label(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + numericUpDownSalary = new NumericUpDown(); + numericUpDownTotalPatients = new NumericUpDown(); + numericUpDownPercentage = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSalary).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownTotalPatients).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPercentage).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 49); + label1.Name = "label1"; + label1.Size = new Size(62, 20); + label1.TabIndex = 0; + label1.Text = "Доктор:"; + // + // comboBoxDoctor + // + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(235, 46); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(178, 28); + comboBoxDoctor.TabIndex = 1; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 104); + label2.Name = "label2"; + label2.Size = new Size(76, 20); + label2.TabIndex = 2; + label2.Text = "Зарплата:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 155); + label3.Name = "label3"; + label3.Size = new Size(130, 20); + label3.TabIndex = 4; + label3.Text = "Всего пациентов:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(12, 201); + label4.Name = "label4"; + label4.Size = new Size(189, 20); + label4.TabIndex = 6; + label4.Text = "Процент выздоровлений:"; + // + // dateTimePickerPayment + // + dateTimePickerPayment.Enabled = false; + dateTimePickerPayment.Location = new Point(235, 238); + dateTimePickerPayment.Name = "dateTimePickerPayment"; + dateTimePickerPayment.Size = new Size(178, 27); + dateTimePickerPayment.TabIndex = 7; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(12, 243); + label5.Name = "label5"; + label5.Size = new Size(44, 20); + label5.TabIndex = 8; + label5.Text = "Дата:"; + // + // ButtonSave + // + ButtonSave.Location = new Point(62, 398); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 10; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(249, 398); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 11; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // numericUpDownSalary + // + numericUpDownSalary.Location = new Point(235, 102); + numericUpDownSalary.Name = "numericUpDownSalary"; + numericUpDownSalary.Size = new Size(178, 27); + numericUpDownSalary.TabIndex = 12; + // + // numericUpDownTotalPatients + // + numericUpDownTotalPatients.Location = new Point(235, 153); + numericUpDownTotalPatients.Name = "numericUpDownTotalPatients"; + numericUpDownTotalPatients.Size = new Size(178, 27); + numericUpDownTotalPatients.TabIndex = 13; + // + // numericUpDownPercentage + // + numericUpDownPercentage.Location = new Point(235, 199); + numericUpDownPercentage.Name = "numericUpDownPercentage"; + numericUpDownPercentage.Size = new Size(178, 27); + numericUpDownPercentage.TabIndex = 14; + // + // FormPayment + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(441, 487); + Controls.Add(numericUpDownPercentage); + Controls.Add(numericUpDownTotalPatients); + Controls.Add(numericUpDownSalary); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(label5); + Controls.Add(dateTimePickerPayment); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(comboBoxDoctor); + Controls.Add(label1); + Name = "FormPayment"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormPayment"; + ((System.ComponentModel.ISupportInitialize)numericUpDownSalary).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownTotalPatients).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPercentage).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private ComboBox comboBoxDoctor; + private Label label2; + private Label label3; + private Label label4; + private DateTimePicker dateTimePickerPayment; + private Label label5; + private Button ButtonSave; + private Button ButtonCancel; + private NumericUpDown numericUpDownSalary; + private NumericUpDown numericUpDownTotalPatients; + private NumericUpDown numericUpDownPercentage; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.cs new file mode 100644 index 0000000..2064d70 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.cs @@ -0,0 +1,51 @@ +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Entities.Enums; +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; + +namespace RegistrationOfPatients.Forms; + +public partial class FormPayment : Form +{ + private readonly IPaymentRepository _paymentRepository; + + private int? _paymentId; + public FormPayment(IPaymentRepository paymentRepository, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _paymentRepository = paymentRepository ?? throw new ArgumentNullException(nameof(paymentRepository)); + + comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "DoctorName"; + comboBoxDoctor.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxDoctor.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _paymentRepository.CreatePayment(Payment.CreateOperation(0, Convert.ToInt32(numericUpDownSalary.Value), Convert.ToInt32(numericUpDownTotalPatients.Value), dateTimePickerPayment.Value, Convert.ToInt32(numericUpDownPercentage.Value), (int)comboBoxDoctor.SelectedValue!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayment.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.Designer.cs new file mode 100644 index 0000000..4aa57ea --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.Designer.cs @@ -0,0 +1,113 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormPayments + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + ButtonDel = new Button(); + ButtonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(703, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 429); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.minus; + ButtonDel.BackgroundImageLayout = ImageLayout.Zoom; + ButtonDel.Location = new Point(23, 107); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(94, 68); + ButtonDel.TabIndex = 1; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Zoom; + ButtonAdd.Location = new Point(23, 33); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(94, 68); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 51; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(703, 429); + dataGridViewData.TabIndex = 1; + // + // FormPayments + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(836, 429); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormPayments"; + StartPosition = FormStartPosition.CenterParent; + Text = "Зарплаты"; + Load += FormPayments_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.cs new file mode 100644 index 0000000..fa5239b --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.cs @@ -0,0 +1,86 @@ +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace RegistrationOfPatients.Forms; + +public partial class FormPayments : Form +{ + private readonly IUnityContainer _container; + + private readonly IPaymentRepository _paymentRepository; + public FormPayments(IUnityContainer container, IPaymentRepository paymentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _paymentRepository = paymentRepository ?? throw new ArgumentNullException(nameof(paymentRepository)); + } + + private void FormPayments_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _paymentRepository.DeletePayment(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _paymentRepository.ReadPayment(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormPayments.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.Designer.cs new file mode 100644 index 0000000..aa48e19 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.Designer.cs @@ -0,0 +1,245 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormReception + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + comboBoxStatus = new ComboBox(); + comboBoxPatient = new ComboBox(); + comboBoxDoctor = new ComboBox(); + textBoxIllness = new TextBox(); + label3 = new Label(); + label4 = new Label(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + groupBoxMedicine = new GroupBox(); + dataGridViewMedicines = new DataGridView(); + Column1 = new DataGridViewComboBoxColumn(); + Column2 = new DataGridViewTextBoxColumn(); + label5 = new Label(); + dateTimePickerReception = new DateTimePicker(); + groupBoxMedicine.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewMedicines).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(69, 15); + label1.Name = "label1"; + label1.Size = new Size(156, 20); + label1.TabIndex = 0; + label1.Text = "Состояние здоровья:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(69, 67); + label2.Name = "label2"; + label2.Size = new Size(70, 20); + label2.TabIndex = 1; + label2.Text = "Болезнь:"; + // + // comboBoxStatus + // + comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStatus.FormattingEnabled = true; + comboBoxStatus.Location = new Point(276, 12); + comboBoxStatus.Name = "comboBoxStatus"; + comboBoxStatus.Size = new Size(178, 28); + comboBoxStatus.TabIndex = 2; + // + // comboBoxPatient + // + comboBoxPatient.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPatient.FormattingEnabled = true; + comboBoxPatient.Location = new Point(276, 107); + comboBoxPatient.Name = "comboBoxPatient"; + comboBoxPatient.Size = new Size(178, 28); + comboBoxPatient.TabIndex = 3; + // + // comboBoxDoctor + // + comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(276, 159); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(178, 28); + comboBoxDoctor.TabIndex = 4; + // + // textBoxIllness + // + textBoxIllness.Location = new Point(276, 60); + textBoxIllness.Name = "textBoxIllness"; + textBoxIllness.Size = new Size(178, 27); + textBoxIllness.TabIndex = 5; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(69, 167); + label3.Name = "label3"; + label3.Size = new Size(62, 20); + label3.TabIndex = 7; + label3.Text = "Доктор:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(69, 115); + label4.Name = "label4"; + label4.Size = new Size(72, 20); + label4.TabIndex = 6; + label4.Text = "Пациент:"; + // + // ButtonSave + // + ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + ButtonSave.Location = new Point(70, 452); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 8; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonCancel.Location = new Point(251, 452); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 9; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // groupBoxMedicine + // + groupBoxMedicine.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxMedicine.Controls.Add(dataGridViewMedicines); + groupBoxMedicine.Location = new Point(70, 274); + groupBoxMedicine.Name = "groupBoxMedicine"; + groupBoxMedicine.Size = new Size(279, 172); + groupBoxMedicine.TabIndex = 10; + groupBoxMedicine.TabStop = false; + groupBoxMedicine.Text = "Лекарства"; + // + // dataGridViewMedicines + // + dataGridViewMedicines.AllowUserToResizeColumns = false; + dataGridViewMedicines.AllowUserToResizeRows = false; + dataGridViewMedicines.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewMedicines.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewMedicines.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewMedicines.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2 }); + dataGridViewMedicines.Location = new Point(3, 23); + dataGridViewMedicines.MultiSelect = false; + dataGridViewMedicines.Name = "dataGridViewMedicines"; + dataGridViewMedicines.RowHeadersVisible = false; + dataGridViewMedicines.RowHeadersWidth = 51; + dataGridViewMedicines.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewMedicines.Size = new Size(276, 121); + dataGridViewMedicines.TabIndex = 0; + // + // Column1 + // + Column1.HeaderText = "Лекарство"; + Column1.MinimumWidth = 6; + Column1.Name = "Column1"; + // + // Column2 + // + Column2.HeaderText = "Количество"; + Column2.MinimumWidth = 6; + Column2.Name = "Column2"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(69, 214); + label5.Name = "label5"; + label5.Size = new Size(44, 20); + label5.TabIndex = 11; + label5.Text = "Дата:"; + // + // dateTimePickerReception + // + dateTimePickerReception.Enabled = false; + dateTimePickerReception.Location = new Point(276, 214); + dateTimePickerReception.Name = "dateTimePickerReception"; + dateTimePickerReception.Size = new Size(178, 27); + dateTimePickerReception.TabIndex = 12; + // + // FormReception + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(486, 493); + Controls.Add(dateTimePickerReception); + Controls.Add(label5); + Controls.Add(groupBoxMedicine); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(label3); + Controls.Add(label4); + Controls.Add(textBoxIllness); + Controls.Add(comboBoxDoctor); + Controls.Add(comboBoxPatient); + Controls.Add(comboBoxStatus); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormReception"; + Text = "FormReception"; + groupBoxMedicine.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewMedicines).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private ComboBox comboBoxStatus; + private ComboBox comboBoxPatient; + private ComboBox comboBoxDoctor; + private TextBox textBoxIllness; + private Label label3; + private Label label4; + private Button ButtonSave; + private Button ButtonCancel; + private GroupBox groupBoxMedicine; + private DataGridView dataGridViewMedicines; + private DataGridViewComboBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private Label label5; + private DateTimePicker dateTimePickerReception; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.cs new file mode 100644 index 0000000..be55d42 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.cs @@ -0,0 +1,71 @@ +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Entities.Enums; +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RegistrationOfPatients.Forms; + +public partial class FormReception : Form +{ + private readonly IReceptionRepository _receptionRepository; + + private int? _receptionId; + + public FormReception(IReceptionRepository receptionRepository, IPatientRepository patientRepository, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _receptionRepository = receptionRepository ?? throw new ArgumentNullException(nameof(receptionRepository)); + + comboBoxStatus.DataSource = Enum.GetValues(typeof(HealthStatus)); + + comboBoxPatient.DataSource = patientRepository.ReadPatients(); + comboBoxPatient.DisplayMember = "Name"; + comboBoxPatient.ValueMember = "Id"; + + comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "DoctorName"; + comboBoxDoctor.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxPatient.SelectedIndex < 0 || string.IsNullOrWhiteSpace(textBoxIllness.Text) || comboBoxStatus.SelectedIndex < 0 || comboBoxDoctor.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _receptionRepository.CreateReception(Reception.CreateOperation(0, dateTimePickerReception.Value, (HealthStatus)comboBoxStatus.SelectedItem!, textBoxIllness.Text, (int)comboBoxPatient.SelectedValue!, (int)comboBoxDoctor.SelectedValue!, CreateListReceptionMedicineFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListReceptionMedicineFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewMedicines.Rows) + { + if (row.Cells["ColumnFeed"].Value == null || row.Cells["ColumnCount"].Value == null) + { + continue; + } + list.Add(ReceptionMedicine.CreateElement(0, Convert.ToInt32(row.Cells["ColumnFeed"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.resx new file mode 100644 index 0000000..59d37f1 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReception.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.Designer.cs new file mode 100644 index 0000000..3b1c018 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.Designer.cs @@ -0,0 +1,99 @@ +namespace RegistrationOfPatients.Forms +{ + partial class FormReceptions + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(639, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(161, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(31, 49); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 65); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.RowHeadersWidth = 51; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(639, 450); + dataGridViewData.TabIndex = 1; + // + // FormReceptions + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormReceptions"; + StartPosition = FormStartPosition.CenterParent; + Text = "Прием"; + Load += FormReceptions_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.cs b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.cs new file mode 100644 index 0000000..f7edde8 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.cs @@ -0,0 +1,52 @@ +using RegistrationOfPatients.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace RegistrationOfPatients.Forms; + +public partial class FormReceptions : Form +{ + private readonly IUnityContainer _container; + + private readonly IReceptionRepository _receptionRepository; + public FormReceptions(IUnityContainer container, IReceptionRepository receptionRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _receptionRepository = receptionRepository ?? throw new ArgumentNullException(nameof(receptionRepository)); + } + + private void FormReceptions_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _receptionRepository.ReadReceptions(); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.resx b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptions.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Program.cs b/RegistrationOfPatients/RegistrationOfPatients/Program.cs index b4de88e..d202395 100644 --- a/RegistrationOfPatients/RegistrationOfPatients/Program.cs +++ b/RegistrationOfPatients/RegistrationOfPatients/Program.cs @@ -1,3 +1,8 @@ +using RegistrationOfPatients.Repositories; +using RegistrationOfPatients.Repositories.Implementations; +using Unity; +using Unity.Lifetime; + namespace RegistrationOfPatients { internal static class Program @@ -11,7 +16,20 @@ namespace RegistrationOfPatients // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + + return container; } } } \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.Designer.cs b/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3c2ce24 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace RegistrationOfPatients.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RegistrationOfPatients.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap add { + get { + object obj = ResourceManager.GetObject("add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pencil { + get { + object obj = ResourceManager.GetObject("pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap polyclinic { + get { + object obj = ResourceManager.GetObject("polyclinic", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.resx b/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.resx new file mode 100644 index 0000000..56b123d --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\polyclinic.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pencil.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/RegistrationOfPatients.csproj b/RegistrationOfPatients/RegistrationOfPatients/RegistrationOfPatients.csproj index e1a0735..accbdf0 100644 --- a/RegistrationOfPatients/RegistrationOfPatients/RegistrationOfPatients.csproj +++ b/RegistrationOfPatients/RegistrationOfPatients/RegistrationOfPatients.csproj @@ -2,10 +2,29 @@ WinExe - net7.0-windows + net8.0-windows enable true enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/IDoctorRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IDoctorRepository.cs new file mode 100644 index 0000000..1928a86 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IDoctorRepository.cs @@ -0,0 +1,21 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories; + +public interface IDoctorRepository +{ + IEnumerable ReadDoctors(); + + Doctor ReadDoctorById(int id); + + void CreateDoctor(Doctor doctor); + + void UpdateDoctor(Doctor doctor); + + void DeleteDoctor(int id); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/IMedicineRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IMedicineRepository.cs new file mode 100644 index 0000000..26e940c --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IMedicineRepository.cs @@ -0,0 +1,16 @@ +using RegistrationOfPatients.Entities; + +namespace RegistrationOfPatients.Repositories; + +public interface IMedicineRepository +{ + IEnumerable ReadMedicine(); + + Medicine ReadMedicineById(int id); + + void CreateMedicine(Medicine medicine); + + void UpdateMedicine(Medicine medicine); + + void DeleteMedicine(int id); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPatientRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPatientRepository.cs new file mode 100644 index 0000000..554062c --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPatientRepository.cs @@ -0,0 +1,16 @@ +using RegistrationOfPatients.Entities; + +namespace RegistrationOfPatients.Repositories; + +public interface IPatientRepository +{ + IEnumerable ReadPatients(); + + Patient ReadPatientById(int id); + + void CreatePatient(Patient patient); + + void UpdatePatient(Patient patient); + + void DeletePatient(int id); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPaymentRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPaymentRepository.cs new file mode 100644 index 0000000..6934080 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IPaymentRepository.cs @@ -0,0 +1,17 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories; + +public interface IPaymentRepository +{ + IEnumerable ReadPayment(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null); + + void CreatePayment(Payment payment); + + void DeletePayment(int id); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/IReceptionRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IReceptionRepository.cs new file mode 100644 index 0000000..3c12361 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/IReceptionRepository.cs @@ -0,0 +1,10 @@ +using RegistrationOfPatients.Entities; + +namespace RegistrationOfPatients.Repositories; + +public interface IReceptionRepository +{ + IEnumerable ReadReceptions(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null, int? patientId = null, int? medicineId = null); + + void CreateReception(Reception reception); +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/DoctorRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/DoctorRepository.cs new file mode 100644 index 0000000..f5af473 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/DoctorRepository.cs @@ -0,0 +1,36 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories.Implementations; + +public class DoctorRepository : IDoctorRepository +{ + public void CreateDoctor(Doctor doctor) + { + + } + + public void DeleteDoctor(int id) + { + + } + + public IEnumerable ReadDoctors() + { + return []; + } + + public Doctor ReadDoctorById(int id) + { + return Doctor.CreateEntity(0, string.Empty); + } + + public void UpdateDoctor(Doctor doctor) + { + + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/MedicineRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/MedicineRepository.cs new file mode 100644 index 0000000..cf3ac58 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/MedicineRepository.cs @@ -0,0 +1,30 @@ +using Microsoft.VisualBasic.FileIO; +using RegistrationOfPatients.Entities; +using RegistrationOfPatients.Entities.Enums; + +namespace RegistrationOfPatients.Repositories.Implementations; + +public class MedicineRepository : IMedicineRepository +{ + public void CreateMedicine(Medicine medicine) + { + } + + public void DeleteMedicine(int id) + { + } + + public Medicine ReadMedicineById(int id) + { + return Medicine.CreateEntity(0, MedicineType.None, string.Empty); + } + + public IEnumerable ReadMedicine() + { + return []; + } + + public void UpdateMedicine(Medicine medicine) + { + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PatientRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PatientRepository.cs new file mode 100644 index 0000000..43cbf64 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PatientRepository.cs @@ -0,0 +1,36 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories.Implementations; + +internal class PatientRepository : IPatientRepository +{ + public void CreatePatient(Patient patient) + { + + } + + public void DeletePatient(int id) + { + + } + + public IEnumerable ReadPatients() + { + return []; + } + + public Patient ReadPatientById(int id) + { + return Patient.CreateEntity(0, string.Empty, string.Empty); + } + + public void UpdatePatient(Patient patient) + { + + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PaymentRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PaymentRepository.cs new file mode 100644 index 0000000..34c8595 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/PaymentRepository.cs @@ -0,0 +1,26 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories.Implementations; + +public class PaymentRepository : IPaymentRepository +{ + public void CreatePayment(Payment payment) + { + + } + + public void DeletePayment(int id) + { + + } + + public IEnumerable ReadPayment(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null) + { + return []; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/ReceptionRepository.cs b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/ReceptionRepository.cs new file mode 100644 index 0000000..c92c4a0 --- /dev/null +++ b/RegistrationOfPatients/RegistrationOfPatients/Repositories/Implementations/ReceptionRepository.cs @@ -0,0 +1,20 @@ +using RegistrationOfPatients.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationOfPatients.Repositories.Implementations; + +public class ReceptionRepository : IReceptionRepository +{ + public void CreateReception(Reception reception) + { + } + + public IEnumerable ReadReceptions(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null, int? patientId = null, int? medicineId = null) + { + return []; + } +} diff --git a/RegistrationOfPatients/RegistrationOfPatients/Resources/add.png b/RegistrationOfPatients/RegistrationOfPatients/Resources/add.png new file mode 100644 index 0000000..7689610 Binary files /dev/null and b/RegistrationOfPatients/RegistrationOfPatients/Resources/add.png differ diff --git a/RegistrationOfPatients/RegistrationOfPatients/Resources/minus.jpg b/RegistrationOfPatients/RegistrationOfPatients/Resources/minus.jpg new file mode 100644 index 0000000..7644885 Binary files /dev/null and b/RegistrationOfPatients/RegistrationOfPatients/Resources/minus.jpg differ diff --git a/RegistrationOfPatients/RegistrationOfPatients/Resources/pencil.jpg b/RegistrationOfPatients/RegistrationOfPatients/Resources/pencil.jpg new file mode 100644 index 0000000..d592328 Binary files /dev/null and b/RegistrationOfPatients/RegistrationOfPatients/Resources/pencil.jpg differ diff --git a/RegistrationOfPatients/RegistrationOfPatients/Resources/polyclinic.jpg b/RegistrationOfPatients/RegistrationOfPatients/Resources/polyclinic.jpg new file mode 100644 index 0000000..dd1b643 Binary files /dev/null and b/RegistrationOfPatients/RegistrationOfPatients/Resources/polyclinic.jpg differ