Compare commits

...

9 Commits
main ... lab4

Author SHA1 Message Date
5040951949 правки 2 2025-01-30 19:03:30 +04:00
15410aec67 правки 2024-12-24 22:53:56 +04:00
208f744ef5 lab4 2024-12-24 01:32:15 +04:00
dbd151ff41 правки 2024-12-22 12:53:35 +04:00
132a1e3134 lab3 2024-12-21 20:48:54 +04:00
7b7a95beb2 правки 2 2024-12-21 14:00:40 +04:00
cf3e7bd678 правки 2024-12-20 20:48:44 +04:00
f1259119a7 lab2 2024-12-12 20:55:40 +04:00
bec5af8d32 Лабораторная работа №1 2024-11-29 15:00:05 +04:00
78 changed files with 8488 additions and 55 deletions

View File

@ -2,10 +2,55 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<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="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
<PackageReference Include="Serialize.Linq" Version="3.1.160" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\DataSources\" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
using System.ComponentModel;
public class Client
{
public int Id { get; private set; }
[DisplayName("Имя")]
public string FirstName { get; private set; } = string.Empty;
[DisplayName("Фамилия")]
public string LastName { get; private set; } = string.Empty;
public string FullName => $"{LastName} {FirstName}";
[DisplayName("Контактная информация")]
public string ContactInformation { get; private set; } = string.Empty;
public static Client CreateEntity(int id, string firstName, string
lastName, string contactInformation)
{
return new Client
{
Id = id,
FirstName = firstName ?? string.Empty,
LastName = lastName ?? string.Empty,
ContactInformation = contactInformation ?? string.Empty,
};
}
}

View File

@ -0,0 +1,14 @@
[Flags]
public enum Color
{
None = 0,
Black = 1,
Red = 2,
Blue = 4,
Green = 8,
Grey = 16,
Yellow = 32,
Pink = 64,
White = 128,
Purple = 256,
}

View File

@ -0,0 +1,9 @@
[Flags]
public enum FabricType
{
None = 0,
Cotton = 1,
Silk = 2,
Linen = 4,
Polyester = 8
}

View File

@ -0,0 +1,9 @@
[Flags]
public enum ModelType
{
None = 0,
Pants = 1,
Skirt = 2,
Dress = 4,
Jacket = 8
}

View File

@ -0,0 +1,7 @@
public enum Status
{
None = 0,
Waiting = 1,
InProcess = 2,
Done = 3
}

View File

@ -0,0 +1,23 @@
using System.ComponentModel;
public class Fabric
{
public int Id { get; private set; }
[DisplayName("Тип ткани")]
public FabricType FabricType { get; private set; }
[DisplayName("Цвет")]
public Color Color { get; private set; }
[DisplayName("Метраж")]
public double Metrage { get; private set; }
public static Fabric CreateEntity(int id, FabricType fabricType, Color color, double metrage)
{
return new Fabric
{
Id = id,
FabricType = fabricType,
Color = color,
Metrage = metrage,
};
}
}

View File

@ -0,0 +1,16 @@
public class FabricModel
{
public int FabricId { get; private set; }
public int ModelId { get; private set; }
public int Count { get; private set; }
public FabricType FabricName { get; private set; }
public static FabricModel CreateElement(int fabricId, int modelId, int count)
{
return new FabricModel
{
FabricId = fabricId,
ModelId = modelId,
Count = count
};
}
}

View File

@ -0,0 +1,38 @@
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel;
public class Model
{
public int Id { get; private set; }
[DisplayName("Модель")]
public ModelType ModelType { get; private set; }
[DisplayName("Цена")]
public double Price { get; private set; }
[DisplayName("Ткань")]
public string Fabric => FabricModel != null ?
string.Join(", ", FabricModel.Select(x => $"{x.FabricName} {x.Count}")) : string.Empty;
[Browsable(false)]
public IEnumerable<FabricModel> FabricModel { get;private set;} = [];
public static Model CreateEntity(int id, ModelType modelType,double price, IEnumerable<FabricModel> fabricModel)
{
return new Model
{
Id = id,
ModelType = modelType,
Price = price,
FabricModel = fabricModel
};
}
public void CreateList(IEnumerable<FabricModel> fabricModel)
{
if (fabricModel != null)
{
FabricModel = fabricModel;
}
}
}

View File

@ -0,0 +1,16 @@
public class ModelOrder
{
public int OrderId { get; private set; }
public int ModelId { get; private set; }
public int Count { get; private set; }
public ModelType ModelName { get; private set; }
public static ModelOrder CreateElement(int orderId, int modelId, int count)
{
return new ModelOrder
{
OrderId = orderId,
ModelId = modelId,
Count = count
};
}
}

View File

@ -0,0 +1,42 @@
using System.ComponentModel;
public class Order
{
public int Id { get; private set; }
[DisplayName("Дата")]
public DateTime Date { get; private set; }
[DisplayName("Статус")]
public Status Status { get; private set; }
[Browsable(false)]
public int ClientId { get; private set; }
[DisplayName("Клиент")]
public string ClientName { get; private set; } = string.Empty;
[Browsable(false)]
public IEnumerable<ModelOrder> ModelOrder { get; private set; } = [];
[DisplayName("Модель")]
public string Model => ModelOrder != null ?
string.Join(", ", ModelOrder.Select(x => $"{x.ModelName} {x.Count}")) : string.Empty;
public static Order CreateOperation(int id,DateTime date, Status status, int clientId, IEnumerable<ModelOrder> modelOrder)
{
return new Order
{
Id = id,
Date = DateTime.Now,
Status = status,
ClientId = clientId,
ModelOrder = modelOrder
};
}
public void SetModelOrder(IEnumerable<ModelOrder> modelOrders)
{
if (modelOrders != null && modelOrders.Any())
{
ModelOrder = modelOrders;
}
}
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel;
public class Storage
{
public int Id { get; private set; }
[Browsable(false)]
public int FabricId { get; private set; }
[DisplayName("Ткань")]
public FabricType FabricName { get; private set; }
[DisplayName("Метраж")]
public double StockMetrage { get; private set; }
[DisplayName("Дата")]
public DateTime DateStorage { get; private set; }
public static Storage CreateOperation(int id, int fabricId, double stockMetrage, DateTime dateStorage)
{
return new Storage
{
Id = id,
FabricId = fabricId,
StockMetrage = stockMetrage,
DateStorage = dateStorage
};
}
}

View File

@ -1,39 +0,0 @@
namespace Atelier
{
partial class Form1
{
/// <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 = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace Atelier
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

170
Atelier/Atelier/FormAtelier.Designer.cs generated Normal file
View File

@ -0,0 +1,170 @@
namespace Atelier
{
partial class FormAtelier
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAtelier));
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
ClientsToolStripMenuItem = new ToolStripMenuItem();
ModelsToolStripMenuItem = new ToolStripMenuItem();
FabricsToolStripMenuItem1 = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
OrdersToolStripMenuItem = new ToolStripMenuItem();
StoragesToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
документСоСправочникамиToolStripMenuItem = new ToolStripMenuItem();
отчётПоЗаказамToolStripMenuItem = new ToolStripMenuItem();
отчётПоСкладуToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(817, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, ModelsToolStripMenuItem, FabricsToolStripMenuItem1 });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// ClientsToolStripMenuItem
//
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
ClientsToolStripMenuItem.Size = new Size(146, 26);
ClientsToolStripMenuItem.Text = "Клиент";
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click_1;
//
// ModelsToolStripMenuItem
//
ModelsToolStripMenuItem.Name = "ModelsToolStripMenuItem";
ModelsToolStripMenuItem.Size = new Size(146, 26);
ModelsToolStripMenuItem.Text = "Модель";
ModelsToolStripMenuItem.Click += ModelsToolStripMenuItem_Click_1;
//
// FabricsToolStripMenuItem1
//
FabricsToolStripMenuItem1.Name = "FabricsToolStripMenuItem1";
FabricsToolStripMenuItem1.Size = new Size(146, 26);
FabricsToolStripMenuItem1.Text = "Ткань";
FabricsToolStripMenuItem1.Click += FabricsToolStripMenuItem1_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrdersToolStripMenuItem, StoragesToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// OrdersToolStripMenuItem
//
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
OrdersToolStripMenuItem.Size = new Size(132, 26);
OrdersToolStripMenuItem.Text = "Заказ";
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click_1;
//
// StoragesToolStripMenuItem
//
StoragesToolStripMenuItem.Name = "StoragesToolStripMenuItem";
StoragesToolStripMenuItem.Size = new Size(132, 26);
StoragesToolStripMenuItem.Text = "Склад";
StoragesToolStripMenuItem.Click += StoragesToolStripMenuItem_Click_1;
//
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem, отчётПоЗаказамToolStripMenuItem, отчётПоСкладуToolStripMenuItem });
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(73, 24);
отчётыToolStripMenuItem.Text = "Отчёты";
//
// документСоСправочникамиToolStripMenuItem
//
документСоСправочникамиToolStripMenuItem.Name = окументСоСправочникамиToolStripMenuItem";
документСоСправочникамиToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
документСоСправочникамиToolStripMenuItem.Size = new Size(350, 26);
документСоСправочникамиToolStripMenuItem.Text = "Документ со справочниками";
документСоСправочникамиToolStripMenuItem.Click += документСоСправочникамиToolStripMenuItem_Click;
//
// отчётПоЗаказамToolStripMenuItem
//
отчётПоЗаказамToolStripMenuItem.Name = "отчётПоЗаказамToolStripMenuItem";
отчётПоЗаказамToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
отчётПоЗаказамToolStripMenuItem.Size = new Size(350, 26);
отчётПоЗаказамToolStripMenuItem.Text = "Отчёт по заказам";
отчётПоЗаказамToolStripMenuItem.Click += отчётПоЗаказамToolStripMenuItem_Click;
//
// отчётПоСкладуToolStripMenuItem
//
отчётПоСкладуToolStripMenuItem.Name = "отчётПоСкладуToolStripMenuItem";
отчётПоСкладуToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
отчётПоСкладуToolStripMenuItem.Size = new Size(350, 26);
отчётПоСкладуToolStripMenuItem.Text = "Отчёт по складу";
отчётПоСкладуToolStripMenuItem.Click += отчётПоСкладуToolStripMenuItem_Click;
//
// FormAtelier
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Zoom;
ClientSize = new Size(817, 467);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormAtelier";
StartPosition = FormStartPosition.CenterScreen;
Text = "Ателье";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem ModelsToolStripMenuItem;
private ToolStripMenuItem FabricsToolStripMenuItem1;
private ToolStripMenuItem OrdersToolStripMenuItem;
private ToolStripMenuItem StoragesToolStripMenuItem;
private ToolStripMenuItem документСоСправочникамиToolStripMenuItem;
private ToolStripMenuItem отчётПоЗаказамToolStripMenuItem;
private ToolStripMenuItem отчётПоСкладуToolStripMenuItem;
}
}

View File

