сохранимся перед уходом

This commit is contained in:
annalyovushkina@yandex.ru 2024-10-22 17:03:21 +04:00
parent 1b0705081f
commit 33954a91c4
10 changed files with 751 additions and 3 deletions

View File

@ -28,7 +28,20 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
controlDataTableTable1 = new ControlsLibraryNet60.Data.ControlDataTableTable();
controlDataTableRow1 = new ControlsLibraryNet60.Data.ControlDataTableRow();
contextMenuStrip1 = new ContextMenuStrip(components);
создатьToolStripMenuItem = new ToolStripMenuItem();
изменитьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem();
wordToolStripMenuItem = new ToolStripMenuItem();
excelToolStripMenuItem = new ToolStripMenuItem();
pdfToolStripMenuItem = new ToolStripMenuItem();
лабаToolStripMenuItem = new ToolStripMenuItem();
pdfImage = new CustomComponents.NonVisualComponents.PdfImage(components);
customExcelTable = new Non_visual_components_Kouvshinoff.CustomComponentExcelTableWithHeader(components);
contextMenuStrip1.SuspendLayout();
SuspendLayout();
//
// controlDataTableTable1
@ -40,19 +53,91 @@
controlDataTableTable1.Size = new Size(799, 447);
controlDataTableTable1.TabIndex = 0;
//
// controlDataTableRow1
//
controlDataTableRow1.Location = new Point(13, 65);
controlDataTableRow1.Margin = new Padding(4, 5, 4, 5);
controlDataTableRow1.Name = "controlDataTableRow1";
controlDataTableRow1.SelectedRowIndex = -1;
controlDataTableRow1.Size = new Size(774, 371);
controlDataTableRow1.TabIndex = 1;
//
// contextMenuStrip1
//
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
contextMenuStrip1.Items.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem, wordToolStripMenuItem, excelToolStripMenuItem, pdfToolStripMenuItem, лабаToolStripMenuItem });
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(146, 172);
//
// создатьToolStripMenuItem
//
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
создатьToolStripMenuItem.Size = new Size(145, 24);
создатьToolStripMenuItem.Text = "создать";
//
// изменитьToolStripMenuItem
//
изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem";
изменитьToolStripMenuItem.Size = new Size(145, 24);
изменитьToolStripMenuItem.Text = "изменить";
//
// удалитьToolStripMenuItem
//
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.Size = new Size(145, 24);
удалитьToolStripMenuItem.Text = "удалить";
//
// wordToolStripMenuItem
//
wordToolStripMenuItem.Name = "wordToolStripMenuItem";
wordToolStripMenuItem.Size = new Size(145, 24);
wordToolStripMenuItem.Text = "word";
//
// excelToolStripMenuItem
//
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
excelToolStripMenuItem.Size = new Size(145, 24);
excelToolStripMenuItem.Text = "excel";
//
// pdfToolStripMenuItem
//
pdfToolStripMenuItem.Name = "pdfToolStripMenuItem";
pdfToolStripMenuItem.Size = new Size(145, 24);
pdfToolStripMenuItem.Text = "pdf";
//
// лабаToolStripMenuItem
//
лабаToolStripMenuItem.Name = абаToolStripMenuItem";
лабаToolStripMenuItem.Size = new Size(145, 24);
лабаToolStripMenuItem.Text = "лаба";
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(controlDataTableRow1);
Controls.Add(controlDataTableTable1);
Name = "Form1";
Text = "Form1";
Load += Form1_Load;
contextMenuStrip1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTableTable1;
private ControlsLibraryNet60.Data.ControlDataTableRow controlDataTableRow1;
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem создатьToolStripMenuItem;
private ToolStripMenuItem изменитьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem wordToolStripMenuItem;
private ToolStripMenuItem excelToolStripMenuItem;
private ToolStripMenuItem pdfToolStripMenuItem;
private ToolStripMenuItem лабаToolStripMenuItem;
private CustomComponents.NonVisualComponents.PdfImage pdfImage;
private Non_visual_components_Kouvshinoff.CustomComponentExcelTableWithHeader customExcelTable;
}
}

View File

