зафиксить

This commit is contained in:
Kristina 2024-02-15 23:56:24 +04:00
parent 81976018e3
commit 4ada37b36c
8 changed files with 641 additions and 70 deletions

View File

@ -32,15 +32,16 @@
labelCost = new Label();
groupBoxManufacture = new GroupBox();
dataGridView = new DataGridView();
ButtonAdd = new Button();
ButtonUpd = new Button();
ButtonDel = new Button();
компоненты = new DataGridViewTextBoxColumn();
колво = new DataGridViewTextBoxColumn();
ButtonRef = new Button();
ButtonDel = new Button();
ButtonUpd = new Button();
ButtonAdd = new Button();
ButtonCancel = new Button();
ButtonSave = new Button();
textBoxName = new TextBox();
textBoxPrice = new TextBox();
// Id = new DataGridViewTextBoxColumn();
Компонент = new DataGridViewTextBoxColumn();
Количество = new DataGridViewTextBoxColumn();
groupBoxManufacture.SuspendLayout();
@ -67,11 +68,11 @@
//
// groupBoxManufacture
//
groupBoxManufacture.Controls.Add(dataGridView);
groupBoxManufacture.Controls.Add(ButtonRef);
groupBoxManufacture.Controls.Add(ButtonDel);
groupBoxManufacture.Controls.Add(ButtonUpd);
groupBoxManufacture.Controls.Add(ButtonAdd);
groupBoxManufacture.Controls.Add(dataGridView);
groupBoxManufacture.Location = new Point(12, 112);
groupBoxManufacture.Name = "groupBoxManufacture";
groupBoxManufacture.Size = new Size(856, 366);
@ -83,51 +84,69 @@
//
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
//dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, Компонент, Количество });
dataGridView.Columns.AddRange(new DataGridViewColumn[] { компоненты, колво });
dataGridView.Enabled = false;
dataGridView.Location = new Point(6, 36);
dataGridView.Location = new Point(0, 41);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 62;
dataGridView.RowTemplate.Height = 33;
dataGridView.Size = new Size(614, 330);
dataGridView.TabIndex = 0;
dataGridView.CellContentClick += dataGridView_CellContentClick;
dataGridView.Size = new Size(666, 319);
dataGridView.TabIndex = 5;
dataGridView.CellContentClick += dataGridView1_CellContentClick;
//
// ButtonAdd
// компоненты
//
ButtonAdd.Location = new Point(696, 30);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(112, 34);
ButtonAdd.TabIndex = 1;
ButtonAdd.Text = "Добавить";
ButtonAdd.UseVisualStyleBackColor = true;
компоненты.HeaderText = "компоненты";
компоненты.MinimumWidth = 8;
компоненты.Name = "компоненты";
компоненты.Width = 400;
//
// ButtonUpd
// колво
//
ButtonUpd.Location = new Point(696, 85);
ButtonUpd.Name = "ButtonUpd";
ButtonUpd.Size = new Size(112, 34);
ButtonUpd.TabIndex = 2;
ButtonUpd.Text = "Изменить";
ButtonUpd.UseVisualStyleBackColor = true;
//
// ButtonDel
//
ButtonDel.Location = new Point(696, 148);
ButtonDel.Name = "ButtonDel";
ButtonDel.Size = new Size(112, 34);
ButtonDel.TabIndex = 3;
ButtonDel.Text = "Удалить";
ButtonDel.UseVisualStyleBackColor = true;
колво.HeaderText = "колво";
колво.MinimumWidth = 8;
колво.Name = "колво";
колво.Width = 150;
//
// ButtonRef
//
ButtonRef.Location = new Point(696, 208);
ButtonRef.Location = new Point(696, 226);
ButtonRef.Name = "ButtonRef";
ButtonRef.Size = new Size(112, 34);
ButtonRef.TabIndex = 4;
ButtonRef.Text = "Обновить";
ButtonRef.UseVisualStyleBackColor = true;
ButtonRef.Click += ButtonRef_Click;
//
// ButtonDel
//
ButtonDel.Location = new Point(696, 166);
ButtonDel.Name = "ButtonDel";
ButtonDel.Size = new Size(112, 34);
ButtonDel.TabIndex = 3;
ButtonDel.Text = "Удалить";
ButtonDel.UseVisualStyleBackColor = true;
ButtonDel.Click += ButtonDel_Click;
//
// ButtonUpd
//
ButtonUpd.Location = new Point(696, 101);
ButtonUpd.Name = "ButtonUpd";
ButtonUpd.Size = new Size(112, 34);
ButtonUpd.TabIndex = 2;
ButtonUpd.Text = "Изменить";
ButtonUpd.UseVisualStyleBackColor = true;
ButtonUpd.Click += ButtonUpd_Click;
//
// ButtonAdd
//
ButtonAdd.Location = new Point(696, 41);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(112, 34);
ButtonAdd.TabIndex = 1;
ButtonAdd.Text = "Добавить";
ButtonAdd.UseVisualStyleBackColor = true;
ButtonAdd.Click += ButtonAdd_Click;
//
// ButtonCancel
//
@ -137,6 +156,7 @@
ButtonCancel.TabIndex = 5;
ButtonCancel.Text = "Отмена";
ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click;
//
// ButtonSave
//
@ -146,6 +166,7 @@
ButtonSave.TabIndex = 6;
ButtonSave.Text = "Сохранить";
ButtonSave.UseVisualStyleBackColor = true;
ButtonSave.Click += ButtonSave_Click;
//
// textBoxName
//
@ -161,27 +182,17 @@
textBoxPrice.Size = new Size(194, 31);
textBoxPrice.TabIndex = 8;
//
//// Id
////
//Id.HeaderText = "Id";
//Id.MinimumWidth = 8;
//Id.Name = "Id";
//Id.Visible = false;
//Id.Width = 150;
//
// Компонент
//
Компонент.HeaderText = "Компонент";
Компонент.MinimumWidth = 8;
Компонент.Name = "Компонент";
Компонент.Width = 200;
Компонент.Width = 150;
//
// Количество
//
Количество.HeaderText = "Количество";
Количество.MinimumWidth = 8;
Количество.Name = "Количество";
Количество.Width = 200;
Количество.Width = 150;
//
// FormManufacture
//
@ -197,6 +208,7 @@
Controls.Add(labelName);
Name = "FormManufacture";
Text = "FormManufacture";
Load += FormManufacture_Load;
groupBoxManufacture.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
@ -208,7 +220,6 @@
private Label labelName;
private Label labelCost;
private GroupBox groupBoxManufacture;
private DataGridView dataGridView;
private Button ButtonRef;
private Button ButtonDel;
private Button ButtonUpd;
@ -220,5 +231,8 @@
private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn Компонент;
private DataGridViewTextBoxColumn Количество;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn компоненты;
private DataGridViewTextBoxColumn колво;
}
}

