лабораторная работа №3
This commit is contained in:
parent
4640f32b8a
commit
fd88b9ed11
@ -6,19 +6,22 @@ namespace RegistrationOfPatients.Entities;
|
||||
|
||||
public class Medicine
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public MedicineType MedicineType { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
public static Medicine CreateEntity(int id, MedicineType medicineType, string name, string description)
|
||||
public int Count { get; private set; }
|
||||
public DateTime Date { get; private set; }
|
||||
public static Medicine CreateEntity(int id, MedicineType medicineType, string name, string description, int count, DateTime date)
|
||||
{
|
||||
return new Medicine
|
||||
{
|
||||
Id = id,
|
||||
MedicineType = medicineType,
|
||||
Name = name,
|
||||
Description = description ?? string.Empty
|
||||
Description = description ?? string.Empty,
|
||||
Count = count,
|
||||
Date = date
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class Payment
|
||||
Id = id,
|
||||
Salary = salary,
|
||||
TotalPatients = totalPatients,
|
||||
Date = DateTime.Now,
|
||||
Date = date,
|
||||
PercentageOfRecoveries = percentageOfRecoveries,
|
||||
DoctorId = doctorId
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ public class Reception
|
||||
return new Reception
|
||||
{
|
||||
Id = id,
|
||||
Date = DateTime.Now,
|
||||
Date = date,
|
||||
HealthStatus = healthStatus,
|
||||
Illness = illness ?? string.Empty,
|
||||
PatientId = patientId,
|
||||
@ -30,7 +30,10 @@ public class Reception
|
||||
return new Reception
|
||||
{
|
||||
Id = tempReceptionMedicine.Id,
|
||||
Date = tempReceptionMedicine.Date,
|
||||
Date = tempReceptionMedicine.Date,
|
||||
HealthStatus = tempReceptionMedicine.HealthStatus,
|
||||
Illness = tempReceptionMedicine.Illness ?? string.Empty,
|
||||
PatientId = tempReceptionMedicine.PatientId,
|
||||
DoctorId = tempReceptionMedicine.DoctorId,
|
||||
ReceptionMedicine = receptionMedicine
|
||||
};
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
public class ReceptionMedicine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ReceptionId { get; set; }
|
||||
public int MedicineId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public static ReceptionMedicine CreateElement(int id, int medicineId, int count)
|
||||
public int Count { get; private set; }
|
||||
public static ReceptionMedicine CreateElement(int receptionId, int medicineId, int count)
|
||||
{
|
||||
return new ReceptionMedicine
|
||||
{
|
||||
Id = id,
|
||||
ReceptionId = receptionId,
|
||||
MedicineId = medicineId,
|
||||
Count = count,
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using RegistrationOfPatients.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -10,9 +11,13 @@ public class TempReceptionMedicine
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int DoctorId { get; private set; }
|
||||
//public int ReceptionId { get; private set; }
|
||||
public HealthStatus HealthStatus { get; private set; }
|
||||
|
||||
public DateTime Date { get; private set; }
|
||||
public string Illness { get; private set; } = string.Empty;
|
||||
public int PatientId { get; private set; }
|
||||
public int DoctorId { get; private set; }
|
||||
|
||||
public int MedicineId { get; private set; }
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
MedicineReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
MedicineDistributionToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -103,7 +104,7 @@
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, MedicineReportToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, MedicineReportToolStripMenuItem, MedicineDistributionToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
@ -124,6 +125,14 @@
|
||||
MedicineReportToolStripMenuItem.Text = "Движение лекарств";
|
||||
MedicineReportToolStripMenuItem.Click += MedicineReportToolStripMenuItem_Click;
|
||||
//
|
||||
// MedicineDistributionToolStripMenuItem
|
||||
//
|
||||
MedicineDistributionToolStripMenuItem.Name = "MedicineDistributionToolStripMenuItem";
|
||||
MedicineDistributionToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
MedicineDistributionToolStripMenuItem.Size = new Size(350, 26);
|
||||
MedicineDistributionToolStripMenuItem.Text = "Распределние лекарств";
|
||||
MedicineDistributionToolStripMenuItem.Click += MedicineDistributionToolStripMenuItem_Click;
|
||||
//
|
||||
// FormRegistration
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -155,5 +164,6 @@
|
||||
private ToolStripMenuItem MedicinesToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem MedicineReportToolStripMenuItem;
|
||||
private ToolStripMenuItem MedicineDistributionToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -95,4 +95,16 @@ public partial class FormRegistration : Form
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void MedicineDistributionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormReceptionDistributionReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,11 @@
|
||||
ButtonCancel = new Button();
|
||||
textBoxName = new TextBox();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
numericUpDownCount = new NumericUpDown();
|
||||
dateTimePickerMedicine = new DateTimePicker();
|
||||
label5 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
@ -58,7 +63,7 @@
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(65, 217);
|
||||
label2.Location = new Point(65, 304);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(82, 20);
|
||||
label2.TabIndex = 2;
|
||||
@ -66,7 +71,7 @@
|
||||
//
|
||||
// textBoxDescription
|
||||
//
|
||||
textBoxDescription.Location = new Point(195, 217);
|
||||
textBoxDescription.Location = new Point(195, 304);
|
||||
textBoxDescription.Multiline = true;
|
||||
textBoxDescription.Name = "textBoxDescription";
|
||||
textBoxDescription.Size = new Size(247, 72);
|
||||
@ -74,7 +79,7 @@
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(65, 314);
|
||||
ButtonSave.Location = new Point(65, 401);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(94, 29);
|
||||
ButtonSave.TabIndex = 4;
|
||||
@ -84,7 +89,7 @@
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(195, 314);
|
||||
ButtonCancel.Location = new Point(195, 401);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(94, 29);
|
||||
ButtonCancel.TabIndex = 5;
|
||||
@ -109,11 +114,47 @@
|
||||
label3.TabIndex = 6;
|
||||
label3.Text = "Название:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(65, 214);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(93, 20);
|
||||
label4.TabIndex = 8;
|
||||
label4.Text = "Количество:";
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
numericUpDownCount.Location = new Point(195, 214);
|
||||
numericUpDownCount.Name = "numericUpDownCount";
|
||||
numericUpDownCount.Size = new Size(247, 27);
|
||||
numericUpDownCount.TabIndex = 10;
|
||||
//
|
||||
// dateTimePickerMedicine
|
||||
//
|
||||
dateTimePickerMedicine.Location = new Point(195, 253);
|
||||
dateTimePickerMedicine.Name = "dateTimePickerMedicine";
|
||||
dateTimePickerMedicine.Size = new Size(178, 27);
|
||||
dateTimePickerMedicine.TabIndex = 14;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(65, 253);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(44, 20);
|
||||
label5.TabIndex = 13;
|
||||
label5.Text = "Дата:";
|
||||
//
|
||||
// FormMedicine
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(593, 421);
|
||||
ClientSize = new Size(593, 499);
|
||||
Controls.Add(dateTimePickerMedicine);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(numericUpDownCount);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(ButtonCancel);
|
||||
@ -125,6 +166,7 @@
|
||||
Name = "FormMedicine";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Лекарства";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -139,5 +181,9 @@
|
||||
private Button ButtonCancel;
|
||||
private TextBox textBoxName;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private DateTimePicker dateTimePickerMedicine;
|
||||
private Label label5;
|
||||
}
|
||||
}
|
@ -92,6 +92,6 @@ public partial class FormMedicine : Form
|
||||
{
|
||||
medicineType |= (MedicineType)elem;
|
||||
}
|
||||
return Medicine.CreateEntity(id, medicineType, textBoxName.Text, textBoxDescription.Text);
|
||||
return Medicine.CreateEntity(id, medicineType, textBoxName.Text, textBoxDescription.Text, Convert.ToInt32(numericUpDownCount.Value), dateTimePickerMedicine.Value);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public partial class FormMedicineReport : Form
|
||||
|
||||
if (comboBoxMedicine.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран корм");
|
||||
throw new Exception("Не выбран лекарство");
|
||||
}
|
||||
|
||||
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||
|
@ -91,7 +91,6 @@
|
||||
//
|
||||
// dateTimePickerPayment
|
||||
//
|
||||
dateTimePickerPayment.Enabled = false;
|
||||
dateTimePickerPayment.Location = new Point(235, 238);
|
||||
dateTimePickerPayment.Name = "dateTimePickerPayment";
|
||||
dateTimePickerPayment.Size = new Size(178, 27);
|
||||
|
@ -40,10 +40,10 @@
|
||||
ButtonCancel = new Button();
|
||||
groupBoxMedicine = new GroupBox();
|
||||
dataGridViewMedicines = new DataGridView();
|
||||
label5 = new Label();
|
||||
dateTimePickerReception = new DateTimePicker();
|
||||
ColumnMedicine = new DataGridViewComboBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
label5 = new Label();
|
||||
dateTimePickerReception = new DateTimePicker();
|
||||
groupBoxMedicine.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewMedicines).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -168,23 +168,6 @@
|
||||
dataGridViewMedicines.Size = new Size(276, 121);
|
||||
dataGridViewMedicines.TabIndex = 0;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(69, 214);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(44, 20);
|
||||
label5.TabIndex = 11;
|
||||
label5.Text = "Дата:";
|
||||
//
|
||||
// dateTimePickerReception
|
||||
//
|
||||
dateTimePickerReception.Enabled = false;
|
||||
dateTimePickerReception.Location = new Point(276, 214);
|
||||
dateTimePickerReception.Name = "dateTimePickerReception";
|
||||
dateTimePickerReception.Size = new Size(178, 27);
|
||||
dateTimePickerReception.TabIndex = 12;
|
||||
//
|
||||
// ColumnMedicine
|
||||
//
|
||||
ColumnMedicine.HeaderText = "Лекарство";
|
||||
@ -197,6 +180,22 @@
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(69, 214);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(44, 20);
|
||||
label5.TabIndex = 11;
|
||||
label5.Text = "Дата:";
|
||||
//
|
||||
// dateTimePickerReception
|
||||
//
|
||||
dateTimePickerReception.Location = new Point(276, 214);
|
||||
dateTimePickerReception.Name = "dateTimePickerReception";
|
||||
dateTimePickerReception.Size = new Size(178, 27);
|
||||
dateTimePickerReception.TabIndex = 12;
|
||||
//
|
||||
// FormReception
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
|
130
RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptionDistributionReport.Designer.cs
generated
Normal file
130
RegistrationOfPatients/RegistrationOfPatients/Forms/FormReceptionDistributionReport.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
||||
namespace RegistrationOfPatients.Forms
|
||||
{
|
||||
partial class FormReceptionDistributionReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ButtonSelectFileName = new Button();
|
||||
label1 = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
ButtonCreate = new Button();
|
||||
comboBoxSelectMedicine = new ComboBox();
|
||||
label2 = new Label();
|
||||
labelFileName = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ButtonSelectFileName
|
||||
//
|
||||
ButtonSelectFileName.Location = new Point(36, 24);
|
||||
ButtonSelectFileName.Name = "ButtonSelectFileName";
|
||||
ButtonSelectFileName.Size = new Size(146, 29);
|
||||
ButtonSelectFileName.TabIndex = 0;
|
||||
ButtonSelectFileName.Text = "Выбрать файл";
|
||||
ButtonSelectFileName.UseVisualStyleBackColor = true;
|
||||
ButtonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(36, 120);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(44, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Дата:";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(148, 115);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(181, 27);
|
||||
dateTimePicker.TabIndex = 2;
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Location = new Point(81, 258);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(179, 29);
|
||||
ButtonCreate.TabIndex = 3;
|
||||
ButtonCreate.Text = "Сформировать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// comboBoxSelectMedicine
|
||||
//
|
||||
comboBoxSelectMedicine.FormattingEnabled = true;
|
||||
comboBoxSelectMedicine.Location = new Point(148, 168);
|
||||
comboBoxSelectMedicine.Name = "comboBoxSelectMedicine";
|
||||
comboBoxSelectMedicine.Size = new Size(181, 28);
|
||||
comboBoxSelectMedicine.TabIndex = 4;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(36, 171);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(27, 20);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "ID:";
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(232, 24);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(45, 20);
|
||||
labelFileName.TabIndex = 6;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// FormReceptionDistributionReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(362, 351);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(comboBoxSelectMedicine);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(ButtonSelectFileName);
|
||||
Name = "FormReceptionDistributionReport";
|
||||
Text = "FormReceptionDistributionReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonSelectFileName;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button ButtonCreate;
|
||||
private ComboBox comboBoxSelectMedicine;
|
||||
private Label label2;
|
||||
private Label labelFileName;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using PdfSharp.Drawing;
|
||||
using RegistrationOfPatients.Reports;
|
||||
using RegistrationOfPatients.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace RegistrationOfPatients.Forms;
|
||||
|
||||
public partial class FormReceptionDistributionReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
private readonly IUnityContainer _container;
|
||||
public FormReceptionDistributionReport(IUnityContainer container, IMedicineRepository medicineRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
|
||||
comboBoxSelectMedicine.DataSource = medicineRepository.ReadMedicine();
|
||||
comboBoxSelectMedicine.DisplayMember = "Name";
|
||||
comboBoxSelectMedicine.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSelectFileName_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Pdf Files | *.pdf"
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_fileName = sfd.FileName;
|
||||
labelFileName.Text = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_fileName))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if (comboBoxSelectMedicine.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбрана запись");
|
||||
}
|
||||
if (_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value, (int)comboBoxSelectMedicine.SelectedValue!))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -16,6 +16,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
|
@ -0,0 +1,51 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using RegistrationOfPatients.Entities;
|
||||
using RegistrationOfPatients.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RegistrationOfPatients.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IReceptionRepository _receptionRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IReceptionRepository receptionRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_receptionRepository = receptionRepository ?? throw new ArgumentNullException(nameof(receptionRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
public bool CreateChart(string filePath, DateTime dateTime, int medicineId)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Записи")
|
||||
.AddPieChart("Виды записей", GetData(dateTime, medicineId))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime, int medicineId)
|
||||
{
|
||||
return _receptionRepository
|
||||
.ReadReceptions()
|
||||
.Where(x => x.Date.Date == dateTime.Date)
|
||||
.GroupBy(x => x.Id, (key, group) => new
|
||||
{
|
||||
Id = key,
|
||||
Count = group.Sum(x => x.ReceptionMedicine.FirstOrDefault(y => y.MedicineId == medicineId)?.Count ?? 0)
|
||||
})
|
||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ internal class ExcelBuilder
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
@ -84,7 +84,7 @@ internal class ExcelBuilder
|
||||
}));
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
@ -92,7 +92,7 @@ internal class ExcelBuilder
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
@ -100,7 +100,7 @@ internal class ExcelBuilder
|
||||
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.SimpleTextWithoutBorder);
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
@ -159,15 +159,15 @@ internal class ExcelBuilder
|
||||
});
|
||||
// TODO добавить шрифт с жирным
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
Bold = new Bold() { Val = true },
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
},
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
@ -289,7 +289,7 @@ internal class ExcelBuilder
|
||||
}
|
||||
|
||||
var newCell = row.Elements<Cell>()
|
||||
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
|
@ -0,0 +1,91 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RegistrationOfPatients.Reports;
|
||||
|
||||
public class PdfBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
public PdfBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
|
||||
public PdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
|
||||
chart.TopArea.AddParagraph(title);
|
||||
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
|
||||
chart.TopArea.AddLegend();
|
||||
|
||||
_document.LastSection.Add(chart);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(_filePath);
|
||||
}
|
||||
private void DefineStyles()
|
||||
{
|
||||
var style = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
style.Font.Bold = true;
|
||||
style.Font.Size = 14;
|
||||
style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
}
|
||||
}
|
@ -12,16 +12,16 @@ internal class TableReport
|
||||
{
|
||||
private readonly IReceptionRepository _receptionRepository;
|
||||
|
||||
private readonly IPaymentRepository _paymentRepository;
|
||||
private readonly IMedicineRepository _medicineRepository;
|
||||
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] item = ["Доктор", "Дата", "Количество пришло", "Количество ушло"];
|
||||
internal static readonly string[] item = ["Дата", "Количество лекарства ушло", "Количество лекарства пришло"];
|
||||
|
||||
public TableReport(IPaymentRepository paymentRepository, IReceptionRepository receptionRepository, ILogger<TableReport> logger)
|
||||
public TableReport(IMedicineRepository medicineRepository, IReceptionRepository receptionRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_receptionRepository = receptionRepository ?? throw new ArgumentNullException(nameof(receptionRepository));
|
||||
_paymentRepository = paymentRepository ?? throw new ArgumentNullException(nameof(paymentRepository));
|
||||
_medicineRepository = medicineRepository ?? throw new ArgumentNullException(nameof(medicineRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
@ -30,9 +30,9 @@ internal class TableReport
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по движению лекарств", 0, 4)
|
||||
.AddHeader("Сводка по движению лекарств", 0, 3)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable([10, 10, 15, 15], GetData(medicineId, startDate, endDate))
|
||||
.AddTable([15, 15, 15], GetData(medicineId, startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
@ -49,24 +49,23 @@ internal class TableReport
|
||||
.ReadReceptions()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ReceptionMedicine.Any(y => y.MedicineId == medicineId))
|
||||
.Select(x => new
|
||||
{
|
||||
x.DoctorId,
|
||||
{
|
||||
Date = x.Date,
|
||||
CountIn = x.ReceptionMedicine.FirstOrDefault(y => y.MedicineId == medicineId)?.Count, CountOut = (int?)null
|
||||
})
|
||||
.Union(
|
||||
_paymentRepository
|
||||
.ReadPayment()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.DoctorId == medicineId)
|
||||
.Select(x => new { x.DoctorId, Date = x.Date, CountIn = (int?)null, CountOut = (int?)null }))
|
||||
_medicineRepository
|
||||
.ReadMedicine()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.Id == medicineId)
|
||||
.Select(x => new { Date = x.Date, CountIn = (int?)null, CountOut = (int?)x.Count }))
|
||||
.OrderBy(x => x.Date);
|
||||
|
||||
return new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] { x.DoctorId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||
.Select(x => new string[] { x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||
.Union(
|
||||
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
||||
[["Всего", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class MedicineRepository : IMedicineRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @" INSERT INTO Medicine (MedicineType, Description, Name) VALUES (@MedicineType, @Description, @Name)";
|
||||
var queryInsert = @" INSERT INTO Medicine (Date, Count, MedicineType, Description, Name) VALUES (@Date, @Count, @MedicineType, @Description, @Name)";
|
||||
connection.Execute(queryInsert, medicine);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -44,7 +44,7 @@ public class MedicineRepository : IMedicineRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @" UPDATE Medicine SET MedicineType=@MedicineType, Description=@Description, Name=@Name WHERE Id=@Id"; connection.Execute(queryUpdate, medicine);
|
||||
var queryUpdate = @" UPDATE Medicine SET Date=@Date, Count=@Count, MedicineType=@MedicineType, Description=@Description, Name=@Name WHERE Id=@Id"; connection.Execute(queryUpdate, medicine);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -35,10 +35,10 @@ public class ReceptionRepository : IReceptionRepository
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @" INSERT INTO Reception (Date, HealthStatus, Illness, PatientId, DoctorId) VALUES (@Date, @HealthStatus, @Illness, @PatientId, @DoctorId); SELECT MAX(Id) FROM Reception";
|
||||
var queryInsert = @" INSERT INTO Reception (Date, HealthStatus, Illness, PatientID, DoctorID) VALUES (@Date, @HealthStatus, @Illness, @PatientID, @DoctorID); SELECT MAX(Id) FROM Reception";
|
||||
|
||||
var receptionId = connection.QueryFirst<int>(queryInsert, reception, transaction);
|
||||
var querySubInsert = @" INSERT INTO ReceptionMedicine (ReceptionID, MedicineId, Count) VALUES (@ReceptionId, @MedicineId, @Count)";
|
||||
var querySubInsert = @" INSERT INTO ReceptionMedicine (ReceptionID, MedicineId, Count) VALUES (@ReceptionID, @MedicineID, @Count)";
|
||||
|
||||
foreach (var elem in reception.ReceptionMedicine)
|
||||
{
|
||||
@ -64,7 +64,7 @@ public class ReceptionRepository : IReceptionRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT r.Id AS ReceptionId, r.DoctorId, r.Patient.Id, r.Date, rm.MedicineId, rm.Count FROM Reception r INNER JOIN ReceptionMedicine rm ON r.DoctorID = r.ID";
|
||||
var querySelect = @"SELECT r.*, rm.MedicineID, rm.Count FROM Reception r INNER JOIN ReceptionMedicine rm on rm.ReceptionID = r.ID";
|
||||
var receptions = connection.Query<TempReceptionMedicine>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(receptions));
|
||||
return receptions.GroupBy(x => x.Id, y => y,
|
||||
|
Loading…
x
Reference in New Issue
Block a user