@ -1,15 +1,272 @@
using System.Windows.Forms;
using UchetLabContracts.BindingModels;
using UchetLabContracts.BusinessLogicsContracts;
using UchetLabBusinessLogic.BusinessLogic;
using UchetLabContracts.BindingModels;
using UchetLabContracts.BusinessLogicsContracts;
using ControlsLibraryNet60.Models;
using ControlsLibraryNet60.Data;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
using CustomComponents.Helpers;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.Data.SqlClient;
using Non_visual_components_Kouvshinoff.InfoModels;
using UchetLabContracts.ViewModels;
namespace WinFormUchetLab
{
public partial class Form1 : Form
{
public Form1()
private readonly ILabLogic _labLogic;
private readonly ICheckerLogic _checkerLogic;
public Form1(ILabLogic dishLogic, ICheckerLogic orderLogic)
{
_labLogic = dishLogic;
_checkerLogic = orderLogic;
InitializeComponent();
List<DataTableColumnConfig> columnConfigs = new List<DataTableColumnConfig>
{
new DataTableColumnConfig
{
ColumnHeader = "Èäåíòèôèêàòîð",
PropertyName = "Id",
Width = 150,
Visible = false
},
new DataTableColumnConfig
{
ColumnHeader = "Çàäàíèå",
PropertyName = "LabTask",
Width = 250,
Visible = true
},
new DataTableColumnConfig
{
ColumnHeader = "Ïðîâåðÿþùèé",
PropertyName = "Checker",
Width = 200,
Visible = true
},
new DataTableColumnConfig
{
ColumnHeader = "Äàòà ñäà÷è",
PropertyName = "CheckDate",
Width = 200,
Visible = true
}
};
controlDataTableRow1.LoadColumns(columnConfigs);
controlDataTableRow1.ContextMenuStrip = contextMenuStrip1;
}
private void Form1_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
controlDataTableRow1.Clear();
try
{
var labs = _labLogic.ReadList(null);
if (labs == null)
{
return;
}
foreach (var lab in labs)
{
controlDataTableRow1.AddRow(lab);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddElement()
{
var service = Program.ServiceProvider?.GetService(typeof(FormLab));
if (!(service is FormLab form))
{
return;
}
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void UpdateElement()
{
var service = Program.ServiceProvider?.GetService(typeof(FormLab));
if (!(service is FormLab form))
{
return;
}
var selectedLab = controlDataTableRow1.GetSelectedObject<LabViewModel>();
if (selectedLab == null)
{
MessageBox.Show("Âûáåðèòå ñ÷åò äëÿ ðåäàêòèðîâàíèÿ!", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
form.Id = Convert.ToInt32(selectedLab.Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void DeleteElement()
{
if (MessageBox.Show("Óäàëèòü çàïèñü?", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
var selectedLab = controlDataTableRow1.GetSelectedObject<LabViewModel>();
int id = Convert.ToInt32(selectedLab.Id);
try
{
_labLogic.Delete(new LabBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
private void CreatePdf()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else return;
}
List<string> images = new List<string>();
var list = _labLogic.ReadList(null);
try
{
if (list != null)
{
foreach (var item in list)
{
images.Add(item.TaskImage);
}
string[] imagesArray = images.ToArray();
pdfImage.CreatePdfDoc(new DataForImage(fileName, "Ñêàíû ÷åêîâ", imagesArray));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
private void CreateExcel()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else return;
}
string title = "Äîêóìåíò ñ òàáëèöåé";
var list = _labLogic.ReadList(null);
List<ColumnInfo> header = new List<ColumnInfo>();
ColumnInfo col1 = new ColumnInfo("Id", 5, "Id");
ColumnInfo col2 = new ColumnInfo("çàäàíèå", 20, "LabTask");
ColumnInfo col3 = new ColumnInfo("ïðîâåðÿþùèé", 6, "Checker");
ColumnInfo col4 = new ColumnInfo("äàòà ïðè¸ìà", 6.5, "CheckDate");
ColumnInfo colExam = new ColumnInfo("ïðè¸ì", new List<ColumnInfo> { col3, col4 });
header.Add(colExam);
try
{
customExcelTable.createExcel(fileName, title,
header, list);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
private void CreateWord()
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else return;
}
var data = new Dictionary<string, List<(int Date, double Value)>>();
var orders = _orderLogic.ReadList(null);
var groupedOrders = orders.GroupBy(order => order.Dish)
.Select(group => new
{
DishName = group.Key,
OrderCount = group.Count()
})
.ToList();
data["Áëþäà"] = new List<(int Date, double Value)>();
int counter = 1;
foreach (var group in groupedOrders)
{
data["Áëþäà"].Add((counter, group.OrderCount));
counter++;
}
try
{
componentDocumentWithChartBarWord.CreateDoc(new ComponentDocumentWithChartConfig
{
Header = "test",
FilePath = fileName,
ChartTitle = "Êîëè÷åñòâî çàêàçîâ îïðåäåëåííûõ áëþä",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = data
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
}
}

View File

@ -117,4 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pdfImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>202, 17</value>
</metadata>
<metadata name="customExcelTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>323, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,39 @@
namespace WinFormUchetLab
{
partial class FormChecker
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormChecker";
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
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 WinFormUchetLab
{
public partial class FormChecker : Form
{
public FormChecker()
{
InitializeComponent();
}
}
}

View 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>

View File

@ -0,0 +1,39 @@
namespace WinFormUchetLab
{
partial class FormLab
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormLab";
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
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 WinFormUchetLab
{
public partial class FormLab : Form
{
public FormLab()
{
InitializeComponent();
}
}
}

View 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>

View File

@ -1,7 +1,20 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using UchetLabBusinessLogic.BusinessLogic;
using UchetLabContracts.BusinessLogicsContracts;
using UchetLabContracts.StorageContracts;
using UchetLabDatabaseImplement.Implements;
namespace WinFormUchetLab
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
/// <summary>
/// IoC-êîíòåéíåð
/// </summary>
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -11,7 +24,33 @@ namespace WinFormUchetLab
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<Form1>());
}
private static void ConfigureServices(ServiceCollection services)
{
// Ëîããåð
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
//option.AddNLog("nlog.config");
});
// IoC-êîíòåéíåð, õðàíèëèùà
services.AddTransient<ILabStorage, LabStorage>();
services.AddTransient<ICheckerStorage, CheckerStorage>();
// IoC-êîíòåéíåð, áèçíåñ-ëîãèêà
services.AddTransient<ILabLogic, LabLogic>();
services.AddTransient<ICheckerLogic, CheckerLogic>();
// IoC-êîíòåéíåð, ôîðìû îòîáðàæåíèÿ
services.AddTransient<Form1>();
services.AddTransient<FormLab>();
services.AddTransient<FormChecker>();
}
}
}