ПИбд-21 Абакаров А.А. Лабораторная работа 3 #3
23
ProjectRepairWork/Entities/BuildingMaterials.cs
Normal file
23
ProjectRepairWork/Entities/BuildingMaterials.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Entities;
|
||||
|
||||
public class BuildingMaterials
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string MaterialsType { get; private set; } = string.Empty;
|
||||
|
||||
public static BuildingMaterials CreatEntity(int id, string materialType)
|
||||
{
|
||||
return new BuildingMaterials
|
||||
{
|
||||
Id = id,
|
||||
MaterialsType = materialType,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
26
ProjectRepairWork/Entities/MaterialProcurement.cs
Normal file
26
ProjectRepairWork/Entities/MaterialProcurement.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Entities;
|
||||
|
||||
public class MaterialProcurement
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int MaterialsId { get; private set; }
|
||||
public DateTime ProcurmentDate { get; private set; }
|
||||
public int MaterialsPrice { get; private set; }
|
||||
|
||||
public static MaterialProcurement CreatOpertions(int id, int materialsId, int materialsPrice)
|
||||
{
|
||||
return new MaterialProcurement
|
||||
{
|
||||
Id = id,
|
||||
MaterialsId = materialsId,
|
||||
ProcurmentDate = DateTime.Now,
|
||||
MaterialsPrice = materialsPrice,
|
||||
};
|
||||
}
|
||||
}
|
@ -11,17 +11,20 @@ public class Repair
|
||||
public int Id { get; private set; }
|
||||
public int ContractorsId { get; private set; }
|
||||
public int PremisesId { get; private set; }
|
||||
|
||||
public DateTime DateRepair { get; private set; }
|
||||
public IEnumerable<RepairRepair> RepairRepair { get; private set; } = [];
|
||||
|
||||
|
||||
|
||||
public static Repair CreatOpertions(int id, int contractorsId, int premisesId, IEnumerable<RepairRepair> repairRepair)
|
||||
public static Repair CreatOpertions(int id, int contractorsId, DateTime dateRepair, int premisesId, IEnumerable<RepairRepair> repairRepair)
|
||||
{
|
||||
return new Repair
|
||||
{
|
||||
Id = id,
|
||||
ContractorsId = contractorsId,
|
||||
PremisesId = premisesId,
|
||||
DateRepair = dateRepair,
|
||||
RepairRepair = repairRepair,
|
||||
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ public class RepairRepair
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int WorkId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public int Count { get; set; }
|
||||
|
||||
|
||||
public static RepairRepair CreatElement(int id, int workId, int count)
|
||||
@ -20,7 +20,6 @@ public class RepairRepair
|
||||
Id = id,
|
||||
WorkId = workId,
|
||||
Count = count,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
16
ProjectRepairWork/Entities/TempRepairRepair.cs
Normal file
16
ProjectRepairWork/Entities/TempRepairRepair.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Entities;
|
||||
|
||||
public class TempRepairRepair
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int ContractorsId { get; private set; }
|
||||
public int PremisesId { get; private set; }
|
||||
public DateTime DateRepair { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
}
|
64
ProjectRepairWork/FormRepairWork.Designer.cs
generated
64
ProjectRepairWork/FormRepairWork.Designer.cs
generated
@ -34,9 +34,14 @@
|
||||
PremisesToolStripMenuItem = new ToolStripMenuItem();
|
||||
CostToolStripMenuItem = new ToolStripMenuItem();
|
||||
WorksToolStripMenuItem = new ToolStripMenuItem();
|
||||
BuildingMaterialsToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
RepairToolStripMenuItem = new ToolStripMenuItem();
|
||||
MaterialProcurementToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
directoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ContractorReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReceiptMaterialsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -52,7 +57,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ContractorsToolStripMenuItem, PremisesToolStripMenuItem, CostToolStripMenuItem, WorksToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ContractorsToolStripMenuItem, PremisesToolStripMenuItem, CostToolStripMenuItem, WorksToolStripMenuItem, BuildingMaterialsToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -60,34 +65,41 @@
|
||||
// ContractorsToolStripMenuItem
|
||||
//
|
||||
ContractorsToolStripMenuItem.Name = "ContractorsToolStripMenuItem";
|
||||
ContractorsToolStripMenuItem.Size = new Size(224, 26);
|
||||
ContractorsToolStripMenuItem.Size = new Size(212, 26);
|
||||
ContractorsToolStripMenuItem.Text = "Подрядчики";
|
||||
ContractorsToolStripMenuItem.Click += ContractorsToolStripMenuItem_Click;
|
||||
//
|
||||
// PremisesToolStripMenuItem
|
||||
//
|
||||
PremisesToolStripMenuItem.Name = "PremisesToolStripMenuItem";
|
||||
PremisesToolStripMenuItem.Size = new Size(224, 26);
|
||||
PremisesToolStripMenuItem.Size = new Size(212, 26);
|
||||
PremisesToolStripMenuItem.Text = "Помещения";
|
||||
PremisesToolStripMenuItem.Click += PremisesToolStripMenuItem_Click;
|
||||
//
|
||||
// CostToolStripMenuItem
|
||||
//
|
||||
CostToolStripMenuItem.Name = "CostToolStripMenuItem";
|
||||
CostToolStripMenuItem.Size = new Size(224, 26);
|
||||
CostToolStripMenuItem.Size = new Size(212, 26);
|
||||
CostToolStripMenuItem.Text = "Затраты";
|
||||
CostToolStripMenuItem.Click += CostToolStripMenuItem_Click;
|
||||
//
|
||||
// WorksToolStripMenuItem
|
||||
//
|
||||
WorksToolStripMenuItem.Name = "WorksToolStripMenuItem";
|
||||
WorksToolStripMenuItem.Size = new Size(224, 26);
|
||||
WorksToolStripMenuItem.Size = new Size(212, 26);
|
||||
WorksToolStripMenuItem.Text = "Работы";
|
||||
WorksToolStripMenuItem.Click += WorksToolStripMenuItem_Click;
|
||||
//
|
||||
// BuildingMaterialsToolStripMenuItem
|
||||
//
|
||||
BuildingMaterialsToolStripMenuItem.Name = "BuildingMaterialsToolStripMenuItem";
|
||||
BuildingMaterialsToolStripMenuItem.Size = new Size(212, 26);
|
||||
BuildingMaterialsToolStripMenuItem.Text = "Стройматериалы";
|
||||
BuildingMaterialsToolStripMenuItem.Click += BuildingMaterialsToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RepairToolStripMenuItem });
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RepairToolStripMenuItem, MaterialProcurementToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
@ -95,16 +107,49 @@
|
||||
// RepairToolStripMenuItem
|
||||
//
|
||||
RepairToolStripMenuItem.Name = "RepairToolStripMenuItem";
|
||||
RepairToolStripMenuItem.Size = new Size(224, 26);
|
||||
RepairToolStripMenuItem.Size = new Size(234, 26);
|
||||
RepairToolStripMenuItem.Text = "Ремонт";
|
||||
RepairToolStripMenuItem.Click += RepairToolStripMenuItem_Click;
|
||||
//
|
||||
// MaterialProcurementToolStripMenuItem
|
||||
//
|
||||
MaterialProcurementToolStripMenuItem.Name = "MaterialProcurementToolStripMenuItem";
|
||||
MaterialProcurementToolStripMenuItem.Size = new Size(234, 26);
|
||||
MaterialProcurementToolStripMenuItem.Text = "Закупка материалов";
|
||||
MaterialProcurementToolStripMenuItem.Click += MaterialProcurementToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem, ContractorReportToolStripMenuItem, ReceiptMaterialsToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// directoryReportToolStripMenuItem
|
||||
//
|
||||
directoryReportToolStripMenuItem.Name = "directoryReportToolStripMenuItem";
|
||||
directoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
directoryReportToolStripMenuItem.Size = new Size(346, 26);
|
||||
directoryReportToolStripMenuItem.Text = "Документ со справочником ";
|
||||
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// ContractorReportToolStripMenuItem
|
||||
//
|
||||
ContractorReportToolStripMenuItem.Name = "ContractorReportToolStripMenuItem";
|
||||
ContractorReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
ContractorReportToolStripMenuItem.Size = new Size(346, 26);
|
||||
ContractorReportToolStripMenuItem.Text = "Отчет по подрядчикам";
|
||||
ContractorReportToolStripMenuItem.Click += ContractorReportToolStripMenuItem_Click;
|
||||
//
|
||||
// ReceiptMaterialsToolStripMenuItem
|
||||
//
|
||||
ReceiptMaterialsToolStripMenuItem.Name = "ReceiptMaterialsToolStripMenuItem";
|
||||
ReceiptMaterialsToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
ReceiptMaterialsToolStripMenuItem.Size = new Size(346, 26);
|
||||
ReceiptMaterialsToolStripMenuItem.Text = "Поступление материалов";
|
||||
ReceiptMaterialsToolStripMenuItem.Click += ReceiptMaterialsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormRepairWork
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -134,5 +179,10 @@
|
||||
private ToolStripMenuItem RepairToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem WorksToolStripMenuItem;
|
||||
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem BuildingMaterialsToolStripMenuItem;
|
||||
private ToolStripMenuItem MaterialProcurementToolStripMenuItem;
|
||||
private ToolStripMenuItem ContractorReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ReceiptMaterialsToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -72,5 +72,65 @@ namespace ProjectRepairWork
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void directoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildingMaterialsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormBuildingMaterials>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void MaterialProcurementToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMaterialProcurements>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ContractorReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRepairReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReceiptMaterialsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMaterialsReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
95
ProjectRepairWork/Forms/FormBuildingMaterial.Designer.cs
generated
Normal file
95
ProjectRepairWork/Forms/FormBuildingMaterial.Designer.cs
generated
Normal file
@ -0,0 +1,95 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormBuildingMaterial
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBoxBuildingMaterial = new TextBox();
|
||||
labelBuildingMaterial = new Label();
|
||||
ButtonCancel = new Button();
|
||||
ButtonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxBuildingMaterial
|
||||
//
|
||||
textBoxBuildingMaterial.Location = new Point(203, 49);
|
||||
textBoxBuildingMaterial.Name = "textBoxBuildingMaterial";
|
||||
textBoxBuildingMaterial.Size = new Size(225, 27);
|
||||
textBoxBuildingMaterial.TabIndex = 0;
|
||||
//
|
||||
// labelBuildingMaterial
|
||||
//
|
||||
labelBuildingMaterial.AutoSize = true;
|
||||
labelBuildingMaterial.Location = new Point(12, 52);
|
||||
labelBuildingMaterial.Name = "labelBuildingMaterial";
|
||||
labelBuildingMaterial.Size = new Size(156, 20);
|
||||
labelBuildingMaterial.TabIndex = 1;
|
||||
labelBuildingMaterial.Text = "Название материала";
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(244, 106);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(169, 29);
|
||||
ButtonCancel.TabIndex = 22;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = true;
|
||||
ButtonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(33, 106);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(169, 29);
|
||||
ButtonSave.TabIndex = 21;
|
||||
ButtonSave.Text = "Сохранить";
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// FormBuildingMaterial
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(468, 147);
|
||||
Controls.Add(ButtonCancel);
|
||||
Controls.Add(ButtonSave);
|
||||
Controls.Add(labelBuildingMaterial);
|
||||
Controls.Add(textBoxBuildingMaterial);
|
||||
Name = "FormBuildingMaterial";
|
||||
Text = "Строительный материалы";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxBuildingMaterial;
|
||||
private Label labelBuildingMaterial;
|
||||
private Button ButtonCancel;
|
||||
private Button ButtonSave;
|
||||
}
|
||||
}
|
82
ProjectRepairWork/Forms/FormBuildingMaterial.cs
Normal file
82
ProjectRepairWork/Forms/FormBuildingMaterial.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using ProjectRepairWork.Entities;
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
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 ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormBuildingMaterial : Form
|
||||
{
|
||||
private readonly IBuildingMaterialsRepository _buildingMaterialsRepository;
|
||||
private int? _buildingMaterialsId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var buildingMaterials = _buildingMaterialsRepository.ReadBuildingMaterialsById(value);
|
||||
if (buildingMaterials == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(buildingMaterials));
|
||||
}
|
||||
textBoxBuildingMaterial.Text = buildingMaterials.MaterialsType;
|
||||
_buildingMaterialsId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormBuildingMaterial(IBuildingMaterialsRepository buildingMaterialsRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_buildingMaterialsRepository = buildingMaterialsRepository ?? throw new ArgumentNullException(nameof(buildingMaterialsRepository));
|
||||
}
|
||||
private void Cancel_Click(object sender, EventArgs e) => Close();
|
||||
private BuildingMaterials CreateBuildingMaterials(int id) => BuildingMaterials.CreatEntity(
|
||||
id,
|
||||
textBoxBuildingMaterial.Text);
|
||||
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxBuildingMaterial.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_buildingMaterialsId.HasValue)
|
||||
{
|
||||
_buildingMaterialsRepository.UpdateBuildingMaterials(CreateBuildingMaterials(_buildingMaterialsId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_buildingMaterialsRepository.CreateBuildingMaterials(CreateBuildingMaterials(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormBuildingMaterial.resx
Normal file
120
ProjectRepairWork/Forms/FormBuildingMaterial.resx
Normal file
@ -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>
|
125
ProjectRepairWork/Forms/FormBuildingMaterials.Designer.cs
generated
Normal file
125
ProjectRepairWork/Forms/FormBuildingMaterials.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormBuildingMaterials
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
ButtonDel = new Button();
|
||||
ButtonUpd = new Button();
|
||||
ButtonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(633, 450);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(ButtonDel);
|
||||
panel1.Controls.Add(ButtonUpd);
|
||||
panel1.Controls.Add(ButtonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(633, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 450);
|
||||
panel1.TabIndex = 4;
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
ButtonDel.BackgroundImage = Properties.Resources.free_icon_font_cross;
|
||||
ButtonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ButtonDel.Location = new Point(32, 252);
|
||||
ButtonDel.Name = "ButtonDel";
|
||||
ButtonDel.Size = new Size(105, 92);
|
||||
ButtonDel.TabIndex = 2;
|
||||
ButtonDel.UseVisualStyleBackColor = true;
|
||||
ButtonDel.Click += ButtonDel_Click;
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
ButtonUpd.BackgroundImage = Properties.Resources.free_icon_font_pencil_3917376;
|
||||
ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ButtonUpd.Location = new Point(32, 137);
|
||||
ButtonUpd.Name = "ButtonUpd";
|
||||
ButtonUpd.Size = new Size(105, 92);
|
||||
ButtonUpd.TabIndex = 1;
|
||||
ButtonUpd.UseVisualStyleBackColor = true;
|
||||
ButtonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus;
|
||||
ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ButtonAdd.Location = new Point(32, 12);
|
||||
ButtonAdd.Name = "ButtonAdd";
|
||||
ButtonAdd.Size = new Size(105, 92);
|
||||
ButtonAdd.TabIndex = 0;
|
||||
ButtonAdd.UseVisualStyleBackColor = true;
|
||||
ButtonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// FormBuildingMaterials
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormBuildingMaterials";
|
||||
Text = "Строительные материалы";
|
||||
Load += FormBuildingMaterials_Load_1;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonAdd;
|
||||
}
|
||||
}
|
108
ProjectRepairWork/Forms/FormBuildingMaterials.cs
Normal file
108
ProjectRepairWork/Forms/FormBuildingMaterials.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
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 ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormBuildingMaterials : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IBuildingMaterialsRepository _buildingMaterialsRepository;
|
||||
public FormBuildingMaterials(IUnityContainer container, IBuildingMaterialsRepository buildingMaterialsRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_buildingMaterialsRepository = buildingMaterialsRepository ?? throw new ArgumentNullException(nameof(buildingMaterialsRepository));
|
||||
}
|
||||
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormBuildingMaterial>().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<FormBuildingMaterial>();
|
||||
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
|
||||
{
|
||||
_buildingMaterialsRepository.DeletedBuildingMaterials(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _buildingMaterialsRepository.ReadBuildingMaterials();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FormBuildingMaterials_Load_1(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormBuildingMaterials.resx
Normal file
120
ProjectRepairWork/Forms/FormBuildingMaterials.resx
Normal file
@ -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>
|
99
ProjectRepairWork/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
99
ProjectRepairWork/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormDirectoryReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkBoxWorks = new CheckBox();
|
||||
checkBoxContractors = new CheckBox();
|
||||
checkBoxPremises = new CheckBox();
|
||||
buttonFormulate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxWorks
|
||||
//
|
||||
checkBoxWorks.AutoSize = true;
|
||||
checkBoxWorks.Location = new Point(27, 30);
|
||||
checkBoxWorks.Name = "checkBoxWorks";
|
||||
checkBoxWorks.Size = new Size(82, 24);
|
||||
checkBoxWorks.TabIndex = 0;
|
||||
checkBoxWorks.Text = "Работы";
|
||||
checkBoxWorks.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxContractors
|
||||
//
|
||||
checkBoxContractors.AutoSize = true;
|
||||
checkBoxContractors.Location = new Point(27, 81);
|
||||
checkBoxContractors.Name = "checkBoxContractors";
|
||||
checkBoxContractors.Size = new Size(117, 24);
|
||||
checkBoxContractors.TabIndex = 1;
|
||||
checkBoxContractors.Text = "Подрядчики";
|
||||
checkBoxContractors.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxPremises
|
||||
//
|
||||
checkBoxPremises.AutoSize = true;
|
||||
checkBoxPremises.Location = new Point(27, 139);
|
||||
checkBoxPremises.Name = "checkBoxPremises";
|
||||
checkBoxPremises.Size = new Size(116, 24);
|
||||
checkBoxPremises.TabIndex = 2;
|
||||
checkBoxPremises.Text = "Помещения";
|
||||
checkBoxPremises.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonFormulate
|
||||
//
|
||||
buttonFormulate.Location = new Point(204, 81);
|
||||
buttonFormulate.Name = "buttonFormulate";
|
||||
buttonFormulate.Size = new Size(173, 29);
|
||||
buttonFormulate.TabIndex = 3;
|
||||
buttonFormulate.Text = "Сформировать";
|
||||
buttonFormulate.UseVisualStyleBackColor = true;
|
||||
buttonFormulate.Click += ButtonFormulate_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(405, 189);
|
||||
Controls.Add(buttonFormulate);
|
||||
Controls.Add(checkBoxPremises);
|
||||
Controls.Add(checkBoxContractors);
|
||||
Controls.Add(checkBoxWorks);
|
||||
Name = "FormDirectoryReport";
|
||||
Text = "Выгрузка справочников";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxWorks;
|
||||
private CheckBox checkBoxContractors;
|
||||
private CheckBox checkBoxPremises;
|
||||
private Button buttonFormulate;
|
||||
}
|
||||
}
|
64
ProjectRepairWork/Forms/FormDirectoryReport.cs
Normal file
64
ProjectRepairWork/Forms/FormDirectoryReport.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using ProjectRepairWork.Reports;
|
||||
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 ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormDirectoryReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormDirectoryReport(IUnityContainer container)
|
||||
{
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ButtonFormulate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!checkBoxContractors.Checked && !checkBoxPremises.Checked && !checkBoxWorks.Checked)
|
||||
{
|
||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||
}
|
||||
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Docx Files | *.docx"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
throw new Exception("Не выбран айл для отчета");
|
||||
}
|
||||
|
||||
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxContractors.Checked,
|
||||
checkBoxPremises.Checked, checkBoxWorks.Checked))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа. Подробности в логах",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибки при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormDirectoryReport.resx
Normal file
120
ProjectRepairWork/Forms/FormDirectoryReport.resx
Normal file
@ -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>
|
142
ProjectRepairWork/Forms/FormMaterialProcurement.Designer.cs
generated
Normal file
142
ProjectRepairWork/Forms/FormMaterialProcurement.Designer.cs
generated
Normal file
@ -0,0 +1,142 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormMaterialProcurement
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
comboBoxMaterialRrocurement = new ComboBox();
|
||||
dateTimePickerMaterialRrocurement = new DateTimePicker();
|
||||
numericUpDownMaterialRrocurement = new NumericUpDown();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
ButtonCancel = new Button();
|
||||
ButtonSave = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaterialRrocurement).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxMaterialRrocurement
|
||||
//
|
||||
comboBoxMaterialRrocurement.FormattingEnabled = true;
|
||||
comboBoxMaterialRrocurement.Location = new Point(169, 44);
|
||||
comboBoxMaterialRrocurement.Name = "comboBoxMaterialRrocurement";
|
||||
comboBoxMaterialRrocurement.Size = new Size(151, 28);
|
||||
comboBoxMaterialRrocurement.TabIndex = 0;
|
||||
//
|
||||
// dateTimePickerMaterialRrocurement
|
||||
//
|
||||
dateTimePickerMaterialRrocurement.Location = new Point(153, 94);
|
||||
dateTimePickerMaterialRrocurement.Name = "dateTimePickerMaterialRrocurement";
|
||||
dateTimePickerMaterialRrocurement.Size = new Size(250, 27);
|
||||
dateTimePickerMaterialRrocurement.TabIndex = 1;
|
||||
//
|
||||
// numericUpDownMaterialRrocurement
|
||||
//
|
||||
numericUpDownMaterialRrocurement.Location = new Point(153, 161);
|
||||
numericUpDownMaterialRrocurement.Name = "numericUpDownMaterialRrocurement";
|
||||
numericUpDownMaterialRrocurement.Size = new Size(150, 27);
|
||||
numericUpDownMaterialRrocurement.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(55, 47);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(89, 20);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Материалы";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(55, 99);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(41, 20);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Дата";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(55, 168);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(45, 20);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "Цена";
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(244, 230);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(169, 29);
|
||||
ButtonCancel.TabIndex = 22;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = true;
|
||||
ButtonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(33, 230);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(169, 29);
|
||||
ButtonSave.TabIndex = 21;
|
||||
ButtonSave.Text = "Сохранить";
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// FormMaterialProcurement
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(434, 278);
|
||||
Controls.Add(ButtonCancel);
|
||||
Controls.Add(ButtonSave);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(numericUpDownMaterialRrocurement);
|
||||
Controls.Add(dateTimePickerMaterialRrocurement);
|
||||
Controls.Add(comboBoxMaterialRrocurement);
|
||||
Name = "FormMaterialProcurement";
|
||||
Text = "Закупка материала";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownMaterialRrocurement).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxMaterialRrocurement;
|
||||
private DateTimePicker dateTimePickerMaterialRrocurement;
|
||||
private NumericUpDown numericUpDownMaterialRrocurement;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Button ButtonCancel;
|
||||
private Button ButtonSave;
|
||||
}
|
||||
}
|
55
ProjectRepairWork/Forms/FormMaterialProcurement.cs
Normal file
55
ProjectRepairWork/Forms/FormMaterialProcurement.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using ProjectRepairWork.Entities.Enums;
|
||||
using ProjectRepairWork.Entities;
|
||||
using ProjectRepairWork.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 ProjectRepairWork.Repositories.Implementation;
|
||||
|
||||
namespace ProjectRepairWork.Forms;
|
||||
|
||||
public partial class FormMaterialProcurement : Form
|
||||
{
|
||||
private readonly IMaterialProcurementRepository _materialProcurementRepository;
|
||||
|
||||
public FormMaterialProcurement(IMaterialProcurementRepository materialProcurementRepository, IBuildingMaterialsRepository buildingMaterialsRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_materialProcurementRepository = materialProcurementRepository ?? throw new ArgumentNullException(nameof(materialProcurementRepository));
|
||||
|
||||
comboBoxMaterialRrocurement.DataSource = buildingMaterialsRepository.ReadBuildingMaterials();
|
||||
comboBoxMaterialRrocurement.DisplayMember = "MaterialsType";
|
||||
comboBoxMaterialRrocurement.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxMaterialRrocurement.SelectedIndex <0)
|
||||
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
_materialProcurementRepository.CreateMaterialProcurement(MaterialProcurement.CreatOpertions(0,
|
||||
(int)comboBoxMaterialRrocurement.SelectedValue!, (int)numericUpDownMaterialRrocurement.Value!));
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
|
||||
}
|
120
ProjectRepairWork/Forms/FormMaterialProcurement.resx
Normal file
120
ProjectRepairWork/Forms/FormMaterialProcurement.resx
Normal file
@ -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>
|
97
ProjectRepairWork/Forms/FormMaterialProcurements.Designer.cs
generated
Normal file
97
ProjectRepairWork/Forms/FormMaterialProcurements.Designer.cs
generated
Normal file
@ -0,0 +1,97 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormMaterialProcurements
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
ButtonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(633, 450);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(ButtonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(633, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 450);
|
||||
panel1.TabIndex = 4;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
ButtonAdd.BackgroundImage = Properties.Resources.free_icon_font_plus;
|
||||
ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ButtonAdd.Location = new Point(32, 12);
|
||||
ButtonAdd.Name = "ButtonAdd";
|
||||
ButtonAdd.Size = new Size(105, 92);
|
||||
ButtonAdd.TabIndex = 0;
|
||||
ButtonAdd.UseVisualStyleBackColor = true;
|
||||
ButtonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// FormMaterialProcurements
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormMaterialProcurements";
|
||||
Text = "Закупка материалов ";
|
||||
Load += FormMaterialProcurements_Load_1;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button ButtonAdd;
|
||||
}
|
||||
}
|
57
ProjectRepairWork/Forms/FormMaterialProcurements.cs
Normal file
57
ProjectRepairWork/Forms/FormMaterialProcurements.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
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 ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormMaterialProcurements : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IMaterialProcurementRepository _materialProcurementRepository;
|
||||
public FormMaterialProcurements(IUnityContainer container, IMaterialProcurementRepository materialProcurementRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_materialProcurementRepository = materialProcurementRepository ?? throw new ArgumentNullException(nameof(materialProcurementRepository));
|
||||
}
|
||||
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _materialProcurementRepository.ReadMaterialProcurement();
|
||||
|
||||
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMaterialProcurement>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMaterialProcurements_Load_1(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormMaterialProcurements.resx
Normal file
120
ProjectRepairWork/Forms/FormMaterialProcurements.resx
Normal file
@ -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>
|
107
ProjectRepairWork/Forms/FormMaterialsReport.Designer.cs
generated
Normal file
107
ProjectRepairWork/Forms/FormMaterialsReport.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormMaterialsReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCreate = new Button();
|
||||
dateTimePickerDate = new DateTimePicker();
|
||||
labelDate = new Label();
|
||||
buttonSelect = new Button();
|
||||
labelFileName = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(24, 120);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(140, 28);
|
||||
buttonCreate.TabIndex = 9;
|
||||
buttonCreate.Text = "Сформировать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// dateTimePickerDate
|
||||
//
|
||||
dateTimePickerDate.Location = new Point(62, 72);
|
||||
dateTimePickerDate.Name = "dateTimePickerDate";
|
||||
dateTimePickerDate.Size = new Size(202, 27);
|
||||
dateTimePickerDate.TabIndex = 8;
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(12, 72);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(44, 20);
|
||||
labelDate.TabIndex = 7;
|
||||
labelDate.Text = "Дата:";
|
||||
//
|
||||
// buttonSelect
|
||||
//
|
||||
buttonSelect.Location = new Point(12, 12);
|
||||
buttonSelect.Name = "buttonSelect";
|
||||
buttonSelect.Size = new Size(84, 28);
|
||||
buttonSelect.TabIndex = 5;
|
||||
buttonSelect.Text = "Выбрать";
|
||||
buttonSelect.UseVisualStyleBackColor = true;
|
||||
buttonSelect.Click += buttonSelect_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(102, 20);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(45, 20);
|
||||
labelFileName.TabIndex = 10;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// FormMaterialsReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(274, 174);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dateTimePickerDate);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(buttonSelect);
|
||||
Name = "FormMaterialsReport";
|
||||
Text = "Пополнение матреиалов";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCreate;
|
||||
private DateTimePicker dateTimePickerDate;
|
||||
private Label labelDate;
|
||||
private Button buttonSelect;
|
||||
private Label labelFileName;
|
||||
}
|
||||
}
|
61
ProjectRepairWork/Forms/FormMaterialsReport.cs
Normal file
61
ProjectRepairWork/Forms/FormMaterialsReport.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using ProjectRepairWork.Reports;
|
||||
using Unity;
|
||||
|
||||
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormMaterialsReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormMaterialsReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void buttonSelect_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
|
||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePickerDate.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormMaterialsReport.resx
Normal file
120
ProjectRepairWork/Forms/FormMaterialsReport.resx
Normal file
@ -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>
|
22
ProjectRepairWork/Forms/FormRepair.Designer.cs
generated
22
ProjectRepairWork/Forms/FormRepair.Designer.cs
generated
@ -37,6 +37,8 @@
|
||||
dataGridViewWorks = new DataGridView();
|
||||
ColumnWork = new DataGridViewComboBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
DateRepair = new Label();
|
||||
dateTimePickerRepair = new DateTimePicker();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewWorks).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -127,11 +129,29 @@
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// DateRepair
|
||||
//
|
||||
DateRepair.AutoSize = true;
|
||||
DateRepair.Location = new Point(7, 131);
|
||||
DateRepair.Name = "DateRepair";
|
||||
DateRepair.Size = new Size(86, 20);
|
||||
DateRepair.TabIndex = 32;
|
||||
DateRepair.Text = "Дата работ";
|
||||
//
|
||||
// dateTimePickerRepair
|
||||
//
|
||||
dateTimePickerRepair.Location = new Point(152, 126);
|
||||
dateTimePickerRepair.Name = "dateTimePickerRepair";
|
||||
dateTimePickerRepair.Size = new Size(200, 27);
|
||||
dateTimePickerRepair.TabIndex = 31;
|
||||
//
|
||||
// FormRepair
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(490, 462);
|
||||
Controls.Add(DateRepair);
|
||||
Controls.Add(dateTimePickerRepair);
|
||||
Controls.Add(dataGridViewWorks);
|
||||
Controls.Add(comboBoxPremises);
|
||||
Controls.Add(comboBoxContractors);
|
||||
@ -156,5 +176,7 @@
|
||||
private DataGridView dataGridViewWorks;
|
||||
private DataGridViewComboBoxColumn ColumnWork;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Label DateRepair;
|
||||
private DateTimePicker dateTimePickerRepair;
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace ProjectRepairWork.Forms
|
||||
public partial class FormRepair : Form
|
||||
{
|
||||
private readonly IRepairRepository _repairRepository;
|
||||
|
||||
|
||||
public FormRepair(IRepairRepository repairRepository, IContractorsRepository contractorsRepository, IPremisesRepository premisesRepository, IWorksRepository worksRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -37,7 +37,7 @@ namespace ProjectRepairWork.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewWorks.RowCount < 1|| comboBoxContractors.SelectedIndex < 0 ||
|
||||
if (dataGridViewWorks.RowCount < 1 || comboBoxContractors.SelectedIndex < 0 ||
|
||||
comboBoxPremises.SelectedIndex < 0)
|
||||
|
||||
{
|
||||
@ -45,7 +45,7 @@ namespace ProjectRepairWork.Forms
|
||||
}
|
||||
|
||||
_repairRepository.CraeteRepair(Repair.CreatOpertions(0,
|
||||
(int)comboBoxContractors.SelectedValue!,
|
||||
(int)comboBoxContractors.SelectedValue!, dateTimePickerRepair.Value,
|
||||
(int)comboBoxPremises.SelectedValue!, CreateRepairFromDataGrid()));
|
||||
|
||||
Close();
|
||||
@ -61,7 +61,7 @@ namespace ProjectRepairWork.Forms
|
||||
private List<RepairRepair> CreateRepairFromDataGrid()
|
||||
{
|
||||
var list = new List<RepairRepair>();
|
||||
foreach(DataGridViewRow row in dataGridViewWorks.Rows)
|
||||
foreach (DataGridViewRow row in dataGridViewWorks.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnWork"].Value == null ||
|
||||
row.Cells["ColumnCount"].Value == null)
|
||||
@ -72,7 +72,10 @@ namespace ProjectRepairWork.Forms
|
||||
Convert.ToInt32(row.Cells["ColumnWork"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||
}
|
||||
return list;
|
||||
|
||||
return list.GroupBy(x => x.WorkId, x => x.Count, (id, counts) => RepairRepair.CreatElement(0, id, counts.Sum())).ToList(); ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -123,4 +123,10 @@
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnWork.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
164
ProjectRepairWork/Forms/FormRepairReport.Designer.cs
generated
Normal file
164
ProjectRepairWork/Forms/FormRepairReport.Designer.cs
generated
Normal file
@ -0,0 +1,164 @@
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
partial class FormRepairReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonMakeReport = new Button();
|
||||
labelDateEnd = new Label();
|
||||
labelDateBegin = new Label();
|
||||
labelContractor = new Label();
|
||||
labelPath = new Label();
|
||||
comboBoxContractor = new ComboBox();
|
||||
buttonSelectFilePath = new Button();
|
||||
textBoxFilePath = new TextBox();
|
||||
dateTimePickerDateEnd = new DateTimePicker();
|
||||
dateTimePickerDateBegin = new DateTimePicker();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonMakeReport
|
||||
//
|
||||
buttonMakeReport.Location = new Point(156, 245);
|
||||
buttonMakeReport.Name = "buttonMakeReport";
|
||||
buttonMakeReport.Size = new Size(122, 28);
|
||||
buttonMakeReport.TabIndex = 19;
|
||||
buttonMakeReport.Text = "Сформировать";
|
||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||
buttonMakeReport.Click += buttonMakeReport_Click;
|
||||
//
|
||||
// labelDateEnd
|
||||
//
|
||||
labelDateEnd.AutoSize = true;
|
||||
labelDateEnd.Location = new Point(36, 186);
|
||||
labelDateEnd.Name = "labelDateEnd";
|
||||
labelDateEnd.Size = new Size(90, 20);
|
||||
labelDateEnd.TabIndex = 18;
|
||||
labelDateEnd.Text = "Дата конца:";
|
||||
//
|
||||
// labelDateBegin
|
||||
//
|
||||
labelDateBegin.AutoSize = true;
|
||||
labelDateBegin.Location = new Point(36, 137);
|
||||
labelDateBegin.Name = "labelDateBegin";
|
||||
labelDateBegin.Size = new Size(97, 20);
|
||||
labelDateBegin.TabIndex = 17;
|
||||
labelDateBegin.Text = "Дата начала:";
|
||||
//
|
||||
// labelContractor
|
||||
//
|
||||
labelContractor.AutoSize = true;
|
||||
labelContractor.Location = new Point(36, 84);
|
||||
labelContractor.Name = "labelContractor";
|
||||
labelContractor.Size = new Size(86, 20);
|
||||
labelContractor.TabIndex = 16;
|
||||
labelContractor.Text = "Подрядчик";
|
||||
//
|
||||
// labelPath
|
||||
//
|
||||
labelPath.AutoSize = true;
|
||||
labelPath.Location = new Point(36, 33);
|
||||
labelPath.Name = "labelPath";
|
||||
labelPath.Size = new Size(112, 20);
|
||||
labelPath.TabIndex = 15;
|
||||
labelPath.Text = "Путь до файла:";
|
||||
//
|
||||
// comboBoxContractor
|
||||
//
|
||||
comboBoxContractor.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxContractor.FormattingEnabled = true;
|
||||
comboBoxContractor.Location = new Point(175, 81);
|
||||
comboBoxContractor.Name = "comboBoxContractor";
|
||||
comboBoxContractor.Size = new Size(223, 28);
|
||||
comboBoxContractor.TabIndex = 14;
|
||||
//
|
||||
// buttonSelectFilePath
|
||||
//
|
||||
buttonSelectFilePath.Location = new Point(365, 30);
|
||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||
buttonSelectFilePath.Size = new Size(32, 28);
|
||||
buttonSelectFilePath.TabIndex = 13;
|
||||
buttonSelectFilePath.Text = ". .";
|
||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
buttonSelectFilePath.Click += buttonSelectFilePath_Click;
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(175, 30);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(173, 27);
|
||||
textBoxFilePath.TabIndex = 12;
|
||||
//
|
||||
// dateTimePickerDateEnd
|
||||
//
|
||||
dateTimePickerDateEnd.Location = new Point(175, 180);
|
||||
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||
dateTimePickerDateEnd.Size = new Size(223, 27);
|
||||
dateTimePickerDateEnd.TabIndex = 11;
|
||||
//
|
||||
// dateTimePickerDateBegin
|
||||
//
|
||||
dateTimePickerDateBegin.Location = new Point(175, 131);
|
||||
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||
dateTimePickerDateBegin.Size = new Size(223, 27);
|
||||
dateTimePickerDateBegin.TabIndex = 10;
|
||||
//
|
||||
// FormRepairReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(429, 330);
|
||||
Controls.Add(buttonMakeReport);
|
||||
Controls.Add(labelDateEnd);
|
||||
Controls.Add(labelDateBegin);
|
||||
Controls.Add(labelContractor);
|
||||
Controls.Add(labelPath);
|
||||
Controls.Add(comboBoxContractor);
|
||||
Controls.Add(buttonSelectFilePath);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(dateTimePickerDateEnd);
|
||||
Controls.Add(dateTimePickerDateBegin);
|
||||
Name = "FormRepairReport";
|
||||
Text = "Отчет по ремонтам ";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonMakeReport;
|
||||
private Label labelDateEnd;
|
||||
private Label labelDateBegin;
|
||||
private Label labelContractor;
|
||||
private Label labelPath;
|
||||
private ComboBox comboBoxContractor;
|
||||
private Button buttonSelectFilePath;
|
||||
private TextBox textBoxFilePath;
|
||||
private DateTimePicker dateTimePickerDateEnd;
|
||||
private DateTimePicker dateTimePickerDateBegin;
|
||||
}
|
||||
}
|
72
ProjectRepairWork/Forms/FormRepairReport.cs
Normal file
72
ProjectRepairWork/Forms/FormRepairReport.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectRepairWork.Forms
|
||||
{
|
||||
public partial class FormRepairReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
|
||||
public FormRepairReport(IUnityContainer container, IContractorsRepository contractorRepository)
|
||||
{
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
InitializeComponent();
|
||||
|
||||
comboBoxContractor.DataSource = contractorRepository.ReadContractors();
|
||||
comboBoxContractor.DisplayMember = "CompanyName";
|
||||
comboBoxContractor.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonMakeReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
|
||||
if (comboBoxContractor.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран подрядчик");
|
||||
}
|
||||
|
||||
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxContractor.SelectedValue!,
|
||||
dateTimePickerDateBegin.Value, dateTimePickerDateEnd.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSelectFilePath_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files | *.xlsx"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
textBoxFilePath.Text = sfd.FileName;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectRepairWork/Forms/FormRepairReport.resx
Normal file
120
ProjectRepairWork/Forms/FormRepairReport.resx
Normal file
@ -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>
|
@ -34,6 +34,8 @@ namespace ProjectRepairWork
|
||||
container.RegisterType<IRepairRepository, RepairRepository>();
|
||||
container.RegisterType<IWorksRepository, WorksRepository>();
|
||||
container.RegisterType<IConnectionString, ConnectionString>();
|
||||
container.RegisterType<IBuildingMaterialsRepository, BuildingMaterialsRepository>();
|
||||
container.RegisterType<IMaterialProcurementRepository, MaterialProcurementRepository>();
|
||||
return container;
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,15 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="MigraDocCore.DocumentObjectModel" Version="1.3.65" />
|
||||
<PackageReference Include="MigraDocCore.Rendering" Version="1.3.65" />
|
||||
<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" />
|
||||
|
74
ProjectRepairWork/Reports/ChartReport.cs
Normal file
74
ProjectRepairWork/Reports/ChartReport.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IMaterialProcurementRepository _materialProcurementRepository;
|
||||
private readonly IBuildingMaterialsRepository _buildingMaterialsRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IMaterialProcurementRepository materialProcurementRepository, IBuildingMaterialsRepository buildingMaterialsRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_buildingMaterialsRepository = buildingMaterialsRepository ?? throw new ArgumentNullException(nameof(buildingMaterialsRepository));
|
||||
_materialProcurementRepository = materialProcurementRepository ?? throw new ArgumentNullException(nameof(materialProcurementRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateChart(string filePath, DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Поступление материалов")
|
||||
.AddPieChart("Виды материала", GetData(dateTime))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
{
|
||||
var materialProcurement = _materialProcurementRepository.ReadMaterialProcurement()
|
||||
.Where(x => x.ProcurmentDate.Date == dateTime.Date).ToList();
|
||||
|
||||
var materials = _buildingMaterialsRepository.ReadBuildingMaterials();
|
||||
|
||||
|
||||
var data = from materialProc in materialProcurement
|
||||
join material in materials on materialProc.MaterialsId equals material.Id
|
||||
select new
|
||||
{
|
||||
material.MaterialsType,
|
||||
materialProc.MaterialsPrice
|
||||
};
|
||||
|
||||
|
||||
var groupedData = data
|
||||
.GroupBy(x => x.MaterialsType)
|
||||
.Select(g => new
|
||||
{
|
||||
MaterialsName = g.Key,
|
||||
TotalCount = g.Sum(x => x.MaterialsPrice)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
var result = groupedData
|
||||
.Select(x => (x.MaterialsName.ToString(), (double)x.TotalCount))
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
93
ProjectRepairWork/Reports/DocReport.cs
Normal file
93
ProjectRepairWork/Reports/DocReport.cs
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
public class DocReport
|
||||
{
|
||||
|
||||
private readonly IContractorsRepository _contractorsRepository;
|
||||
private readonly IPremisesRepository _premisesRepository;
|
||||
private readonly IWorksRepository _worksRepository;
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(ILogger<DocReport> logger, IContractorsRepository contractorsRepository, IPremisesRepository premisesRepository, IWorksRepository worksRepository)
|
||||
{
|
||||
|
||||
_contractorsRepository = contractorsRepository ?? throw new ArgumentNullException(nameof(contractorsRepository));
|
||||
_premisesRepository = premisesRepository ?? throw new ArgumentNullException(nameof(premisesRepository));
|
||||
_worksRepository = worksRepository ?? throw new ArgumentNullException(nameof(worksRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeContractors, bool includePremises, bool includeWork)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||
|
||||
|
||||
if (includeContractors)
|
||||
{
|
||||
builder.AddParagraph("Подрядчики").AddTable([2400, 2400], GetContractors());
|
||||
}
|
||||
|
||||
if (includePremises)
|
||||
{
|
||||
builder.AddParagraph("Помещения").AddTable([2400, 2400, 2400, 2400, 2400, 2400], GetPremises());
|
||||
}
|
||||
|
||||
if (includeWork)
|
||||
{
|
||||
builder.AddParagraph("Работы").AddTable([2400, 2400], GetWork());
|
||||
}
|
||||
|
||||
builder.Build();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetContractors()
|
||||
{
|
||||
return [
|
||||
["Название компании", "Контакты"],
|
||||
.. _contractorsRepository
|
||||
.ReadContractors()
|
||||
.Select(x => new string[] { x.CompanyName, x.Contacts}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetPremises()
|
||||
{
|
||||
return [
|
||||
["Имя клиента", "Адрес", "Площадь", "Тип помещения","Дата начала","Дата конца"],
|
||||
.. _premisesRepository
|
||||
.ReadPremises()
|
||||
.Select(x => new string[] { x.ClientName, x.Address, x.Area.ToString(), x.PremisesType.ToString(), x.DateStart.ToString(), x.DateEnd.ToString()}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetWork()
|
||||
{
|
||||
return [
|
||||
["Название работы", "Материалы"],
|
||||
.. _worksRepository
|
||||
.ReadWorks()
|
||||
.Select(x => new string[] { x.WorkName, x.MaterialsName.ToString()}),
|
||||
];
|
||||
}
|
||||
}
|
316
ProjectRepairWork/Reports/ExcelBuilder.cs
Normal file
316
ProjectRepairWork/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,316 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
internal class ExcelBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly SheetData _sheetData;
|
||||
private readonly MergeCells _mergeCells;
|
||||
private readonly Columns _columns;
|
||||
private uint _rowIndex = 0;
|
||||
|
||||
public ExcelBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
}
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||
});
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
}
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
|
||||
if (_columns.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
}
|
||||
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts()
|
||||
{
|
||||
Count = 2,
|
||||
KnownFonts = BooleanValue.FromBoolean(true)
|
||||
};
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
});
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
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);
|
||||
|
||||
// Default Fill
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill()
|
||||
{
|
||||
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
// Default Border
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
// Default cell format and a date cell format
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Right,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
}
|
||||
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null &&
|
||||
c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null &&
|
||||
cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
return columnName;
|
||||
}
|
||||
}
|
76
ProjectRepairWork/Reports/PdfBuilder.cs
Normal file
76
ProjectRepairWork/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
internal 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 headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
95
ProjectRepairWork/Reports/TableReport.cs
Normal file
95
ProjectRepairWork/Reports/TableReport.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectRepairWork.Repositories;
|
||||
using ProjectRepairWork.Repositories.Implementation;
|
||||
using ProjectRepairWork.Entities;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
internal class TableReport
|
||||
{
|
||||
private readonly IRepairRepository _repairRepository;
|
||||
private readonly IWorksRepository _worksRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] Headers = { "Работа", "Дата", "Количество" };
|
||||
|
||||
public TableReport(IRepairRepository repairRepository, IWorksRepository worksRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_repairRepository = repairRepository ?? throw new ArgumentNullException(nameof(repairRepository));
|
||||
_worksRepository = worksRepository ?? throw new ArgumentNullException(nameof(worksRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int contractorsId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = GetData(contractorsId, startDate, endDate);
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по подрядчикам", 0, 3)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable(new int[] { 10, 15, 15 }, data)
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int contractorsId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var repairs = _repairRepository.ReadRepair()
|
||||
.Where(x => x.DateRepair >= startDate && x.DateRepair <= endDate && x.ContractorsId == contractorsId)
|
||||
.ToList();
|
||||
|
||||
var repairRepairs = _repairRepository.ReadRepairRepair();
|
||||
var works = _worksRepository.ReadWorks();
|
||||
|
||||
var data = from repair in repairs
|
||||
join repairRepair in repairRepairs on repair.Id equals repairRepair.Id
|
||||
join work in works on repairRepair.WorkId equals work.Id
|
||||
select new
|
||||
{
|
||||
work.WorkName,
|
||||
repairRepair.Count,
|
||||
repair.DateRepair
|
||||
};
|
||||
|
||||
|
||||
var groupedData = data
|
||||
.GroupBy(x => new { x.WorkName, x.DateRepair })
|
||||
.Select(g => new
|
||||
{
|
||||
WorksName = g.Key.WorkName,
|
||||
Date = g.Key.DateRepair,
|
||||
Quantity = g.Sum(x => x.Count)
|
||||
})
|
||||
.OrderBy(x => x.Date)
|
||||
.ToList();
|
||||
|
||||
var totalQuantity = groupedData.Sum(x => x.Quantity);
|
||||
|
||||
var result = new List<string[]>() { Headers }
|
||||
.Union(
|
||||
groupedData
|
||||
.Select(x => new string[] {
|
||||
x.WorksName.ToString(), x.Date.ToString(), x.Quantity.ToString()
|
||||
}))
|
||||
.Union(
|
||||
new List<string[]>() { new string[] { "Всего", "", totalQuantity.ToString() } })
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
131
ProjectRepairWork/Reports/WordBuilder.cs
Normal file
131
ProjectRepairWork/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
|
||||
namespace ProjectRepairWork.Reports;
|
||||
|
||||
public class WordBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
private readonly Body _body;
|
||||
|
||||
public WordBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
_body = _document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
public WordBuilder AddHeader(string header)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
var runProperties = run.AppendChild(new RunProperties());
|
||||
runProperties.AppendChild(new Bold());
|
||||
run.AppendChild(new Text(header));
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddParagraph(string text)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
run.AppendChild(new Text(text));
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||
{
|
||||
if (widths == null || widths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(widths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != widths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
var table = new Table();
|
||||
table.AppendChild(new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
)
|
||||
));
|
||||
|
||||
var tr = new TableRow();
|
||||
for (var j = 0; j < widths.Length; ++j)
|
||||
{
|
||||
tr.Append(new TableCell(
|
||||
new TableCellProperties(new TableCellWidth()
|
||||
{
|
||||
Width =
|
||||
widths[j].ToString()
|
||||
}),
|
||||
new Paragraph(new Run(new RunProperties(new Bold()), new
|
||||
Text(data.First()[j])))));
|
||||
}
|
||||
table.Append(tr);
|
||||
|
||||
table.Append(data.Skip(1).Select(x =>
|
||||
new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||
_body.Append(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var wordDocument = WordprocessingDocument.Create(_filePath,
|
||||
WordprocessingDocumentType.Document);
|
||||
var mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = _document;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
using ProjectRepairWork.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Repositories;
|
||||
|
||||
public interface IBuildingMaterialsRepository
|
||||
{
|
||||
IEnumerable<BuildingMaterials> ReadBuildingMaterials();
|
||||
|
||||
BuildingMaterials ReadBuildingMaterialsById(int id);
|
||||
void CreateBuildingMaterials(BuildingMaterials buildingMaterials);
|
||||
void UpdateBuildingMaterials(BuildingMaterials buildingMaterials);
|
||||
void DeletedBuildingMaterials(int id);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using ProjectRepairWork.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Repositories;
|
||||
|
||||
public interface IMaterialProcurementRepository
|
||||
{
|
||||
IEnumerable<MaterialProcurement> ReadMaterialProcurement();
|
||||
MaterialProcurement ReadMaterialProcurementById(int id);
|
||||
void CreateMaterialProcurement(MaterialProcurement materialProcurement);
|
||||
}
|
@ -10,5 +10,6 @@ namespace ProjectRepairWork.Repositories;
|
||||
public interface IRepairRepository
|
||||
{
|
||||
IEnumerable<Repair> ReadRepair(int? contractorsId = null, int? costId = null, int? worksId = null, int? premisesId = null);
|
||||
IEnumerable<RepairRepair> ReadRepairRepair();
|
||||
void CraeteRepair(Repair repair);
|
||||
}
|
||||
|
@ -0,0 +1,127 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectRepairWork.Entities;
|
||||
using ProjectRepairWork.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Repositories.Implementation;
|
||||
|
||||
public class BuildingMaterialsRepository : IBuildingMaterialsRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<BuildingMaterialsRepository> _logger;
|
||||
public BuildingMaterialsRepository(IConnectionString connectionString, ILogger<BuildingMaterialsRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateBuildingMaterials(BuildingMaterials buildingMaterials)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(buildingMaterials));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO BuildingMaterials (MaterialsType)
|
||||
VALUES (@MaterialsType)";
|
||||
connection.Execute(queryInsert, buildingMaterials);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateBuildingMaterials(BuildingMaterials buildingMaterials)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(buildingMaterials));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE BuildingMaterials
|
||||
SET
|
||||
BuildingMaterials=@BuildingMaterials
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, buildingMaterials);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeletedBuildingMaterials(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM BuildingMaterials
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BuildingMaterials> ReadBuildingMaterials()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM buildingmaterials";
|
||||
var buildingMaterials = connection.Query<BuildingMaterials>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(buildingMaterials));
|
||||
return buildingMaterials;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public BuildingMaterials ReadBuildingMaterialsById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM BuildingMaterials
|
||||
WHERE Id=@id";
|
||||
var buildingMaterials = connection.QueryFirst<BuildingMaterials>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(buildingMaterials));
|
||||
return buildingMaterials;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectRepairWork.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectRepairWork.Repositories.Implementation;
|
||||
|
||||
public class MaterialProcurementRepository : IMaterialProcurementRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<MaterialProcurementRepository> _logger;
|
||||
|
||||
public MaterialProcurementRepository(IConnectionString connectionString, ILogger<MaterialProcurementRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateMaterialProcurement(MaterialProcurement materialProcurement)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(materialProcurement));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO MaterialProcurement (MaterialsId, MaterialsPrice, ProcurmentDate)
|
||||
VALUES (@MaterialsId, @MaterialsPrice, @ProcurmentDate)";
|
||||
connection.Execute(queryInsert, materialProcurement);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialProcurement ReadMaterialProcurementById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM MaterialProcurement
|
||||
WHERE Id=@id";
|
||||
var materialProcurement = connection.QueryFirst<MaterialProcurement>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(materialProcurement));
|
||||
return materialProcurement;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public IEnumerable<MaterialProcurement> ReadMaterialProcurement()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM MaterialProcurement";
|
||||
var materialProcurement = connection.Query<MaterialProcurement>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(materialProcurement));
|
||||
return materialProcurement;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -33,8 +33,8 @@ public class RepairRepository : IRepairRepository
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO Repair (ContractorsId, PremisesId)
|
||||
VALUES (@ContractorsId, @PremisesId);
|
||||
INSERT INTO Repair (ContractorsId, PremisesId, DateRepair)
|
||||
VALUES (@ContractorsId, @PremisesId, @DateRepair);
|
||||
SELECT MAX(Id) FROM Repair";
|
||||
var repairId =
|
||||
connection.QueryFirst<int>(queryInsert, repair, transaction);
|
||||
@ -77,4 +77,24 @@ public class RepairRepository : IRepairRepository
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<RepairRepair> ReadRepairRepair()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM RepairRepair";
|
||||
var repairRepairs = connection.Query<RepairRepair>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(repairRepairs));
|
||||
return repairRepairs;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user