@ -0,0 +1,131 @@
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;
using Atelier.Forms;
namespace Atelier
{
public partial class FormAtelier : Form
{
private readonly IUnityContainer _container;
public FormAtelier(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ClientsToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClients>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ModelsToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormModels>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FabricsToolStripMenuItem1_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormFabrics>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrdersToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOrders>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void StoragesToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStorages>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void документСоСправочникамиToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormDirectoryReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void отчётПоЗаказамToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOrderReports>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void отчётПоСкладуToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStorageReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,141 @@
namespace Atelier.Forms
{
partial class FormClient
{
/// <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()
{
textBoxFirstName = new TextBox();
labelFirstName = new Label();
textBoxLastName = new TextBox();
labelLastName = new Label();
labelContactInf = new Label();
textBoxContactInf = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(171, 42);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(235, 27);
textBoxFirstName.TabIndex = 0;
//
// labelFirstName
//
labelFirstName.AutoSize = true;
labelFirstName.Location = new Point(12, 49);
labelFirstName.Name = "labelFirstName";
labelFirstName.Size = new Size(101, 20);
labelFirstName.TabIndex = 1;
labelFirstName.Text = "Имя клиента:";
//
// textBoxLastName
//
textBoxLastName.Location = new Point(171, 104);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(235, 27);
textBoxLastName.TabIndex = 2;
//
// labelLastName
//
labelLastName.AutoSize = true;
labelLastName.Location = new Point(12, 111);
labelLastName.Name = "labelLastName";
labelLastName.Size = new Size(135, 20);
labelLastName.TabIndex = 3;
labelLastName.Text = "Фамилия клиента:";
//
// labelContactInf
//
labelContactInf.AutoSize = true;
labelContactInf.Location = new Point(114, 178);
labelContactInf.Name = "labelContactInf";
labelContactInf.Size = new Size(186, 20);
labelContactInf.TabIndex = 4;
labelContactInf.Text = "Контактная информация:";
//
// textBoxContactInf
//
textBoxContactInf.Location = new Point(59, 221);
textBoxContactInf.Name = "textBoxContactInf";
textBoxContactInf.Size = new Size(306, 27);
textBoxContactInf.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(95, 282);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(223, 282);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(444, 348);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxContactInf);
Controls.Add(labelContactInf);
Controls.Add(labelLastName);
Controls.Add(textBoxLastName);
Controls.Add(labelFirstName);
Controls.Add(textBoxFirstName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиент";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxFirstName;
private Label labelFirstName;
private TextBox textBoxLastName;
private Label labelLastName;
private Label labelContactInf;
private TextBox textBoxContactInf;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,79 @@
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 Atelier.Forms
{
public partial class FormClient : Form
{
private readonly IClientRepository _clientRepository;
private int? _clientId;
public int Id
{
set
{
try
{
var client =
_clientRepository.ReadClientById(value);
if (client == null)
{
throw new
InvalidDataException(nameof(client));
}
textBoxFirstName.Text = client.FirstName;
textBoxLastName.Text = client.LastName;
textBoxContactInf.Text = client.ContactInformation;
_clientId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepository clientRepository)
{
InitializeComponent();
_clientRepository = clientRepository ??
throw new
ArgumentNullException(nameof(clientRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) || string.IsNullOrWhiteSpace(textBoxContactInf.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_clientId.HasValue)
{
_clientRepository.UpdateClient(CreateClient(_clientId.Value));
}
else
{
_clientRepository.CreateClient(CreateClient(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Client CreateClient(int id) => Client.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, textBoxContactInf.Text);
}
}

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,126 @@
namespace Atelier.Forms
{
partial class FormClients
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormClients));
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(1001, 604);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1001, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 604);
panel1.TabIndex = 1;
//
// buttonDel
//
buttonDel.Image = (Image)resources.GetObject("buttonDel.Image");
buttonDel.Location = new Point(14, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(107, 88);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.Image = (Image)resources.GetObject("buttonUpd.Image");
buttonUpd.Location = new Point(14, 107);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(107, 91);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.Image = (Image)resources.GetObject("buttonAdd.Image");
buttonAdd.Location = new Point(14, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 89);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 604);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormClients";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиенты";
Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,125 @@
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;
using Atelier.Forms;
namespace Atelier.Forms
{
public partial class FormClients : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepository _clientRepository;
public FormClients(IUnityContainer container, IClientRepository clientRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_clientRepository = clientRepository ??
throw new
ArgumentNullException(nameof(clientRepository));
}
private void FormClients_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClient>().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<FormClient>();
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
{
_clientRepository.DeleteClient(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView1.DataSource = _clientRepository.ReadClients();
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["FullName"].Visible = false;
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,226 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DAAACwwBP0AiyAAABNVJREFUeF7tnL9uXHUQhZ2OKk8ANRJ5AHipNInXgCFKyuD1H/ECZJ11Eh7AViCP
ELeJaCgQHV2gIIULc0cZ0KfRaDTaO2Ph63ukrzg+oxnOzxvT7dasWbNmzbpafX93fXtve/XTcnt1sVwc
X47iw46XslPXT1/LxerbvcXqxcOHTz7SH20s2TE84o9728cP9EfT1/B4b5f3n36udrQOdp58sbc4/kXt
tPV4Z3VnKPv75dblLf3RaMmu4Zfy2/L++jP90XQ1/L16NPz921dbpuHPwoHsVjtdVf/z/Vf/63/G+/d+
+ORo99nL/Z31+//+7zdRpOPQ9efvFutPtf44yeMdfn3y7vTF+cWb8z8uf33716SRjmdD1/0vn/4p3fUZ
Npd88mShd2zKnD4/vzjaPTnTZ9hcB8NH+iZ88izSefgUvtdn2Fzyd8E7cBOQ7voMm2t+wJGaH3CkZMlN
Rp+hTrLU+21NgZYHs5ofcKTmBxyp+QFHyj5g9KDZx97kl1Kx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8o
PYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3Z
J+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZ
eK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U
7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpI
do5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0
JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWaf
vKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bi
tWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx
22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZ
OVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKT
KCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3y
jtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nX
mn3apOx1YX7AkVzJA8q3m03xq6DevJavelr/rTX7dLh78kq+mMv7j7jOnD5/fXH0zbNTrdkn+V49+Wo4
ecQpfBLlkyePd/jV+t3jnfXHWrNXH76Q8eRMvt1M/m5cZ6SDfPKu7PFmzZo1azLa2voHHNxQxvmbf3YA
AAAASUVORK5CYII=
</value>
</data>
<data name="buttonUpd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DAAACwwBP0AiyAAAB1ZJREFUeF7tmllPG1cUx+nePrXqB6j60OdK/QRVK/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D+9cB0+R/KMF/V6fkvAUWANuU9IPlqcNofXq9HQwyLC/SoXfUO2T5RF1PCH/aktij5aX
J8cMgfW60jXAQNsrnAyeWl5qfekYjnxjysBTlGS732OjhnLs9cHKta1NWJ4cZe+XfqKWd33kUw6e4qhZ
/FQxQDVhanMTqFmiewZ7tnzTwz5rkhpSDp6CnqdrDdCa8PfKNNybi7DOcDZ8CSL9Q6xDpIapco/cBzAh
PC6lV/m/TK3ANviIFn67ws87UxaeAiH8eigmk/Qv7Q64riP4+iz18VgsRQS2YnOzD499e+S7mg/5v0nd
sFvEzxGmhZ74oEwI+FlxjvR+0v3EPBOZyMSziays/wB+daIEvDXupgAAAABJRU5ErkJggg==
</value>
</data>
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DAAACwwBP0AiyAAACDBJREFUeF7tXFlTFFcU9inbQ5JfkOU9eyqVPGT7B6kk5UsEZmkYfMFUCpnunkE2
Uy6pCotCEKa3ARQliklYRWMEyvigErSMmriRlMlDSpGSmaFUoHO/yaUmNncchpnunhnmq/qqKObc7VR3
n3PPPeeuyyOPtQtPW/VTjgD/YaFUsdGpCM3Fmu8k4ZRbFf5xKnzYEfDOg/gb/8NvkIFsUcBbWihXfIA+
aHdrA4527ztEKVtLgv5zTtl7b9P+upnagYZw46isq6f36z0Xvtd7L/Xr/VeG9eEbx6LE3/gffoMMZGtI
m03ddTPogyh10inxdQVy+dt0mNxCQXv5i0WKt5Y8RX9v7Npyd/tIy/3gxAF98NqIPjL1Y0pEH9rZA/o2
0mdpZ+Usp4p/OWS+xqHyL9DhsxeOgPAmWdCwWxUjW4ea5vadP8RUQjq579whvW5w15xbFubcqn9wg1Lx
Bp1O9gCKc6niaLHqDzWNygvpeNKSJcYkr/piseaPcKpvrFDiX6fTy1w41M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Hh+zdYrt1NQuot3VKQjV5MieQZ4Las+q+hlDjqBQtYkECY7yLuPEb8vMa
Tsg62iDRB32ggtIl81VJXQyRC0CSDraGjkCFBzl3RKnjXNB3HSm0yNleugqeuEkh/A+/IbkRsmiD3UPc
RJ888lgDWLfuXyHjrOzkVJ7gAAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -0,0 +1,100 @@
namespace Atelier.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()
{
buttonBuild = new Button();
checkBoxClients = new CheckBox();
checkBoxFabrics = new CheckBox();
checkBoxModels = new CheckBox();
SuspendLayout();
//
// buttonBuild
//
buttonBuild.Location = new Point(205, 95);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(133, 36);
buttonBuild.TabIndex = 0;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// checkBoxClients
//
checkBoxClients.AutoSize = true;
checkBoxClients.Location = new Point(38, 38);
checkBoxClients.Name = "checkBoxClients";
checkBoxClients.Size = new Size(91, 24);
checkBoxClients.TabIndex = 1;
checkBoxClients.Text = "Клиенты";
checkBoxClients.UseVisualStyleBackColor = true;
//
// checkBoxFabrics
//
checkBoxFabrics.AutoSize = true;
checkBoxFabrics.Location = new Point(38, 102);
checkBoxFabrics.Name = "checkBoxFabrics";
checkBoxFabrics.Size = new Size(72, 24);
checkBoxFabrics.TabIndex = 2;
checkBoxFabrics.Text = "Ткани";
checkBoxFabrics.UseVisualStyleBackColor = true;
//
// checkBoxModels
//
checkBoxModels.AutoSize = true;
checkBoxModels.Location = new Point(38, 169);
checkBoxModels.Name = "checkBoxModels";
checkBoxModels.Size = new Size(86, 24);
checkBoxModels.TabIndex = 3;
checkBoxModels.Text = "Модели";
checkBoxModels.UseVisualStyleBackColor = true;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(383, 225);
Controls.Add(checkBoxModels);
Controls.Add(checkBoxFabrics);
Controls.Add(checkBoxClients);
Controls.Add(buttonBuild);
Name = "FormDirectoryReport";
StartPosition = FormStartPosition.CenterParent;
Text = "Выгрузка справочников";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonBuild;
private CheckBox checkBoxClients;
private CheckBox checkBoxFabrics;
private CheckBox checkBoxModels;
}
}

View File

@ -0,0 +1,61 @@
using Atelier.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 Atelier.Forms;
public partial class FormDirectoryReport : Form
{
private readonly IUnityContainer _container;
public FormDirectoryReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (!checkBoxClients.Checked && !checkBoxFabrics.Checked && !checkBoxModels.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, checkBoxClients.Checked, checkBoxFabrics.Checked,
checkBoxModels.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);
}
}
}

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,148 @@
namespace Atelier.Forms
{
partial class FormFabric
{
/// <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()
{
labelFabric = new Label();
labelColor = new Label();
labelMetrage = new Label();
checkedListBoxColor = new CheckedListBox();
comboBoxFabric = new ComboBox();
numericUpDownMetrage = new NumericUpDown();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownMetrage).BeginInit();
SuspendLayout();
//
// labelFabric
//
labelFabric.AutoSize = true;
labelFabric.Location = new Point(60, 33);
labelFabric.Name = "labelFabric";
labelFabric.Size = new Size(52, 20);
labelFabric.TabIndex = 0;
labelFabric.Text = "Ткань:";
//
// labelColor
//
labelColor.AutoSize = true;
labelColor.Location = new Point(67, 77);
labelColor.Name = "labelColor";
labelColor.Size = new Size(45, 20);
labelColor.TabIndex = 1;
labelColor.Text = "Цвет:";
//
// labelMetrage
//
labelMetrage.AutoSize = true;
labelMetrage.Location = new Point(55, 229);
labelMetrage.Name = "labelMetrage";
labelMetrage.Size = new Size(67, 20);
labelMetrage.TabIndex = 2;
labelMetrage.Text = "Метраж:";
//
// checkedListBoxColor
//
checkedListBoxColor.FormattingEnabled = true;
checkedListBoxColor.Location = new Point(146, 77);
checkedListBoxColor.Name = "checkedListBoxColor";
checkedListBoxColor.Size = new Size(150, 114);
checkedListBoxColor.TabIndex = 3;
//
// comboBoxFabric
//
comboBoxFabric.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxFabric.FormattingEnabled = true;
comboBoxFabric.Location = new Point(145, 25);
comboBoxFabric.Name = "comboBoxFabric";
comboBoxFabric.Size = new Size(151, 28);
comboBoxFabric.TabIndex = 4;
//
// numericUpDownMetrage
//
numericUpDownMetrage.DecimalPlaces = 2;
numericUpDownMetrage.Location = new Point(146, 229);
numericUpDownMetrage.Minimum = new decimal(new int[] { 5, 0, 0, 65536 });
numericUpDownMetrage.Name = "numericUpDownMetrage";
numericUpDownMetrage.Size = new Size(150, 27);
numericUpDownMetrage.TabIndex = 5;
numericUpDownMetrage.Value = new decimal(new int[] { 5, 0, 0, 65536 });
//
// buttonSave
//
buttonSave.Location = new Point(67, 296);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(215, 296);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormFabric
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(367, 352);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownMetrage);
Controls.Add(comboBoxFabric);
Controls.Add(checkedListBoxColor);
Controls.Add(labelMetrage);
Controls.Add(labelColor);
Controls.Add(labelFabric);
Name = "FormFabric";
StartPosition = FormStartPosition.CenterParent;
Text = "Ткань";
((System.ComponentModel.ISupportInitialize)numericUpDownMetrage).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelFabric;
private Label labelColor;
private Label labelMetrage;
private CheckedListBox checkedListBoxColor;
private ComboBox comboBoxFabric;
private NumericUpDown numericUpDownMetrage;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,105 @@
using Microsoft.VisualBasic.FileIO;
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 Atelier.Forms
{
public partial class FormFabric : Form
{
private readonly IFabricRepository _fabricRepository;
private int? _fabricId;
public FormFabric(IFabricRepository fabricRepository)
{
InitializeComponent();
_fabricRepository = fabricRepository ?? throw new ArgumentNullException(nameof(fabricRepository));
comboBoxFabric.DataSource = Enum.GetValues(typeof(FabricType));
// Инициализация CheckedListBox
foreach (Color elem in Enum.GetValues(typeof(Color)))
{
checkedListBoxColor.Items.Add(elem);
}
// Отладочный вывод
foreach (var item in checkedListBoxColor.Items)
{
Console.WriteLine(item);
}
}
public int Id
{
set
{
try
{
var fabric = _fabricRepository.ReadFabricById(value);
if (fabric == null)
{
throw new InvalidDataException(nameof(fabric));
}
comboBoxFabric.SelectedItem = fabric.FabricType;
foreach (Color elem in Enum.GetValues(typeof(Color)))
{
if ((elem & fabric.Color) != 0)
{
checkedListBoxColor.SetItemChecked(checkedListBoxColor.Items.IndexOf(elem), true);
}
}
numericUpDownMetrage.Value = (decimal)fabric.Metrage;
_fabricId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxFabric.SelectedIndex < 0.50 || checkedListBoxColor.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_fabricId.HasValue)
{
_fabricRepository.UpdateFabric(CreateFabric(_fabricId.Value));
}
else
{
_fabricRepository.CreateFabric(CreateFabric(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Fabric CreateFabric(int id)
{
Color color = Color.None;
foreach (var elem in checkedListBoxColor.CheckedItems)
{
color |= (Color)elem;
}
return Fabric.CreateEntity(id, (FabricType)comboBoxFabric.SelectedItem!, color, Convert.ToDouble(numericUpDownMetrage.Value)); ;
}
}
}

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,126 @@
namespace Atelier.Forms
{
partial class FormFabrics
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormFabrics));
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(1001, 604);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1001, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 604);
panel1.TabIndex = 1;
//
// buttonDel
//
buttonDel.Image = (Image)resources.GetObject("buttonDel.Image");
buttonDel.Location = new Point(14, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(107, 88);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.Image = (Image)resources.GetObject("buttonUpd.Image");
buttonUpd.Location = new Point(14, 107);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(107, 91);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.Image = (Image)resources.GetObject("buttonAdd.Image");
buttonAdd.Location = new Point(14, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 89);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormFabrics
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 604);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormFabrics";
StartPosition = FormStartPosition.CenterParent;
Text = "Ткани";
Load += FormFabrics_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,114 @@
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 Atelier.Forms
{
public partial class FormFabrics : Form
{
private readonly IUnityContainer _container;
private readonly IFabricRepository _fabricRepository;
public FormFabrics(IUnityContainer container, IFabricRepository fabricRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_fabricRepository = fabricRepository ??
throw new
ArgumentNullException(nameof(fabricRepository));
}
private void FormFabrics_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormFabric>().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<FormFabric>();
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
{
_fabricRepository.DeleteFabric(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView1.DataSource = _fabricRepository.ReadFabrics();
dataGridView1.Columns["Id"].Visible = false;
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,226 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAABNVJREFUeF7tnL9uXHUQhZ2OKk8ANRJ5AHipNInXgCFKyuD1H/ECZJ11Eh7AViCP
ELeJaCgQHV2gIIULc0cZ0KfRaDTaO2Ph63ukrzg+oxnOzxvT7dasWbNmzbpafX93fXtve/XTcnt1sVwc
X47iw46XslPXT1/LxerbvcXqxcOHTz7SH20s2TE84o9728cP9EfT1/B4b5f3n36udrQOdp58sbc4/kXt
tPV4Z3VnKPv75dblLf3RaMmu4Zfy2/L++jP90XQ1/L16NPz921dbpuHPwoHsVjtdVf/z/Vf/63/G+/d+
+ORo99nL/Z31+//+7zdRpOPQ9efvFutPtf44yeMdfn3y7vTF+cWb8z8uf33716SRjmdD1/0vn/4p3fUZ
Npd88mShd2zKnD4/vzjaPTnTZ9hcB8NH+iZ88izSefgUvtdn2Fzyd8E7cBOQ7voMm2t+wJGaH3CkZMlN
Rp+hTrLU+21NgZYHs5ofcKTmBxyp+QFHyj5g9KDZx97kl1Kx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8o
PYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3Z
J+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZ
eK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U
7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpI
do5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0
JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWaf
vKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bi
tWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx
22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZ
OVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKT
KCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3y
jtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nX
mn3apOx1YX7AkVzJA8q3m03xq6DevJavelr/rTX7dLh78kq+mMv7j7jOnD5/fXH0zbNTrdkn+V49+Wo4
ecQpfBLlkyePd/jV+t3jnfXHWrNXH76Q8eRMvt1M/m5cZ6SDfPKu7PFmzZo1azLa2voHHNxQxvmbf3YA
AAAASUVORK5CYII=
</value>
</data>
<data name="buttonUpd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
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c6JgjH+H7o+HnWcFTq31zUo68EvQ8jRK9FuPZ
XZevUwYh4Uxw7JG/kEwLeAqsyr2U7M0rlw0N+GN+EjrcHeD5uQGKsUdQzDCq9vPdtOaVaZ8kT2m3Ckx0
nBK+MzNuaIBWD+9cB0+R/KMF/V6fkvAUWANuU9IPlqcNofXq9HQwyLC/SoXfUO2T5RF1PCH/aktij5aX
J8cMgfW60jXAQNsrnAyeWl5qfekYjnxjysBTlGS732OjhnLs9cHKta1NWJ4cZe+XfqKWd33kUw6e4qhZ
/FQxQDVhanMTqFmiewZ7tnzTwz5rkhpSDp6CnqdrDdCa8PfKNNybi7DOcDZ8CSL9Q6xDpIapco/cBzAh
PC6lV/m/TK3ANviIFn67ws87UxaeAiH8eigmk/Qv7Q64riP4+iz18VgsRQS2YnOzD499e+S7mg/5v0nd
sFvEzxGmhZ74oEwI+FlxjvR+0v3EPBOZyMSziays/wB+daIEvDXupgAAAABJRU5ErkJggg==
</value>
</data>
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAACDBJREFUeF7tXFlTFFcU9inbQ5JfkOU9eyqVPGT7B6kk5UsEZmkYfMFUCpnunkE2
Uy6pCotCEKa3ARQliklYRWMEyvigErSMmriRlMlDSpGSmaFUoHO/yaUmNncchpnunhnmq/qqKObc7VR3
n3PPPeeuyyOPtQtPW/VTjgD/YaFUsdGpCM3Fmu8k4ZRbFf5xKnzYEfDOg/gb/8NvkIFsUcBbWihXfIA+
aHdrA4527ztEKVtLgv5zTtl7b9P+upnagYZw46isq6f36z0Xvtd7L/Xr/VeG9eEbx6LE3/gffoMMZGtI
m03ddTPogyh10inxdQVy+dt0mNxCQXv5i0WKt5Y8RX9v7Npyd/tIy/3gxAF98NqIPjL1Y0pEH9rZA/o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EpBBVwe4i5b2tFUBAlnwbj3OqGIKRQUictTgz
iTHrRwPznOrDFaDHLb+hLR2AIos13wDOE1Bva/b1KbCsOD3DARDGJIrrM90xtgKo9HYE+CocmaJkdNuR
5vs45U/Hk4k+0BcOvXFui6NHh+zdYrt1NQuot3VKQjV5MieQZ4Las+q+hlDjqBQtYkECY7yLuPEb8vMa
Tsg62iDRB32ggtIl81VJXQyRC0CSDraGjkCFBzl3RKnjXNB3HSm0yNleugqeuEkh/A+/IbkRsmiD3UPc
RJ888lgDWLfuXyHjrOzkVJ7gAAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -0,0 +1,182 @@
namespace Atelier.Forms
{
partial class FormModel
{
/// <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()
{
labelModel = new Label();
labelPrice = new Label();
comboBoxModel = new ComboBox();
numericUpDownPrice = new NumericUpDown();
buttonSave = new Button();
buttonCancel = new Button();
groupBox1 = new GroupBox();
dataGridView1 = new DataGridView();
ColumnFabric = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// labelModel
//
labelModel.AutoSize = true;
labelModel.Location = new Point(30, 52);
labelModel.Name = "labelModel";
labelModel.Size = new Size(66, 20);
labelModel.TabIndex = 0;
labelModel.Text = "Модель:";
//
// labelPrice
//
labelPrice.AutoSize = true;
labelPrice.Location = new Point(48, 118);
labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(48, 20);
labelPrice.TabIndex = 1;
labelPrice.Text = "Цена:";
//
// comboBoxModel
//
comboBoxModel.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxModel.FormattingEnabled = true;
comboBoxModel.Location = new Point(119, 52);
comboBoxModel.Name = "comboBoxModel";
comboBoxModel.Size = new Size(151, 28);
comboBoxModel.TabIndex = 2;
//
// numericUpDownPrice
//
numericUpDownPrice.DecimalPlaces = 2;
numericUpDownPrice.Location = new Point(120, 118);
numericUpDownPrice.Maximum = new decimal(5000); ;
numericUpDownPrice.Minimum = new decimal(500);
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(150, 27);
numericUpDownPrice.TabIndex = 3;
numericUpDownPrice.Value = new decimal(500);
//
// buttonSave
//
buttonSave.Location = new Point(48, 206);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(176, 206);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// groupBox1
//
groupBox1.Controls.Add(dataGridView1);
groupBox1.Location = new Point(323, 23);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(251, 227);
groupBox1.TabIndex = 6;
groupBox1.TabStop = false;
groupBox1.Text = "Ткани";
//
// dataGridView1
//
dataGridView1.AllowUserToOrderColumns = true;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnFabric, ColumnCount });
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(3, 23);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new Size(245, 201);
dataGridView1.TabIndex = 0;
//
// ColumnFabric
//
ColumnFabric.HeaderText = "Ткань";
ColumnFabric.MinimumWidth = 6;
ColumnFabric.Name = "ColumnFabric";
ColumnFabric.Resizable = DataGridViewTriState.True;
ColumnFabric.SortMode = DataGridViewColumnSortMode.Automatic;
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
ColumnCount.Resizable = DataGridViewTriState.True;
ColumnCount.SortMode = DataGridViewColumnSortMode.NotSortable;
//
// FormModel
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(619, 284);
Controls.Add(groupBox1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownPrice);
Controls.Add(comboBoxModel);
Controls.Add(labelPrice);
Controls.Add(labelModel);
Name = "FormModel";
StartPosition = FormStartPosition.CenterParent;
Text = "Модель";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelModel;
private Label labelPrice;
private ComboBox comboBoxModel;
private NumericUpDown numericUpDownPrice;
private Button buttonSave;
private Button buttonCancel;
private GroupBox groupBox1;
private DataGridView dataGridView1;
private DataGridViewComboBoxColumn ColumnFabric;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,106 @@
using Microsoft.VisualBasic.FileIO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Atelier.Forms
{
public partial class FormModel : Form
{
private readonly IModelRepository _modelRepository;
private int? _modelId;
public int Id
{
set
{
try
{
var model = _modelRepository.ReadModelById(value);
if (model == null)
{
throw new
InvalidDataException(nameof(model));
}
comboBoxModel.SelectedItem = model.ModelType;
numericUpDownPrice.Value = (decimal)model.Price;
foreach (var fm in model.FabricModel)
{
dataGridView1.Rows.Add(new object[] { fm.FabricId, fm.Count });
}
_modelId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormModel(IModelRepository modelRepository, IFabricRepository fabricRepository)
{
InitializeComponent();
_modelRepository = modelRepository ??
throw new ArgumentNullException(nameof(modelRepository));
comboBoxModel.DataSource = Enum.GetValues(typeof(ModelType));
ColumnFabric.DataSource = fabricRepository.ReadFabrics();
ColumnFabric.DisplayMember = "FabricType";
ColumnFabric.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (numericUpDownPrice.Value < 500 || dataGridView1.RowCount < 1 || comboBoxModel.SelectedIndex < 1 )
{
throw new Exception("Имеются незаполненные поля");
}
if (_modelId.HasValue)
{
_modelRepository.UpdateModel(CreateModel(_modelId.Value));
}
else
{
_modelRepository.CreateModel(CreateModel(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Model CreateModel(int id)
{
List<FabricModel> fabricModels = new List<FabricModel>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ColumnFabric"].Value == null || row.Cells["ColumnCount"].Value == null)
{
continue;
}
int fabricId = Convert.ToInt32(row.Cells["ColumnFabric"].Value);
int count = Convert.ToInt32(row.Cells["ColumnCount"].Value);
fabricModels.Add(FabricModel.CreateElement(fabricId, 0, count));
}
return Model.CreateEntity(id, (ModelType)comboBoxModel.SelectedItem!, Convert.ToDouble(numericUpDownPrice.Value), fabricModels);
}
}
}

View File

@ -0,0 +1,126 @@
<?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>
<metadata name="ColumnFabric.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>

View File

@ -0,0 +1,128 @@
namespace Atelier.Forms
{
partial class FormModels
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormModels));
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(1001, 604);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1001, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 604);
panel1.TabIndex = 1;
//
// buttonDel
//
buttonDel.Image = (Image)resources.GetObject("buttonDel.Image");
buttonDel.Location = new Point(14, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(107, 88);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.Image = (Image)resources.GetObject("buttonUpd.Image");
buttonUpd.Location = new Point(14, 107);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(107, 91);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.Image = (Image)resources.GetObject("buttonAdd.Image");
buttonAdd.Location = new Point(14, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 89);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormModels
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 604);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormModels";
StartPosition = FormStartPosition.CenterParent;
Text = "Модели";
Load += FormModels_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

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 Unity;
namespace Atelier.Forms
{
public partial class FormModels : Form
{
private readonly IUnityContainer _container;
private readonly IModelRepository _modelRepository;
public FormModels(IUnityContainer container, IModelRepository modelRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_modelRepository = modelRepository ??
throw new
ArgumentNullException(nameof(modelRepository));
}
private void FormModels_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormModel>().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<FormModel>();
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
{
_modelRepository.DeleteModel(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView1.DataSource = _modelRepository.ReadModels();
dataGridView1.Columns["Id"].Visible = false;
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,226 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAABNVJREFUeF7tnL9uXHUQhZ2OKk8ANRJ5AHipNInXgCFKyuD1H/ECZJ11Eh7AViCP
ELeJaCgQHV2gIIULc0cZ0KfRaDTaO2Ph63ukrzg+oxnOzxvT7dasWbNmzbpafX93fXtve/XTcnt1sVwc
X47iw46XslPXT1/LxerbvcXqxcOHTz7SH20s2TE84o9728cP9EfT1/B4b5f3n36udrQOdp58sbc4/kXt
tPV4Z3VnKPv75dblLf3RaMmu4Zfy2/L++jP90XQ1/L16NPz921dbpuHPwoHsVjtdVf/z/Vf/63/G+/d+
+ORo99nL/Z31+//+7zdRpOPQ9efvFutPtf44yeMdfn3y7vTF+cWb8z8uf33716SRjmdD1/0vn/4p3fUZ
Npd88mShd2zKnD4/vzjaPTnTZ9hcB8NH+iZ88izSefgUvtdn2Fzyd8E7cBOQ7voMm2t+wJGaH3CkZMlN
Rp+hTrLU+21NgZYHs5ofcKTmBxyp+QFHyj5g9KDZx97kl1Kx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8o
PYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3Z
J+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum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ing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAAB1ZJREFUeF7tmllPG1cUx+nePrXqB6j60OdK/QRVK/Wx6lPfKlVVpUiNbZakJKSp
SpSoNE1sszsZsGfwQqEGQmIWB0zYkhAgDklYTIBAAgRQtlZN1QRSKafn3LkzDOMxmCiNl/hIfwnP2Mz5
/e+9557xOCsTmchESobV4v7IahJzrGapwGap+QSy4CV+Kr3D/6X/FZtZcqBAK6tJCh3eIbzN35aeIcOL
HgIusUgQ3OWEblSFWXzCjRhMWxO08KWoifxquF8gMC3sqYJqiyjPBpMYtuVVv8s/lh5B8DjFvUbwRiZg
XbiU8ibYTK5v7GapzWoWf0DVEVgZKpJfFQWvaGFvFVRl85mQysvBZpIOcAhVsUZer5SfCSo8FrnfhD4o
zvM+ptdVFtfMXQNgI2lnAm6VQykzE7QjXy+eg/5LK3C6c1o1QbS4xp7WhOIc6R1+meQM/bRv8FxgBjAT
QusmSNniRNqZoIcXDp2E3sFF1YBnZQJuoz2FhYUv88smR2Bi+Sw5XPOSNQjuko6N8GEunQkui2t8OyaU
WcRH9Dn7TvELfunER2Gh/3WruYYBNdUOr0NzdfXfgMr9fqguCqjHmAm5ak2IxGtCMLd6iRltlo7yyyc+
aDriHn+PEvNWhNSRJp05dxMq9tWzqes63KoeV03QzIQ7BsB6NeQ6J+n9uDUW8csnPugODlvXZkqM5NOY
cKLuIjsmHGyGnqGN9YCZ0Dml3R0im5mAzdMTvM4qu47F9TG/fGKD4LEyl1JSJTk1TFoTei8uQ6D5KvQO
L6nQ3efnobF2CLoHZEPiMYE6R7tZXKP3UDvNL5/Y0MNPDQzD9HAYSnLdzARvWSf0hZdVcAXe8WMjO08m
KMe1fYIz2zWpNWESO8dikySPvElsLbWUvsFTSFwYwT/+c46JTCiNYQIVQjpO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Dh
NdqS4kGlUeDICJTk5dD5KANItb82MYhwoA4eXG9i8LQc6JgjH+H7o+HnWcFTq31zUo68EvQ8jRK9FuPZ
XZevUwYh4Uxw7JG/kEwLeAqsyr2U7M0rlw0N+GN+EjrcHeD5uQGKsUdQzDCq9vPdtOaVaZ8kT2m3Ckx0
nBK+MzNuaIBWD+9cB0+R/KMF/V6fkvAUWANuU9IPlqcNofXq9HQwyLC/SoXfUO2T5RF1PCH/aktij5aX
J8cMgfW60jXAQNsrnAyeWl5qfekYjnxjysBTlGS732OjhnLs9cHKta1NWJ4cZe+XfqKWd33kUw6e4qhZ
/FQxQDVhanMTqFmiewZ7tnzTwz5rkhpSDp6CnqdrDdCa8PfKNNybi7DOcDZ8CSL9Q6xDpIapco/cBzAh
PC6lV/m/TK3ANviIFn67ws87UxaeAiH8eigmk/Qv7Q64riP4+iz18VgsRQS2YnOzD499e+S7mg/5v0nd
sFvEzxGmhZ74oEwI+FlxjvR+0v3EPBOZyMSziays/wB+daIEvDXupgAAAABJRU5ErkJggg==
</value>
</data>
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAACDBJREFUeF7tXFlTFFcU9inbQ5JfkOU9eyqVPGT7B6kk5UsEZmkYfMFUCpnunkE2
Uy6pCotCEKa3ARQliklYRWMEyvigErSMmriRlMlDSpGSmaFUoHO/yaUmNncchpnunhnmq/qqKObc7VR3
n3PPPeeuyyOPtQtPW/VTjgD/YaFUsdGpCM3Fmu8k4ZRbFf5xKnzYEfDOg/gb/8NvkIFsUcBbWihXfIA+
aHdrA4527ztEKVtLgv5zTtl7b9P+upnagYZw46isq6f36z0Xvtd7L/Xr/VeG9eEbx6LE3/gffoMMZGtI
m03ddTPogyh10inxdQVy+dt0mNxCQXv5i0WKt5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BQ1VcfIa7YdNp2GOkG9s4uTWxFFAeV3nYWbC8RMU2EpBBVwe4i5b2tFUBAlnwbj3OqGIKRQUictTgz
iTHrRwPznOrDFaDHLb+hLR2AIos13wDOE1Bva/b1KbCsOD3DARDGJIrrM90xtgKo9HYE+CocmaJkdNuR
5vs45U/Hk4k+0BcOvXFui6NHh+zdYrt1NQuot3VKQjV5MieQZ4Las+q+hlDjqBQtYkECY7yLuPEb8vMa
Tsg62iDRB32ggtIl81VJXQyRC0CSDraGjkCFBzl3RKnjXNB3HSm0yNleugqeuEkh/A+/IbkRsmiD3UPc
RJ888lgDWLfuXyHjrOzkVJ7gAAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -0,0 +1,183 @@
namespace Atelier.Forms
{
partial class FormOrder
{
/// <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()
{
dateTimePicker1 = new DateTimePicker();
groupBox1 = new GroupBox();
dataGridView1 = new DataGridView();
ColumnModel = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
labelClient = new Label();
comboBoxClient = new ComboBox();
comboBoxStatus = new ComboBox();
labelStatus = new Label();
buttonSave = new Button();
buttonCancel = new Button();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dateTimePicker1
//
dateTimePicker1.Enabled = false;
dateTimePicker1.Location = new Point(20, 12);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(250, 27);
dateTimePicker1.TabIndex = 0;
//
// groupBox1
//
groupBox1.Controls.Add(dataGridView1);
groupBox1.Location = new Point(302, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(223, 176);
groupBox1.TabIndex = 1;
groupBox1.TabStop = false;
groupBox1.Text = "Модели";
//
// dataGridView1
//
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnModel, ColumnCount });
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(3, 23);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new Size(217, 150);
dataGridView1.TabIndex = 0;
//
// ColumnModel
//
ColumnModel.HeaderText = "Модель";
ColumnModel.MinimumWidth = 6;
ColumnModel.Name = "ColumnModel";
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(20, 79);
labelClient.Name = "labelClient";
labelClient.Size = new Size(61, 20);
labelClient.TabIndex = 2;
labelClient.Text = "Клиент:";
//
// comboBoxClient
//
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(95, 79);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(151, 28);
comboBoxClient.TabIndex = 3;
//
// comboBoxStatus
//
comboBoxStatus.FormattingEnabled = true;
comboBoxStatus.Location = new Point(95, 139);
comboBoxStatus.Name = "comboBoxStatus";
comboBoxStatus.Size = new Size(151, 28);
comboBoxStatus.TabIndex = 6;
//
// labelStatus
//
labelStatus.AutoSize = true;
labelStatus.Location = new Point(26, 142);
labelStatus.Name = "labelStatus";
labelStatus.Size = new Size(55, 20);
labelStatus.TabIndex = 7;
labelStatus.Text = "Статус:";
//
// buttonSave
//
buttonSave.Location = new Point(152, 231);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(302, 231);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(556, 298);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelStatus);
Controls.Add(comboBoxStatus);
Controls.Add(comboBoxClient);
Controls.Add(labelClient);
Controls.Add(groupBox1);
Controls.Add(dateTimePicker1);
Name = "FormOrder";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказ";
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePicker1;
private GroupBox groupBox1;
private DataGridView dataGridView1;
private DataGridViewComboBoxColumn ColumnModel;
private DataGridViewTextBoxColumn ColumnCount;
private Label labelClient;
private ComboBox comboBoxClient;
private ComboBox comboBoxStatus;
private Label labelStatus;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,72 @@
using Microsoft.VisualBasic.FileIO;
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 Atelier.Forms
{
public partial class FormOrder : Form
{
private readonly IOrderRepository _orderRepository;
public FormOrder(IOrderRepository orderRepository, IModelRepository modelRepository, IClientRepository clientRepository)
{
InitializeComponent();
_orderRepository = orderRepository ??
throw new
ArgumentNullException(nameof(orderRepository));
comboBoxClient.DataSource = clientRepository.ReadClients();
comboBoxClient.DisplayMember = "FullName";
comboBoxClient.ValueMember = "Id";
comboBoxStatus.DataSource = orderRepository.ReadOrders();
comboBoxStatus.DataSource = Enum.GetValues(typeof(Status));
ColumnModel.DataSource = modelRepository.ReadModels();
ColumnModel.DisplayMember = "ModelType";
ColumnModel.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridView1.RowCount < 1 || comboBoxClient.SelectedIndex < 0 || comboBoxStatus.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_orderRepository.CreateOrder(Order.CreateOperation(0, dateTimePicker1.Value, (Status)comboBoxStatus.SelectedValue,
(int)comboBoxClient.SelectedValue, CreateListModelOrderFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) =>
Close();
private List<ModelOrder>
CreateListModelOrderFromDataGrid()
{
var list = new List<ModelOrder>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ColumnModel"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(ModelOrder.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnModel"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
}
}

View File

@ -0,0 +1,132 @@
<?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>
<metadata name="ColumnModel.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>
<metadata name="ColumnModel.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>

View File

@ -0,0 +1,163 @@
namespace Atelier.Forms
{
partial class FormOrderReports
{
/// <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()
{
dateTimePickerStart = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker();
comboBoxModel = new ComboBox();
textBoxFile = new TextBox();
labelFile = new Label();
labelModel = new Label();
labelStart = new Label();
labelEnd = new Label();
buttonFile = new Button();
buttonBuild = new Button();
SuspendLayout();
//
// dateTimePickerStart
//
dateTimePickerStart.Location = new Point(202, 201);
dateTimePickerStart.Name = "dateTimePickerStart";
dateTimePickerStart.Size = new Size(250, 27);
dateTimePickerStart.TabIndex = 0;
//
// dateTimePickerEnd
//
dateTimePickerEnd.Location = new Point(202, 276);
dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerEnd.Size = new Size(250, 27);
dateTimePickerEnd.TabIndex = 1;
//
// comboBoxModel
//
comboBoxModel.FormattingEnabled = true;
comboBoxModel.Location = new Point(202, 129);
comboBoxModel.Name = "comboBoxModel";
comboBoxModel.Size = new Size(250, 28);
comboBoxModel.TabIndex = 2;
//
// textBoxFile
//
textBoxFile.Location = new Point(202, 61);
textBoxFile.Name = "textBoxFile";
textBoxFile.Size = new Size(208, 27);
textBoxFile.TabIndex = 3;
//
// labelFile
//
labelFile.AutoSize = true;
labelFile.Location = new Point(63, 64);
labelFile.Name = "labelFile";
labelFile.Size = new Size(112, 20);
labelFile.TabIndex = 4;
labelFile.Text = "Путь до файла:\r\n";
//
// labelModel
//
labelModel.AutoSize = true;
labelModel.Location = new Point(63, 129);
labelModel.Name = "labelModel";
labelModel.Size = new Size(66, 20);
labelModel.TabIndex = 5;
labelModel.Text = "Модель:";
//
// labelStart
//
labelStart.AutoSize = true;
labelStart.Location = new Point(63, 206);
labelStart.Name = "labelStart";
labelStart.Size = new Size(97, 20);
labelStart.TabIndex = 6;
labelStart.Text = "Дата начала:";
//
// labelEnd
//
labelEnd.AutoSize = true;
labelEnd.Location = new Point(63, 281);
labelEnd.Name = "labelEnd";
labelEnd.Size = new Size(90, 20);
labelEnd.TabIndex = 7;
labelEnd.Text = "Дата конца:";
//
// buttonFile
//
buttonFile.Location = new Point(416, 61);
buttonFile.Name = "buttonFile";
buttonFile.Size = new Size(36, 27);
buttonFile.TabIndex = 8;
buttonFile.Text = "..";
buttonFile.UseVisualStyleBackColor = true;
buttonFile.Click += ButtonFile_Click;
//
// buttonBuild
//
buttonBuild.Location = new Point(167, 357);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(155, 29);
buttonBuild.TabIndex = 9;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// FormOrderReports
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(517, 421);
Controls.Add(buttonBuild);
Controls.Add(buttonFile);
Controls.Add(labelEnd);
Controls.Add(labelStart);
Controls.Add(labelModel);
Controls.Add(labelFile);
Controls.Add(textBoxFile);
Controls.Add(comboBoxModel);
Controls.Add(dateTimePickerEnd);
Controls.Add(dateTimePickerStart);
Name = "FormOrderReports";
StartPosition = FormStartPosition.CenterParent;
Text = "Отчёт по заказам";
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd;
private ComboBox comboBoxModel;
private TextBox textBoxFile;
private Label labelFile;
private Label labelModel;
private Label labelStart;
private Label labelEnd;
private Button buttonFile;
private Button buttonBuild;
}
}

View File

@ -0,0 +1,66 @@
using Atelier.Reports;
using System;
using System.ComponentModel;
using System.Windows.Forms;
using Unity;
namespace Atelier.Forms
{
public partial class FormOrderReports : Form
{
private readonly IUnityContainer _container;
public FormOrderReports(IUnityContainer container, IOrderRepository orderRepository, IModelRepository modelRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
comboBoxModel.DataSource = modelRepository.ReadModels();
comboBoxModel.DisplayMember = "ModelType";
comboBoxModel.ValueMember = "Id";
}
private void ButtonFile_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Excel Files | *.xlsx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
return;
}
textBoxFile.Text = sfd.FileName;
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFile.Text))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if (comboBoxModel.SelectedIndex < 0)
{
throw new Exception("Не выбрана модель");
}
if (dateTimePickerEnd.Value <= dateTimePickerStart.Value)
{
throw new Exception("Дата начала должна быть раньше даты окончания");
}
if (_container.Resolve<TableReport>().CreateTable(textBoxFile.Text, (int)comboBoxModel.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.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);
}
}
}
}

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,113 @@
namespace Atelier.Forms
{
partial class FormOrders
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormOrders));
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDel = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(1001, 604);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1001, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 604);
panel1.TabIndex = 1;
//
// buttonDel
//
buttonDel.Image = (Image)resources.GetObject("buttonDel.Image");
buttonDel.Location = new Point(14, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(107, 88);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.Image = (Image)resources.GetObject("buttonAdd.Image");
buttonAdd.Location = new Point(14, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 89);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormOrders
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 604);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormOrders";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказы";
Load += FormOrders_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonDel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,97 @@
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;
using static Atelier.Forms.FormOrders;
namespace Atelier.Forms
{
public partial class FormOrders : Form
{
private readonly IUnityContainer _container;
private readonly IOrderRepository _orderRepository;
public FormOrders(IUnityContainer container,
IOrderRepository orderRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_orderRepository = orderRepository ??
throw new
ArgumentNullException(nameof(orderRepository));
}
private void FormOrders_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOrder>().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
{
_orderRepository.DeleteOrder(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView1.DataSource = _orderRepository.ReadOrders();
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,189 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DAAACwwBP0AiyAAABNVJREFUeF7tnL9uXHUQhZ2OKk8ANRJ5AHipNInXgCFKyuD1H/ECZJ11Eh7AViCP
ELeJaCgQHV2gIIULc0cZ0KfRaDTaO2Ph63ukrzg+oxnOzxvT7dasWbNmzbpafX93fXtve/XTcnt1sVwc
X47iw46XslPXT1/LxerbvcXqxcOHTz7SH20s2TE84o9728cP9EfT1/B4b5f3n36udrQOdp58sbc4/kXt
tPV4Z3VnKPv75dblLf3RaMmu4Zfy2/L++jP90XQ1/L16NPz921dbpuHPwoHsVjtdVf/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3yjtKT
KCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3y
jtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nX
mn3apOx1YX7AkVzJA8q3m03xq6DevJavelr/rTX7dLh78kq+mMv7j7jOnD5/fXH0zbNTrdkn+V49+Wo4
ecQpfBLlkyePd/jV+t3jnfXHWrNXH76Q8eRMvt1M/m5cZ6SDfPKu7PFmzZo1azLa2voHHNxQxvmbf3YA
AAAASUVORK5CYII=
</value>
</data>
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DAAACwwBP0AiyAAACDBJREFUeF7tXFlTFFcU9inbQ5JfkOU9eyqVPGT7B6kk5UsEZmkYfMFUCpnunkE2
Uy6pCotCEKa3ARQliklYRWMEyvigErSMmriRlMlDSpGSmaFUoHO/yaUmNncchpnunhnmq/qqKObc7VR3
n3PPPeeuyyOPtQtPW/VTjgD/YaFUsdGpCM3Fmu8k4ZRbFf5xKnzYEfDOg/gb/8NvkIFsUcBbWihXfIA+
aHdrA4527ztEKVtLgv5zTtl7b9P+upnagYZw46isq6f36z0Xvtd7L/Xr/VeG9eEbx6LE3/gffoMMZGtI
m03ddTPogyh10inxdQVy+dt0mNxCQXv5i0WKt5Y8RX9v7Npyd/tIy/3gxAF98NqIPjL1Y0pEH9rZA/o2
0mdpZ+Usp4p/OWS+xqHyL9DhsxeOgPAmWdCwWxUjW4ea5vadP8RUQjq579whvW5w15xbFubcqn9wg1Lx
Bp1O9gCKc6niaLHqDzWNygvpeNKSJcYkr/piseaPcKpvrFDiX6fTy1w41M+fdSuCRJ66cPO4tjB8/Shz
cVYSc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+q+hlDjqBQtYkECY7yLuPEb8vMa
Tsg62iDRB32ggtIl81VJXQyRC0CSDraGjkCFBzl3RKnjXNB3HSm0yNleugqeuEkh/A+/IbkRsmiD3UPc
RJ888lgDWLfuXyHjrOzkVJ7gAAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -0,0 +1,122 @@
namespace Atelier.Forms
{
partial class FormStorage
{
/// <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()
{
comboBoxFabric = new ComboBox();
numericUpDownMetrage = new NumericUpDown();
labelFabric = new Label();
labelMetrage = new Label();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownMetrage).BeginInit();
SuspendLayout();
//
// comboBoxFabric
//
comboBoxFabric.FormattingEnabled = true;
comboBoxFabric.Location = new Point(130, 22);
comboBoxFabric.Name = "comboBoxFabric";
comboBoxFabric.Size = new Size(151, 28);
comboBoxFabric.TabIndex = 0;
//
// numericUpDownMetrage
//
numericUpDownMetrage.DecimalPlaces = 2;
numericUpDownMetrage.Location = new Point(131, 81);
numericUpDownMetrage.Name = "numericUpDownMetrage";
numericUpDownMetrage.Size = new Size(150, 27);
numericUpDownMetrage.TabIndex = 1;
//
// labelFabric
//
labelFabric.AutoSize = true;
labelFabric.Location = new Point(40, 30);
labelFabric.Name = "labelFabric";
labelFabric.Size = new Size(52, 20);
labelFabric.TabIndex = 2;
labelFabric.Text = "Ткань:";
//
// labelMetrage
//
labelMetrage.AutoSize = true;
labelMetrage.Location = new Point(40, 88);
labelMetrage.Name = "labelMetrage";
labelMetrage.Size = new Size(67, 20);
labelMetrage.TabIndex = 3;
labelMetrage.Text = "Метраж:";
//
// buttonSave
//
buttonSave.Location = new Point(50, 148);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(171, 148);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormStorage
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(320, 213);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelMetrage);
Controls.Add(labelFabric);
Controls.Add(numericUpDownMetrage);
Controls.Add(comboBoxFabric);
Name = "FormStorage";
StartPosition = FormStartPosition.CenterParent;
Text = "Склад";
((System.ComponentModel.ISupportInitialize)numericUpDownMetrage).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxFabric;
private NumericUpDown numericUpDownMetrage;
private Label labelFabric;
private Label labelMetrage;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,49 @@
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 Atelier.Forms
{
public partial class FormStorage : Form
{
private readonly IStorageRepository _storageRepository;
public FormStorage(IStorageRepository storageRepository, IFabricRepository fabricRepository)
{
InitializeComponent();
_storageRepository = storageRepository ??
throw new
ArgumentNullException(nameof(storageRepository));
comboBoxFabric.DataSource = fabricRepository.ReadFabrics();
comboBoxFabric.DisplayMember = "FabricType";
comboBoxFabric.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxFabric.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
var currentDate = DateTime.Now.Date;
_storageRepository.CreateStorage(Storage.CreateOperation(0, (int)comboBoxFabric.SelectedValue!, Convert.ToInt32(numericUpDownMetrage.Value), currentDate));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

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,108 @@
namespace Atelier.Forms
{
partial class FormStorageReport
{
/// <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()
{
dateTimePickerStorage = new DateTimePicker();
labelDate = new Label();
labelFile = new Label();
buttonBuild = new Button();
buttonChoose = new Button();
SuspendLayout();
//
// dateTimePickerStorage
//
dateTimePickerStorage.Location = new Point(106, 110);
dateTimePickerStorage.Name = "dateTimePickerStorage";
dateTimePickerStorage.Size = new Size(183, 27);
dateTimePickerStorage.TabIndex = 0;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(33, 110);
labelDate.Name = "labelDate";
labelDate.Size = new Size(44, 20);
labelDate.TabIndex = 1;
labelDate.Text = "Дата:";
//
// labelFile
//
labelFile.AutoSize = true;
labelFile.Location = new Point(179, 54);
labelFile.Name = "labelFile";
labelFile.Size = new Size(45, 20);
labelFile.TabIndex = 2;
labelFile.Text = "Файл";
//
// buttonBuild
//
buttonBuild.Location = new Point(74, 169);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(141, 33);
buttonBuild.TabIndex = 3;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += ButtonBuild_Click;
//
// buttonChoose
//
buttonChoose.Location = new Point(33, 45);
buttonChoose.Name = "buttonChoose";
buttonChoose.Size = new Size(94, 29);
buttonChoose.TabIndex = 4;
buttonChoose.Text = "Выбрать";
buttonChoose.UseVisualStyleBackColor = true;
buttonChoose.Click += ButtonChoose_Click;
//
// FormStorageReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(314, 249);
Controls.Add(buttonChoose);
Controls.Add(buttonBuild);
Controls.Add(labelFile);
Controls.Add(labelDate);
Controls.Add(dateTimePickerStorage);
Name = "FormStorageReport";
StartPosition = FormStartPosition.CenterParent;
Text = "Отчёт по складу";
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePickerStorage;
private Label labelDate;
private Label labelFile;
private Button buttonBuild;
private Button buttonChoose;
}
}

View File

@ -0,0 +1,67 @@
using Atelier.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 Atelier.Forms;
public partial class FormStorageReport : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public FormStorageReport(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ButtonChoose_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
labelFile.Text = Path.GetFileName(_fileName);
}
}
private void ButtonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePickerStorage.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);
}
}
}

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,113 @@
namespace Atelier.Forms
{
partial class FormStorages
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormStorages));
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDel = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(1001, 604);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(1001, 0);
panel1.Name = "panel1";
panel1.Size = new Size(133, 604);
panel1.TabIndex = 1;
//
// buttonDel
//
buttonDel.Image = (Image)resources.GetObject("buttonDel.Image");
buttonDel.Location = new Point(14, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(107, 88);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.Image = (Image)resources.GetObject("buttonAdd.Image");
buttonAdd.Location = new Point(14, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 89);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormStorages
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1134, 604);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormStorages";
StartPosition = FormStartPosition.CenterParent;
Text = "Склады";
Load += FormStorages_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonDel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,96 @@
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 Atelier.Forms
{
public partial class FormStorages : Form
{
private readonly IUnityContainer _container;
private readonly IStorageRepository _storageRepository;
public FormStorages(IUnityContainer container, IStorageRepository storageRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_storageRepository = storageRepository ??
throw new
ArgumentNullException(nameof(storageRepository));
}
private void FormStorages_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormStorage>().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
{
_storageRepository.DeleteStorage(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView1.DataSource = _storageRepository.ReadStorage();
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["DateStorage"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,189 @@
<?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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
Dg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8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx22bi
tWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZOVKx
22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKTKCPZ
OVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3yjtKT
KCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nXmn3y
jtKTKCPZOVKx22bitWafvKP0JMpIdo5U7LaZeK3ZJ+8oPYkykp0jFbttJl5r9sk7Sk+ijGTnSMVum4nX
mn3apOx1YX7AkVzJA8q3m03xq6DevJavelr/rTX7dLh78kq+mMv7j7jOnD5/fXH0zbNTrdkn+V49+Wo4
ecQpfBLlkyePd/jV+t3jnfXHWrNXH76Q8eRMvt1M/m5cZ6SDfPKu7PFmzZo1azLa2voHHNxQxvmbf3YA
AAAASUVORK5CYII=
</value>
</data>
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
DgAACw4BQL7hQQAACDBJREFUeF7tXFlTFFcU9inbQ5JfkOU9eyqVPGT7B6kk5UsEZmkYfMFUCpnunkE2
Uy6pCotCEKa3ARQliklYRWMEyvigErSMmriRlMlDSpGSmaFUoHO/yaUmNncchpnunhnmq/qqKObc7VR3
n3PPPeeuyyOPtQtPW/VTjgD/YaFUsdGpCM3Fmu8k4ZRbFf5xKnzYEfDOg/gb/8NvkIFsUcBbWihXfIA+
aHdrA4527ztEKVtLgv5zTtl7b9P+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TtD
2eQnws/jD++IuDXfr6YZjJUCLo5LFvbg8jGUybMmnEnEDqMk6I+4NH9r2l2VVIALGrD1wRVzqPRmTd5O
IjBQ1VcfIa7YdNp2GOkG9s4uTWxFFAeV3nYWbC8RMU2EpBBVwe4i5b2tFUBAlnwbj3OqGIKRQUictTgz
iTHrRwPznOrDFaDHLb+hLR2AIos13wDOE1Bva/b1KbCsOD3DARDGJIrrM90xtgKo9HYE+CocmaJkdNuR
5vs45U/Hk4k+0BcOvXFui6NHh+zdYrt1NQuot3VKQjV5MieQZ4Las+q+hlDjqBQtYkECY7yLuPEb8vMa
Tsg62iDRB32ggtIl81VJXQyRC0CSDraGjkCFBzl3RKnjXNB3HSm0yNleugqeuEkh/A+/IbkRsmiD3UPc
RJ888lgDWLfuXyHjrOzkVJ7gAAAAAElFTkSuQmCC
</value>
</data>
</root>

View File

@ -1,5 +1,13 @@
namespace Atelier
{
using Atelier;
using Atelier.Repositories;
using Atelier.Repositories.Implementations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Unity;
using Unity.Lifetime;
using Unity.Microsoft.Logging;
internal static class Program
{
/// <summary>
@ -11,7 +19,31 @@ namespace Atelier
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormAtelier>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IClientRepository,ClientRepository>(new TransientLifetimeManager());
container.RegisterType<IFabricRepository,FabricRepository>(new TransientLifetimeManager());
container.RegisterType<IModelRepository, ModelRepository>(new TransientLifetimeManager());
container.RegisterType<IOrderRepository,OrderRepository>(new TransientLifetimeManager());
container.RegisterType<IStorageRepository,StorageRepository>(new TransientLifetimeManager());
container.RegisterType<IConnectionString, ConnectionString>(new TransientLifetimeManager());
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Atelier.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Atelier.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,53 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
namespace Atelier.Reports
{
internal class ChartReport
{
private readonly IStorageRepository _storageRepository;
private readonly ILogger<ChartReport> _logger;
public ChartReport(IStorageRepository storageRepository, ILogger<ChartReport> logger)
{
_storageRepository = storageRepository ?? throw new ArgumentNullException(nameof(storageRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
var data = GetData(dateTime);
_logger.LogDebug("Data for chart: {Data}", JsonSerializer.Serialize(data));
new PdfBuilder(filePath)
.AddHeader("Склад")
.AddPieChart($"Остатки на {dateTime:dd MMMM yyyy}", data)
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
var data = _storageRepository
.ReadStorage()
.Where(x => x.DateStorage.Date == dateTime.Date)
.GroupBy(x => x.FabricName, (key, group) => new { Name = key, Stock = group.Sum(x => x.StockMetrage) })
.Select(x => (x.Name.ToString(), (double)x.Stock))
.ToList();
_logger.LogDebug("Raw data: {Data}", JsonSerializer.Serialize(data));
return data;
}
}
}

View File

@ -0,0 +1,120 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Atelier.Reports
{
internal class DocReport
{
private readonly IClientRepository _clientRepository;
private readonly IFabricRepository _fabricRepository;
private readonly IModelRepository _modelRepository;
private readonly ILogger<DocReport> _logger;
public DocReport(IClientRepository clientRepository, IFabricRepository fabricRepository, IModelRepository modelRepository, ILogger<DocReport> logger)
{
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
_fabricRepository = fabricRepository ?? throw new ArgumentNullException(nameof(fabricRepository));
_modelRepository = modelRepository ?? throw new ArgumentNullException(nameof(modelRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeClients, bool includeFabrics, bool includeModels)
{
try
{
var builder = new WordBuilder(filePath)
.AddHeader("Документ со справочниками");
if (includeClients)
{
builder.AddParagraph("Клиенты")
.AddTable(new[] { 2400, 2400, 2400 }, GetClients());
}
if (includeFabrics)
{
builder.AddParagraph("Ткани")
.AddTable(new[] { 2400, 2400, 2400 }, GetFabrics());
}
if (includeModels)
{
builder.AddParagraph("Модели")
.AddTable(new[] { 2400, 2400, 1200, 1200 }, GetModels());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetClients()
{
var clients = _clientRepository.ReadClients()
.Select(x => new string[] { x.FirstName, x.LastName, x.ContactInformation })
.ToList();
var result = new List<string[]>
{
new[] { "Имя", "Фамилия", "Контактные данные" }
};
result.AddRange(clients);
return result;
}
private List<string[]> GetFabrics()
{
var fabrics = _fabricRepository.ReadFabrics()
.Select(x => new string[] { x.FabricType.ToString(), x.Color.ToString(), x.Metrage.ToString() })
.ToList();
var result = new List<string[]>
{
new[] { "Тип ткани", "Цвет", "Метраж" }
};
result.AddRange(fabrics);
return result;
}
private List<string[]> GetModels()
{
// Заголовок таблицы
var result = new List<string[]>
{
new[] { "Тип модели", "Цена", "Ткань", "Количество" }
};
// Добавляем строки с данными
var models = _modelRepository.ReadModels().ToList();
_logger.LogDebug("Models: {Models}", JsonConvert.SerializeObject(models));
result.AddRange(
models.Select(x =>
{
// Формируем строки для каждой модели
var fabricTypes = string.Join(", ", x.FabricModel
.Select(y => _fabricRepository.ReadFabricById(y.FabricId)?.FabricType)
.Where(type => type != null)); // Filter out null types
var fabricCounts = string.Join(", ", x.FabricModel.Select(y => y.Count.ToString()));
_logger.LogDebug("ModelType: {ModelType}, Price: {Price}, FabricTypes: {FabricTypes}, FabricCounts: {FabricCounts}", x.ModelType, x.Price, fabricTypes, fabricCounts);
return new[]
{
x.ModelType.ToString(),
x.Price.ToString(),
fabricTypes,
fabricCounts
};
})
);
return result;
}
}
}

View File

@ -0,0 +1,315 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atelier.Reports
{
public 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);
_mergeCells.Append(new MergeCell()
{
Reference = new StringValue($"{GetExcelColumnName(columnIndex)}{_rowIndex}:{GetExcelColumnName(columnIndex + 1)}{_rowIndex}")
});
_rowIndex++;
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());
}
spreadsheetDocument.WorkbookPart.Workbook.Save();
}
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" },
Bold = new Bold(),
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
FontScheme = new FontScheme()
{
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
}
});
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.Medium },
RightBorder = new RightBorder() { Style = BorderStyleValues.Medium },
TopBorder = new TopBorder() { Style = BorderStyleValues.Medium },
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Medium },
DiagonalBorder = new DiagonalBorder() { Style = BorderStyleValues.Medium },
});
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 = 1,
FormatId = 0,
FontId = 0,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 2,
FormatId = 0,
FontId = 1,
BorderId = 0,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
cellFormats.Append(new CellFormat
{
NumberFormatId = 3,
FormatId = 0,
FontId = 1,
BorderId = 1,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
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;
}
}
}

View File

@ -0,0 +1,88 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atelier.Reports;
public class PdfBuilder
{
private readonly string _filePath;
private readonly Document _document;
public PdfBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
DefineStyles();
}
public PdfBuilder AddHeader(string header)
{
_document.AddSection().AddParagraph(header, "NormalBold");
return this;
}
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
{
if (data == null || data.Count == 0)
{
return this;
}
var chart = new Chart(ChartType.Pie2D);
var series = chart.SeriesCollection.AddSeries();
series.Add(data.Select(x => x.Value).ToArray());
var xseries = chart.XValues.AddXSeries();
xseries.Add(data.Select(x => x.Caption).ToArray());
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.TopArea.AddParagraph(title);
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.TopArea.AddLegend();
_document.LastSection.Add(chart);
return this;
}
public void Build()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(_filePath);
}
private void DefineStyles()
{
var headerStyle = _document.AddStyle("NormalBold", "Normal");
headerStyle.Font.Bold = true;
headerStyle.Font.Size = 14;
headerStyle.Font.Color = Colors.DeepPink;
}
}

View File

@ -0,0 +1,75 @@
using Atelier.Repositories;
using DocumentFormat.OpenXml.Office2010.Excel;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Atelier.Reports
{
internal class TableReport
{
private readonly IOrderRepository _orderRepository;
private readonly IModelRepository _modelRepository;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] Headers = { "Клиент", "Дата", "Модель", "Статус", "Новые заказы", "Заказы в работе", "Выполненные заказы" };
public TableReport(IOrderRepository orderRepository, IModelRepository modelRepository, ILogger<TableReport> logger)
{
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
_modelRepository = modelRepository ?? throw new ArgumentNullException(nameof(modelRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, int? modelId = null, DateTime? startDate = null, DateTime? endDate = null, Status? status = null, int? clientId = null)
{
try
{
new ExcelBuilder(filePath)
.AddHeader("Сводка по заказам", 0, 4)
.AddParagraph($"за период с {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0)
.AddTable(new[] { 15, 15, 15, 15, 15, 15, 15 }, GetData(modelId, startDate, endDate, status, clientId))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetData(int? modelId, DateTime? startDate, DateTime? endDate, Status? status, int? clientId)
{
var orders = _orderRepository.ReadOrders(modelId, startDate, endDate, status, clientId).ToList();
var result = new List<string[]>() { Headers };
var newOrdersCount = 0;
var inProcessOrdersCount = 0;
var doneOrdersCount = 0;
foreach (var order in orders)
{
foreach (var modelOrder in order.ModelOrder)
{
var model = _modelRepository.ReadModelById(modelOrder.ModelId);
var modelName = model?.ModelType.ToString() ?? "Неизвестно";
var newOrder = order.Status == Status.Waiting ? "1" : "0";
var inProcessOrder = order.Status == Status.InProcess ? "1" : "0";
var doneOrder = order.Status == Status.Done ? "1" : "0";
result.Add(new string[] { order.ClientName, order.Date.ToString("yyyy-MM-dd"), modelName, order.Status.ToString(), newOrder, inProcessOrder, doneOrder });
if (order.Status == Status.Waiting) newOrdersCount++;
if (order.Status == Status.InProcess) inProcessOrdersCount++;
if (order.Status == Status.Done) doneOrdersCount++;
}
}
result.Add(new[] { "Всего", "", "", "", newOrdersCount.ToString(), inProcessOrdersCount.ToString(), doneOrdersCount.ToString() });
return result;
}
}
}

View File

@ -0,0 +1,133 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atelier.Reports;
internal 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());
run.PrependChild(new RunProperties());
run.RunProperties.AddChild(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;
}
}

View File

@ -0,0 +1,9 @@
public interface IClientRepository
{
IEnumerable<Client> ReadClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atelier.Repositories;
internal interface IConnectionString
{
string ConnectionString { get; }
}

View File

@ -0,0 +1,9 @@
public interface IFabricRepository
{
IEnumerable<Fabric> ReadFabrics();
Fabric ReadFabricById(int id);
void CreateFabric(Fabric fabric);
void UpdateFabric(Fabric fabric);
void DeleteFabric(int id);
}

View File

@ -0,0 +1,9 @@
public interface IModelRepository
{
IEnumerable<Model> ReadModels();
Model ReadModelById(int id);
void CreateModel(Model model);
void UpdateModel(Model model);
void DeleteModel(int id);
}

View File

@ -0,0 +1,7 @@
public interface IOrderRepository
{
IEnumerable<Order> ReadOrders(int? id = null, DateTime? dateFrom = null, DateTime? dateTo = null,
Status? status = null, int? clientId = null);
void CreateOrder(Order order);
void DeleteOrder(int id);
}

View File

@ -0,0 +1,6 @@
public interface IStorageRepository
{
IEnumerable<Storage> ReadStorage(int? fabricId = null, double? StockMetrage = null, DateTime? startDate = null, DateTime? endDate = null);
void CreateStorage(Storage storage);
void DeleteStorage(int id);
}

View File

@ -0,0 +1,136 @@
using Atelier.Repositories;
using Dapper;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Devices;
using Microsoft.VisualBasic.FileIO;
using Newtonsoft.Json;
using Npgsql;
using System.Data.SqlClient;
internal class ClientRepository : IClientRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ClientRepository> _logger;
public ClientRepository(IConnectionString connectionString, Logger<ClientRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateClient(Client client)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Clients (FirstName, LastName, ContactInformation)
VALUES (@FirstName, @LastName, @ContactInformation)";
connection.Execute(queryInsert, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateClient(Client client)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(client));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Clients
SET
FirstName=@FirstName,
LastName=@LastName,
ContactInformation=@ContactInformation
WHERE Id=@Id";
connection.Execute(queryUpdate, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteClient(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Clients
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Client ReadClientById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Clients
WHERE Id=@id";
var client = connection.QueryFirst<Client>(querySelect, new
{
id
});
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(client));
return client;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Client> ReadClients()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Clients";
var clients = connection.Query<Client>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(clients));
return clients;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atelier.Repositories.Implementations;
internal class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Server=localhost, 5432;Database=;Uid=postgres;Pwd=postgres;";
}

View File

@ -0,0 +1,133 @@
using Atelier.Repositories;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
internal class FabricRepository : IFabricRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<FabricRepository> _logger;
public FabricRepository(IConnectionString connectionString, Logger<FabricRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateFabric(Fabric fabric)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(fabric));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Fabrics (FabricType, Color, Metrage)
VALUES (@FabricType, @Color, @Metrage)";
connection.Execute(queryInsert, fabric);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateFabric(Fabric fabric)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(fabric));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Fabrics
SET
FabricType=@FabricType,
Color=@Color,
Metrage=@Metrage
WHERE Id=@Id";
connection.Execute(queryUpdate, fabric);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteFabric(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Fabrics
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Fabric ReadFabricById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Fabrics
WHERE Id=@id";
var fabric = connection.QueryFirst<Fabric>(querySelect, new
{
id
});
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(fabric));
return fabric;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Fabric> ReadFabrics()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Fabrics";
var fabrics = connection.Query<Fabric>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(fabrics));
return fabrics;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,197 @@
using Atelier.Repositories;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using System.Collections.Generic;
using System.Linq;
internal class ModelRepository : IModelRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ModelRepository> _logger;
public ModelRepository(IConnectionString connectionString, ILogger<ModelRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateModel(Model model)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(model));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Models (ModelType, Price)
VALUES (@ModelType, @Price)
RETURNING Id";
var modelId = connection.QueryFirst<int>(queryInsert, model, transaction);
var querySubInsert = @"
INSERT INTO FabricModel (ModelId, FabricId, Count)
VALUES (@ModelId, @FabricId, @Count)";
foreach (var elem in model.FabricModel)
{
connection.Execute(querySubInsert, new
{
ModelId = modelId,
elem.FabricId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateModel(Model model)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(model));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryUpdateModel = @"
UPDATE Models
SET ModelType = @ModelType, Price = @Price
WHERE Id = @Id";
connection.Execute(queryUpdateModel, model, transaction);
var queryDeleteFabricModel = @"
DELETE FROM FabricModel
WHERE ModelId = @Id";
connection.Execute(queryDeleteFabricModel, new { model.Id }, transaction);
var queryInsertFabricModel = @"
INSERT INTO FabricModel (ModelId, FabricId, Count)
VALUES (@ModelId, @FabricId, @Count)";
foreach (var elem in model.FabricModel)
{
connection.Execute(queryInsertFabricModel, new
{
ModelId = model.Id,
elem.FabricId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteModel(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryDeleteFabricModel = @"
DELETE FROM FabricModel
WHERE ModelId = @Id";
connection.Execute(queryDeleteFabricModel, new { Id = id }, transaction);
var queryDeleteModel = @"
DELETE FROM Models
WHERE Id = @Id";
connection.Execute(queryDeleteModel, new { Id = id }, transaction);
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Model ReadModelById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT * FROM Models
WHERE Id = @id";
var model = connection.QueryFirstOrDefault<Model>(querySelect, new { id });
var querySelectSub = @$"SELECT *
FROM FabricModel fm
WHERE ModelId = {id}";
var fabricModel = connection.Query<FabricModel>(querySelectSub);
model.CreateList(fabricModel);
if (model == null)
{
_logger.LogWarning("Объект с идентификатором {id} не найден", id);
throw new KeyNotFoundException($"Модель с идентификатором {id} не найдена");
}
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(model));
return model;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Model> ReadModels()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Models";
var models = connection.Query<Model>(querySelect).ToList();
foreach (var model in models)
{
var querySelectSub = @$"SELECT fm.FabricId, fm.Count, f.FabricType as FabricName
FROM FabricModel fm
JOIN Fabrics f ON f.Id = fm.FabricId
WHERE ModelId = {model.Id}";
var fabricModel = connection.Query<FabricModel>(querySelectSub).ToList();
model.CreateList(fabricModel);
_logger.LogDebug("Model ID: {ModelId}, FabricModels: {FabricModels}", model.Id, JsonConvert.SerializeObject(fabricModel));
}
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(models));
return models;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,176 @@
using Atelier.Repositories;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using System.Text;
using System.Collections.Generic;
using System.Linq;
internal class OrderRepository : IOrderRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<Order> _logger;
public OrderRepository(IConnectionString connectionString, ILogger<Order> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateOrder(Order order)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Orders (Date, Status, ClientId)
VALUES (@Date, @Status, @ClientId);
SELECT MAX(Id) FROM Orders";
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
var querySubInsert = @"
INSERT INTO ModelOrder (OrderId, ModelId, Count)
VALUES (@OrderId, @ModelId, @Count)";
foreach (var elem in order.ModelOrder)
{
connection.Execute(querySubInsert, new
{
orderId,
elem.ModelId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteOrder(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Orders
WHERE Id = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
internal class QueryBuilder
{
private readonly StringBuilder _builder;
public QueryBuilder()
{
_builder = new();
}
public QueryBuilder AddCondition(string condition)
{
if (_builder.Length > 0)
{
_builder.Append(" AND ");
}
_builder.Append(condition);
return this;
}
public string Build()
{
return _builder.Length == 0 ? string.Empty : $"WHERE {_builder}";
}
}
public IEnumerable<Order> ReadOrders(int? modelId = null, DateTime? startDate = null, DateTime? endDate = null, Status? status = null, int? clientId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
var builder = new QueryBuilder();
if (startDate.HasValue)
{
builder.AddCondition("o.Date >= @startDate");
}
if (endDate.HasValue)
{
builder.AddCondition("o.Date <= @endDate");
}
if (modelId.HasValue)
{
builder.AddCondition("mo.ModelId = @modelId");
}
if (status.HasValue)
{
builder.AddCondition("o.Status = @status");
}
if (clientId.HasValue)
{
builder.AddCondition("o.ClientId = @clientId");
}
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @$"
SELECT
o.*,
CONCAT(c.LastName, ' ', c.FirstName) as ClientName,
mo.ModelId,
mo.Count,
m.ModelType as ModelName
FROM Orders o
LEFT JOIN Clients c on c.Id = o.ClientId
INNER JOIN ModelOrder mo on mo.OrderId = o.Id
LEFT JOIN Models m ON m.Id = mo.ModelId
{builder.Build()}";
var orderDict = new Dictionary<int, List<ModelOrder>>();
var orders = connection.Query<Order, ModelOrder, Order>(
querySelect,
(order, modelOrder) =>
{
if (!orderDict.TryGetValue(order.Id, out var modelOrders))
{
modelOrders = new List<ModelOrder>();
orderDict.Add(order.Id, modelOrders);
}
modelOrders.Add(modelOrder);
return order;
},
splitOn: "ModelId",
param: new
{
startDate,
endDate,
modelId,
status,
clientId
});
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(orders));
return orderDict.Select(x =>
{
var o = orders.First(y => y.Id == x.Key);
o.SetModelOrder(x.Value);
return o;
}).ToArray();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,134 @@
using Atelier.Repositories;
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using System.Text;
using static System.Runtime.InteropServices.JavaScript.JSType;
internal class StorageRepository : IStorageRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<Storage> _logger;
public StorageRepository(IConnectionString connectionString,
ILogger<Storage> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateStorage(Storage storage)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(storage));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Storages (FabricId, StockMetrage, DateStorage)
VALUES (@FabricId, @StockMetrage, @DateStorage)";
connection.Execute(queryInsert, storage);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteStorage(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Storages
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
internal class QueryBuilder
{
private readonly StringBuilder _builder;
public QueryBuilder()
{
_builder = new();
}
public QueryBuilder AddCondition(string condition)
{
if (_builder.Length > 0)
{
_builder.Append(" AND ");
}
_builder.Append(condition);
return this;
}
public string Build()
{
if (_builder.Length == 0)
{
return string.Empty;
}
return $"WHERE {_builder}";
}
}
public IEnumerable<Storage> ReadStorage(int? fabricId = null, double? stockMetrage = null, DateTime? startDate = null, DateTime? endDate = null)
{
_logger.LogInformation("Получение всех данных о складе");
try
{
var builder = new QueryBuilder();
if (startDate.HasValue)
{
builder.AddCondition("s.DateStorage >= @startDate");
}
if (endDate.HasValue)
{
builder.AddCondition("s.DateStorage <= @endDate");
}
if (fabricId.HasValue)
{
builder.AddCondition("s.FabricId = @fabricId");
}
if (stockMetrage.HasValue)
{
builder.AddCondition("s.StockMetrage = @stockMetrage");
}
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @$"
SELECT
s.*,
f.FabricType as FabricName
FROM Storages s
LEFT JOIN Fabrics f on f.Id = s.FabricId
{builder.Build()}";
var storage = connection.Query<Storage>(querySelect, new
{
startDate,
endDate,
fabricId,
stockMetrage
});
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(storage));
return storage;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/atelier_log.txt",
"rollingInterval": "Day"
}
}
]
}
}