Лабораторная работа №1

This commit is contained in:
Олег Кудринский 2024-11-22 04:38:03 +04:00
parent 0e4a9e7594
commit 746109f7a7
28 changed files with 2120 additions and 83 deletions

View File

@ -1,4 +1,6 @@
namespace ProjectWorkshop.Entities;
using ProjectWorkshop.Entities.Enums;
namespace ProjectWorkshop.Entities;
public class Assembly
{
@ -6,9 +8,9 @@ public class Assembly
public int Count { get; private set; }
public string ProductType { get; private set; } = string.Empty;
public ProductType ProductType { get; private set; }
public static Assembly CreateEntity(int id, int count, string productType)
public static Assembly CreateElement(int id, int count, ProductType productType)
{
return new Assembly()
{

View File

@ -8,13 +8,16 @@ public class ProductAssembly
public int Count { get; private set; }
public static ProductAssembly CreateOperation(int productID, int assemblyID, int count)
public IEnumerable<Assembly> ProductAssemblies { get; private set; } = [];
public static ProductAssembly CreateOperation(int productID, int assemblyID, int count, IEnumerable<Assembly> productAssemblies)
{
return new ProductAssembly()
{
ProductId = productID,
AssemblyID = assemblyID,
Count = count
Count = count,
ProductAssemblies = productAssemblies
};
}
}

View File

@ -29,69 +29,74 @@
private void InitializeComponent()
{
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
сборщикиToolStripMenuItem = new ToolStripMenuItem();
сборкиToolStripMenuItem = new ToolStripMenuItem();
изделияToolStripMenuItem = new ToolStripMenuItem();
manualToolStripMenuItem = new ToolStripMenuItem();
AssemblersToolStripMenuItem = new ToolStripMenuItem();
AssembliesToolStripMenuItem = new ToolStripMenuItem();
ProductsToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
сборкаToolStripMenuItem = new ToolStripMenuItem();
ВыйтиНаСменуToolStripMenuItem = new ToolStripMenuItem();
ProductAssemblyToolStripMenuItem = new ToolStripMenuItem();
AssemblerShiftToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Items.AddRange(new ToolStripItem[] { manualToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(784, 24);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip";
//
// справочникиToolStripMenuItem
// manualToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сборщикиToolStripMenuItem, сборкиToolStripMenuItem, изделияToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники";
manualToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AssemblersToolStripMenuItem, AssembliesToolStripMenuItem, ProductsToolStripMenuItem });
manualToolStripMenuItem.Name = "manualToolStripMenuItem";
manualToolStripMenuItem.Size = new Size(94, 20);
manualToolStripMenuItem.Text = "Справочники";
//
// сборщикиToolStripMenuItem
// AssemblersToolStripMenuItem
//
сборщикиToolStripMenuItem.Name = "сборщикиToolStripMenuItem";
сборщикиToolStripMenuItem.Size = new Size(134, 22);
сборщикиToolStripMenuItem.Text = "Сборщики";
AssemblersToolStripMenuItem.Name = "AssemblersToolStripMenuItem";
AssemblersToolStripMenuItem.Size = new Size(134, 22);
AssemblersToolStripMenuItem.Text = "Сборщики";
AssemblersToolStripMenuItem.Click += AssemblersToolStripMenuItem_Click_1;
//
// сборкиToolStripMenuItem
// AssembliesToolStripMenuItem
//
сборкиToolStripMenuItem.Name = "сборкиToolStripMenuItem";
сборкиToolStripMenuItem.Size = new Size(134, 22);
сборкиToolStripMenuItem.Text = "Сборки";
AssembliesToolStripMenuItem.Name = "AssembliesToolStripMenuItem";
AssembliesToolStripMenuItem.Size = new Size(134, 22);
AssembliesToolStripMenuItem.Text = "Сборки";
AssembliesToolStripMenuItem.Click += AssembliesToolStripMenuItem_Click_1;
//
// изделияToolStripMenuItem
// ProductsToolStripMenuItem
//
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
изделияToolStripMenuItem.Size = new Size(134, 22);
изделияToolStripMenuItem.Text = "Изделия";
ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
ProductsToolStripMenuItem.Size = new Size(134, 22);
ProductsToolStripMenuItem.Text = "Изделия";
ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click_1;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сборкаToolStripMenuItem, ВыйтиНаСменуToolStripMenuItem });
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ProductAssemblyToolStripMenuItem, AssemblerShiftToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Text = "Операции";
//
// сборкаToolStripMenuItem
// ProductAssemblyToolStripMenuItem
//
сборкаToolStripMenuItem.Name = "сборкаToolStripMenuItem";
сборкаToolStripMenuItem.Size = new Size(192, 22);
сборкаToolStripMenuItem.Text = "Сборка";
ProductAssemblyToolStripMenuItem.Name = "ProductAssemblyToolStripMenuItem";
ProductAssemblyToolStripMenuItem.Size = new Size(180, 22);
ProductAssemblyToolStripMenuItem.Text = "Сборка";
ProductAssemblyToolStripMenuItem.Click += ProductAssemblyToolStripMenuItem_Click_1;
//
// ВыйтиНаСменуToolStripMenuItem
// AssemblerShiftToolStripMenuItem
//
ВыйтиНаСменуToolStripMenuItem.Name = "ВыйтиНаСменуToolStripMenuItem";
ВыйтиНаСменуToolStripMenuItem.Size = new Size(180, 22);
ВыйтиНаСменуToolStripMenuItem.Text = "Выйти на Смену";
AssemblerShiftToolStripMenuItem.Name = "AssemblerShiftToolStripMenuItem";
AssemblerShiftToolStripMenuItem.Size = new Size(180, 22);
AssemblerShiftToolStripMenuItem.Text = "Выйти на Смену";
AssemblerShiftToolStripMenuItem.Click += AssemblerShiftToolStripMenuItem_Click_1;
//
// отчетыToolStripMenuItem
//
@ -120,13 +125,13 @@
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem сборщикиToolStripMenuItem;
private ToolStripMenuItem сборкиToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem;
private ToolStripMenuItem manualToolStripMenuItem;
private ToolStripMenuItem AssemblersToolStripMenuItem;
private ToolStripMenuItem AssembliesToolStripMenuItem;
private ToolStripMenuItem ProductsToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem сборкаToolStripMenuItem;
private ToolStripMenuItem ВыйтиНаСменуToolStripMenuItem;
private ToolStripMenuItem ProductAssemblyToolStripMenuItem;
private ToolStripMenuItem AssemblerShiftToolStripMenuItem;
}
}

