почти готово
This commit is contained in:
parent
10f31c88a5
commit
4640f32b8a
@ -24,4 +24,15 @@ public class Reception
|
|||||||
ReceptionMedicine = receptionMedicine
|
ReceptionMedicine = receptionMedicine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Reception CreateOperation(TempReceptionMedicine tempReceptionMedicine, IEnumerable<ReceptionMedicine> receptionMedicine)
|
||||||
|
{
|
||||||
|
return new Reception
|
||||||
|
{
|
||||||
|
Id = tempReceptionMedicine.Id,
|
||||||
|
Date = tempReceptionMedicine.Date,
|
||||||
|
DoctorId = tempReceptionMedicine.DoctorId,
|
||||||
|
ReceptionMedicine = receptionMedicine
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RegistrationOfPatients.Entities;
|
||||||
|
|
||||||
|
public class TempReceptionMedicine
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int DoctorId { get; private set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public int MedicineId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
}
|
@ -38,6 +38,7 @@
|
|||||||
PaymentToolStripMenuItem = new ToolStripMenuItem();
|
PaymentToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
MedicineReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -102,7 +103,7 @@
|
|||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem });
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, MedicineReportToolStripMenuItem });
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
@ -115,6 +116,14 @@
|
|||||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// MedicineReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
MedicineReportToolStripMenuItem.Name = "MedicineReportToolStripMenuItem";
|
||||||
|
MedicineReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
MedicineReportToolStripMenuItem.Size = new Size(350, 26);
|
||||||
|
MedicineReportToolStripMenuItem.Text = "Движение лекарств";
|
||||||
|
MedicineReportToolStripMenuItem.Click += MedicineReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormRegistration
|
// FormRegistration
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -145,5 +154,6 @@
|
|||||||
private ToolStripMenuItem PaymentToolStripMenuItem;
|
private ToolStripMenuItem PaymentToolStripMenuItem;
|
||||||
private ToolStripMenuItem MedicinesToolStripMenuItem;
|
private ToolStripMenuItem MedicinesToolStripMenuItem;
|
||||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem MedicineReportToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -83,4 +83,16 @@ public partial class FormRegistration : Form
|
|||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MedicineReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormMedicineReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -71,6 +71,6 @@ public partial class FormReception : Form
|
|||||||
}
|
}
|
||||||
list.Add(ReceptionMedicine.CreateElement(0, Convert.ToInt32(row.Cells["ColumnMedicine"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
list.Add(ReceptionMedicine.CreateElement(0, Convert.ToInt32(row.Cells["ColumnMedicine"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||||
}
|
}
|
||||||
return list;
|
return list.GroupBy(x => x.MedicineId, x => x.Count, (id, counts) => ReceptionMedicine.CreateElement(0, id, counts.Sum())).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class ReceptionRepository : IReceptionRepository
|
|||||||
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 receptionId = connection.QueryFirst<int>(queryInsert, reception, transaction);
|
||||||
var querySubInsert = @" INSERT INTO ReceptionMedicine (MedicineId, Count) VALUES (@MedicineId, @Count)";
|
var querySubInsert = @" INSERT INTO ReceptionMedicine (ReceptionID, MedicineId, Count) VALUES (@ReceptionId, @MedicineId, @Count)";
|
||||||
|
|
||||||
foreach (var elem in reception.ReceptionMedicine)
|
foreach (var elem in reception.ReceptionMedicine)
|
||||||
{
|
{
|
||||||
@ -64,10 +64,12 @@ public class ReceptionRepository : IReceptionRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT * FROM Reception";
|
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 receptions = connection.Query<Reception>(querySelect);
|
var receptions = connection.Query<TempReceptionMedicine>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(receptions));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(receptions));
|
||||||
return receptions;
|
return receptions.GroupBy(x => x.Id, y => y,
|
||||||
|
(key, value) => Reception.CreateOperation(value.First(),
|
||||||
|
value.Select(z => ReceptionMedicine.CreateElement(0, z.MedicineId, z.Count)))).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user