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

This commit is contained in:
Егор 2024-11-25 03:21:05 +04:00
parent 3271d2f326
commit 672ec3ddf8
30 changed files with 1249 additions and 69 deletions

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class Client
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public int Age { get; private set; }
public double Earnings { get; private set; }
public static Client CreateEntity(int id, string name, string address, int age, double earnings)
{
return new Client
{
Id = id,
Name = name ?? string.Empty,
Address = address ?? string.Empty,
Age = age,
Earnings = earnings
};
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class Delivery
{
public int Id { get; private set; }
public int WorkerId { get; private set; }
public string Status { get; private set; } = string.Empty;
public DateTime DateDelivery { get; private set; }
public IEnumerable<DeliveryProduct> DeliveryProducts { get; private set; } = [];
public static Delivery CreateOperation(int id, int workerId, string status, IEnumerable<DeliveryProduct> deliveryProducts)
{
return new Delivery
{
Id = id,
WorkerId = workerId,
Status = status,
DateDelivery = DateTime.Now,
DeliveryProducts = deliveryProducts
};
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class DeliveryProduct
{
public int Id { get; private set; }
public int ProductId { get; private set; }
public int DeliveryId { get; private set; }
public int Count { get; private set; }
public static DeliveryProduct CreateElement(int id, int productId, int deliveryId, int count)
{
return new DeliveryProduct
{
Id = id,
ProductId = productId,
DeliveryId = deliveryId,
Count = count
};
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities.Enums;
[Flags]
public enum Material
{
None = 0,
Wood = 1,
Stone = 2,
Glass = 4,
Metal = 8
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities.Enums;
public enum WorkerPost
{
None = 0,
Beginner = 1,
Advanced = 2,
Professional = 3
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class Invoice
{
public int Id { get; private set; }
public int WorkerId { get; private set; }
public int ClientId { get; private set; }
public int ProductId { get; private set; }
public DateTime Date { get; private set; }
public int CountProduct { get; private set; }
public static Invoice CreateOperation(int id, int workerId, int clientId, int productId, int countProduct)
{
return new Invoice
{
Id = id,
WorkerId = workerId,
ClientId = clientId,
ProductId = productId,
Date = DateTime.Now,
CountProduct = countProduct
};
}
}

View File

@ -0,0 +1,30 @@
using FurnitureCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class Product
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public Material Material { get; private set; }
public double Price { get; private set; }
public static Product CreateEntity(int id, Material material, string name, double price)
{
return new Product
{
Id = id,
Material = material,
Name = name ?? string.Empty,
Price = price
};
}
}

View File

@ -0,0 +1,30 @@
using FurnitureCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Entities;
public class Worker
{
public int Id { get; private set; }
public string Surname { get; private set; } = string.Empty;
public int Expirience { get; private set; }
public WorkerPost WorkerPost { get; private set; }
public static Worker CreateEntity(int id, string surname, int expirience, WorkerPost workerPost)
{
return new Worker
{
Id = id,
Surname = surname ?? string.Empty,
Expirience = expirience,
WorkerPost = workerPost
};
}
}

View File

@ -1,39 +0,0 @@
namespace FurnitureCompany
{
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

@ -0,0 +1,133 @@
namespace FurnitureCompany
{
partial class FormFurnitureCompany
{
/// <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()
{
menuStrip1 = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
работникиToolStripMenuItem = new ToolStripMenuItem();
клиентыToolStripMenuItem = new ToolStripMenuItem();
изделияToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
оформлениеЗаказаToolStripMenuItem = new ToolStripMenuItem();
доставкаToolStripMenuItem = new ToolStripMenuItem();
отчётыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(782, 28);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { работникиToolStripMenuItem, клиентыToolStripMenuItem, изделияToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// работникиToolStripMenuItem
//
работникиToolStripMenuItem.Name = "работникиToolStripMenuItem";
работникиToolStripMenuItem.Size = new Size(166, 26);
работникиToolStripMenuItem.Text = "Работники";
//
// клиентыToolStripMenuItem
//
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
клиентыToolStripMenuItem.Size = new Size(166, 26);
клиентыToolStripMenuItem.Text = "Клиенты";
//
// изделияToolStripMenuItem
//
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
изделияToolStripMenuItem.Size = new Size(166, 26);
изделияToolStripMenuItem.Text = "Изделия";
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { оформлениеЗаказаToolStripMenuItem, доставкаToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// оформлениеЗаказаToolStripMenuItem
//
оформлениеЗаказаToolStripMenuItem.Name = "оформлениеЗаказаToolStripMenuItem";
оформлениеЗаказаToolStripMenuItem.Size = new Size(233, 26);
оформлениеЗаказаToolStripMenuItem.Text = "Оформление заказа";
//
// доставкаToolStripMenuItem
//
доставкаToolStripMenuItem.Name = оставкаToolStripMenuItem";
доставкаToolStripMenuItem.Size = new Size(233, 26);
доставкаToolStripMenuItem.Text = "Доставка";
//
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(73, 24);
отчётыToolStripMenuItem.Text = "Отчёты";
//
// FormFurnitureCompany
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources._57435d62a4b6bbc87520597c0e8c4c3a;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(782, 403);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormFurnitureCompany";
StartPosition = FormStartPosition.CenterScreen;
Text = "Мебельная компания";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem работникиToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчётыToolStripMenuItem;
private ToolStripMenuItem оформлениеЗаказаToolStripMenuItem;
private ToolStripMenuItem доставкаToolStripMenuItem;
}
}

View File

@ -1,10 +1,11 @@
namespace FurnitureCompany
{
public partial class Form1 : Form
public partial class FormFurnitureCompany : Form
{
public Form1()
public FormFurnitureCompany()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,123 @@
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,172 @@
namespace FurnitureCompany.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()
{
labelClientName = new Label();
labelClientAddress = new Label();
labelClientAge = new Label();
textBoxClientName = new TextBox();
textBoxClientAddress = new TextBox();
labelClientEarnings = new Label();
numericUpDownClientEarnings = new NumericUpDown();
buttonSave = new Button();
buttonCancel = new Button();
numericUpDownClientAge = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDownClientEarnings).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownClientAge).BeginInit();
SuspendLayout();
//
// labelClientName
//
labelClientName.AutoSize = true;
labelClientName.Location = new Point(46, 34);
labelClientName.Name = "labelClientName";
labelClientName.Size = new Size(101, 20);
labelClientName.TabIndex = 0;
labelClientName.Text = "Имя клиента:";
//
// labelClientAddress
//
labelClientAddress.AutoSize = true;
labelClientAddress.Location = new Point(46, 95);
labelClientAddress.Name = "labelClientAddress";
labelClientAddress.Size = new Size(147, 20);
labelClientAddress.TabIndex = 1;
labelClientAddress.Text = "Адрес проживания:";
//
// labelClientAge
//
labelClientAge.AutoSize = true;
labelClientAge.Location = new Point(46, 160);
labelClientAge.Name = "labelClientAge";
labelClientAge.Size = new Size(67, 20);
labelClientAge.TabIndex = 2;
labelClientAge.Text = "Возраст:";
//
// textBoxClientName
//
textBoxClientName.Location = new Point(212, 31);
textBoxClientName.Name = "textBoxClientName";
textBoxClientName.Size = new Size(192, 27);
textBoxClientName.TabIndex = 3;
//
// textBoxClientAddress
//
textBoxClientAddress.Location = new Point(212, 92);
textBoxClientAddress.Name = "textBoxClientAddress";
textBoxClientAddress.Size = new Size(192, 27);
textBoxClientAddress.TabIndex = 4;
//
// labelClientEarnings
//
labelClientEarnings.AutoSize = true;
labelClientEarnings.Location = new Point(46, 223);
labelClientEarnings.Name = "labelClientEarnings";
labelClientEarnings.Size = new Size(71, 20);
labelClientEarnings.TabIndex = 6;
labelClientEarnings.Text = "Выручка:";
//
// numericUpDownClientEarnings
//
numericUpDownClientEarnings.DecimalPlaces = 2;
numericUpDownClientEarnings.Location = new Point(212, 221);
numericUpDownClientEarnings.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
numericUpDownClientEarnings.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDownClientEarnings.Name = "numericUpDownClientEarnings";
numericUpDownClientEarnings.Size = new Size(150, 27);
numericUpDownClientEarnings.TabIndex = 7;
numericUpDownClientEarnings.Value = new decimal(new int[] { 1, 0, 0, 131072 });
//
// buttonSave
//
buttonSave.Location = new Point(99, 300);
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(268, 300);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// numericUpDownClientAge
//
numericUpDownClientAge.Location = new Point(212, 158);
numericUpDownClientAge.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownClientAge.Name = "numericUpDownClientAge";
numericUpDownClientAge.Size = new Size(150, 27);
numericUpDownClientAge.TabIndex = 10;
numericUpDownClientAge.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(450, 365);
Controls.Add(numericUpDownClientAge);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownClientEarnings);
Controls.Add(labelClientEarnings);
Controls.Add(textBoxClientAddress);
Controls.Add(textBoxClientName);
Controls.Add(labelClientAge);
Controls.Add(labelClientAddress);
Controls.Add(labelClientName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиент";
((System.ComponentModel.ISupportInitialize)numericUpDownClientEarnings).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownClientAge).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelClientName;
private Label labelClientAddress;
private Label labelClientAge;
private TextBox textBoxClientName;
private TextBox textBoxClientAddress;
private Label labelClientEarnings;
private NumericUpDown numericUpDownClientEarnings;
private Button buttonSave;
private Button buttonCancel;
private NumericUpDown numericUpDownClientAge;
}
}

View File

@ -0,0 +1,88 @@
using FurnitureCompany.Entities;
using FurnitureCompany.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 FurnitureCompany.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));
}
textBoxClientName.Text = client.Name;
textBoxClientAddress.Text = client.Address;
numericUpDownClientAge.Value = client.Age;
numericUpDownClientEarnings.Value = (decimal)client.Earnings;
_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(textBoxClientName.Text) ||
string.IsNullOrWhiteSpace(textBoxClientAddress.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,
textBoxClientName.Text, textBoxClientAddress.Text,
Convert.ToInt32(numericUpDownClientAge.Value),
Convert.ToDouble(numericUpDownClientEarnings.Value));
}
}

View File

@ -8,4 +8,23 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</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>
</Project>

View File

@ -1,3 +1,7 @@
using FurnitureCompany.Repositories;
using FurnitureCompany.Repositories.Implementations;
using Unity;
namespace FurnitureCompany
{
internal static class Program
@ -11,7 +15,20 @@ namespace FurnitureCompany
// 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<FormFurnitureCompany>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IClientRepository, ClientRepository>();
container.RegisterType<IWorkerRepository, WorkerRepository>();
container.RegisterType<IProductRepository, ProductRepository>();
container.RegisterType<IInvoiceRepository, InvoiceRepository>();
container.RegisterType<IDeliveryRepository, DeliveryRepository>();
return container;
}
}
}

View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FurnitureCompany.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("FurnitureCompany.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;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _57435d62a4b6bbc87520597c0e8c4c3a {
get {
object obj = ResourceManager.GetObject("57435d62a4b6bbc87520597c0e8c4c3a", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?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.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="57435d62a4b6bbc87520597c0e8c4c3a" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\57435d62a4b6bbc87520597c0e8c4c3a.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,21 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories;
public interface IClientRepository
{
IEnumerable<Client> GetClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,18 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories;
public interface IDeliveryRepository
{
IEnumerable<Delivery> ReadDeliverys(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null,
int? workerId = null);
void CreateDelivery(Delivery delivery);
void DeleteDelivery(Delivery delivery);
}

View File

@ -0,0 +1,16 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories;
public interface IInvoiceRepository
{
IEnumerable<Invoice> ReadInvoices(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null,
int? workerId = null, int? clientId = null);
void CreateInvoice(Invoice invoice);
}

View File

@ -0,0 +1,21 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories;
public interface IProductRepository
{
IEnumerable<Product> ReadProducts();
Product ReadProductById(int id);
void CreateProduct(Product product);
void UpdateProduct(Product product);
void DeleteProduct(int id);
}

View File

@ -0,0 +1,21 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories;
public interface IWorkerRepository
{
IEnumerable<Worker> ReadWorkers();
Worker ReadWorkerById(int id);
void CreateWorker(Worker worker);
void UpdateWorker(Worker worker);
void DeleteWorker(int id);
}

View File

@ -0,0 +1,33 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories.Implementations;
public class ClientRepository : IClientRepository
{
public void CreateClient(Client client)
{
}
public void DeleteClient(int id)
{
}
public IEnumerable<Client> GetClients()
{
return[];
}
public Client ReadClientById(int id)
{
return Client.CreateEntity(0, string.Empty, string.Empty, 0, 0);
}
public void UpdateClient(Client client)
{
}
}

View File

@ -0,0 +1,24 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories.Implementations;
public class DeliveryRepository : IDeliveryRepository
{
public void CreateDelivery(Delivery delivery)
{
}
public void DeleteDelivery(Delivery delivery)
{
}
public IEnumerable<Delivery> ReadDeliverys(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? workerId = null)
{
return [];
}
}

View File

@ -0,0 +1,20 @@
using FurnitureCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories.Implementations;
public class InvoiceRepository : IInvoiceRepository
{
public void CreateInvoice(Invoice invoice)
{
}
public IEnumerable<Invoice> ReadInvoices(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? workerId = null, int? clientId = null)
{
return [];
}
}

View File

@ -0,0 +1,34 @@
using FurnitureCompany.Entities;
using FurnitureCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories.Implementations;
public class ProductRepository : IProductRepository
{
public void CreateProduct(Product product)
{
}
public void DeleteProduct(int id)
{
}
public Product ReadProductById(int id)
{
return Product.CreateEntity(0, Material.None, string.Empty, 0);
}
public IEnumerable<Product> ReadProducts()
{
return [];
}
public void UpdateProduct(Product product)
{
}
}

View File

@ -0,0 +1,34 @@
using FurnitureCompany.Entities;
using FurnitureCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureCompany.Repositories.Implementations;
public class WorkerRepository : IWorkerRepository
{
public void CreateWorker(Worker worker)
{
}
public void DeleteWorker(int id)
{
}
public Worker ReadWorkerById(int id)
{
return Worker.CreateEntity(0, string.Empty, 0, WorkerPost.None);
}
public IEnumerable<Worker> ReadWorkers()
{
return [];
}
public void UpdateWorker(Worker worker)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB