diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Diagnosis.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Diagnosis.cs deleted file mode 100644 index d710b53..0000000 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Diagnosis.cs +++ /dev/null @@ -1,25 +0,0 @@ -using ProjectPolyclinic.Entities.Enums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectPolyclinic.Entities -{ - public class Diagnosis - { - public int Id { get; private set; } - public DiagnosisName DiagnosisName { get; private set; } - public static Diagnosis CreateEntity(int id, DiagnosisName diagnosisName) - { - return new Diagnosis - { - Id = id, - DiagnosisName = diagnosisName - - }; - } - - } -} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DiagnosisName.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DiagnosisName.cs index f2f669e..4dfa984 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DiagnosisName.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Enums/DiagnosisName.cs @@ -5,13 +5,13 @@ using System.Text; using System.Threading.Tasks; namespace ProjectPolyclinic.Entities.Enums; - +[Flags] public enum DiagnosisName { None = 0, Flu = 1, Fracture = 2, - Asthma = 3, - SkinInfection = 4, - HeartDisease = 5 + Asthma = 4, + SkinInfection = 8, + HeartDisease = 16 } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Medication.cs similarity index 50% rename from ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines.cs rename to ProjectPolyclinic/ProjectPolyclinic/Entities/Medication.cs index fb02358..5ee2a61 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Medication.cs @@ -7,18 +7,20 @@ using System.Threading.Tasks; namespace ProjectPolyclinic.Entities; -public class Medicines +public class Medication { public int Id { get; private set; } public MedicinesType MedicinesType { get; private set; } - public int Dosing { get; private set; } - public static Medicines CreateElement(int id,MedicinesType medicinesType,int dosing) + public string Dosing { get; private set; } = string.Empty; + public string Description { get; private set; } = string.Empty; + public static Medication CreateEntity(int id,MedicinesType medicinesType,string dosing, string description) { - return new Medicines + return new Medication { Id = id, MedicinesType = medicinesType, - Dosing = dosing + Dosing = dosing ?? string.Empty, + Description = description ?? string.Empty, }; } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines_Visiting.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines_Visiting.cs index d3b7890..b790cd8 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines_Visiting.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Medicines_Visiting.cs @@ -8,5 +8,17 @@ namespace ProjectPolyclinic.Entities; public class Medicines_Visiting { + public int MedicinesId { get; private set; } + public int VisitingId { get; private set; } + public int Count { get; private set; } + public static Medicines_Visiting CreateElement(int medicinesId, int visitingId, int count) + { + return new Medicines_Visiting + { + MedicinesId = medicinesId, + VisitingId = visitingId, + Count = count + }; + } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Patient.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Patient.cs index 2bf3885..d81780e 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Patient.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Patient.cs @@ -11,15 +11,15 @@ namespace ProjectPolyclinic.Entities public int Id { get;private set; } public string First_Name { get; private set; } = string.Empty; public string Last_Name { get; private set; } = string.Empty; - public DateTime Date_Of_Birth { get; private set; } - public static Patient CreateEntity(int id, string first_Name, string last_Name, DateTime date_of_birth) + public string ContactNumber { get; private set; } = string.Empty; + public static Patient CreateEntity(int id, string first_Name, string last_Name, string contactNumber) { return new Patient { Id = id, First_Name = first_Name, Last_Name = last_Name, - Date_Of_Birth = date_of_birth + ContactNumber = contactNumber }; } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/ProfessionalDevelopment.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/ProfessionalDevelopment.cs new file mode 100644 index 0000000..7d1c440 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/ProfessionalDevelopment.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Entities +{ + public class ProfessionalDevelopment + { + public int Id { get; private set; } + public int DoctorId { get; private set; } + public DateTime ProfessionalDevelopmentTime { get; private set; } + //public string Description { get; private set; } = string.Empty; + public static ProfessionalDevelopment CreateOperation(int id, int doctorId, DateTime professionalDevelopmentTime) + { + return new ProfessionalDevelopment + { + Id = id, + DoctorId = doctorId, + ProfessionalDevelopmentTime = professionalDevelopmentTime, + // Description = description ?? string.Empty + }; + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Entities/Visiting.cs b/ProjectPolyclinic/ProjectPolyclinic/Entities/Visiting.cs index 3620f3e..60e9404 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Entities/Visiting.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Entities/Visiting.cs @@ -1,4 +1,5 @@ -using System; +using ProjectPolyclinic.Entities.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,17 +12,23 @@ public class Visiting public int Id { get; private set; } public int DoctorId { get; private set; } public int PatientId { get; private set; } - public int DiagnosisId { get; private set; } + public DiagnosisName DiagnosisName { get; private set; } public DateTime VisitingTime { get; private set; } - public static Visiting CreateOperation(int id, int doctorId, int patientId, int diagnosisId, DateTime visitingTime) + public IEnumerable Medicines + { + get; + private set; + } = []; + public static Visiting CreateOperation(int id, int doctorId, int patientId, DiagnosisName diagnosisName, DateTime visitingTime, IEnumerable medicines) { return new Visiting { Id = id, DoctorId = doctorId, PatientId = patientId, - DiagnosisId = diagnosisId, - VisitingTime = visitingTime + DiagnosisName = diagnosisName, + VisitingTime = DateTime.Now, + Medicines = medicines }; } } diff --git a/ProjectPolyclinic/ProjectPolyclinic/Form1.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Form1.Designer.cs deleted file mode 100644 index 9f1767d..0000000 --- a/ProjectPolyclinic/ProjectPolyclinic/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectPolyclinic -{ - 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/ProjectPolyclinic/ProjectPolyclinic/Form1.cs b/ProjectPolyclinic/ProjectPolyclinic/Form1.cs deleted file mode 100644 index f5c71a4..0000000 --- a/ProjectPolyclinic/ProjectPolyclinic/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectPolyclinic -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.Designer.cs new file mode 100644 index 0000000..7f4a266 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.Designer.cs @@ -0,0 +1,137 @@ +namespace ProjectPolyclinic +{ + 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() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + пациентыToolStripMenuItem = new ToolStripMenuItem(); + DoctorsToolStripMenuItem = new ToolStripMenuItem(); + MedicinesToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + VisitingsToolStripMenuItem = new ToolStripMenuItem(); + ProfessionalDevelopmentsToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пациентыToolStripMenuItem, DoctorsToolStripMenuItem, MedicinesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // пациентыToolStripMenuItem + // + пациентыToolStripMenuItem.Name = "пациентыToolStripMenuItem"; + пациентыToolStripMenuItem.Size = new Size(180, 22); + пациентыToolStripMenuItem.Text = "Пациенты"; + пациентыToolStripMenuItem.Click += PatientsToolStripMenuItem_Click; + // + // DoctorsToolStripMenuItem + // + DoctorsToolStripMenuItem.Name = "DoctorsToolStripMenuItem"; + DoctorsToolStripMenuItem.Size = new Size(180, 22); + DoctorsToolStripMenuItem.Text = "Врачи"; + DoctorsToolStripMenuItem.Click += DoctorsToolStripMenuItem_Click; + // + // MedicinesToolStripMenuItem + // + MedicinesToolStripMenuItem.Name = "MedicinesToolStripMenuItem"; + MedicinesToolStripMenuItem.Size = new Size(180, 22); + MedicinesToolStripMenuItem.Text = "Медикаменты"; + MedicinesToolStripMenuItem.Click += MedicinesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { VisitingsToolStripMenuItem, ProfessionalDevelopmentsToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // VisitingsToolStripMenuItem + // + VisitingsToolStripMenuItem.Name = "VisitingsToolStripMenuItem"; + VisitingsToolStripMenuItem.Size = new Size(226, 22); + VisitingsToolStripMenuItem.Text = "Визиты"; + VisitingsToolStripMenuItem.Click += VisitingsToolStripMenuItem_Click; + // + // ProfessionalDevelopmentsToolStripMenuItem + // + ProfessionalDevelopmentsToolStripMenuItem.Name = "ProfessionalDevelopmentsToolStripMenuItem"; + ProfessionalDevelopmentsToolStripMenuItem.Size = new Size(226, 22); + ProfessionalDevelopmentsToolStripMenuItem.Text = "Повышение квалификации"; + ProfessionalDevelopmentsToolStripMenuItem.Click += ProfessionalDevelopmentsToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormPolyclinic + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.поликлиника; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormPolyclinic"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Поликлиника"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem пациентыToolStripMenuItem; + private ToolStripMenuItem DoctorsToolStripMenuItem; + private ToolStripMenuItem MedicinesToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem VisitingsToolStripMenuItem; + private ToolStripMenuItem ProfessionalDevelopmentsToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.cs b/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.cs new file mode 100644 index 0000000..176025a --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.cs @@ -0,0 +1,83 @@ +using ProjectPolyclinic.Forms; +using Unity; + +namespace ProjectPolyclinic +{ + public partial class FormPolyclinic : Form + { + private readonly IUnityContainer _container; + public FormPolyclinic(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void PatientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void DoctorsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void MedicinesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void VisitingsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ProfessionalDevelopmentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.resx b/ProjectPolyclinic/ProjectPolyclinic/FormPolyclinic.resx new file mode 100644 index 0000000..b48baf1 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.Designer.cs new file mode 100644 index 0000000..54e45a5 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.Designer.cs @@ -0,0 +1,141 @@ +namespace ProjectPolyclinic.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() + { + comboBoxSpec = new ComboBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + textBoxNameDoctor = new TextBox(); + textBoxName2Doctor = new TextBox(); + button1 = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxSpec + // + comboBoxSpec.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSpec.FormattingEnabled = true; + comboBoxSpec.Location = new Point(170, 96); + comboBoxSpec.Name = "comboBoxSpec"; + comboBoxSpec.Size = new Size(159, 23); + comboBoxSpec.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(34, 29); + label1.Name = "label1"; + label1.Size = new Size(72, 15); + label1.TabIndex = 1; + label1.Text = "Имя врача :"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(34, 69); + label2.Name = "label2"; + label2.Size = new Size(99, 15); + label2.TabIndex = 2; + label2.Text = "Фамилия врача :"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(34, 104); + label3.Name = "label3"; + label3.Size = new Size(98, 15); + label3.TabIndex = 3; + label3.Text = "Специальность :"; + // + // textBoxNameDoctor + // + textBoxNameDoctor.Location = new Point(170, 29); + textBoxNameDoctor.Name = "textBoxNameDoctor"; + textBoxNameDoctor.Size = new Size(159, 23); + textBoxNameDoctor.TabIndex = 4; + // + // textBoxName2Doctor + // + textBoxName2Doctor.Location = new Point(170, 61); + textBoxName2Doctor.Name = "textBoxName2Doctor"; + textBoxName2Doctor.Size = new Size(159, 23); + textBoxName2Doctor.TabIndex = 5; + // + // button1 + // + button1.Location = new Point(66, 153); + button1.Name = "button1"; + button1.Size = new Size(95, 34); + button1.TabIndex = 6; + button1.Text = "Сохранить"; + button1.UseVisualStyleBackColor = true; + button1.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(194, 153); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(95, 34); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormDoctor + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(460, 237); + Controls.Add(buttonCancel); + Controls.Add(button1); + Controls.Add(textBoxName2Doctor); + Controls.Add(textBoxNameDoctor); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(comboBoxSpec); + Name = "FormDoctor"; + Text = "Врач"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxSpec; + private Label label1; + private Label label2; + private Label label3; + private TextBox textBoxNameDoctor; + private TextBox textBoxName2Doctor; + private Button button1; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs new file mode 100644 index 0000000..6f86d89 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.cs @@ -0,0 +1,83 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Entities.Enums; +using ProjectPolyclinic.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectPolyclinic.Forms +{ + public partial class FormDoctor : Form + { + private readonly IDoctorRepository _doctorRepository; + private int? _doctorId; + public int Id + { + set + { + try + { + var doctor = _doctorRepository.ReadDoctorById(value); + if (doctor == null) + { + throw new InvalidDataException(nameof(doctor)); + } + textBoxNameDoctor.Text = doctor.First_Name; + textBoxName2Doctor.Text = doctor.Last_Name; + comboBoxSpec.SelectedItem = doctor.Specialization; + _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)); + comboBoxSpec.DataSource = Enum.GetValues(typeof(Specialization)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxNameDoctor.Text) || + string.IsNullOrWhiteSpace(textBoxName2Doctor.Text) + || + comboBoxSpec.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, textBoxNameDoctor.Text, textBoxName2Doctor.Text, + (Specialization)comboBoxSpec.SelectedItem!); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Form1.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.resx similarity index 92% rename from ProjectPolyclinic/ProjectPolyclinic/Form1.resx rename to ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.resx index 1af7de1..8b2ff64 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Form1.resx +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctor.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.Designer.cs new file mode 100644 index 0000000..b64ce05 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormDoctors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(674, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(126, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(23, 148); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(80, 55); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.карандаш; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(23, 87); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(80, 55); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(21, 26); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(80, 55); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(674, 450); + dataGridViewData.TabIndex = 1; + // + // FormDoctors + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormDoctors"; + Text = "Врачи"; + Load += FormDoctors_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs new file mode 100644 index 0000000..9407381 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.cs @@ -0,0 +1,114 @@ +using ProjectPolyclinic.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 ProjectPolyclinic.Forms +{ + public partial class FormDoctors : Form + { + private readonly IUnityContainer _container; + private readonly IDoctorRepository _doctorRepository; + public FormDoctors(IUnityContainer container, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _doctorRepository = doctorRepository ?? + throw new + ArgumentNullException(nameof(doctorRepository)); + } + private void FormDoctors_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _doctorRepository.DeleteDoctor(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void LoadList() => dataGridViewData.DataSource =_doctorRepository.ReadDoctors(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormDoctors.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.Designer.cs new file mode 100644 index 0000000..a3b7b8c --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.Designer.cs @@ -0,0 +1,141 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormMedication + { + /// + /// 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() + { + checkedListBoxMedicinesType = new CheckedListBox(); + textBoxDosing = new TextBox(); + richTextBoxDescription = new RichTextBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // checkedListBoxMedicinesType + // + checkedListBoxMedicinesType.FormattingEnabled = true; + checkedListBoxMedicinesType.Location = new Point(122, 32); + checkedListBoxMedicinesType.Name = "checkedListBoxMedicinesType"; + checkedListBoxMedicinesType.Size = new Size(150, 112); + checkedListBoxMedicinesType.TabIndex = 0; + // + // textBoxDosing + // + textBoxDosing.Location = new Point(122, 160); + textBoxDosing.Name = "textBoxDosing"; + textBoxDosing.Size = new Size(150, 23); + textBoxDosing.TabIndex = 1; + // + // richTextBoxDescription + // + richTextBoxDescription.Location = new Point(122, 215); + richTextBoxDescription.Name = "richTextBoxDescription"; + richTextBoxDescription.Size = new Size(150, 96); + richTextBoxDescription.TabIndex = 2; + richTextBoxDescription.Text = ""; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(30, 32); + label1.Name = "label1"; + label1.Size = new Size(63, 15); + label1.TabIndex = 3; + label1.Text = "Таблетки :"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(30, 168); + label2.Name = "label2"; + label2.Size = new Size(72, 15); + label2.TabIndex = 4; + label2.Text = "Дозировка :"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(30, 218); + label3.Name = "label3"; + label3.Size = new Size(68, 15); + label3.TabIndex = 5; + label3.Text = "Описание :"; + // + // buttonSave + // + buttonSave.Location = new Point(43, 349); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(86, 34); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(218, 349); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(85, 34); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormMedication + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(358, 450); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(richTextBoxDescription); + Controls.Add(textBoxDosing); + Controls.Add(checkedListBoxMedicinesType); + Name = "FormMedication"; + Text = "Медикамент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CheckedListBox checkedListBoxMedicinesType; + private TextBox textBoxDosing; + private RichTextBox richTextBoxDescription; + private Label label1; + private Label label2; + private Label label3; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.cs new file mode 100644 index 0000000..7d11587 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.cs @@ -0,0 +1,107 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Entities.Enums; +using ProjectPolyclinic.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectPolyclinic.Forms +{ + public partial class FormMedication : Form + { + private readonly IMedicationRepository _medicationRepository; + private int? _medicationId; + + public int Id + { + set + { + try + { + var medication = _medicationRepository.ReadMedicationById(value); + if (medication == null) + { + throw new + InvalidDataException(nameof(medication)); + } + foreach (MedicinesType elem in + Enum.GetValues(typeof(MedicinesType))) + { + if ((elem & medication.MedicinesType) != 0) + { + checkedListBoxMedicinesType.SetItemChecked(checkedListBoxMedicinesType.Items.IndexOf( + elem), true); + } + } + textBoxDosing.Text = medication.Dosing; + richTextBoxDescription.Text = medication.Description; + _medicationId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + + } + } + } + public FormMedication(IMedicationRepository medicationRepository) + { + InitializeComponent(); + _medicationRepository = medicationRepository ?? throw new ArgumentNullException(nameof(medicationRepository)); + foreach (var elem in Enum.GetValues(typeof(MedicinesType))) + { + checkedListBoxMedicinesType.Items.Add(elem); + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDosing.Text) || + string.IsNullOrWhiteSpace(richTextBoxDescription.Text) || + checkedListBoxMedicinesType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_medicationId.HasValue) + { + _medicationRepository.UpdateMedication(CreateMedication(_medicationId.Value)); + } + else + { + _medicationRepository.CreateMedication(CreateMedication(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Medication CreateMedication(int id) + { + MedicinesType medicinesType = MedicinesType.None; + foreach (var elem in checkedListBoxMedicinesType.CheckedItems) + { + medicinesType |= (MedicinesType)elem; + } + return Medication.CreateEntity(id, medicinesType, textBoxDosing.Text, + richTextBoxDescription.Text); + } + } + + + +} + diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedication.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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.Designer.cs new file mode 100644 index 0000000..abc616e --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormMedicines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(671, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(129, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(31, 157); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 58); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.карандаш; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(31, 90); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(75, 61); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(31, 26); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 58); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(671, 450); + dataGridViewData.TabIndex = 1; + // + // FormMedicines + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormMedicines"; + StartPosition = FormStartPosition.CenterParent; + Text = "Медикаменты"; + Load += FormMedicines_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.cs new file mode 100644 index 0000000..9d93267 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.cs @@ -0,0 +1,115 @@ +using ProjectPolyclinic.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 ProjectPolyclinic.Forms +{ + public partial class FormMedicines : Form + { + private readonly IUnityContainer _container; + private readonly IMedicationRepository _medicationRepository; + public FormMedicines(IUnityContainer container, IMedicationRepository medicationRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _medicationRepository = medicationRepository ?? throw new ArgumentNullException(nameof(medicationRepository)); + } + + private void FormMedicines_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _medicationRepository.DeleteMedication(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _medicationRepository.ReadMedication(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + + } + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormMedicines.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.Designer.cs new file mode 100644 index 0000000..fa9ab85 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.Designer.cs @@ -0,0 +1,140 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormPatient + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + textBoxNamePatient = new TextBox(); + textBoxName2Patient = new TextBox(); + textBoxNumberPatient = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(40, 37); + label1.Name = "label1"; + label1.Size = new Size(91, 15); + label1.TabIndex = 0; + label1.Text = "Имя пациента :"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(40, 78); + label2.Name = "label2"; + label2.Size = new Size(118, 15); + label2.TabIndex = 1; + label2.Text = "Фамилия пациента :"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(40, 116); + label3.Name = "label3"; + label3.Size = new Size(105, 15); + label3.TabIndex = 2; + label3.Text = "Номер пациента :"; + // + // textBoxNamePatient + // + textBoxNamePatient.Location = new Point(176, 37); + textBoxNamePatient.Name = "textBoxNamePatient"; + textBoxNamePatient.Size = new Size(203, 23); + textBoxNamePatient.TabIndex = 3; + // + // textBoxName2Patient + // + textBoxName2Patient.Location = new Point(176, 70); + textBoxName2Patient.Name = "textBoxName2Patient"; + textBoxName2Patient.Size = new Size(203, 23); + textBoxName2Patient.TabIndex = 4; + // + // textBoxNumberPatient + // + textBoxNumberPatient.Location = new Point(176, 113); + textBoxNumberPatient.Name = "textBoxNumberPatient"; + textBoxNumberPatient.Size = new Size(203, 23); + textBoxNumberPatient.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(56, 176); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(112, 36); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(230, 176); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(104, 36); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormPatient + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(425, 250); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxNumberPatient); + Controls.Add(textBoxName2Patient); + Controls.Add(textBoxNamePatient); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormPatient"; + StartPosition = FormStartPosition.CenterParent; + Text = "Пациент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private TextBox textBoxNamePatient; + private TextBox textBoxName2Patient; + private TextBox textBoxNumberPatient; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.cs new file mode 100644 index 0000000..5d283ba --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.cs @@ -0,0 +1,79 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectPolyclinic.Forms +{ + public partial class FormPatient : Form + { + private readonly IPatientRepository _patientRepository; + private int? _patientId; + public int Id + { + set + { + try + { + var patient = _patientRepository.ReadPatientById(value); + if (patient == null) + { + throw new InvalidDataException(nameof(patient)); + + } + textBoxNamePatient.Text = patient.First_Name; + textBoxName2Patient.Text = patient.Last_Name; + textBoxNumberPatient.Text = patient.ContactNumber; + _patientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + } + } + public FormPatient(IPatientRepository patientRepository) + { + InitializeComponent(); + _patientRepository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxNamePatient.Text) || string.IsNullOrWhiteSpace(textBoxName2Patient.Text) || string.IsNullOrWhiteSpace(textBoxNumberPatient.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_patientId.HasValue) + { + _patientRepository.UpdatePatient(CreatePatient(_patientId.Value)); + + } + else + { + _patientRepository.CreatePatient(CreatePatient(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Patient CreatePatient(int id) => Patient.CreateEntity(id, textBoxNamePatient.Text, textBoxName2Patient.Text, textBoxNumberPatient.Text); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatient.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs new file mode 100644 index 0000000..a214104 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormPatients + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(667, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(139, 506); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(23, 173); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(104, 71); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.карандаш; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(23, 90); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(104, 77); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(23, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(104, 72); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(667, 506); + dataGridViewData.TabIndex = 1; + // + // FormPatients + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(806, 506); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormPatients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Пациенты"; + Load += FormPatients_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs new file mode 100644 index 0000000..fe2781d --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.cs @@ -0,0 +1,116 @@ +using ProjectPolyclinic.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 ProjectPolyclinic.Forms +{ + public partial class FormPatients : Form + { + private readonly IUnityContainer _container; + private readonly IPatientRepository _patientRepository; + public FormPatients(IUnityContainer container, IPatientRepository patientRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _patientRepository = patientRepository ?? throw new ArgumentNullException(nameof(patientRepository)); + } + + private void FormPatients_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _patientRepository.DeletePatient(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void LoadList() => dataGridViewData.DataSource = _patientRepository.ReadPatients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormPatients.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.Designer.cs new file mode 100644 index 0000000..76a6482 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.Designer.cs @@ -0,0 +1,121 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormProfessionalDevelopment + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + comboBoxDoctor = new ComboBox(); + dateTimePickerProfessionalDevelopmentDate = new DateTimePicker(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(45, 37); + label1.Name = "label1"; + label1.Size = new Size(40, 15); + label1.TabIndex = 0; + label1.Text = "Врач :"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(45, 96); + label2.Name = "label2"; + label2.Size = new Size(38, 15); + label2.TabIndex = 1; + label2.Text = "Дата :"; + // + // comboBoxDoctor + // + comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(144, 32); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(138, 23); + comboBoxDoctor.TabIndex = 3; + // + // dateTimePickerProfessionalDevelopmentDate + // + dateTimePickerProfessionalDevelopmentDate.Location = new Point(144, 96); + dateTimePickerProfessionalDevelopmentDate.Name = "dateTimePickerProfessionalDevelopmentDate"; + dateTimePickerProfessionalDevelopmentDate.Size = new Size(200, 23); + dateTimePickerProfessionalDevelopmentDate.TabIndex = 4; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(45, 134); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(84, 38); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(211, 134); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(87, 38); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormProfessionalDevelopment + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(368, 184); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerProfessionalDevelopmentDate); + Controls.Add(comboBoxDoctor); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormProfessionalDevelopment"; + Text = "Повышение квалификации врача"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private ComboBox comboBoxDoctor; + private DateTimePicker dateTimePickerProfessionalDevelopmentDate; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.cs new file mode 100644 index 0000000..8979d98 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.cs @@ -0,0 +1,54 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectPolyclinic.Forms +{ + public partial class FormProfessionalDevelopment : Form + { + private readonly IProfessionalDevelopmentRepository _professionalDevelopmentRepository; + + public FormProfessionalDevelopment(IProfessionalDevelopmentRepository professionalDevelopmentRepository, IDoctorRepository doctorRepository) + { + InitializeComponent(); + _professionalDevelopmentRepository = professionalDevelopmentRepository ?? + throw new ArgumentNullException(nameof(professionalDevelopmentRepository)); + comboBoxDoctor.DataSource = doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "FirstName"; + comboBoxDoctor.ValueMember = "Id"; + + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxDoctor.SelectedIndex < 0 ) + { + throw new Exception("Имеются незаполненные поля"); + } + _professionalDevelopmentRepository.CreateProfessionalDevelopment(ProfessionalDevelopment.CreateOperation( + 0, + (int)comboBoxDoctor.SelectedValue!, + dateTimePickerProfessionalDevelopmentDate.Value)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopment.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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.Designer.cs new file mode 100644 index 0000000..295c445 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.Designer.cs @@ -0,0 +1,97 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormProfessional_developments + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(654, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(146, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(35, 38); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(80, 58); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(654, 450); + dataGridViewData.TabIndex = 1; + // + // FormProfessional_developments + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormProfessional_developments"; + Text = "Повышение квалификации врачей"; + Load += FormProfessionalDevelopments_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.cs new file mode 100644 index 0000000..f1bd6f1 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.cs @@ -0,0 +1,59 @@ +using ProjectPolyclinic.Repositories; +using ProjectPolyclinic.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 ProjectPolyclinic.Forms +{ + public partial class FormProfessional_developments : Form + { + private readonly IUnityContainer _container; + private readonly IProfessionalDevelopmentRepository _professionalDevelopmentRepository; + public FormProfessional_developments(IUnityContainer container, IProfessionalDevelopmentRepository professionalDevelopmentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _professionalDevelopmentRepository = professionalDevelopmentRepository ?? + throw new + ArgumentNullException(nameof(professionalDevelopmentRepository)); + } + + private void FormProfessionalDevelopments_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _professionalDevelopmentRepository.ReadProfessionalDevelopment(); + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormProfessionalDevelopments.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/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.Designer.cs new file mode 100644 index 0000000..c91eb57 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.Designer.cs @@ -0,0 +1,217 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormVisiting + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + checkedListBoxDiagnosisName = new CheckedListBox(); + comboBoxDoctor = new ComboBox(); + comboBoxPatient = new ComboBox(); + dateTimePickerVisiting = new DateTimePicker(); + buttonSave = new Button(); + buttonCancel = new Button(); + dataGridViewMedicines = new DataGridView(); + ColumnMedicines = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + groupBoxMedicines = new GroupBox(); + ((System.ComponentModel.ISupportInitialize)dataGridViewMedicines).BeginInit(); + groupBoxMedicines.SuspendLayout(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(34, 35); + label1.Name = "label1"; + label1.Size = new Size(40, 15); + label1.TabIndex = 0; + label1.Text = "Врач :"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(34, 88); + label2.Name = "label2"; + label2.Size = new Size(60, 15); + label2.TabIndex = 1; + label2.Text = "Пациент :"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(34, 140); + label3.Name = "label3"; + label3.Size = new Size(58, 15); + label3.TabIndex = 2; + label3.Text = "Диагноз :"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(34, 255); + label4.Name = "label4"; + label4.Size = new Size(38, 15); + label4.TabIndex = 3; + label4.Text = "Дата :"; + // + // checkedListBoxDiagnosisName + // + checkedListBoxDiagnosisName.FormattingEnabled = true; + checkedListBoxDiagnosisName.Location = new Point(124, 140); + checkedListBoxDiagnosisName.Name = "checkedListBoxDiagnosisName"; + checkedListBoxDiagnosisName.Size = new Size(145, 94); + checkedListBoxDiagnosisName.TabIndex = 4; + // + // comboBoxDoctor + // + comboBoxDoctor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDoctor.FormattingEnabled = true; + comboBoxDoctor.Location = new Point(123, 35); + comboBoxDoctor.Name = "comboBoxDoctor"; + comboBoxDoctor.Size = new Size(146, 23); + comboBoxDoctor.TabIndex = 5; + // + // comboBoxPatient + // + comboBoxPatient.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPatient.FormattingEnabled = true; + comboBoxPatient.Location = new Point(124, 86); + comboBoxPatient.Name = "comboBoxPatient"; + comboBoxPatient.Size = new Size(145, 23); + comboBoxPatient.TabIndex = 6; + // + // dateTimePickerVisiting + // + dateTimePickerVisiting.Enabled = false; + dateTimePickerVisiting.Location = new Point(128, 250); + dateTimePickerVisiting.Name = "dateTimePickerVisiting"; + dateTimePickerVisiting.Size = new Size(200, 23); + dateTimePickerVisiting.TabIndex = 7; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(81, 457); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(119, 34); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(491, 457); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(135, 34); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // dataGridViewMedicines + // + dataGridViewMedicines.AllowUserToResizeColumns = false; + dataGridViewMedicines.AllowUserToResizeRows = false; + dataGridViewMedicines.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewMedicines.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewMedicines.Columns.AddRange(new DataGridViewColumn[] { ColumnMedicines, ColumnCount }); + dataGridViewMedicines.Location = new Point(20, 22); + dataGridViewMedicines.MultiSelect = false; + dataGridViewMedicines.Name = "dataGridViewMedicines"; + dataGridViewMedicines.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewMedicines.Size = new Size(272, 329); + dataGridViewMedicines.TabIndex = 10; + // + // ColumnMedicines + // + ColumnMedicines.HeaderText = "Медикаменты"; + ColumnMedicines.Name = "ColumnMedicines"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + // + // groupBoxMedicines + // + groupBoxMedicines.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxMedicines.Controls.Add(dataGridViewMedicines); + groupBoxMedicines.Location = new Point(334, 35); + groupBoxMedicines.Name = "groupBoxMedicines"; + groupBoxMedicines.Size = new Size(315, 369); + groupBoxMedicines.TabIndex = 11; + groupBoxMedicines.TabStop = false; + groupBoxMedicines.Text = "Медикаменты"; + // + // FormVisiting + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(733, 567); + Controls.Add(groupBoxMedicines); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerVisiting); + Controls.Add(comboBoxPatient); + Controls.Add(comboBoxDoctor); + Controls.Add(checkedListBoxDiagnosisName); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormVisiting"; + Text = "Визит"; + ((System.ComponentModel.ISupportInitialize)dataGridViewMedicines).EndInit(); + groupBoxMedicines.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private CheckedListBox checkedListBoxDiagnosisName; + private ComboBox comboBoxDoctor; + private ComboBox comboBoxPatient; + private DateTimePicker dateTimePickerVisiting; + private Button buttonSave; + private Button buttonCancel; + private DataGridView dataGridViewMedicines; + private GroupBox groupBoxMedicines; + private DataGridViewComboBoxColumn ColumnMedicines; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.cs new file mode 100644 index 0000000..d10f993 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.cs @@ -0,0 +1,93 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Entities.Enums; +using ProjectPolyclinic.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectPolyclinic.Forms +{ + public partial class FormVisiting : Form + { + private readonly IVisitingRepository _visitingRepository; + public FormVisiting(IVisitingRepository visitingRepository, IDoctorRepository doctorRepository, IPatientRepository patientRepository, IMedicationRepository medicationRepository) + { + InitializeComponent(); + _visitingRepository = visitingRepository ?? throw new ArgumentNullException(nameof(visitingRepository)); + comboBoxDoctor.DataSource = + doctorRepository.ReadDoctors(); + comboBoxDoctor.DisplayMember = "FirstName"; + comboBoxDoctor.ValueMember = "Id"; + comboBoxPatient.DataSource = patientRepository.ReadPatients(); + comboBoxPatient.DisplayMember = "FirstName"; + comboBoxPatient.ValueMember = "Id"; + foreach (var elem in Enum.GetValues(typeof(DiagnosisName))) + { + checkedListBoxDiagnosisName.Items.Add(elem); + } + ColumnMedicines.DataSource = medicationRepository.ReadMedication(); + ColumnMedicines.DisplayMember = "MedicinesType"; + ColumnMedicines.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxDoctor.SelectedIndex < 0 || + comboBoxPatient.SelectedIndex < 0 || + checkedListBoxDiagnosisName.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + DiagnosisName diagnosisName = DiagnosisName.None; + foreach (var elem in checkedListBoxDiagnosisName.CheckedItems) + { + diagnosisName |= (DiagnosisName)elem; + } + _visitingRepository.CreateVisiting(Visiting.CreateOperation( + 0, + (int)comboBoxDoctor.SelectedValue!, + (int)comboBoxPatient.SelectedValue!, + diagnosisName, + dateTimePickerVisiting.Value, CreateListMedicines_VisitingFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + + + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListMedicines_VisitingFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewMedicines.Rows) + { + if (row.Cells["ColumnFeed"].Value == null || + row.Cells["ColumnCount"].Value == null) + { + continue; + } + list.Add(Medicines_Visiting.CreateElement(0, + Convert.ToInt32(row.Cells["ColumnMedicines"].Value), + Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } + + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.resx new file mode 100644 index 0000000..0ccc710 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisiting.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.Designer.cs new file mode 100644 index 0000000..aaf8775 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.Designer.cs @@ -0,0 +1,112 @@ +namespace ProjectPolyclinic.Forms +{ + partial class FormVisitings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(673, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(127, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(27, 133); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 62); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(27, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 62); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(673, 450); + dataGridViewData.TabIndex = 1; + // + // FormVisitings + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormVisitings"; + StartPosition = FormStartPosition.CenterParent; + Text = "Визиты"; + Load += FormVisitings_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.cs b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.cs new file mode 100644 index 0000000..7208ae8 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.cs @@ -0,0 +1,96 @@ +using ProjectPolyclinic.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 ProjectPolyclinic.Forms +{ + public partial class FormVisitings : Form + { + private readonly IUnityContainer _container; + private readonly IVisitingRepository _visitingRepository; + public FormVisitings(IUnityContainer container, IVisitingRepository visitingRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _visitingRepository = visitingRepository ?? + throw new + ArgumentNullException(nameof(visitingRepository)); + } + + private void FormVisitings_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", +MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _visitingRepository.DeleteVisiting(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void LoadList() => dataGridViewData.DataSource = _visitingRepository.ReadVisiting(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.resx b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Forms/FormVisitings.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/ProjectPolyclinic/ProjectPolyclinic/Program.cs b/ProjectPolyclinic/ProjectPolyclinic/Program.cs index 86d17b9..1e56aec 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/Program.cs +++ b/ProjectPolyclinic/ProjectPolyclinic/Program.cs @@ -1,3 +1,7 @@ +using ProjectPolyclinic.Repositories; +using ProjectPolyclinic.Repositories.Implementations; +using Unity; +using Unity.Lifetime; namespace ProjectPolyclinic { internal static class Program @@ -11,7 +15,17 @@ namespace ProjectPolyclinic // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve ()); + } + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; } } } \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj b/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj index 663fdb8..accbdf0 100644 --- a/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj +++ b/ProjectPolyclinic/ProjectPolyclinic/ProjectPolyclinic.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.Designer.cs b/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.Designer.cs new file mode 100644 index 0000000..38a037e --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectPolyclinic.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("ProjectPolyclinic.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 карандаш { + get { + object obj = ResourceManager.GetObject("карандаш", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap минус { + get { + object obj = ResourceManager.GetObject("минус", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap плюс { + get { + object obj = ResourceManager.GetObject("плюс", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap поликлиника { + get { + object obj = ResourceManager.GetObject("поликлиника", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.resx b/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.resx new file mode 100644 index 0000000..ccb7d04 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\поликлиника.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\карандаш.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\плюс.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\минус.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorRepository.cs new file mode 100644 index 0000000..1b82cf4 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IDoctorRepository.cs @@ -0,0 +1,18 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories +{ + public interface IDoctorRepository + { + IEnumerable ReadDoctors(); + Doctor ReadDoctorById(int id); + void CreateDoctor(Doctor doctor); + void UpdateDoctor(Doctor doctor); + void DeleteDoctor(int id); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IMedicationRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IMedicationRepository.cs new file mode 100644 index 0000000..31d2f13 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IMedicationRepository.cs @@ -0,0 +1,18 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories +{ + public interface IMedicationRepository + { + IEnumerable ReadMedication(); + Medication ReadMedicationById(int id); + void CreateMedication(Medication medication); + void UpdateMedication(Medication medication); + void DeleteMedication(int id); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IPatientRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IPatientRepository.cs new file mode 100644 index 0000000..ffcb0ea --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IPatientRepository.cs @@ -0,0 +1,18 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories +{ + public interface IPatientRepository + { + IEnumerable ReadPatients(); + Patient ReadPatientById(int id); + void CreatePatient(Patient patient); + void UpdatePatient(Patient patient); + void DeletePatient(int id); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IProfessionalDevelopmentRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IProfessionalDevelopmentRepository.cs new file mode 100644 index 0000000..734f23e --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IProfessionalDevelopmentRepository.cs @@ -0,0 +1,16 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories +{ + public interface IProfessionalDevelopmentRepository + { + IEnumerable ReadProfessionalDevelopment(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null, int? Id = null); + void CreateProfessionalDevelopment(ProfessionalDevelopment professionalDevelopment); + + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/IVisitingRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IVisitingRepository.cs new file mode 100644 index 0000000..93d0738 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/IVisitingRepository.cs @@ -0,0 +1,16 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories +{ + public interface IVisitingRepository + { + IEnumerable ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null,int ? visitingId = null); + void CreateVisiting(Visiting visiting); + void DeleteVisiting(int id); + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs new file mode 100644 index 0000000..8e33bd0 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/DoctorRepository.cs @@ -0,0 +1,34 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories.Implementations +{ + internal class DoctorRepository:IDoctorRepository + { + public void CreateDoctor(Doctor doctor) + { + + } + public void DeleteDoctor(int id) + { + + } + public Doctor ReadDoctorById(int id) + { + return Doctor.CreateEntity(0, string.Empty, string.Empty, Specialization.None); + } + public IEnumerable ReadDoctors() + { + return []; + } + public void UpdateDoctor(Doctor doctor) + { + + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicationRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicationRepository.cs new file mode 100644 index 0000000..2ea4f41 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/MedicationRepository.cs @@ -0,0 +1,34 @@ +using ProjectPolyclinic.Entities; +using ProjectPolyclinic.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories.Implementations +{ + internal class MedicationRepository:IMedicationRepository + { + public void CreateMedication(Medication medication) + { + + } + public void DeleteMedication(int id) + { + + } + public Medication ReadMedicationById(int id) + { + return Medication.CreateEntity(0, MedicinesType.None, string.Empty, string.Empty); + } + public IEnumerable ReadMedication() + { + return []; + } + public void UpdateMedication(Medication medication) + { + + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs new file mode 100644 index 0000000..f04e9be --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/PatientRepository.cs @@ -0,0 +1,33 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories.Implementations +{ + internal class PatientRepository:IPatientRepository + { + public void CreatePatient(Patient patient) + { + + } + public void DeletePatient(int id) + { + + } + public Patient ReadPatientById(int id) + { + return Patient.CreateEntity(0, string.Empty, string.Empty, string.Empty); + } + public IEnumerable ReadPatients() + { + return []; + } + public void UpdatePatient(Patient patient) + { + + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ProfessionalDevelopmentRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ProfessionalDevelopmentRepository.cs new file mode 100644 index 0000000..a92b071 --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/ProfessionalDevelopmentRepository.cs @@ -0,0 +1,21 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories.Implementations +{ + internal class ProfessionalDevelopmentRepository:IProfessionalDevelopmentRepository + { + public void CreateProfessionalDevelopment(ProfessionalDevelopment professionalDevelopment) + { + } + + public IEnumerable ReadProfessionalDevelopment(DateTime? dateForm = null, DateTime? dateTo = null, int? doctorId = null, int? Id = null) + { + return []; + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/VisitingRepository.cs b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/VisitingRepository.cs new file mode 100644 index 0000000..c538d1f --- /dev/null +++ b/ProjectPolyclinic/ProjectPolyclinic/Repositories/Implementations/VisitingRepository.cs @@ -0,0 +1,25 @@ +using ProjectPolyclinic.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPolyclinic.Repositories.Implementations +{ + internal class VisitingRepository:IVisitingRepository + { + public void CreateVisiting(Visiting visiting) + { + } + + public void DeleteVisiting(int id) + { + } + + public IEnumerable ReadVisiting(DateTime? dateForm = null, DateTime? dateTo = null, int? patientId = null, int? doctorId = null,int ? visitingId = null) + { + return []; + } + } +} diff --git a/ProjectPolyclinic/ProjectPolyclinic/Resources/карандаш.jpg b/ProjectPolyclinic/ProjectPolyclinic/Resources/карандаш.jpg new file mode 100644 index 0000000..44c4c5d Binary files /dev/null and b/ProjectPolyclinic/ProjectPolyclinic/Resources/карандаш.jpg differ diff --git a/ProjectPolyclinic/ProjectPolyclinic/Resources/минус.png b/ProjectPolyclinic/ProjectPolyclinic/Resources/минус.png new file mode 100644 index 0000000..f743fbc Binary files /dev/null and b/ProjectPolyclinic/ProjectPolyclinic/Resources/минус.png differ diff --git a/ProjectPolyclinic/ProjectPolyclinic/Resources/плюс.png b/ProjectPolyclinic/ProjectPolyclinic/Resources/плюс.png new file mode 100644 index 0000000..7689610 Binary files /dev/null and b/ProjectPolyclinic/ProjectPolyclinic/Resources/плюс.png differ diff --git a/ProjectPolyclinic/ProjectPolyclinic/Resources/поликлиника.png b/ProjectPolyclinic/ProjectPolyclinic/Resources/поликлиника.png new file mode 100644 index 0000000..e041141 Binary files /dev/null and b/ProjectPolyclinic/ProjectPolyclinic/Resources/поликлиника.png differ