diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Drug.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Drug.cs new file mode 100644 index 0000000..d9be20a --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Drug.cs @@ -0,0 +1,30 @@ +using RegistrationPatientsPolyclinic.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Entities; + +public class Drug // Наподобие Feed +{ + public int Id { get; private set; } + + public DrugName DrugName { get; private set; } + + public int Grams { get; private set; } + + public string Description { get; private set; } = string.Empty; + + public static Drug CreateElement(int id, DrugName name, int grams, string description) + { + return new Drug + { + Id = id, + DrugName = name, + Grams = grams, + Description = description ?? string.Empty + }; + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/DrugMedicalHistory.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/DrugMedicalHistory.cs new file mode 100644 index 0000000..0745d4f --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/DrugMedicalHistory.cs @@ -0,0 +1,30 @@ +using RegistrationPatientsPolyclinic.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Entities; + +public class DrugMedicalHistory // Тоже самое что FeedFeedRepleshments +{ + public int Id { get; private set; } + + public int DrugId { get; private set; } + + //public int MedicalHistoryId { get; private set; } + + //public string Description { get; private set; } + + public static DrugMedicalHistory CreateEntity(int id, int drugId) + { + return new DrugMedicalHistory + { + Id = id, + DrugId = drugId, + // MedicalHistoryId = medicalHistoryId, + // Description = description + }; + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/Diagnosis.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/Diagnosis.cs index cfe2c06..d9f3ee4 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/Diagnosis.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/Diagnosis.cs @@ -10,16 +10,16 @@ namespace RegistrationPatientsPolyclinic.Entities.Enums; // то его поле DoctorPost, то мы в него занесем только один из возможных вариантов(None, Junior, Senior, Head) // а по атрибуту Flags позволяет хранить несколько записей // ВАЖНО!!! Чтобы в перечеслении значения были степени двойки - +// битовое объединение public enum Diagnosis { - None = 0, + None = 0, - Flu = 1, + Flu = 1, // 0001 - Quinsy = 2, - - Callous = 4, - - Bronchitis = 8 + Quinsy = 2, // 0010 + + Callous = 4, // 0100 + + Bronchitis = 8 // 1000 } diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/DrugName.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/DrugName.cs new file mode 100644 index 0000000..cdc0624 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Enums/DrugName.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Entities.Enums; +[Flags] +public enum DrugName +{ + None = 0, + + Synopret = 1, + + Pentalginum = 2, + + Paracetamol = 4, + + Citrine = 8, + + Tonsilgon = 16 +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/MedicalHistory.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/MedicalHistory.cs index 175c7e1..e15c2e2 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/MedicalHistory.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/MedicalHistory.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace RegistrationPatientsPolyclinic.Entities; -public class MedicalHistory +public class MedicalHistory // сущность пополнения, наподобие FeedReplenushment { public int Id { get; private set; } @@ -15,22 +15,26 @@ public class MedicalHistory public int DoctorId { get; private set; } - public Diagnosis Diagnosis { get; private set; } + // public Diagnosis Diagnosis { get; private set; } public DateTime VisitDate { get; private set; } - public Status Status { get; private set; } + // public Status Status { get; private set; } - public static MedicalHistory CreateEntity(int id, int patientId,int doctorId,Diagnosis diagnosis, int visitData, Status status) + public IEnumerable DrugMedicalHistory { get; private set; } = []; + + public static MedicalHistory CreateEntity(int id, int patientId,int doctorId, + IEnumerable drugMedicalHistory) { return new MedicalHistory { Id = id, PatientId = patientId, DoctorId = doctorId, - Diagnosis = diagnosis, + // Diagnosis = diagnosis, VisitDate = DateTime.Now, - Status = status + // Status = status, + DrugMedicalHistory = drugMedicalHistory }; } } diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Patient.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Patient.cs index fe03a4b..2ab6bfa 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Patient.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Entities/Patient.cs @@ -17,9 +17,9 @@ public class Patient public string ContactNumber { get; private set; } - // ТУТ СДЕЛАЕМ СТАТИСТИЧЕСКИЙ МЕТОД + // ТУТ СДЕЛАЕМ СТАТИСТИЧЕСКИЙ МЕТОД, который будет отвечать за создание объекта - public static Patient CreatePatient(int id, string firts_Name, string last_Name, string contactNumber) + public static Patient CreateEntity(int id, string firts_Name, string last_Name, string contactNumber) { return new Patient { diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.Designer.cs deleted file mode 100644 index 26dd054..0000000 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace RegistrationPatientsPolyclinic -{ - 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 - } -} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.cs deleted file mode 100644 index 5c74e1c..0000000 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace RegistrationPatientsPolyclinic -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.Designer.cs new file mode 100644 index 0000000..e43a861 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.Designer.cs @@ -0,0 +1,156 @@ +namespace RegistrationPatientsPolyclinic +{ + partial class FormPolyclinic + { + /// + /// 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(); + HandBookToolStripMenuItem = new ToolStripMenuItem(); + DoctorsToolStripMenuItem = new ToolStripMenuItem(); + PacientToolStripMenuItem = new ToolStripMenuItem(); + MedicalHistoryToolStripMenuItem = new ToolStripMenuItem(); + DoctorPaymentsToolStripMenuItem = new ToolStripMenuItem(); + DrugToolStripMenuItem = new ToolStripMenuItem(); + OperationToolStripMenuItem = new ToolStripMenuItem(); + DoctorPaymentToolStripMenuItem = new ToolStripMenuItem(); + DiseaseRegistrationToolStripMenuItem = new ToolStripMenuItem(); + ReportToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { HandBookToolStripMenuItem, OperationToolStripMenuItem, ReportToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(782, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // HandBookToolStripMenuItem + // + HandBookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DoctorsToolStripMenuItem, PacientToolStripMenuItem, MedicalHistoryToolStripMenuItem, DoctorPaymentsToolStripMenuItem, DrugToolStripMenuItem }); + HandBookToolStripMenuItem.Name = "HandBookToolStripMenuItem"; + HandBookToolStripMenuItem.Size = new Size(117, 24); + HandBookToolStripMenuItem.Text = "Справочники"; + // + // DoctorsToolStripMenuItem + // + DoctorsToolStripMenuItem.Name = "DoctorsToolStripMenuItem"; + DoctorsToolStripMenuItem.Size = new Size(248, 26); + DoctorsToolStripMenuItem.Text = "Врачи"; + DoctorsToolStripMenuItem.Click += DoctorsToolStripMenuItem_Click; + // + // PacientToolStripMenuItem + // + PacientToolStripMenuItem.Name = "PacientToolStripMenuItem"; + PacientToolStripMenuItem.Size = new Size(248, 26); + PacientToolStripMenuItem.Text = "Пациенты"; + PacientToolStripMenuItem.Click += PacientToolStripMenuItem_Click; + // + // MedicalHistoryToolStripMenuItem + // + MedicalHistoryToolStripMenuItem.Name = "MedicalHistoryToolStripMenuItem"; + MedicalHistoryToolStripMenuItem.Size = new Size(248, 26); + MedicalHistoryToolStripMenuItem.Text = "Медицинская история"; + MedicalHistoryToolStripMenuItem.Click += MedicalHistoryToolStripMenuItem_Click; + // + // DoctorPaymentsToolStripMenuItem + // + DoctorPaymentsToolStripMenuItem.Name = "DoctorPaymentsToolStripMenuItem"; + DoctorPaymentsToolStripMenuItem.Size = new Size(248, 26); + DoctorPaymentsToolStripMenuItem.Text = "Оплата Врачам"; + DoctorPaymentsToolStripMenuItem.Click += DoctorPaymentsToolStripMenuItem_Click; + // + // DrugToolStripMenuItem + // + DrugToolStripMenuItem.Name = "DrugToolStripMenuItem"; + DrugToolStripMenuItem.Size = new Size(248, 26); + DrugToolStripMenuItem.Text = "Лекарство"; + DrugToolStripMenuItem.Click += DrugToolStripMenuItem_Click; + // + // OperationToolStripMenuItem + // + OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DoctorPaymentToolStripMenuItem, DiseaseRegistrationToolStripMenuItem }); + OperationToolStripMenuItem.Name = "OperationToolStripMenuItem"; + OperationToolStripMenuItem.Size = new Size(95, 24); + OperationToolStripMenuItem.Text = "Операции"; + // + // DoctorPaymentToolStripMenuItem + // + DoctorPaymentToolStripMenuItem.Name = "DoctorPaymentToolStripMenuItem"; + DoctorPaymentToolStripMenuItem.Size = new Size(186, 26); + DoctorPaymentToolStripMenuItem.Text = "Оплата врачу"; + DoctorPaymentToolStripMenuItem.Click += DoctorPaymentToolStripMenuItem_Click; + // + // DiseaseRegistrationToolStripMenuItem + // + DiseaseRegistrationToolStripMenuItem.Name = "DiseaseRegistrationToolStripMenuItem"; + DiseaseRegistrationToolStripMenuItem.Size = new Size(186, 26); + DiseaseRegistrationToolStripMenuItem.Text = "Учет болезни"; + DiseaseRegistrationToolStripMenuItem.Click += DiseaseRegistrationToolStripMenuItem_Click; + // + // ReportToolStripMenuItem + // + ReportToolStripMenuItem.Name = "ReportToolStripMenuItem"; + ReportToolStripMenuItem.Size = new Size(73, 24); + ReportToolStripMenuItem.Text = "Отчеты"; + // + // FormPolyclinic + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.og_og_1643042666277656852; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(782, 403); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormPolyclinic"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Поликлиника"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem HandBookToolStripMenuItem; + private ToolStripMenuItem OperationToolStripMenuItem; + private ToolStripMenuItem DoctorsToolStripMenuItem; + private ToolStripMenuItem PacientToolStripMenuItem; + private ToolStripMenuItem MedicalHistoryToolStripMenuItem; + private ToolStripMenuItem DoctorPaymentsToolStripMenuItem; + private ToolStripMenuItem ReportToolStripMenuItem; + private ToolStripMenuItem DoctorPaymentToolStripMenuItem; + private ToolStripMenuItem DiseaseRegistrationToolStripMenuItem; + private ToolStripMenuItem DrugToolStripMenuItem; + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.cs new file mode 100644 index 0000000..87db6dc --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.cs @@ -0,0 +1,94 @@ +using RegistrationPatientsPolyclinic.Forms; +using Unity; + +namespace RegistrationPatientsPolyclinic +{ + public partial class FormPolyclinic : Form + { + private readonly IUnityContainer _container; + public FormPolyclinic(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 PacientToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void MedicalHistoryToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DoctorPaymentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DoctorPaymentToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DiseaseRegistrationToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void DrugToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/FormPolyclinic.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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.Designer.cs new file mode 100644 index 0000000..d1582fc --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.Designer.cs @@ -0,0 +1,141 @@ +namespace RegistrationPatientsPolyclinic.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() + { + comboBoxPost = new ComboBox(); + labelFirstName = new Label(); + labelLastName = new Label(); + labelPost = new Label(); + textBoxFirstName = new TextBox(); + textBoxLastName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxPost + // + comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPost.FormattingEnabled = true; + comboBoxPost.Location = new Point(119, 144); + comboBoxPost.Name = "comboBoxPost"; + comboBoxPost.Size = new Size(125, 28); + comboBoxPost.TabIndex = 0; + // + // labelFirstName + // + labelFirstName.AutoSize = true; + labelFirstName.Location = new Point(12, 40); + labelFirstName.Name = "labelFirstName"; + labelFirstName.Size = new Size(39, 20); + labelFirstName.TabIndex = 1; + labelFirstName.Text = "Имя"; + // + // labelLastName + // + labelLastName.AutoSize = true; + labelLastName.Location = new Point(12, 91); + labelLastName.Name = "labelLastName"; + labelLastName.Size = new Size(73, 20); + labelLastName.TabIndex = 2; + labelLastName.Text = "Фамилия"; + // + // labelPost + // + labelPost.AutoSize = true; + labelPost.Location = new Point(12, 144); + labelPost.Name = "labelPost"; + labelPost.Size = new Size(86, 20); + labelPost.TabIndex = 3; + labelPost.Text = "Должность"; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(119, 40); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(125, 27); + textBoxFirstName.TabIndex = 4; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(119, 91); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(125, 27); + textBoxLastName.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(12, 230); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 7; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(150, 230); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 8; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormDoctor + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxLastName); + Controls.Add(textBoxFirstName); + Controls.Add(labelPost); + Controls.Add(labelLastName); + Controls.Add(labelFirstName); + Controls.Add(comboBoxPost); + Name = "FormDoctor"; + Text = "Доктор"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxPost; + private Label labelFirstName; + private Label labelLastName; + private Label labelPost; + private TextBox textBoxFirstName; + private TextBox textBoxLastName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.cs new file mode 100644 index 0000000..6965cc6 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.cs @@ -0,0 +1,91 @@ +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Entities.Enums; +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDoctor : Form + { + // Понадобиться интерфейс работника + // так же будет сеттер с id + + 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)); + } + textBoxFirstName.Text = doctor.First_Name; + textBoxLastName.Text = doctor.Last_Name; + comboBoxPost.SelectedItem = doctor.DoctorPost; + _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)); + + comboBoxPost.DataSource = Enum.GetValues(typeof(DoctorPost)); // вытащи значение из этого перечисления, вернет массив строк, т.е. массив тпеих элементов(DoctorPost) + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || + comboBoxPost.SelectedIndex < 1) + { + 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, textBoxFirstName.Text, textBoxLastName.Text, (DoctorPost)comboBoxPost.SelectedItem!); + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.resx similarity index 92% rename from RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.resx rename to RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.resx index 1af7de1..8b2ff64 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Form1.resx +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctor.resx @@ -1,17 +1,17 @@  - diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.Designer.cs new file mode 100644 index 0000000..5f4e2a8 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.Designer.cs @@ -0,0 +1,164 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormDoctorPayment + { + /// + /// 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() + { + labelDoctor = new Label(); + comboBoxDoctor = new ComboBox(); + groupBox = new GroupBox(); + dataGridViewPayment = new DataGridView(); + ColumnMonth = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ColumnPayment = new DataGridViewTextBoxColumn(); + buttonSave = new Button(); + buttonCancel = new Button(); + groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewPayment).BeginInit(); + SuspendLayout(); + // + // labelDoctor + // + labelDoctor.AutoSize = true; + labelDoctor.Location = new Point(30, 21); + labelDoctor.Name = "labelDoctor"; + labelDoctor.Size = new Size(59, 20); + labelDoctor.TabIndex = 13; + labelDoctor.Text = "Доктор"; + // + // comboBoxDoctor + // + comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(112, 21); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(151, 28); + comboBoxDoctor.TabIndex = 12; + // + // groupBox + // + groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox.Controls.Add(dataGridViewPayment); + groupBox.Location = new Point(13, 72); + groupBox.Name = "groupBox"; + groupBox.Size = new Size(610, 282); + groupBox.TabIndex = 14; + groupBox.TabStop = false; + groupBox.Text = "groupBox"; + // + // dataGridViewPayment + // + dataGridViewPayment.AllowUserToResizeColumns = false; + dataGridViewPayment.AllowUserToResizeRows = false; + dataGridViewPayment.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewPayment.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewPayment.Columns.AddRange(new DataGridViewColumn[] { ColumnMonth, ColumnCount, ColumnPayment }); + dataGridViewPayment.Location = new Point(3, 23); + dataGridViewPayment.MultiSelect = false; + dataGridViewPayment.Name = "dataGridViewPayment"; + dataGridViewPayment.RowHeadersVisible = false; + dataGridViewPayment.RowHeadersWidth = 51; + dataGridViewPayment.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewPayment.Size = new Size(413, 256); + dataGridViewPayment.TabIndex = 0; + // + // ColumnMonth + // + ColumnMonth.HeaderText = "Месяц"; + ColumnMonth.MinimumWidth = 6; + ColumnMonth.Name = "ColumnMonth"; + ColumnMonth.Resizable = DataGridViewTriState.True; + ColumnMonth.SortMode = DataGridViewColumnSortMode.NotSortable; + ColumnMonth.Width = 125; + // + // ColumnCount + // + ColumnCount.HeaderText = "Кол-во пациентов"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.Width = 125; + // + // ColumnPayment + // + ColumnPayment.HeaderText = "Оплата"; + ColumnPayment.MinimumWidth = 6; + ColumnPayment.Name = "ColumnPayment"; + ColumnPayment.Width = 125; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(16, 406); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 15; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(98, 406); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 16; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormDoctorPayment + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(659, 471); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBox); + Controls.Add(labelDoctor); + Controls.Add(comboBoxDoctor); + Name = "FormDoctorPayment"; + Text = "FormDoctorPayment"; + groupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewPayment).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelDoctor; + private ComboBox comboBoxDoctor; + private GroupBox groupBox; + private DataGridView dataGridViewPayment; + private Button buttonSave; + private Button buttonCancel; + private DataGridViewTextBoxColumn ColumnMonth; + private DataGridViewTextBoxColumn ColumnCount; + private DataGridViewTextBoxColumn ColumnPayment; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.cs new file mode 100644 index 0000000..2c7c665 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.cs @@ -0,0 +1,82 @@ +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDoctorPayment : Form + { + private readonly IDoctorPaymentsRepository _doctorPaymentsRepository; + public FormDoctorPayment(IDoctorPaymentsRepository doctorPaymentsRepository, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _doctorPaymentsRepository = doctorPaymentsRepository ?? + throw new ArgumentNullException(nameof(doctorPaymentsRepository)); + + comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "Firts_Name"; + comboBoxDoctor.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewPayment.RowCount < 1 || comboBoxDoctor.SelectedIndex < 0) + { + throw new Exception("Имеются не заполненные поля"); + } + + // Получаем значение из первой строки колонки ColumnMonth + string month = dataGridViewPayment.Rows[0].Cells["ColumnMonth"].Value?.ToString(); + int countPatient = int.Parse(dataGridViewPayment.Rows[0].Cells["Column2"].Value?.ToString() ?? "0"); + int payment = int.Parse(dataGridViewPayment.Rows[0].Cells["Column3"].Value?.ToString() ?? "0"); + + // Проверяем, что месяц не пустой + if (string.IsNullOrEmpty(month)) + { + throw new Exception("Месяц не заполнен"); + } + + // Создаем элемент DoctorPayments + _doctorPaymentsRepository.CreateDoctorPayments(DoctorPayments.CreateElement(0, (int)comboBoxDoctor.SelectedValue!, month, countPatient, payment)); + + + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListDoctorPaymentsFromDataGrid() + { + var list = new List(); + foreach(DataGridViewRow row in dataGridViewPayment.Rows) + { + if (row.Cells["ColumnMonth"].Value == null || row.Cells["ColumnCount"].Value == null || row.Cells["ColumnPayment"] == null) + { + continue; + } + // ДОДЕЛАТЬ!!! + list.Add(DoctorPayments.CreateElement(0, 0, row.Cells["ColumnMonth"].Value.ToString(), Convert.ToInt32(row.Cells["ColumnCount"].Value), + Convert.ToInt32(row.Cells["ColumnPayment"].Value))); + } + + return list; + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.resx new file mode 100644 index 0000000..a75bc11 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayment.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.Designer.cs new file mode 100644 index 0000000..514cc73 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.Designer.cs @@ -0,0 +1,99 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormDoctorPayments + { + /// + /// 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(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(622, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(158, 414); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources._5668287_middle; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 46); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 66); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(622, 414); + dataGridView.TabIndex = 1; + // + // FormDoctorPayments + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(780, 414); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormDoctorPayments"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormDoctorPayments"; + Load += FormDoctorPayments_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.cs new file mode 100644 index 0000000..bca62ed --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.cs @@ -0,0 +1,59 @@ +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDoctorPayments : Form + { + private readonly IDoctorPaymentsRepository _doctorPaymentsRepository; + + private readonly IUnityContainer _container; + public FormDoctorPayments(IUnityContainer container, IDoctorPaymentsRepository doctorPaymentsRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _doctorPaymentsRepository = doctorPaymentsRepository ?? + throw new ArgumentNullException(nameof(doctorPaymentsRepository)); + } + + 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 FormDoctorPayments_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _doctorPaymentsRepository.ReadDoctorPayments(); + + + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctorPayments.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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.Designer.cs new file mode 100644 index 0000000..39348db --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationPatientsPolyclinic.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(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(602, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(150, 424); + panel1.TabIndex = 0; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_07_173309; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(28, 209); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(94, 77); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(28, 113); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(94, 75); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources._5668287_middle; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 66); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(602, 424); + dataGridView.TabIndex = 1; + // + // FormDoctors + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(752, 424); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormDoctors"; + StartPosition = FormStartPosition.CenterParent; + Text = "Докторы"; + Load += FormDoctors_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpd; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.cs new file mode 100644 index 0000000..6ac9389 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.cs @@ -0,0 +1,117 @@ +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDoctors : Form + { + // Здесь понадобится экземпляр IUnity контейнер через который мы будем создавать объекты FormDoctor и вызывать его + // IPatientRepository через который мы будем получать список + + 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); + } + } + // отдельный метод который будет загружать в GridView + + private void LoadList() => dataGridView.DataSource = _doctorRepository.ReadDoctors(); + + + private bool TryGetIdentifierFromSelectedRow(out int id) // возвращает смог н извлечь или нет + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["id"].Value); + return true; + } + + 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 + { + _doctorRepository.DeleteDoctor(findId); + 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); + } + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDoctors.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.Designer.cs new file mode 100644 index 0000000..7c6a744 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.Designer.cs @@ -0,0 +1,141 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormDrug + { + /// + /// 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() + { + labelName = new Label(); + labelGrams = new Label(); + labelDescription = new Label(); + textBoxGrams = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + textBoxDescription = new TextBox(); + checkedListBoxName = new CheckedListBox(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(25, 34); + labelName.Name = "labelName"; + labelName.Size = new Size(49, 20); + labelName.TabIndex = 0; + labelName.Text = "Name"; + // + // labelGrams + // + labelGrams.AutoSize = true; + labelGrams.Location = new Point(25, 91); + labelGrams.Name = "labelGrams"; + labelGrams.Size = new Size(51, 20); + labelGrams.TabIndex = 1; + labelGrams.Text = "Grams"; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Location = new Point(25, 142); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(85, 20); + labelDescription.TabIndex = 2; + labelDescription.Text = "Description"; + // + // textBoxGrams + // + textBoxGrams.Location = new Point(137, 88); + textBoxGrams.Name = "textBoxGrams"; + textBoxGrams.Size = new Size(125, 27); + textBoxGrams.TabIndex = 4; + // + // buttonSave + // + buttonSave.Location = new Point(16, 317); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(168, 317); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(137, 142); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(125, 123); + textBoxDescription.TabIndex = 8; + // + // checkedListBoxName + // + checkedListBoxName.FormattingEnabled = true; + checkedListBoxName.Location = new Point(137, 34); + checkedListBoxName.Name = "checkedListBoxName"; + checkedListBoxName.Size = new Size(150, 26); + checkedListBoxName.TabIndex = 9; + // + // FormDrug + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(354, 450); + Controls.Add(checkedListBoxName); + Controls.Add(textBoxDescription); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxGrams); + Controls.Add(labelDescription); + Controls.Add(labelGrams); + Controls.Add(labelName); + Name = "FormDrug"; + Text = "FormDrug"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelGrams; + private Label labelDescription; + private TextBox textBoxGrams; + private Button buttonSave; + private Button buttonCancel; + private TextBox textBoxDescription; + private CheckedListBox checkedListBoxName; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.cs new file mode 100644 index 0000000..53c7c91 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.cs @@ -0,0 +1,108 @@ +using RegistrationPatientsPolyclinic.Entities.Enums; +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 Microsoft.VisualBasic.FileIO; + +namespace RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDrug : Form + { + private readonly IDrugRepository _drugRepository; + + private int? _dragId; + + public int Id + { + set + { + try + { + var drag = _drugRepository.ReadDrugById(value); + if (drag == null) + { + throw new InvalidDataException(nameof(drag)); + } + // проходимся по всем значениям перечисления + foreach (DrugName elem in Enum.GetValues(typeof(DrugName))) + { + if ((elem & drag.DrugName) != 0) + { + checkedListBoxName.SetItemChecked(checkedListBoxName.Items.IndexOf(elem), true); + } + } + textBoxGrams.Text = drag.Grams.ToString(); + textBoxDescription.Text = drag.Description; + _dragId = value; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormDrug(IDrugRepository drugRepository) + { + InitializeComponent(); + _drugRepository = drugRepository?? + throw new ArgumentNullException(nameof(drugRepository)); + // вытаскиваем все значения + foreach(var elem in Enum.GetValues(typeof(DrugName))) + { + checkedListBoxName.Items.Add(elem); // заполняем поэлементно значения + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxGrams.Text) || string.IsNullOrWhiteSpace(textBoxDescription.Text) || + checkedListBoxName.CheckedItems.Count == 0) + { + throw new Exception("Имеется незаполненные поля"); + } + + if (_dragId.HasValue) + { + _drugRepository.UpdateDrug(CreateDrag(_dragId.Value)); + } + else + { + _drugRepository.CreateDrug(CreateDrag(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Drug CreateDrag(int id) + { + DrugName drugName = DrugName.None; + + foreach(var elem in checkedListBoxName.CheckedItems) + { + drugName |= (DrugName)elem; + } + + return Drug.CreateElement(id, drugName, Convert.ToInt32(textBoxGrams.Text), textBoxDescription.Text); + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrug.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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.Designer.cs new file mode 100644 index 0000000..34af571 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormDrugs + { + /// + /// 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(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(629, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(171, 450); + panel1.TabIndex = 0; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_07_173309; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(38, 241); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(94, 95); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(38, 127); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(94, 86); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources._5668287_middle; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(38, 21); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 86); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(629, 450); + dataGridView.TabIndex = 1; + // + // FormDrags + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormDrags"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormDrags"; + Load += FormDrags_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpd; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.cs new file mode 100644 index 0000000..3ee7682 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.cs @@ -0,0 +1,106 @@ +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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.Xml.Linq; +using Unity; + +namespace RegistrationPatientsPolyclinic.Forms +{ + public partial class FormDrugs : Form + { + private readonly IUnityContainer _container; + + private readonly IDrugRepository _dragRepository; + public FormDrugs(IUnityContainer container, IDrugRepository dragRepository) + { + InitializeComponent(); + _container = container ?? // мы получаем через контейнер объект + throw new ArgumentNullException(nameof(container)); + _dragRepository = dragRepository ?? + throw new ArgumentNullException(nameof(dragRepository)); + } + + + private void LoadList() => dataGridView.DataSource = _dragRepository.ReadDrug(); + + + 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 + { + _dragRepository.DeleteDrug(findId); + 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 FormDrags_Load(object sender, EventArgs e) + { + + } + + private bool TryGetIdentifierFromSelectedRow(out int id) // возвращает смог н извлечь или нет + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["id"].Value); + return true; + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormDrugs.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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.Designer.cs new file mode 100644 index 0000000..e127fc2 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.Designer.cs @@ -0,0 +1,113 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormMedicalHistories + { + /// + /// 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(); + dataGridView = new DataGridView(); + buttonDel = new Button(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(646, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(154, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources._5668287_middle; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(32, 25); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 76); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(646, 450); + dataGridView.TabIndex = 1; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(32, 162); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(94, 89); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // FormMedicalHistories + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormMedicalHistories"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormMedicalHistories"; + Load += FormMedicalHistories_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + private Button buttonDel; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.cs new file mode 100644 index 0000000..839eab8 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.cs @@ -0,0 +1,92 @@ +using RegistrationPatientsPolyclinic.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 RegistrationPatientsPolyclinic.Forms +{ + + public partial class FormMedicalHistories : Form // Посмотри на FeedingAnimals + { + private readonly IMedicalHistoryRepository _medicalHistoryRepository; + + private readonly IUnityContainer _container; + public FormMedicalHistories(IUnityContainer container, IMedicalHistoryRepository medicalHistoryRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _medicalHistoryRepository = medicalHistoryRepository ?? + throw new ArgumentNullException(nameof(medicalHistoryRepository)); + } + + 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 FormMedicalHistories_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _medicalHistoryRepository.ReadMedicalHistory(); + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _medicalHistoryRepository.DeletemedicalHistory(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistories.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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.Designer.cs new file mode 100644 index 0000000..3bda3cf --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.Designer.cs @@ -0,0 +1,189 @@ +namespace RegistrationPatientsPolyclinic.Forms +{ + partial class FormMedicalHistory + { + /// + /// 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() + { + buttonSave = new Button(); + buttonCancel = new Button(); + comboBoxPacient = new ComboBox(); + labelPacient = new Label(); + groupBox1 = new GroupBox(); + dataGridView = new DataGridView(); + ColumnDiagnosis = new DataGridViewComboBoxColumn(); + ColumnStatus = new DataGridViewComboBoxColumn(); + ColumnDrug = new DataGridViewComboBoxColumn(); + labelDoctor = new Label(); + comboBoxDoctor = new ComboBox(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(39, 444); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom; + buttonCancel.Location = new Point(455, 444); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // comboBoxPacient + // + comboBoxPacient.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPacient.FormattingEnabled = true; + comboBoxPacient.Location = new Point(177, 30); + comboBoxPacient.Name = "comboBoxPacient"; + comboBoxPacient.Size = new Size(151, 28); + comboBoxPacient.TabIndex = 8; + // + // labelPacient + // + labelPacient.AutoSize = true; + labelPacient.Location = new Point(21, 33); + labelPacient.Name = "labelPacient"; + labelPacient.Size = new Size(69, 20); + labelPacient.TabIndex = 9; + labelPacient.Text = "Пациент"; + // + // groupBox1 + // + groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox1.Controls.Add(dataGridView); + groupBox1.Location = new Point(12, 151); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(817, 248); + groupBox1.TabIndex = 14; + groupBox1.TabStop = false; + groupBox1.Text = "groupBox1"; + // + // dataGridView + // + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnDiagnosis, ColumnStatus, ColumnDrug }); + dataGridView.Location = new Point(9, 26); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(510, 188); + dataGridView.TabIndex = 0; + // + // ColumnDiagnosis + // + ColumnDiagnosis.HeaderText = "Диагноз"; + ColumnDiagnosis.MinimumWidth = 6; + ColumnDiagnosis.Name = "ColumnDiagnosis"; + ColumnDiagnosis.Resizable = DataGridViewTriState.True; + ColumnDiagnosis.SortMode = DataGridViewColumnSortMode.Automatic; + ColumnDiagnosis.Width = 125; + // + // ColumnStatus + // + ColumnStatus.HeaderText = "Статус"; + ColumnStatus.MinimumWidth = 6; + ColumnStatus.Name = "ColumnStatus"; + ColumnStatus.Width = 125; + // + // ColumnDrug + // + ColumnDrug.HeaderText = "Лекарство"; + ColumnDrug.MinimumWidth = 6; + ColumnDrug.Name = "ColumnDrug"; + ColumnDrug.Resizable = DataGridViewTriState.True; + ColumnDrug.SortMode = DataGridViewColumnSortMode.Automatic; + ColumnDrug.Width = 125; + // + // labelDoctor + // + labelDoctor.AutoSize = true; + labelDoctor.Location = new Point(35, 86); + labelDoctor.Name = "labelDoctor"; + labelDoctor.Size = new Size(59, 20); + labelDoctor.TabIndex = 15; + labelDoctor.Text = "Доктор"; + // + // comboBoxDoctor + // + comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(177, 86); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(151, 28); + comboBoxDoctor.TabIndex = 16; + // + // FormMedicalHistory + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(841, 659); + Controls.Add(comboBoxDoctor); + Controls.Add(labelDoctor); + Controls.Add(groupBox1); + Controls.Add(labelPacient); + Controls.Add(comboBoxPacient); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Name = "FormMedicalHistory"; + Text = "FormMedicalHistory"; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Button buttonSave; + private Button buttonCancel; + private ComboBox comboBoxPacient; + private Label labelPacient; + private GroupBox groupBox1; + private DataGridView dataGridView; + private DataGridViewComboBoxColumn ColumnDiagnosis; + private DataGridViewComboBoxColumn ColumnStatus; + private DataGridViewComboBoxColumn ColumnDrug; + private Label labelDoctor; + private ComboBox comboBoxDoctor; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.cs new file mode 100644 index 0000000..90cdd3e --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.cs @@ -0,0 +1,100 @@ +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Entities.Enums; +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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.Markup; +using System.Xml.Linq; +using Unity; + +namespace RegistrationPatientsPolyclinic.Forms +{ + public partial class FormMedicalHistory : Form + { + private readonly IMedicalHistoryRepository _medicalHistoryRepository; + + + + + public FormMedicalHistory(IMedicalHistoryRepository medicalHistoryRepository, IPatientRepository patientRepository, + IDoctorRepository doctorRepository, IDrugRepository drugRepository) + { + InitializeComponent(); + _medicalHistoryRepository = medicalHistoryRepository ?? + throw new ArgumentNullException(nameof(medicalHistoryRepository)); + + comboBoxPacient.DataSource = patientRepository.ReadPatient(); // передает набор всех пациентов + comboBoxPacient.DisplayMember = "First_Name"; // отображение в combobox + comboBoxPacient.ValueMember = "Id"; + + + comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "First_Name"; + comboBoxDoctor.ValueMember = "Id"; + + ColumnDrug.DataSource = drugRepository.ReadDrug(); + ColumnDrug.DisplayMember = "DrugName"; + ColumnDrug.ValueMember = "Id"; + + + } + + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridView.RowCount < 1 || comboBoxPacient.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + /* + CreateEntity(0, + Convert.ToInt32(comboBoxPacient.Text), + Convert.ToInt32(row.Cells["ColumnDoctor"].Value), (Diagnosis)row.Cells["ColumnDiagnosis"].Value, + (Status)row.Cells["ColumnStatus"].Value, ColumnDrug); + */ + + _medicalHistoryRepository.CreateMedicalHistory(MedicalHistory.CreateEntity(0, (int)comboBoxPacient.SelectedValue!, + (int)comboBoxDoctor.SelectedValue!, CreateListMedicalHistoryFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + + private void LoadList() => dataGridView.DataSource = +_medicalHistoryRepository.ReadMedicalHistory(); + + private List CreateListMedicalHistoryFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView.Rows) + { + if (row.Cells["ColumnDrug"].Value == null) + { + continue; + } + list.Add(DrugMedicalHistory.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnDrug"].Value))); + } + return list; + } + + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.resx new file mode 100644 index 0000000..f8b0fa0 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormMedicalHistory.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.Designer.cs new file mode 100644 index 0000000..04eec9a --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.Designer.cs @@ -0,0 +1,140 @@ +namespace RegistrationPatientsPolyclinic.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() + { + labelFirstName = new Label(); + textBoxName = new TextBox(); + labelLastName = new Label(); + textBoxLastName = new TextBox(); + labelContactNumber = new Label(); + textBoxContactNumber = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelFirstName + // + labelFirstName.AutoSize = true; + labelFirstName.Location = new Point(16, 25); + labelFirstName.Name = "labelFirstName"; + labelFirstName.Size = new Size(39, 20); + labelFirstName.TabIndex = 0; + labelFirstName.Text = "Имя"; + // + // textBoxName + // + textBoxName.Location = new Point(169, 25); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(125, 27); + textBoxName.TabIndex = 1; + // + // labelLastName + // + labelLastName.AutoSize = true; + labelLastName.Location = new Point(16, 82); + labelLastName.Name = "labelLastName"; + labelLastName.Size = new Size(73, 20); + labelLastName.TabIndex = 2; + labelLastName.Text = "Фамилия"; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(169, 82); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(125, 27); + textBoxLastName.TabIndex = 3; + // + // labelContactNumber + // + labelContactNumber.AutoSize = true; + labelContactNumber.Location = new Point(12, 147); + labelContactNumber.Name = "labelContactNumber"; + labelContactNumber.Size = new Size(142, 20); + labelContactNumber.TabIndex = 4; + labelContactNumber.Text = "Контактный номер"; + // + // textBoxContactNumber + // + textBoxContactNumber.Location = new Point(169, 144); + textBoxContactNumber.Name = "textBoxContactNumber"; + textBoxContactNumber.Size = new Size(125, 27); + textBoxContactNumber.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(16, 223); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(200, 224); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 28); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormPatient + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(829, 441); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxContactNumber); + Controls.Add(labelContactNumber); + Controls.Add(textBoxLastName); + Controls.Add(labelLastName); + Controls.Add(textBoxName); + Controls.Add(labelFirstName); + Name = "FormPatient"; + StartPosition = FormStartPosition.CenterParent; + Text = "Пациент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelFirstName; + private TextBox textBoxName; + private Label labelLastName; + private TextBox textBoxLastName; + private Label labelContactNumber; + private TextBox textBoxContactNumber; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.cs new file mode 100644 index 0000000..4a0db59 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.cs @@ -0,0 +1,102 @@ +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormPatient : Form + { + // Нам для логики потребуется интерфейс IPatientRepository, мы будем его через конструктор передавать + // Когда запись будет открываться на редактирование, надо будет хранить id + // Надо будет как то id передавать (через свойства сетер) + + + private readonly IPatientRepository _patientRepository; + + private int? _patientId; + + public int Id // свойство + { + set + { + try + { + var patient = _patientRepository.ReadPatientById(value); // value - некое значение + if (patient == null) // по этому значению пытаемся найти запись в репозитории + { + throw new InvalidDataException(nameof(patient)); // если не находим выкидываем ошибку + } + // Если все норм, то пытаемся заполнить поля + textBoxName.Text = patient.Firts_Name; + textBoxLastName.Text = patient.Last_Name; + textBoxContactNumber.Text = patient.ContactNumber; + _patientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + // Конструктор, в параметрах Ioc контейнер + // Когда мы попросим Ioc контейнер создать объект от FormPatient, он посмотрит что требуются + // такая зависимость IPatientRepository patientRepository(параметры конструктора) + // в programm.cs это подставлять + // потом создаст объект и передаст его сюда(public FormPatient(IPatientRepository patientRepository){ сюда }) + + 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(textBoxLastName.Text) || string.IsNullOrWhiteSpace(textBoxContactNumber.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + // проверка есть ли у нас id + if (_patientId.HasValue) + { + // мы создаем запись и передаем id + _patientRepository.UpdatePatient(CreatePatient(_patientId.Value)); + } + else + { + // если id нет, то мы создаем запись, с id ноль + _patientRepository.CreatPatient(CreatePatient(0)); + } + // закрываем форму + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + // создаем запись + + // Вызываем статичный метод Patient.CreateEntity + private Patient CreatePatient(int id) => Patient.CreateEntity(id, textBoxName.Text, textBoxLastName.Text, textBoxContactNumber.Text); + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatient.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.Designer.cs new file mode 100644 index 0000000..db0e289 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.Designer.cs @@ -0,0 +1,127 @@ +namespace RegistrationPatientsPolyclinic.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(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(880, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(133, 451); + panel1.TabIndex = 0; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_07_173309; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(19, 178); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(94, 62); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(19, 92); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(94, 64); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources._5668287_middle; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(19, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 63); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(880, 451); + dataGridView.TabIndex = 1; + // + // FormPatients + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1013, 451); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormPatients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Пациенты"; + Load += FormPatients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpd; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.cs new file mode 100644 index 0000000..1ec5ec3 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.cs @@ -0,0 +1,117 @@ +using RegistrationPatientsPolyclinic.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 RegistrationPatientsPolyclinic.Forms +{ + public partial class FormPatients : Form + { + // Здесь понадобится экземпляр IUnity контейнер через который мы будем создавать объекты FormPatient и вызывать его + // IPatientRepository через который мы будем получать список + + private readonly IUnityContainer _container; + + private readonly IPatientRepository _pacientRepository; + public FormPatients(IUnityContainer container, IPatientRepository pacientRepository) + { + InitializeComponent(); + _container = container ?? // мы получаем через контейнер объект + throw new ArgumentNullException(nameof(container)); + _pacientRepository = pacientRepository ?? + throw new ArgumentNullException(nameof(pacientRepository)); ; + } + + 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) + { + // мы получаем через container объект FormPatient и вызываем его + try + { + _container.Resolve().ShowDialog(); + LoadList(); // обновление списка + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + // нужно будет вытаскивать идентификатор из dataGridView + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _pacientRepository.DeletePatient(findId); + 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); + } + } + + // отдельный метод который будет загружать в GridView + + private void LoadList() => dataGridView.DataSource = _pacientRepository.ReadPatient(); + + + private bool TryGetIdentifierFromSelectedRow(out int id) // возвращает смог н извлечь или нет + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["id"].Value); + return true; + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Forms/FormPatients.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/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/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Program.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Program.cs index d54f157..0deec3f 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Program.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Program.cs @@ -1,3 +1,7 @@ +using RegistrationPatientsPolyclinic.Repositories; +using RegistrationPatientsPolyclinic.Repositories.Implementations; +using Unity; + namespace RegistrationPatientsPolyclinic { internal static class Program @@ -11,7 +15,25 @@ namespace RegistrationPatientsPolyclinic // 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()); // + } + + // , + // var - + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + // + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.Designer.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f620bc8 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace RegistrationPatientsPolyclinic.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("RegistrationPatientsPolyclinic.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 _5668287_middle { + get { + object obj = ResourceManager.GetObject("5668287-middle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap del { + get { + object obj = ResourceManager.GetObject("del", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap og_og_1643042666277656852 { + get { + object obj = ResourceManager.GetObject("og_og_1643042666277656852", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap photo_2024_11_06_22_13_46 { + get { + object obj = ResourceManager.GetObject("photo_2024-11-06_22-13-46", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Снимок_экрана_2024_11_07_173309 { + get { + object obj = ResourceManager.GetObject("Снимок экрана 2024-11-07 173309", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.resx b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.resx new file mode 100644 index 0000000..ea5686b --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\og_og_1643042666277656852.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\photo_2024-11-06_22-13-46.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\5668287-middle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Снимок экрана 2024-11-07 173309.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic.csproj b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic.csproj index 663fdb8..accbdf0 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic.csproj +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugMedicalHistory.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugMedicalHistory.cs new file mode 100644 index 0000000..264724a --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugMedicalHistory.cs @@ -0,0 +1,18 @@ +using RegistrationPatientsPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace RegistrationPatientsPolyclinic.Repositories; + +public interface IDrugMedicalHistory +{ + IEnumerable ReadDragMedicalHistory(int? drugId, string description); // чтение всего + + void CreateDrugMedicalHistory(DrugMedicalHistory drugHistory); // создание объекта + + void DeleteDrugMedicalHistory(int Id); +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugRepository.cs new file mode 100644 index 0000000..50fc6d2 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IDrugRepository.cs @@ -0,0 +1,21 @@ +using RegistrationPatientsPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Repositories; + +public interface IDrugRepository +{ + IEnumerable ReadDrug(); + + Drug ReadDrugById(int id); + + void CreateDrug(Drug drag); + + void UpdateDrug(Drug drag); + + void DeleteDrug(int id); +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IMedicalHistoryRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IMedicalHistoryRepository.cs index 7056b85..d7caca5 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IMedicalHistoryRepository.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/IMedicalHistoryRepository.cs @@ -12,5 +12,9 @@ public interface IMedicalHistoryRepository IEnumerable ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null); // по этим параметрам можно не весь список читать, а только какую то часть + void CreateMedicalHistory(MedicalHistory medicalHistory); // объекь будет заносится в список + + + void DeletemedicalHistory(int id); } diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugMedicalHistoryRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugMedicalHistoryRepository.cs new file mode 100644 index 0000000..d71d6b9 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugMedicalHistoryRepository.cs @@ -0,0 +1,26 @@ +using RegistrationPatientsPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Repositories.Implementations; + +public class DrugMedicalHistoryRepository : IDrugMedicalHistory +{ + public void CreateDrugMedicalHistory(DrugMedicalHistory drugHistory) + { + + } + + public void DeleteDrugMedicalHistory(int Id) + { + + } + + public IEnumerable ReadDragMedicalHistory(int? drugId, string description) + { + return []; + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugRepository.cs new file mode 100644 index 0000000..c64d8e9 --- /dev/null +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/DrugRepository.cs @@ -0,0 +1,37 @@ +using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RegistrationPatientsPolyclinic.Repositories.Implementations; + +public class DrugRepository : IDrugRepository +{ + public void CreateDrug(Drug drag) + { + + } + + public void DeleteDrug(int id) + { + + } + + public IEnumerable ReadDrug() + { + return []; + } + + public Drug ReadDrugById(int id) + { + return Drug.CreateElement(0, DrugName.None, 0, string.Empty); + } + + public void UpdateDrug(Drug drag) + { + + } +} diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs index bbe5896..a16c292 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/MedicalHistoryRepository.cs @@ -1,4 +1,5 @@ using RegistrationPatientsPolyclinic.Entities; +using RegistrationPatientsPolyclinic.Entities.Enums; using System; using System.Collections.Generic; using System.Linq; @@ -11,10 +12,20 @@ public class MedicalHistoryRepository : IMedicalHistoryRepository { public void CreateMedicalHistory(MedicalHistory medicalHistory) { + + } + + + public void DeletemedicalHistory(int id) + { + } public IEnumerable ReadMedicalHistory(DateTime? dateForm = null, DateTime? dateTo = null, int? PatientId = null, int? DoctorId = null) { return []; } + + + } diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/PatientRepository.cs b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/PatientRepository.cs index e1c3e33..1dbcbda 100644 --- a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/PatientRepository.cs +++ b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Repositories/Implementations/PatientRepository.cs @@ -24,7 +24,7 @@ public class PatientRepository : IPatientRepository public Patient ReadPatientById(int id) { - return Patient.CreatePatient(0, string.Empty, string.Empty, string.Empty); + return Patient.CreateEntity(0, string.Empty, string.Empty, string.Empty); } public void UpdatePatient(Patient patient) diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/5668287-middle.png b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/5668287-middle.png new file mode 100644 index 0000000..b48e019 Binary files /dev/null and b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/5668287-middle.png differ diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/del.png b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/del.png new file mode 100644 index 0000000..a4de224 Binary files /dev/null and b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/del.png differ diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/og_og_1643042666277656852.jpg b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/og_og_1643042666277656852.jpg new file mode 100644 index 0000000..ee235e0 Binary files /dev/null and b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/og_og_1643042666277656852.jpg differ diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/photo_2024-11-06_22-13-46.jpg b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/photo_2024-11-06_22-13-46.jpg new file mode 100644 index 0000000..8b0b8bd Binary files /dev/null and b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/photo_2024-11-06_22-13-46.jpg differ diff --git a/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/Снимок экрана 2024-11-07 173309.png b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/Снимок экрана 2024-11-07 173309.png new file mode 100644 index 0000000..a796c90 Binary files /dev/null and b/RegistrationPatientsPolyclinic/RegistrationPatientsPolyclinic/Resources/Снимок экрана 2024-11-07 173309.png differ