View File

@ -1,13 +1,78 @@
using ProjectWorkshop.Forms;
using ProjectWorkshop.Repositories;
using Unity;
namespace ProjectWorkshop
{
public partial class FormWorkshop : Form
{
public FormWorkshop()
private readonly IUnityContainer _container;
public FormWorkshop(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void AssemblersToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAssemblers>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AssembliesToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAssemblies>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProductsToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProducts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProductAssemblyToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProductAssemblies>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AssemblerShiftToolStripMenuItem_Click_1(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAssemblerShifts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,97 @@
namespace ProjectWorkshop.Forms
{
partial class FormAssemblerShifts
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
panel1 = new Panel();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(647, 450);
dataGridView.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(647, 0);
panel1.Name = "panel1";
panel1.Size = new Size(153, 450);
panel1.TabIndex = 2;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.plus1;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(28, 25);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(100, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormAssemblerShifts
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormAssemblerShifts";
Text = "Смены сборщиков";
Load += FormAssemblerShifts_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Panel panel1;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,56 @@
using ProjectWorkshop.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectWorkshop.Forms
{
public partial class FormAssemblerShifts : Form
{
private readonly IUnityContainer _container;
private readonly IAssemblerShiftRepository _assemblerShiftRepository;
public FormAssemblerShifts(IUnityContainer container, IAssemblerShiftRepository assemblerShiftRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_assemblerShiftRepository = assemblerShiftRepository ??
throw new ArgumentNullException(nameof(assemblerShiftRepository));
}
private void FormAssemblerShifts_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<FormAssesmblerShift>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _assemblerShiftRepository.ReadAssemblerShifts();
}
}

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

@ -18,13 +18,13 @@ namespace ProjectWorkshop.Forms
private readonly IUnityContainer _container;
private readonly IAssemblyRepository _assemblyRepository;
public FormAssemblies(IUnityContainer container, IAssemblyRepository employeeRepository)
public FormAssemblies(IUnityContainer container, IAssemblyRepository assemblyRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_assemblyRepository = employeeRepository ??
throw new ArgumentNullException(nameof(employeeRepository));
_assemblyRepository = assemblyRepository ??
throw new ArgumentNullException(nameof(assemblyRepository));
}
private void ButtonAdd_Click(object sender, EventArgs e)

View File

@ -30,48 +30,41 @@
{
labelCount = new Label();
labelProductType = new Label();
textBoxProductType = new TextBox();
numericUpDownCount = new NumericUpDown();
buttonSave = new Button();
buttonCancel = new Button();
checkedListBoxProductType = new CheckedListBox();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout();
//
// labelCount
//
labelCount.AutoSize = true;
labelCount.Location = new Point(113, 101);
labelCount.Location = new Point(58, 160);
labelCount.Name = "labelCount";
labelCount.Size = new Size(46, 15);
labelCount.Size = new Size(49, 15);
labelCount.TabIndex = 0;
labelCount.Text = "Кол-во";
labelCount.Text = "Кол-во:";
//
// labelProductType
//
labelProductType.AutoSize = true;
labelProductType.Location = new Point(100, 51);
labelProductType.Location = new Point(58, 51);
labelProductType.Name = "labelProductType";
labelProductType.Size = new Size(74, 15);
labelProductType.Size = new Size(77, 15);
labelProductType.TabIndex = 1;
labelProductType.Text = "Тип изделия";
//
// textBoxProductType
//
textBoxProductType.Location = new Point(201, 48);
textBoxProductType.Name = "textBoxProductType";
textBoxProductType.Size = new Size(116, 23);
textBoxProductType.TabIndex = 2;
labelProductType.Text = "Тип изделия:";
//
// numericUpDownCount
//
numericUpDownCount.Location = new Point(201, 99);
numericUpDownCount.Location = new Point(156, 158);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(116, 23);
numericUpDownCount.Size = new Size(195, 23);
numericUpDownCount.TabIndex = 3;
//
// buttonSave
//
buttonSave.Location = new Point(100, 169);
buttonSave.Location = new Point(74, 275);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 4;
@ -81,7 +74,7 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(232, 169);
buttonCancel.Location = new Point(261, 275);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 5;
@ -89,15 +82,23 @@
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// checkedListBoxProductType
//
checkedListBoxProductType.FormattingEnabled = true;
checkedListBoxProductType.Location = new Point(156, 41);
checkedListBoxProductType.Name = "checkedListBoxProductType";
checkedListBoxProductType.Size = new Size(195, 94);
checkedListBoxProductType.TabIndex = 6;
//
// FormAssembly
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(420, 220);
ClientSize = new Size(453, 366);
Controls.Add(checkedListBoxProductType);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownCount);
Controls.Add(textBoxProductType);
Controls.Add(labelProductType);
Controls.Add(labelCount);
Name = "FormAssembly";
@ -112,9 +113,9 @@
private Label labelCount;
private Label labelProductType;
private TextBox textBoxProductType;
private NumericUpDown numericUpDownCount;
private Button buttonSave;
private Button buttonCancel;
private CheckedListBox checkedListBoxProductType;
}
}

View File

@ -1,4 +1,5 @@
using ProjectWorkshop.Entities;
using ProjectWorkshop.Entities.Enums;
using ProjectWorkshop.Repositories;
using System;
using System.Collections.Generic;
@ -27,10 +28,17 @@ namespace ProjectWorkshop.Forms
var assembly = _assemblyRepository.ReadAssemblyByID(value);
if (assembly == null)
{
throw new
InvalidDataException(nameof(assembly));
throw new InvalidDataException(nameof(assembly));
}
textBoxProductType.Text = assembly.ProductType;
foreach (ProductType elem in Enum.GetValues(typeof(ProductType)))
{
if ((elem & assembly.ProductType) != 0)
{
checkedListBoxProductType.SetItemChecked(checkedListBoxProductType.Items.IndexOf(elem), true);
}
}
numericUpDownCount.Value = assembly.Count;
_assemblyId = value;
}
@ -41,19 +49,23 @@ namespace ProjectWorkshop.Forms
}
}
}
public FormAssembly()
public FormAssembly(IAssemblyRepository assemblyRepository)
{
InitializeComponent();
InitializeComponent();
_assemblyRepository = _assemblyRepository ??
throw new ArgumentNullException(nameof(_assemblyRepository));
_assemblyRepository = assemblyRepository ??
throw new ArgumentNullException(nameof(assemblyRepository));
foreach (var elem in Enum.GetValues(typeof(ProductType)))
{
checkedListBoxProductType.Items.Add(elem);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxProductType.Text) || string.IsNullOrWhiteSpace(textBoxProductType.Text) || numericUpDownCount.Value < 1)
if (numericUpDownCount.Value < 1 || checkedListBoxProductType.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
@ -80,7 +92,15 @@ namespace ProjectWorkshop.Forms
Close();
}
private Assembly CreateAssembly(int id) =>
Assembly.CreateEntity(id, (int)numericUpDownCount.Value, textBoxProductType.Text);
private Assembly CreateAssembly(int id)
{
ProductType productType = ProductType.None;
foreach (var elem in checkedListBoxProductType.CheckedItems)
{
productType |= (ProductType)elem;
}
return Assembly.CreateElement(id, (int)numericUpDownCount.Value, productType);
}
}
}