View File

@ -1,4 +1,7 @@
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
using BlacksmithWorkshop;
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
using BlacksmithWorkshopContracts.SearchModels;
using BlacksmithWorkshopDataModels.Models;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging;
@ -29,9 +32,198 @@ namespace BlacksmithWorkshopView
_manufactureComponents = new Dictionary<int, (IComponentModel, int)>();
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void FormManufacture_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка кузнечного изделия");
try
{
var view = _logic.ReadElement(new ManufactureSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.ManufactureName;
textBoxPrice.Text = view.Price.ToString();
_manufactureComponents = view.ManufactureComponents ?? new
Dictionary<int, (IComponentModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки кузнечного изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка компонентов кузнечного изделия");
try
{
if (_manufactureComponents != null)
{
dataGridView.Rows.Clear();
foreach (var pc in _manufactureComponents)
{
dataGridView.Rows.Add(new object[] { pc.Key,
pc.Value.Item1.ComponentName, pc.Value.Item2 });
}
textBoxPrice.Text = CalcPrice().ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки компонентов кузнечного изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent));
if (service is FormManufactureComponent form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ComponentModel == null)
{
return;
}
_logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
if (_manufactureComponents.ContainsKey(form.Id))
{
_manufactureComponents[form.Id] = (form.ComponentModel, form.Count);
}
else
{
_manufactureComponents.Add(form.Id, (form.ComponentModel, form.Count));
}
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormManufactureComponent));
if (service is FormManufactureComponent form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.Count = _manufactureComponents[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ComponentModel == null)
{
return;
}
_logger.LogInformation("Изменение компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
_manufactureComponents[form.Id] = (form.ComponentModel, form.Count);
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_logger.LogInformation("Удаление компонента:{ ComponentName}- { Count} ", dataGridView.SelectedRows[0].Cells[1].Value);
_manufactureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPrice.Text))
{
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
if (_manufactureComponents == null || _manufactureComponents.Count == 0)
{
MessageBox.Show("Заполните компоненты", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение кузнечного изделия");
try
{
var model = new ManufactureBindingModel
{
Id = _id ?? 0,
ManufactureName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.Text),
ManufactureComponents = _manufactureComponents
};
var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения кузнечного изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private double CalcPrice()
{
double price = 0;
foreach (var elem in _manufactureComponents)
{
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
}
return Math.Round(price * 1.1, 2);
}
}
}

View File

@ -117,7 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="компоненты.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="колво.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Компонент.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -0,0 +1,114 @@
namespace BlacksmithWorkshopView
{
partial class FormManufactures
{
/// <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();
AddButton = new Button();
UpdateButton = new Button();
DeleteButton = new Button();
RefreshButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 62;
dataGridView.RowTemplate.Height = 33;
dataGridView.Size = new Size(431, 449);
dataGridView.TabIndex = 0;
//
// AddButton
//
AddButton.Location = new Point(481, 12);
AddButton.Name = "AddButton";
AddButton.Size = new Size(112, 34);
AddButton.TabIndex = 1;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// UpdateButton
//
UpdateButton.Location = new Point(481, 73);
UpdateButton.Name = "UpdateButton";
UpdateButton.Size = new Size(112, 34);
UpdateButton.TabIndex = 2;
UpdateButton.Text = "Изменить";
UpdateButton.UseVisualStyleBackColor = true;
UpdateButton.Click += UpdateButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(481, 133);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(112, 34);
DeleteButton.TabIndex = 3;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// RefreshButton
//
RefreshButton.Location = new Point(481, 198);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(112, 34);
RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// FormManufactures
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(RefreshButton);
Controls.Add(DeleteButton);
Controls.Add(UpdateButton);
Controls.Add(AddButton);
Controls.Add(dataGridView);
Name = "FormManufactures";
Text = "FormManufactures";
Load += FormManufactures_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button AddButton;
private Button UpdateButton;
private Button DeleteButton;
private Button RefreshButton;
}
}

View File

@ -0,0 +1,115 @@
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 BlacksmithWorkshop;
using BlacksmithWorkshopContracts.BindingModels;
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging;
namespace BlacksmithWorkshopView
{
public partial class FormManufactures : Form
{
private readonly ILogger _logger;
private readonly IManufactureLogic _logic;
public FormManufactures(ILogger<FormManufactures> logger, IManufactureLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormManufactures_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ManufactureComponents"].Visible = false;
}
_logger.LogInformation("Загрузка кузнечных изделий");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки кузнечных изделий");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
if (service is FormManufacture form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void UpdateButton_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
if (service is FormManufacture form)
{
var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление кузнечного изделия");
try
{
if (!_logic.Delete(new ManufactureBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления кузнечного изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

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

@ -5,6 +5,7 @@ using BlacksmithWorkshopView;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using BlacksmithWorkshopBusinessList.BusinessLogics;
namespace BlacksmithWorkshop
{
@ -26,29 +27,29 @@ namespace BlacksmithWorkshop
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
private static void ConfigureServices(ServiceCollection services)
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IManufactureStorage, ManufactureStorage>();
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IManufactureStorage, ManufactureStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IManufactureLogic, ComponentLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IManufactureLogic, ManufactureLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormManufacture>();
services.AddTransient<FormManufactures>();
services.AddTransient<FormManufactureComponent>();
}
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormManufacture>();
services.AddTransient<FormManufactures>();
services.AddTransient<FormManufactureComponent>();
}
}
}

View File

@ -1,3 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>