View File

@ -0,0 +1,149 @@
namespace ProjectWorkshop.Forms
{
partial class FormAssesmblerShift
{
/// <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()
{
labelWorkHours = new Label();
numericUpDownWorkHours = new NumericUpDown();
groupBox = new GroupBox();
dataGridViewAssemblerShift = new DataGridView();
ColumnAssembler = new DataGridViewComboBoxColumn();
ColumnShift = new DataGridViewComboBoxColumn();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).BeginInit();
groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShift).BeginInit();
SuspendLayout();
//
// labelWorkHours
//
labelWorkHours.AutoSize = true;
labelWorkHours.Location = new Point(35, 33);
labelWorkHours.Name = "labelWorkHours";
labelWorkHours.Size = new Size(111, 15);
labelWorkHours.TabIndex = 0;
labelWorkHours.Text = "Отработано часов:";
//
// numericUpDownWorkHours
//
numericUpDownWorkHours.Location = new Point(198, 31);
numericUpDownWorkHours.Name = "numericUpDownWorkHours";
numericUpDownWorkHours.Size = new Size(113, 23);
numericUpDownWorkHours.TabIndex = 1;
//
// groupBox
//
groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox.Controls.Add(dataGridViewAssemblerShift);
groupBox.Location = new Point(35, 78);
groupBox.Name = "groupBox";
groupBox.Size = new Size(280, 328);
groupBox.TabIndex = 3;
groupBox.TabStop = false;
groupBox.Text = "groupBox1";
//
// dataGridViewAssemblerShift
//
dataGridViewAssemblerShift.AllowUserToResizeColumns = false;
dataGridViewAssemblerShift.AllowUserToResizeRows = false;
dataGridViewAssemblerShift.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewAssemblerShift.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewAssemblerShift.Columns.AddRange(new DataGridViewColumn[] { ColumnAssembler, ColumnShift });
dataGridViewAssemblerShift.Dock = DockStyle.Fill;
dataGridViewAssemblerShift.Location = new Point(3, 19);
dataGridViewAssemblerShift.Name = "dataGridViewAssemblerShift";
dataGridViewAssemblerShift.RowHeadersVisible = false;
dataGridViewAssemblerShift.Size = new Size(274, 306);
dataGridViewAssemblerShift.TabIndex = 3;
//
// ColumnAssembler
//
ColumnAssembler.HeaderText = "Сборщик";
ColumnAssembler.Name = "ColumnAssembler";
//
// ColumnShift
//
ColumnShift.HeaderText = "Смена";
ColumnShift.Name = "ColumnShift";
ColumnShift.Resizable = DataGridViewTriState.True;
ColumnShift.SortMode = DataGridViewColumnSortMode.Automatic;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom;
buttonSave.Location = new Point(53, 431);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom;
buttonCancel.Location = new Point(220, 431);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormAssesmblerShift
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(355, 466);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBox);
Controls.Add(numericUpDownWorkHours);
Controls.Add(labelWorkHours);
Name = "FormAssesmblerShift";
Text = "Смена сборщика";
((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).EndInit();
groupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShift).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelWorkHours;
private NumericUpDown numericUpDownWorkHours;
private GroupBox groupBox;
private DataGridView dataGridViewAssemblerShift;
private DataGridViewComboBoxColumn ColumnAssembler;
private DataGridViewComboBoxColumn ColumnShift;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,62 @@
using ProjectWorkshop.Entities;
using ProjectWorkshop.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectWorkshop.Forms
{
public partial class FormAssesmblerShift : Form
{
private readonly IAssemblerShiftRepository _assemblerShiftRepository;
public FormAssesmblerShift(IAssemblerShiftRepository assemblerShiftRepository, IShiftRepository shiftRepository,
IAssemblerRepository assemblerRepository)
{
InitializeComponent();
_assemblerShiftRepository = assemblerShiftRepository ??
throw new ArgumentNullException(nameof(assemblerShiftRepository));
numericUpDownWorkHours.Value = 1;
ColumnAssembler.DataSource = assemblerRepository.ReadAssemblers();
ColumnAssembler.DisplayMember = "FullName";
ColumnAssembler.ValueMember = "Id";
ColumnShift.DataSource = shiftRepository.ReadShifts();
ColumnShift.DisplayMember = "Id";
ColumnShift.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (numericUpDownWorkHours.Value < 1 || dataGridViewAssemblerShift.RowCount < 1)
{
throw new Exception("Имеются незаполненные поля");
}
_assemblerShiftRepository.CreateAssemblerShift(AssemblerShift.CreateOperation((int)numericUpDownWorkHours.Value,
Convert.ToInt32(ColumnAssembler.ValueMember), Convert.ToInt32(ColumnShift.ValueMember)));
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,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="ColumnAssembler.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnShift.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAssembler.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnShift.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,141 @@
namespace ProjectWorkshop.Forms
{
partial class FormProduct
{
/// <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()
{
labelProductName = new Label();
labelPrice = new Label();
numericUpDownPrice = new NumericUpDown();
textBoxProductName = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
comboBoxAssembler = new ComboBox();
labelAssembler = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
SuspendLayout();
//
// labelProductName
//
labelProductName.AutoSize = true;
labelProductName.Location = new Point(33, 50);
labelProductName.Name = "labelProductName";
labelProductName.Size = new Size(109, 15);
labelProductName.TabIndex = 1;
labelProductName.Text = "Название изделия:";
//
// labelPrice
//
labelPrice.AutoSize = true;
labelPrice.Location = new Point(49, 149);
labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(70, 15);
labelPrice.TabIndex = 2;
labelPrice.Text = "Стоимость:";
//
// numericUpDownPrice
//
numericUpDownPrice.Location = new Point(159, 147);
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(204, 23);
numericUpDownPrice.TabIndex = 3;
//
// textBoxProductName
//
textBoxProductName.Location = new Point(159, 47);
textBoxProductName.Name = "textBoxProductName";
textBoxProductName.Size = new Size(204, 23);
textBoxProductName.TabIndex = 4;
//
// buttonSave
//
buttonSave.Location = new Point(75, 224);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(79, 27);
buttonSave.TabIndex = 5;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(253, 224);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(79, 27);
buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// comboBoxAssembler
//
comboBoxAssembler.FormattingEnabled = true;
comboBoxAssembler.Location = new Point(159, 97);
comboBoxAssembler.Name = "comboBoxAssembler";
comboBoxAssembler.Size = new Size(204, 23);
comboBoxAssembler.TabIndex = 7;
//
// labelAssembler
//
labelAssembler.AutoSize = true;
labelAssembler.Location = new Point(49, 100);
labelAssembler.Name = "labelAssembler";
labelAssembler.Size = new Size(63, 15);
labelAssembler.TabIndex = 8;
labelAssembler.Text = "Сборщик:";
//
// FormProduct
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(440, 295);
Controls.Add(labelAssembler);
Controls.Add(comboBoxAssembler);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxProductName);
Controls.Add(numericUpDownPrice);
Controls.Add(labelPrice);
Controls.Add(labelProductName);
Name = "FormProduct";
Text = "FormProduct";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelProductName;
private Label labelPrice;
private NumericUpDown numericUpDownPrice;
private TextBox textBoxProductName;
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxAssembler;
private Label labelAssembler;
}
}

View File

@ -0,0 +1,88 @@
using ProjectWorkshop.Entities;
using ProjectWorkshop.Repositories;
using ProjectWorkshop.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectWorkshop.Forms
{
public partial class FormProduct : Form
{
private readonly IProductRepository _productRepository;
private int? _productID;
public int Id
{
set
{
try
{
var product = _productRepository.ReadProductByID(value);
if (product != null)
{
throw new InvalidDataException(nameof(product));
}
textBoxProductName.Text = product.ProductName;
numericUpDownPrice.Value = (int)product.Price;
comboBoxAssembler.SelectedItem = product.AssemblerID;
_productID = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormProduct(IProductRepository productRepository)
{
InitializeComponent();
_productRepository = productRepository ??
throw new ArgumentNullException(nameof(productRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxProductName.Text))
{
throw new Exception("Имеется незаполненное поле");
}
if (_productID.HasValue || comboBoxAssembler.Created)
{
_productRepository.UpdateProduct(CreateProduct(_productID.Value));
}
else
{
_productRepository.CreateProduct(CreateProduct(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Product CreateProduct(int id) => Product.CreateEntity(id, textBoxProductName.Text, Convert.ToInt32(numericUpDownPrice.Value),
(int)comboBoxAssembler.SelectedItem!);
}
}

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,97 @@
namespace ProjectWorkshop.Forms
{
partial class FormProductAssemblies
{
/// <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()
{
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1 = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.plus1;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(28, 25);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(100, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(647, 450);
dataGridView.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(647, 0);
panel1.Name = "panel1";
panel1.Size = new Size(153, 450);
panel1.TabIndex = 2;
//
// FormProductAssemblies
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormProductAssemblies";
Text = "Сборки продуктов";
Load += FormProductAssemblies_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button buttonAdd;
private DataGridView dataGridView;
private Panel panel1;
}
}

View File

@ -0,0 +1,56 @@
using ProjectWorkshop.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectWorkshop.Forms
{
public partial class FormProductAssemblies : Form
{
private readonly IUnityContainer _container;
private readonly IProductAssemblyRepository _productAssemblyRepository;
public FormProductAssemblies(IUnityContainer container, IProductAssemblyRepository productAssemblyRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_productAssemblyRepository = productAssemblyRepository ??
throw new ArgumentNullException(nameof(productAssemblyRepository));
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProductAssembly>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _productAssemblyRepository.ReadProductAssembly();
private void FormProductAssemblies_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
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,146 @@
namespace ProjectWorkshop.Forms
{
partial class FormProductAssembly
{
/// <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()
{
labelProduct = new Label();
comboBoxProduct = new ComboBox();
groupBox = new GroupBox();
dataGridViewProductAssembly = new DataGridView();
ColumnProductType = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
buttonSave = new Button();
buttonCancel = new Button();
groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewProductAssembly).BeginInit();
SuspendLayout();
//
// labelProduct
//
labelProduct.AutoSize = true;
labelProduct.Location = new Point(12, 41);
labelProduct.Name = "labelProduct";
labelProduct.Size = new Size(56, 15);
labelProduct.TabIndex = 0;
labelProduct.Text = "Изделие:";
//
// comboBoxProduct
//
comboBoxProduct.FormattingEnabled = true;
comboBoxProduct.Location = new Point(95, 38);
comboBoxProduct.Name = "comboBoxProduct";
comboBoxProduct.Size = new Size(214, 23);
comboBoxProduct.TabIndex = 1;
//
// groupBox
//
groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox.Controls.Add(dataGridViewProductAssembly);
groupBox.Location = new Point(12, 86);
groupBox.Name = "groupBox";
groupBox.Size = new Size(299, 368);
groupBox.TabIndex = 2;
groupBox.TabStop = false;
groupBox.Text = "groupBox1";
//
// dataGridViewProductAssembly
//
dataGridViewProductAssembly.AllowUserToResizeColumns = false;
dataGridViewProductAssembly.AllowUserToResizeRows = false;
dataGridViewProductAssembly.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewProductAssembly.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewProductAssembly.Columns.AddRange(new DataGridViewColumn[] { ColumnProductType, ColumnCount });
dataGridViewProductAssembly.Dock = DockStyle.Fill;
dataGridViewProductAssembly.Location = new Point(3, 19);
dataGridViewProductAssembly.Name = "dataGridViewProductAssembly";
dataGridViewProductAssembly.RowHeadersVisible = false;
dataGridViewProductAssembly.Size = new Size(293, 346);
dataGridViewProductAssembly.TabIndex = 3;
//
// ColumnProductType
//
ColumnProductType.HeaderText = "Тип изделия";
ColumnProductType.Name = "ColumnProductType";
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.Name = "ColumnCount";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.Location = new Point(46, 476);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 3;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(204, 476);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 4;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormProductAssembly
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(348, 529);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBox);
Controls.Add(comboBoxProduct);
Controls.Add(labelProduct);
Name = "FormProductAssembly";
Text = "Сборка изделия";
groupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewProductAssembly).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelProduct;
private ComboBox comboBoxProduct;
private GroupBox groupBox;
private DataGridView dataGridViewProductAssembly;
private Button buttonSave;
private Button buttonCancel;
private DataGridViewComboBoxColumn ColumnProductType;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,74 @@
using ProjectWorkshop.Entities;
using ProjectWorkshop.Entities.Enums;
using ProjectWorkshop.Repositories;
using ProjectWorkshop.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectWorkshop.Forms
{
public partial class FormProductAssembly : Form
{
private readonly IProductAssemblyRepository _productAssemblyRepository;
public FormProductAssembly(IProductAssemblyRepository productAssemblyRepository, IProductRepository productRepository,
IAssemblyRepository assemblyRepository)
{
InitializeComponent();
_productAssemblyRepository = productAssemblyRepository ??
throw new ArgumentNullException(nameof(productAssemblyRepository));
comboBoxProduct.DataSource = productAssemblyRepository.ReadProductAssembly();
ColumnProductType.DataSource = assemblyRepository.ReadAssemblies();
ColumnProductType.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewProductAssembly.RowCount < 1 || comboBoxProduct.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_productAssemblyRepository.CreateProductAssembly(ProductAssembly.CreateOperation(0, (int)comboBoxProduct.SelectedValue!, 0,
CreateListAssemblyFromDataGrid()));
Close();
}
catch (Exception ex) {
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private List<Assembly> CreateListAssemblyFromDataGrid()
{
var list = new List<Assembly>();
foreach (DataGridViewRow row in dataGridViewProductAssembly.Rows)
{
if (row.Cells["ColumnFeed"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(Assembly.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnCount"].Value),
(ProductType)Convert.ToInt32(row.Cells["ColumnProductType"].Value)));
}
return list;
}
}
}

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="ColumnProductType.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,125 @@
namespace ProjectWorkshop.Forms
{
partial class FormProducts
{
/// <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()
{
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1 = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(28, 288);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(100, 86);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.pencil;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(28, 159);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(100, 86);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.plus;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(28, 25);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(100, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(646, 450);
dataGridView.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(646, 0);
panel1.Name = "panel1";
panel1.Size = new Size(154, 450);
panel1.TabIndex = 2;
//
// FormProducts
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormProducts";
Text = "Изделия";
Load += FormProducts_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
private Panel panel1;
}
}

View File

@ -0,0 +1,111 @@
using ProjectWorkshop.Repositories;
using ProjectWorkshop.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectWorkshop.Forms
{
public partial class FormProducts : Form
{
private readonly IUnityContainer _container;
private readonly IProductRepository _productRepository;
public FormProducts(IUnityContainer container, IProductRepository productRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_productRepository = productRepository ??
throw new ArgumentNullException(nameof(productRepository));
}
private void FormProducts_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<FormProduct>().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<FormProduct>();
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
{
_productRepository.DeleteProduct(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

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

@ -3,7 +3,7 @@ namespace ProjectWorkshop.Repositories;
public interface IAssemblerShiftRepository
{
IEnumerable<AssemblerShift> ReadProductAssembly(int? workHours = null, int? assemblerID = null, int? shiftID = null);
IEnumerable<AssemblerShift> ReadAssemblerShifts(int? workHours = null, int? assemblerID = null, int? shiftID = null);
void CreateAssemblerShift(AssemblerShift assemblerShift);

View File

@ -17,7 +17,7 @@ public class AssemblerShiftRepository : IAssemblerShiftRepository
{
}
public IEnumerable<AssemblerShift> ReadProductAssembly(int? workHours = null, int? assemblerID = null, int? shiftID = null)
public IEnumerable<AssemblerShift> ReadAssemblerShifts(int? workHours = null, int? assemblerID = null, int? shiftID = null)
{
return [];
}

View File

@ -1,4 +1,5 @@
using ProjectWorkshop.Entities;
using ProjectWorkshop.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@ -19,7 +20,7 @@ public class AssemblyRepository : IAssemblyRepository
public Assembly ReadAssemblyByID(int id)
{
return Assembly.CreateEntity(0, 0, string.Empty);
return Assembly.CreateElement(0, 0, 0);
}
public IEnumerable<Assembly> ReadAssemblies()