Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
55d1dc935f | |||
c8d6fef874 | |||
113cd58d30 | |||
ab5e73553b |
21
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Client.cs
Normal file
21
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Client.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class Client
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public static Client CreateClient(int id, string name)
|
||||
{
|
||||
return new Client
|
||||
{
|
||||
Id = id,
|
||||
Name = name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites.Enums;
|
||||
|
||||
public enum FrameMaterial
|
||||
{
|
||||
None = 0,
|
||||
Golden = 1,
|
||||
Titan = 2,
|
||||
Plastic = 3,
|
||||
Iron = 4
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites.Enums;
|
||||
|
||||
public enum OrderStatus
|
||||
{
|
||||
Canceled = 0,
|
||||
InProgress = 1,
|
||||
Ordered = 2
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum ProductType
|
||||
{
|
||||
None = 0,
|
||||
Case = 1,
|
||||
ContactLens = 2,
|
||||
GlassLens = 4,
|
||||
Frame = 8
|
||||
}
|
26
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Lens.cs
Normal file
26
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Lens.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class Lens
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public float Dioptres { get; private set; } = 0;
|
||||
|
||||
public float Astigmatism { get; private set; } = 0;
|
||||
|
||||
public static Lens CreateLens(int id, float dioptres, float astigmatism)
|
||||
{
|
||||
return new Lens
|
||||
{
|
||||
Id = id,
|
||||
Dioptres = dioptres,
|
||||
Astigmatism = astigmatism
|
||||
};
|
||||
}
|
||||
}
|
33
ProjectOpticsSalon/ProjectOpticsSalon/Entites/MakeOrder.cs
Normal file
33
ProjectOpticsSalon/ProjectOpticsSalon/Entites/MakeOrder.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class MakeOrder
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int Price { get; private set; } = 0;
|
||||
|
||||
public DateTime OrderDate { get; private set; }
|
||||
|
||||
public int ClientId { get; private set; }
|
||||
public OrderStatus OrderStatus { get; private set; }
|
||||
public IEnumerable<Order_Product> Products { get; private set; } = [];
|
||||
public static MakeOrder CreateOrder(int id, int price, int client, OrderStatus orderStatus, IEnumerable<Order_Product> products)
|
||||
{
|
||||
return new MakeOrder
|
||||
{
|
||||
Id = id,
|
||||
Price = price,
|
||||
OrderDate = DateTime.Now,
|
||||
ClientId = client,
|
||||
OrderStatus = orderStatus,
|
||||
Products = products
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class Order_Product
|
||||
{
|
||||
public int OrderId { get; private set; }
|
||||
public int ProductId { get; private set;}
|
||||
public static Order_Product CreateElement(int orderId, int productId)
|
||||
{
|
||||
return new Order_Product { OrderId = orderId, ProductId = productId };
|
||||
}
|
||||
}
|
28
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Product.cs
Normal file
28
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Product.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public ProductType ProductType { get; private set; }
|
||||
public FrameMaterial FrameMaterial { get; private set; } = 0;
|
||||
public int LeftLensId { get; private set; } = 0;
|
||||
public int RightLensId { get; private set; } = 0;
|
||||
public static Product CreateProduct(int id, ProductType productType, FrameMaterial frameMaterial, int leftLenseId, int rightLensId)
|
||||
{
|
||||
return new Product
|
||||
{
|
||||
Id = id,
|
||||
ProductType = productType,
|
||||
FrameMaterial = frameMaterial,
|
||||
LeftLensId = leftLenseId,
|
||||
RightLensId = rightLensId
|
||||
};
|
||||
}
|
||||
}
|
27
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Production.cs
Normal file
27
ProjectOpticsSalon/ProjectOpticsSalon/Entites/Production.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Entites;
|
||||
|
||||
public class Production
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public double ComponentsPrice { get; private set; }
|
||||
public double WorkPrice { get; private set; }
|
||||
public int ProductId { get; private set; }
|
||||
public DateTime Date { get; private set; }
|
||||
public static Production CreateProduction(int id, double componentsPrice, double workPrice, int productId)
|
||||
{
|
||||
return new Production
|
||||
{
|
||||
Id = id,
|
||||
ComponentsPrice = componentsPrice,
|
||||
WorkPrice = workPrice,
|
||||
ProductId = productId,
|
||||
Date = DateTime.Now
|
||||
};
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace ProjectOpticsSalon
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace ProjectOpticsSalon
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
168
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.Designer.cs
generated
Normal file
168
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.Designer.cs
generated
Normal file
@ -0,0 +1,168 @@
|
||||
namespace ProjectOpticsSalon
|
||||
{
|
||||
partial class FormOpticsSalon
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
menuStrip = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
productsToolStripMenuItem = new ToolStripMenuItem();
|
||||
lensesToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
orderToolStripMenuItem = new ToolStripMenuItem();
|
||||
productionToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
directoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётПоОперациямToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётПоПроизводстуToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 28);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsToolStripMenuItem, productsToolStripMenuItem, lensesToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// clientsToolStripMenuItem
|
||||
//
|
||||
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
clientsToolStripMenuItem.Size = new Size(152, 26);
|
||||
clientsToolStripMenuItem.Text = "Клиенты";
|
||||
clientsToolStripMenuItem.Click += clientsToolStripMenuItem_Click;
|
||||
//
|
||||
// productsToolStripMenuItem
|
||||
//
|
||||
productsToolStripMenuItem.Name = "productsToolStripMenuItem";
|
||||
productsToolStripMenuItem.Size = new Size(152, 26);
|
||||
productsToolStripMenuItem.Text = "Товары";
|
||||
productsToolStripMenuItem.Click += productsToolStripMenuItem_Click;
|
||||
//
|
||||
// lensesToolStripMenuItem
|
||||
//
|
||||
lensesToolStripMenuItem.Name = "lensesToolStripMenuItem";
|
||||
lensesToolStripMenuItem.Size = new Size(152, 26);
|
||||
lensesToolStripMenuItem.Text = "Линзы";
|
||||
lensesToolStripMenuItem.Click += lensesToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { orderToolStripMenuItem, productionToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// orderToolStripMenuItem
|
||||
//
|
||||
orderToolStripMenuItem.Name = "orderToolStripMenuItem";
|
||||
orderToolStripMenuItem.Size = new Size(192, 26);
|
||||
orderToolStripMenuItem.Text = "Заказ";
|
||||
orderToolStripMenuItem.Click += orderToolStripMenuItem_Click;
|
||||
//
|
||||
// productionToolStripMenuItem
|
||||
//
|
||||
productionToolStripMenuItem.Name = "productionToolStripMenuItem";
|
||||
productionToolStripMenuItem.Size = new Size(192, 26);
|
||||
productionToolStripMenuItem.Text = "Производство";
|
||||
productionToolStripMenuItem.Click += productionToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem, отчётПоОперациямToolStripMenuItem, отчётПоПроизводстуToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// directoryReportToolStripMenuItem
|
||||
//
|
||||
directoryReportToolStripMenuItem.Name = "directoryReportToolStripMenuItem";
|
||||
directoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
directoryReportToolStripMenuItem.Size = new Size(350, 26);
|
||||
directoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётПоОперациямToolStripMenuItem
|
||||
//
|
||||
отчётПоОперациямToolStripMenuItem.Name = "отчётПоОперациямToolStripMenuItem";
|
||||
отчётПоОперациямToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
отчётПоОперациямToolStripMenuItem.Size = new Size(350, 26);
|
||||
отчётПоОперациямToolStripMenuItem.Text = "Отчёт по операциям";
|
||||
отчётПоОперациямToolStripMenuItem.Click += отчётПоОперациямToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётПоПроизводстуToolStripMenuItem
|
||||
//
|
||||
отчётПоПроизводстуToolStripMenuItem.Name = "отчётПоПроизводстуToolStripMenuItem";
|
||||
отчётПоПроизводстуToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
отчётПоПроизводстуToolStripMenuItem.Size = new Size(350, 26);
|
||||
отчётПоПроизводстуToolStripMenuItem.Text = "Отчёт по производсту";
|
||||
отчётПоПроизводстуToolStripMenuItem.Click += отчётПоПроизводстуToolStripMenuItem_Click;
|
||||
//
|
||||
// FormOpticsSalon
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackgroundImage = Properties.Resources.OpticsSalon;
|
||||
BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormOpticsSalon";
|
||||
Text = "Салон оптики";
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
private ToolStripMenuItem productsToolStripMenuItem;
|
||||
private ToolStripMenuItem lensesToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem orderToolStripMenuItem;
|
||||
private ToolStripMenuItem productionToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётПоОперациямToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётПоПроизводстуToolStripMenuItem;
|
||||
}
|
||||
}
|
121
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.cs
Normal file
121
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System.ComponentModel;
|
||||
using ProjectOpticsSalon.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectOpticsSalon
|
||||
{
|
||||
public partial class FormOpticsSalon : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormOpticsSalon(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void clientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormClients>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void productsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormProducts>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void lensesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormLenses>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void orderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormOrders>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void productionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormProductions>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void directoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void îò÷¸òÏîÎïåðàöèÿìToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormOrderReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void îò÷¸òÏîÏðîèçâîäñòóToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormProductionReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.resx
Normal file
123
ProjectOpticsSalon/ProjectOpticsSalon/FormOpticsSalon.resx
Normal 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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
95
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClient.Designer.cs
generated
Normal file
95
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,95 @@
|
||||
namespace ProjectOpticsSalon.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()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxName = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(36, 50);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(45, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "ФИО:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(87, 47);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(172, 27);
|
||||
textBoxName.TabIndex = 1;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(36, 107);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 2;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(165, 107);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// FormClient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(285, 179);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormClient";
|
||||
Text = "Клиент";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private TextBox textBoxName;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
75
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClient.cs
Normal file
75
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClient.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
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 ProjectOpticsSalon.Forms;
|
||||
|
||||
public partial class FormClient : Form
|
||||
{
|
||||
public readonly IClientRepository _clientRepository;
|
||||
private int? _clientId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = _clientRepository.ReadClientById(value);
|
||||
if (client == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(client));
|
||||
}
|
||||
|
||||
textBoxName.Text = client.Name;
|
||||
_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(textBoxName.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.CreateClient(id,
|
||||
textBoxName.Text);
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.Designer.cs
generated
Normal file
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(612, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(166, 456);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.DeleteButton;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDel.Location = new Point(38, 234);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(94, 94);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.PenButton;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUpd.Location = new Point(38, 134);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(94, 94);
|
||||
buttonUpd.TabIndex = 1;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.PlusButton;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonAdd.Location = new Point(38, 34);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToDeleteRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(612, 456);
|
||||
dataGridViewData.TabIndex = 1;
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(778, 456);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormClients";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Клиенты";
|
||||
Load += FormClients_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridViewData;
|
||||
}
|
||||
}
|
107
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.cs
Normal file
107
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using ProjectOpticsSalon.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 ProjectOpticsSalon.Forms;
|
||||
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IClientRepository _clientRepository;
|
||||
public FormClients(IUnityContainer container, IClientRepository clientRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_clientRepository = clientRepository ??
|
||||
throw new ArgumentNullException(nameof(_clientRepository));
|
||||
}
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormClient>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormClient>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_clientRepository.DeleteClient(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewData.DataSource = _clientRepository.ReadClients();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewData.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormClients.resx
Normal 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>
|
99
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
99
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormDirectoryReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
checkBoxClients = new CheckBox();
|
||||
checkBoxLenses = new CheckBox();
|
||||
checkBoxProducts = new CheckBox();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxClients
|
||||
//
|
||||
checkBoxClients.AutoSize = true;
|
||||
checkBoxClients.Location = new Point(12, 12);
|
||||
checkBoxClients.Name = "checkBoxClients";
|
||||
checkBoxClients.Size = new Size(91, 24);
|
||||
checkBoxClients.TabIndex = 0;
|
||||
checkBoxClients.Text = "Клиенты";
|
||||
checkBoxClients.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxLenses
|
||||
//
|
||||
checkBoxLenses.AutoSize = true;
|
||||
checkBoxLenses.Location = new Point(12, 42);
|
||||
checkBoxLenses.Name = "checkBoxLenses";
|
||||
checkBoxLenses.Size = new Size(77, 24);
|
||||
checkBoxLenses.TabIndex = 1;
|
||||
checkBoxLenses.Text = "Линзы";
|
||||
checkBoxLenses.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxProducts
|
||||
//
|
||||
checkBoxProducts.AutoSize = true;
|
||||
checkBoxProducts.Location = new Point(12, 72);
|
||||
checkBoxProducts.Name = "checkBoxProducts";
|
||||
checkBoxProducts.Size = new Size(99, 24);
|
||||
checkBoxProducts.TabIndex = 2;
|
||||
checkBoxProducts.Text = "Продукты";
|
||||
checkBoxProducts.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(177, 39);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(125, 29);
|
||||
buttonBuild.TabIndex = 3;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += buttonBuild_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(314, 116);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(checkBoxProducts);
|
||||
Controls.Add(checkBoxLenses);
|
||||
Controls.Add(checkBoxClients);
|
||||
Name = "FormDirectoryReport";
|
||||
Text = "FormDirectoryReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxClients;
|
||||
private CheckBox checkBoxLenses;
|
||||
private CheckBox checkBoxProducts;
|
||||
private Button buttonBuild;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using ProjectOpticsSalon.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormDirectoryReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormDirectoryReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void buttonBuild_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!checkBoxClients.Checked && !checkBoxLenses.Checked && !checkBoxProducts.Checked)
|
||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Docx Files | *.docx"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
throw new Exception("Не выбран файла для отчета");
|
||||
|
||||
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxClients.Checked, checkBoxLenses.Checked, checkBoxProducts.Checked))
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
116
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.Designer.cs
generated
Normal file
116
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormLens
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label2 = new Label();
|
||||
maskedTextBoxDioptres = new MaskedTextBox();
|
||||
maskedTextBoxAstigmatism = new MaskedTextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(46, 93);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(99, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Астигматизм";
|
||||
//
|
||||
// maskedTextBoxDioptres
|
||||
//
|
||||
maskedTextBoxDioptres.Location = new Point(158, 32);
|
||||
maskedTextBoxDioptres.Name = "maskedTextBoxDioptres";
|
||||
maskedTextBoxDioptres.Size = new Size(156, 27);
|
||||
maskedTextBoxDioptres.TabIndex = 2;
|
||||
//
|
||||
// maskedTextBoxAstigmatism
|
||||
//
|
||||
maskedTextBoxAstigmatism.Location = new Point(158, 90);
|
||||
maskedTextBoxAstigmatism.Name = "maskedTextBoxAstigmatism";
|
||||
maskedTextBoxAstigmatism.Size = new Size(156, 27);
|
||||
maskedTextBoxAstigmatism.TabIndex = 3;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(46, 151);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(220, 151);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(46, 35);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(79, 20);
|
||||
label1.TabIndex = 6;
|
||||
label1.Text = "Диоптрии";
|
||||
//
|
||||
// FormLens
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(354, 219);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(maskedTextBoxAstigmatism);
|
||||
Controls.Add(maskedTextBoxDioptres);
|
||||
Controls.Add(label2);
|
||||
Name = "FormLens";
|
||||
Text = "Линза";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Label label2;
|
||||
private MaskedTextBox maskedTextBoxDioptres;
|
||||
private MaskedTextBox maskedTextBoxAstigmatism;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
81
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.cs
Normal file
81
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormLens : Form
|
||||
{
|
||||
public readonly ILensRepository _lensRepository;
|
||||
private int? _lensId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var lens = _lensRepository.ReadLensById(value);
|
||||
if (lens == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(lens));
|
||||
}
|
||||
|
||||
maskedTextBoxDioptres.Text = lens.Dioptres.ToString();
|
||||
maskedTextBoxAstigmatism.Text = lens.Astigmatism.ToString();
|
||||
_lensId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormLens(ILensRepository lensRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_lensRepository = lensRepository ?? throw new ArgumentNullException(nameof(lensRepository));
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(maskedTextBoxDioptres.Text) ||
|
||||
string.IsNullOrEmpty(maskedTextBoxAstigmatism.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_lensId.HasValue)
|
||||
{
|
||||
_lensRepository.UpdateLens(CreateLens(_lensId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_lensRepository.CreateLens(CreateLens(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private Lens CreateLens(int id) => Lens.CreateLens(id,
|
||||
(float)Convert.ToDouble(maskedTextBoxDioptres.Text), (float)Convert.ToDouble(maskedTextBoxAstigmatism.Text));
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLens.resx
Normal 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>
|
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.Designer.cs
generated
Normal file
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormLenses
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToDeleteRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(634, 450);
|
||||
dataGridViewData.TabIndex = 3;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(634, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(166, 450);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.DeleteButton;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDel.Location = new Point(38, 234);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(94, 94);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.PenButton;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUpd.Location = new Point(38, 134);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(94, 94);
|
||||
buttonUpd.TabIndex = 1;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.PlusButton;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonAdd.Location = new Point(38, 34);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormLenses
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormLenses";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Линзы";
|
||||
Load += FormLenses_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewData;
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button buttonDel;
|
||||
}
|
||||
}
|
112
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.cs
Normal file
112
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormLenses : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly ILensRepository _lensRepository;
|
||||
|
||||
public FormLenses(IUnityContainer container, ILensRepository lensRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_lensRepository = lensRepository ??
|
||||
throw new ArgumentNullException(nameof(_lensRepository));
|
||||
}
|
||||
|
||||
private void FormLenses_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<FormLens>().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<FormLens>();
|
||||
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
|
||||
{
|
||||
_lensRepository.DeleteLens(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewData.DataSource = _lensRepository.ReadLens();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewData.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormLenses.resx
Normal 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>
|
190
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.Designer.cs
generated
Normal file
190
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,190 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridViewData = new DataGridView();
|
||||
comboBoxClient = new ComboBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label2 = new Label();
|
||||
comboBoxStatus = new ComboBox();
|
||||
maskedTextBoxPrice = new MaskedTextBox();
|
||||
label3 = new Label();
|
||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(39, 25);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(58, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Клиент";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBox1.Controls.Add(dataGridViewData);
|
||||
groupBox1.Location = new Point(12, 147);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(276, 314);
|
||||
groupBox1.TabIndex = 2;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "groupBox1";
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct });
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(3, 23);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(270, 288);
|
||||
dataGridViewData.TabIndex = 0;
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(103, 22);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(151, 28);
|
||||
comboBoxClient.TabIndex = 3;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(191, 471);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonSave.Location = new Point(12, 471);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(39, 73);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(45, 20);
|
||||
label2.TabIndex = 8;
|
||||
label2.Text = "Цена";
|
||||
//
|
||||
// comboBoxStatus
|
||||
//
|
||||
comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStatus.FormattingEnabled = true;
|
||||
comboBoxStatus.Location = new Point(103, 113);
|
||||
comboBoxStatus.Name = "comboBoxStatus";
|
||||
comboBoxStatus.Size = new Size(151, 28);
|
||||
comboBoxStatus.TabIndex = 10;
|
||||
//
|
||||
// maskedTextBoxPrice
|
||||
//
|
||||
maskedTextBoxPrice.Location = new Point(103, 66);
|
||||
maskedTextBoxPrice.Name = "maskedTextBoxPrice";
|
||||
maskedTextBoxPrice.Size = new Size(151, 27);
|
||||
maskedTextBoxPrice.TabIndex = 9;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(39, 116);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(52, 20);
|
||||
label3.TabIndex = 11;
|
||||
label3.Text = "Статус";
|
||||
//
|
||||
// ColumnProduct
|
||||
//
|
||||
ColumnProduct.HeaderText = "Продукт";
|
||||
ColumnProduct.MinimumWidth = 6;
|
||||
ColumnProduct.Name = "ColumnProduct";
|
||||
ColumnProduct.Width = 125;
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(300, 512);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(comboBoxStatus);
|
||||
Controls.Add(maskedTextBoxPrice);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(label1);
|
||||
Name = "FormOrder";
|
||||
Text = "Заказ";
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private GroupBox groupBox1;
|
||||
private DataGridView dataGridViewData;
|
||||
private ComboBox comboBoxClient;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxStatus;
|
||||
private MaskedTextBox maskedTextBoxPrice;
|
||||
private Label label3;
|
||||
private DataGridViewComboBoxColumn ColumnProduct;
|
||||
}
|
||||
}
|
70
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.cs
Normal file
70
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.cs
Normal file
@ -0,0 +1,70 @@
|
||||
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 ProjectOpticsSalon.Entites;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
public FormOrder(IOrderRepository orderRepository, IProductRepository productRepository, IClientRepository clientRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_orderRepository = orderRepository ??
|
||||
throw new ArgumentNullException(nameof(_orderRepository));
|
||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||
comboBoxClient.DisplayMember = "Name";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
|
||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||
ColumnProduct.DisplayMember = "Id";
|
||||
ColumnProduct.ValueMember = "Id";
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(OrderStatus)))
|
||||
{
|
||||
comboBoxStatus.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewData.Rows.Count < 1 || comboBoxClient.SelectedIndex < 0 ||
|
||||
string.IsNullOrWhiteSpace(maskedTextBoxPrice.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
_orderRepository.CreateOrder(MakeOrder.CreateOrder(0, Convert.ToInt32(maskedTextBoxPrice.Text), (int)comboBoxClient.SelectedValue!,(OrderStatus)comboBoxStatus.SelectedItem!, CreateListProducts()));
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<Order_Product> CreateListProducts()
|
||||
{
|
||||
var list = new List<Order_Product>();
|
||||
foreach (DataGridViewRow row in dataGridViewData.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnProduct"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
list.Add(Order_Product.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
123
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.resx
Normal file
123
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrder.resx
Normal 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="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
163
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrderReport.Designer.cs
generated
Normal file
163
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrderReport.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormOrderReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBoxFilePath = new TextBox();
|
||||
label1 = new Label();
|
||||
buttonSelectFilePath = new Button();
|
||||
label2 = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
label4 = new Label();
|
||||
label3 = new Label();
|
||||
dateTimePickerEndDate = new DateTimePicker();
|
||||
dateTimePickerStartDate = new DateTimePicker();
|
||||
buttonMakeReport = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(167, 31);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(125, 27);
|
||||
textBoxFilePath.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 34);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(109, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Сохранить как";
|
||||
//
|
||||
// buttonSelectFilePath
|
||||
//
|
||||
buttonSelectFilePath.Location = new Point(298, 31);
|
||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||
buttonSelectFilePath.Size = new Size(31, 29);
|
||||
buttonSelectFilePath.TabIndex = 2;
|
||||
buttonSelectFilePath.Text = "..";
|
||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
buttonSelectFilePath.Click += buttonSelectFilePath_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 87);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 20);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "Клиент";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(167, 79);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(151, 28);
|
||||
comboBoxClient.TabIndex = 4;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(18, 184);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(87, 20);
|
||||
label4.TabIndex = 13;
|
||||
label4.Text = "Дата конца";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(18, 133);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(94, 20);
|
||||
label3.TabIndex = 12;
|
||||
label3.Text = "Дата начала";
|
||||
//
|
||||
// dateTimePickerEndDate
|
||||
//
|
||||
dateTimePickerEndDate.Location = new Point(133, 179);
|
||||
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
||||
dateTimePickerEndDate.Size = new Size(185, 27);
|
||||
dateTimePickerEndDate.TabIndex = 11;
|
||||
//
|
||||
// dateTimePickerStartDate
|
||||
//
|
||||
dateTimePickerStartDate.Location = new Point(133, 128);
|
||||
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
||||
dateTimePickerStartDate.Size = new Size(185, 27);
|
||||
dateTimePickerStartDate.TabIndex = 10;
|
||||
//
|
||||
// buttonMakeReport
|
||||
//
|
||||
buttonMakeReport.Location = new Point(99, 233);
|
||||
buttonMakeReport.Name = "buttonMakeReport";
|
||||
buttonMakeReport.Size = new Size(129, 29);
|
||||
buttonMakeReport.TabIndex = 14;
|
||||
buttonMakeReport.Text = "Сформировать";
|
||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||
buttonMakeReport.Click += buttonMakeReport_Click;
|
||||
//
|
||||
// FormOrderReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(377, 295);
|
||||
Controls.Add(buttonMakeReport);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(dateTimePickerEndDate);
|
||||
Controls.Add(dateTimePickerStartDate);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonSelectFilePath);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Name = "FormOrderReport";
|
||||
Text = "FormOrderReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxFilePath;
|
||||
private Label label1;
|
||||
private Button buttonSelectFilePath;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxClient;
|
||||
private Label label4;
|
||||
private Label label3;
|
||||
private DateTimePicker dateTimePickerEndDate;
|
||||
private DateTimePicker dateTimePickerStartDate;
|
||||
private Button buttonMakeReport;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Reports;
|
||||
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormOrderReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormOrderReport(IUnityContainer container, IClientRepository client)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
|
||||
comboBoxClient.DataSource = client.ReadClients();
|
||||
comboBoxClient.DisplayMember = "Name";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonSelectFilePath_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files | *.xlsx"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
textBoxFilePath.Text = sfd.FileName;
|
||||
}
|
||||
|
||||
private void buttonMakeReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
|
||||
if (comboBoxClient.SelectedIndex < 0 || comboBoxClient.SelectedIndex < 0)
|
||||
throw new Exception("Не выбран клиент");
|
||||
|
||||
if (dateTimePickerEndDate.Value <= dateTimePickerStartDate.Value)
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxClient.SelectedValue!, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value))
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrderReport.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrderReport.resx
Normal 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>
|
99
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.Designer.cs
generated
Normal file
99
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormOrders
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToDeleteRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(634, 450);
|
||||
dataGridViewData.TabIndex = 3;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(634, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(166, 450);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.PlusButton;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonAdd.Location = new Point(38, 34);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormOrders";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заказы";
|
||||
Load += FormOrders_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewData;
|
||||
private Panel panel1;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
59
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.cs
Normal file
59
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using ProjectOpticsSalon.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 ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormOrders : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
|
||||
_orderRepository = orderRepository ??
|
||||
throw new ArgumentNullException(nameof(orderRepository));
|
||||
}
|
||||
|
||||
private void FormOrders_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormOrder>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewData.DataSource = _orderRepository.ReadOrder();
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormOrders.resx
Normal 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>
|
168
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.Designer.cs
generated
Normal file
168
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.Designer.cs
generated
Normal file
@ -0,0 +1,168 @@
|
||||
namespace ProjectOpticsSalon.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()
|
||||
{
|
||||
comboBoxFrameMaterial = new ComboBox();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
checkedListBoxProductType = new CheckedListBox();
|
||||
comboBoxLeftLens = new ComboBox();
|
||||
comboBoxRightLens = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxFrameMaterial
|
||||
//
|
||||
comboBoxFrameMaterial.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxFrameMaterial.FormattingEnabled = true;
|
||||
comboBoxFrameMaterial.Location = new Point(166, 109);
|
||||
comboBoxFrameMaterial.Name = "comboBoxFrameMaterial";
|
||||
comboBoxFrameMaterial.Size = new Size(148, 28);
|
||||
comboBoxFrameMaterial.TabIndex = 0;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 9);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(109, 20);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Тип продукта: ";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 112);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(128, 20);
|
||||
label3.TabIndex = 3;
|
||||
label3.Text = "Материал рамы: ";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(12, 168);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(125, 20);
|
||||
label4.TabIndex = 4;
|
||||
label4.Text = "ID левой линзы: ";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(12, 221);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(135, 20);
|
||||
label5.TabIndex = 5;
|
||||
label5.Text = "ID правой линзы: ";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(12, 283);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(125, 29);
|
||||
buttonSave.TabIndex = 10;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(189, 283);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(125, 29);
|
||||
buttonCancel.TabIndex = 11;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// checkedListBoxProductType
|
||||
//
|
||||
checkedListBoxProductType.FormattingEnabled = true;
|
||||
checkedListBoxProductType.Location = new Point(166, 9);
|
||||
checkedListBoxProductType.Name = "checkedListBoxProductType";
|
||||
checkedListBoxProductType.Size = new Size(148, 92);
|
||||
checkedListBoxProductType.TabIndex = 12;
|
||||
//
|
||||
// comboBoxLeftLens
|
||||
//
|
||||
comboBoxLeftLens.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxLeftLens.FormattingEnabled = true;
|
||||
comboBoxLeftLens.Location = new Point(166, 165);
|
||||
comboBoxLeftLens.Name = "comboBoxLeftLens";
|
||||
comboBoxLeftLens.Size = new Size(148, 28);
|
||||
comboBoxLeftLens.TabIndex = 13;
|
||||
//
|
||||
// comboBoxRightLens
|
||||
//
|
||||
comboBoxRightLens.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRightLens.FormattingEnabled = true;
|
||||
comboBoxRightLens.Location = new Point(166, 218);
|
||||
comboBoxRightLens.Name = "comboBoxRightLens";
|
||||
comboBoxRightLens.Size = new Size(148, 28);
|
||||
comboBoxRightLens.TabIndex = 14;
|
||||
//
|
||||
// FormProduct
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(328, 338);
|
||||
Controls.Add(comboBoxRightLens);
|
||||
Controls.Add(comboBoxLeftLens);
|
||||
Controls.Add(checkedListBoxProductType);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(comboBoxFrameMaterial);
|
||||
Name = "FormProduct";
|
||||
Text = "Продукт";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxFrameMaterial;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private CheckedListBox checkedListBoxProductType;
|
||||
private ComboBox comboBoxLeftLens;
|
||||
private ComboBox comboBoxRightLens;
|
||||
}
|
||||
}
|
116
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.cs
Normal file
116
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormProduct : Form
|
||||
{
|
||||
public readonly IProductRepository _productRepository;
|
||||
private int? _productId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var product = _productRepository.ReadProductById(value);
|
||||
if (product == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(product));
|
||||
}
|
||||
|
||||
foreach (ProductType elem in Enum.GetValues(typeof(ProductType))) {
|
||||
if ((elem & product.ProductType) != 0)
|
||||
{
|
||||
checkedListBoxProductType.SetItemChecked(checkedListBoxProductType.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
|
||||
comboBoxFrameMaterial.SelectedItem = product.FrameMaterial;
|
||||
comboBoxLeftLens.SelectedValue = product.LeftLensId;
|
||||
comboBoxRightLens.SelectedValue = product.RightLensId;
|
||||
_productId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormProduct(IProductRepository productRepository, ILensRepository lensRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(ProductType)))
|
||||
{
|
||||
checkedListBoxProductType.Items.Add(elem);
|
||||
}
|
||||
|
||||
comboBoxLeftLens.DataSource = lensRepository.ReadLens();
|
||||
comboBoxLeftLens.DisplayMember = "Id";
|
||||
comboBoxLeftLens.ValueMember = "Id";
|
||||
|
||||
comboBoxRightLens.DataSource = lensRepository.ReadLens();
|
||||
comboBoxRightLens.DisplayMember= "Id";
|
||||
comboBoxRightLens.ValueMember = "Id";
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(FrameMaterial)))
|
||||
{
|
||||
comboBoxFrameMaterial.Items.Add(elem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxLeftLens.SelectedIndex < 0 ||
|
||||
comboBoxRightLens.SelectedIndex < 0 ||
|
||||
checkedListBoxProductType.CheckedItems.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_productId.HasValue)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
ProductType productType = ProductType.None;
|
||||
foreach (var elem in checkedListBoxProductType.CheckedItems)
|
||||
{
|
||||
productType |= (ProductType)elem;
|
||||
}
|
||||
return Product.CreateProduct(id, productType, (FrameMaterial)comboBoxFrameMaterial.SelectedItem!, (int)comboBoxLeftLens.SelectedValue!, (int)comboBoxRightLens.SelectedValue!);
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduct.resx
Normal 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>
|
141
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduction.Designer.cs
generated
Normal file
141
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduction.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormProduction
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
maskedTextBoxComponentsPrice = new MaskedTextBox();
|
||||
maskedTextBoxWorkPrice = new MaskedTextBox();
|
||||
comboBoxProduct = new ComboBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(84, 120);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(101, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Цена работы";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(84, 60);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(143, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Цена компонентов";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(84, 185);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(83, 20);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "ID продукт";
|
||||
//
|
||||
// maskedTextBoxComponentsPrice
|
||||
//
|
||||
maskedTextBoxComponentsPrice.Location = new Point(260, 57);
|
||||
maskedTextBoxComponentsPrice.Name = "maskedTextBoxComponentsPrice";
|
||||
maskedTextBoxComponentsPrice.Size = new Size(151, 27);
|
||||
maskedTextBoxComponentsPrice.TabIndex = 3;
|
||||
//
|
||||
// maskedTextBoxWorkPrice
|
||||
//
|
||||
maskedTextBoxWorkPrice.Location = new Point(260, 117);
|
||||
maskedTextBoxWorkPrice.Name = "maskedTextBoxWorkPrice";
|
||||
maskedTextBoxWorkPrice.Size = new Size(151, 27);
|
||||
maskedTextBoxWorkPrice.TabIndex = 4;
|
||||
//
|
||||
// comboBoxProduct
|
||||
//
|
||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxProduct.FormattingEnabled = true;
|
||||
comboBoxProduct.Location = new Point(260, 182);
|
||||
comboBoxProduct.Name = "comboBoxProduct";
|
||||
comboBoxProduct.Size = new Size(151, 28);
|
||||
comboBoxProduct.TabIndex = 5;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(317, 259);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(84, 259);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// FormProduction
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(457, 338);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxProduct);
|
||||
Controls.Add(maskedTextBoxWorkPrice);
|
||||
Controls.Add(maskedTextBoxComponentsPrice);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormProduction";
|
||||
Text = "Производство";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private MaskedTextBox maskedTextBoxComponentsPrice;
|
||||
private MaskedTextBox maskedTextBoxWorkPrice;
|
||||
private ComboBox comboBoxProduct;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormProduction : Form
|
||||
{
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
private int? _productionId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var production = _productionRepository.ReadProductionById(value);
|
||||
if (production == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(production));
|
||||
}
|
||||
|
||||
maskedTextBoxComponentsPrice.Text = production.ComponentsPrice.ToString();
|
||||
maskedTextBoxWorkPrice.Text = production.WorkPrice.ToString();
|
||||
comboBoxProduct.SelectedValue = production.ProductId;
|
||||
|
||||
_productionId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormProduction(IProductionRepository productionRepository, IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productionRepository = productionRepository ?? throw new ArgumentNullException(nameof(productionRepository));
|
||||
comboBoxProduct.DataSource = productRepository.ReadProducts();
|
||||
comboBoxProduct.DisplayMember = "Id";
|
||||
comboBoxProduct.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(maskedTextBoxComponentsPrice.Text) ||
|
||||
string.IsNullOrWhiteSpace(maskedTextBoxWorkPrice.Text) ||
|
||||
comboBoxProduct.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_productionRepository.CreateProduction(Production.CreateProduction(0, Convert.ToDouble(maskedTextBoxComponentsPrice.Text), Convert.ToDouble(maskedTextBoxWorkPrice.Text), (int)comboBoxProduct.SelectedValue!));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduction.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProduction.resx
Normal 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>
|
107
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductionReport.Designer.cs
generated
Normal file
107
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductionReport.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormProductionReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonSelectFileName = new Button();
|
||||
label1 = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonCreate = new Button();
|
||||
labelFileName = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSelectFileName
|
||||
//
|
||||
buttonSelectFileName.Location = new Point(12, 30);
|
||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||
buttonSelectFileName.Size = new Size(146, 29);
|
||||
buttonSelectFileName.TabIndex = 0;
|
||||
buttonSelectFileName.Text = "Выбрать файл";
|
||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||
buttonSelectFileName.Click += buttonSelectFileName_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 83);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(41, 20);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Дата";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(59, 78);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(210, 27);
|
||||
dateTimePicker.TabIndex = 2;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(59, 133);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(139, 29);
|
||||
buttonCreate.TabIndex = 3;
|
||||
buttonCreate.Text = "Сформировать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(232, 34);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(45, 20);
|
||||
labelFileName.TabIndex = 4;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// FormProductionReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(447, 192);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonSelectFileName);
|
||||
Name = "FormProductionReport";
|
||||
Text = "FormProductionReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSelectFileName;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonCreate;
|
||||
private Label labelFileName;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using ProjectOpticsSalon.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormProductionReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
public FormProductionReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void buttonSelectFileName_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Pdf Files | *.pdf"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_fileName = sfd.FileName;
|
||||
labelFileName.Text = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_fileName))
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
|
||||
if
|
||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
113
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductions.Designer.cs
generated
Normal file
113
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductions.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace ProjectOpticsSalon.Forms
|
||||
{
|
||||
partial class FormProductions
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToDeleteRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(634, 450);
|
||||
dataGridViewData.TabIndex = 5;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(634, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(166, 450);
|
||||
panel1.TabIndex = 4;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.PenButton;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUpd.Location = new Point(38, 134);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(94, 94);
|
||||
buttonUpd.TabIndex = 1;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.PlusButton;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonAdd.Location = new Point(38, 34);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormProductions
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormProductions";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Производства";
|
||||
Load += Productions_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewData;
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 ProjectOpticsSalon.Forms
|
||||
{
|
||||
public partial class FormProductions : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
public FormProductions(IUnityContainer container, IProductionRepository productionRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_productionRepository = productionRepository ??
|
||||
throw new ArgumentNullException(nameof(_productionRepository));
|
||||
}
|
||||
|
||||
private void Productions_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<FormProduction>().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<FormProduction>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewData.DataSource = _productionRepository.ReadProduction();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewData.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductions.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProductions.resx
Normal 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>
|
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.Designer.cs
generated
Normal file
127
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
namespace ProjectOpticsSalon.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()
|
||||
{
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToDeleteRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.RowHeadersWidth = 51;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(634, 450);
|
||||
dataGridViewData.TabIndex = 3;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(634, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(166, 450);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.DeleteButton;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDel.Location = new Point(38, 234);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(94, 94);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.PenButton;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUpd.Location = new Point(38, 134);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(94, 94);
|
||||
buttonUpd.TabIndex = 1;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.PlusButton;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonAdd.Location = new Point(38, 34);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormProducts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormProducts";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Продукты";
|
||||
Load += FormProducts_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridViewData;
|
||||
private Panel panel1;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
112
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.cs
Normal file
112
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
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 ProjectOpticsSalon.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() => dataGridViewData.DataSource = _productRepository.ReadProducts();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewData.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.resx
Normal file
120
ProjectOpticsSalon/ProjectOpticsSalon/Forms/FormProducts.resx
Normal 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>
|
@ -1,3 +1,11 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
using Serilog;
|
||||
using Unity;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
namespace ProjectOpticsSalon
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +19,33 @@ namespace ProjectOpticsSalon
|
||||
// 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<FormOpticsSalon>());
|
||||
}
|
||||
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
|
||||
container.RegisterType<IClientRepository, ClientRepository>();
|
||||
container.RegisterType<ILensRepository, LensRepository>();
|
||||
container.RegisterType<IOrderRepository, OrderRepository>();
|
||||
container.RegisterType<IProductionRepository, ProductionRepository>();
|
||||
container.RegisterType<IProductRepository, ProductRepository>();
|
||||
container.RegisterType<IConnectionString, ConnectionString>();
|
||||
return container;
|
||||
}
|
||||
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,44 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
103
ProjectOpticsSalon/ProjectOpticsSalon/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectOpticsSalon/ProjectOpticsSalon/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectOpticsSalon.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("ProjectOpticsSalon.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 DeleteButton {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("DeleteButton", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap OpticsSalon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("OpticsSalon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap PenButton {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("PenButton", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap PlusButton {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("PlusButton", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectOpticsSalon/ProjectOpticsSalon/Properties/Resources.resx
Normal file
133
ProjectOpticsSalon/ProjectOpticsSalon/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?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="OpticsSalon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpticsSalon.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="PenButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\PenButton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="PlusButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\PlusButton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DeleteButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\DeleteButton.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
56
ProjectOpticsSalon/ProjectOpticsSalon/Reports/ChartReport.cs
Normal file
56
ProjectOpticsSalon/ProjectOpticsSalon/Reports/ChartReport.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IProductionRepository productionRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_productionRepository = productionRepository ?? throw new ArgumentNullException(nameof(productionRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateChart(string filePath, DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Отчет по производству")
|
||||
.AddPieChart($"Стоимость производства {dateTime: dd MMMM yyyy}", GetData(dateTime))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании отчета");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
{
|
||||
return _productionRepository
|
||||
.ReadProduction()
|
||||
.Where(x => x.Date.Date == dateTime.Date)
|
||||
.GroupBy(
|
||||
x => x.Id,
|
||||
(key, group) => new
|
||||
{
|
||||
Id = key,
|
||||
TotalPrice = group.Sum(y => y.WorkPrice+y.ComponentsPrice)
|
||||
})
|
||||
.Select(x => ($"{x.Id}", (double)x.TotalPrice))
|
||||
.ToList();
|
||||
}
|
||||
}
|
82
ProjectOpticsSalon/ProjectOpticsSalon/Reports/DocReport.cs
Normal file
82
ProjectOpticsSalon/ProjectOpticsSalon/Reports/DocReport.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class DocReport
|
||||
{
|
||||
private readonly IClientRepository _clientRepository;
|
||||
private readonly ILensRepository _lensRepository;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(IClientRepository clientRepository, ILensRepository lensRepository, IProductRepository productRepository, ILogger<DocReport> logger)
|
||||
{
|
||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
||||
_lensRepository = lensRepository ?? throw new ArgumentNullException(nameof(lensRepository));
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeClients, bool includeLenses, bool includeProducts)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||
if (includeClients)
|
||||
builder.AddParagraph("Клиенты").AddTable([2400], GetClients());
|
||||
|
||||
if (includeLenses)
|
||||
builder.AddParagraph("Линзы").AddTable([2400, 2400], GetLenses());
|
||||
|
||||
if (includeProducts)
|
||||
builder.AddParagraph("Продукты").AddTable([2400, 2400, 1200, 1200], GetProducts());
|
||||
|
||||
builder.Build();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetClients()
|
||||
{
|
||||
return [
|
||||
["Имя клиента"],
|
||||
.. _clientRepository
|
||||
.ReadClients()
|
||||
.Select(x => new string[] { x.Name}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetLenses()
|
||||
{
|
||||
return [
|
||||
["Диоптрии", "Астигматизм"],
|
||||
.. _lensRepository
|
||||
.ReadLens()
|
||||
.Select(x => new string[] { x.Dioptres.ToString(), x.Astigmatism.ToString()}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetProducts()
|
||||
{
|
||||
return [
|
||||
["Тип продукта", "Материал рамы", "ID левой линзы", "ID правой линзы"],
|
||||
.. _productRepository
|
||||
.ReadProducts()
|
||||
.Select(x => new string[] { x.ProductType.ToString(), x.FrameMaterial.ToString(), x.LeftLensId.ToString(), x.RightLensId.ToString() }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
312
ProjectOpticsSalon/ProjectOpticsSalon/Reports/ExcelBuilder.cs
Normal file
312
ProjectOpticsSalon/ProjectOpticsSalon/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,312 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class ExcelBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
|
||||
private readonly SheetData _sheetData;
|
||||
|
||||
private readonly MergeCells _mergeCells;
|
||||
|
||||
private readonly Columns _columns;
|
||||
|
||||
private uint _rowIndex = 0;
|
||||
|
||||
public ExcelBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
_filePath = filePath;
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||
});
|
||||
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
|
||||
if (data == null || data.Count == 0)
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
|
||||
_rowIndex++;
|
||||
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
|
||||
_rowIndex++;
|
||||
}
|
||||
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
|
||||
if (_columns.HasChildren)
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
|
||||
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
|
||||
sheets.Append(sheet);
|
||||
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts() { Count = 2, KnownFonts = BooleanValue.FromBoolean(true) };
|
||||
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) }
|
||||
});
|
||||
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) },
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill() { PatternType = new EnumValue<PatternValues>(PatternValues.None) }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Right,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
|
||||
}
|
||||
|
||||
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null && cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
|
||||
}
|
90
ProjectOpticsSalon/ProjectOpticsSalon/Reports/PdfBuilder.cs
Normal file
90
ProjectOpticsSalon/ProjectOpticsSalon/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class PdfBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
|
||||
private readonly Document _document;
|
||||
|
||||
public PdfBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
|
||||
public PdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
return this;
|
||||
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
|
||||
chart.TopArea.AddParagraph(title);
|
||||
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
|
||||
chart.TopArea.AddLegend();
|
||||
|
||||
_document.LastSection.Add(chart);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(_filePath);
|
||||
}
|
||||
private void DefineStyles()
|
||||
{
|
||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
81
ProjectOpticsSalon/ProjectOpticsSalon/Reports/TableReport.cs
Normal file
81
ProjectOpticsSalon/ProjectOpticsSalon/Reports/TableReport.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectOpticsSalon.Entites.Enums;
|
||||
using ProjectOpticsSalon.Repositories.Implementations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class TableReport
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
private readonly IClientRepository _clientRepository;
|
||||
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] item = ["Клиент", "Дата", "Цена", "Доставлен"];
|
||||
|
||||
public TableReport(IOrderRepository orderRepository, IProductionRepository productionRepository, IClientRepository clientRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
_productionRepository = productionRepository ?? throw new ArgumentNullException(nameof(productionRepository));
|
||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int lensId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по заказам", 0, 4)
|
||||
.AddParagraph($"за период с {startDate:dd.MM.yyyy} по {endDate:dd.MM.yyyy}", 0)
|
||||
.AddTable([10, 10, 15, 15], GetData(lensId, startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int clientId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var client = _clientRepository.ReadClientById(clientId);
|
||||
var orders = _orderRepository
|
||||
.ReadOrder()
|
||||
.Where(x => x.OrderDate >= startDate && x.OrderDate <= endDate && x.ClientId == clientId && x.OrderStatus == OrderStatus.Ordered)
|
||||
.Select(x => new {client.Name, x.OrderDate, Price = (int?)x.Price, CountOrdered = (int?)1})
|
||||
.ToList();
|
||||
|
||||
_logger.LogDebug("Объединённые данные в отчёт: {json}", JsonConvert.SerializeObject(orders));
|
||||
return new List<string[]> { item }
|
||||
.Union(orders.Select(x => new string[]
|
||||
{
|
||||
client.Name,
|
||||
x.OrderDate.ToString("dd.MM.yyyy"),
|
||||
x.Price.ToString() ?? string.Empty,
|
||||
x.CountOrdered.ToString() ?? string.Empty
|
||||
}))
|
||||
.Union(new[]
|
||||
{
|
||||
new string[]
|
||||
{
|
||||
"Всего",
|
||||
string.Empty,
|
||||
|
||||
orders.Sum(x => x.Price ?? 0).ToString(),
|
||||
orders.Sum(x => x.CountOrdered ?? 0).ToString(),
|
||||
}
|
||||
}).ToList();
|
||||
}
|
||||
}
|
104
ProjectOpticsSalon/ProjectOpticsSalon/Reports/WordBuilder.cs
Normal file
104
ProjectOpticsSalon/ProjectOpticsSalon/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
|
||||
namespace ProjectOpticsSalon.Reports;
|
||||
|
||||
public class WordBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
private readonly Body _body;
|
||||
|
||||
public WordBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
_body = _document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
public WordBuilder AddHeader(string header)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
|
||||
var runProperties = run.AppendChild(new RunProperties());
|
||||
runProperties.AppendChild(new Bold());
|
||||
|
||||
run.AppendChild(new Text(header));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddParagraph(string text)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
|
||||
var runProperties = run.AppendChild(new RunProperties());
|
||||
runProperties.AppendChild(new Bold());
|
||||
|
||||
run.AppendChild(new Text(text));
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||
{
|
||||
if (widths == null || widths.Length == 0)
|
||||
throw new ArgumentNullException(nameof(widths));
|
||||
|
||||
if (data == null || data.Count == 0)
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
|
||||
if (data.Any(x => x.Length != widths.Length))
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
|
||||
var table = new Table();
|
||||
table.AppendChild(new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 })));
|
||||
|
||||
var tr = new TableRow();
|
||||
for (var j = 0; j < widths.Length; ++j)
|
||||
{
|
||||
tr.Append(new TableCell(
|
||||
new TableCellProperties(new TableCellWidth() { Width = widths[j].ToString() }),
|
||||
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||
}
|
||||
table.Append(tr);
|
||||
|
||||
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||
|
||||
_body.Append(table);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
|
||||
var mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = _document;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories;
|
||||
|
||||
public interface IClientRepository
|
||||
{
|
||||
IEnumerable<Client> ReadClients();
|
||||
Client ReadClientById(int id);
|
||||
void CreateClient(Client client);
|
||||
void UpdateClient(Client client);
|
||||
void DeleteClient(int id);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories
|
||||
{
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get;}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories;
|
||||
|
||||
public interface ILensRepository
|
||||
{
|
||||
IEnumerable<Lens> ReadLens();
|
||||
Lens ReadLensById(int id);
|
||||
void CreateLens(Lens lens);
|
||||
void UpdateLens(Lens lens);
|
||||
void DeleteLens(int id);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories;
|
||||
|
||||
public interface IOrderRepository
|
||||
{
|
||||
IEnumerable<MakeOrder> ReadOrder();
|
||||
void CreateOrder(MakeOrder order);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories;
|
||||
|
||||
public interface IProductRepository
|
||||
{
|
||||
IEnumerable<Product> ReadProducts();
|
||||
Product ReadProductById(int id);
|
||||
void CreateProduct(Product product);
|
||||
void UpdateProduct(Product product);
|
||||
void DeleteProduct(int id);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories;
|
||||
|
||||
public interface IProductionRepository
|
||||
{
|
||||
IEnumerable<Production> ReadProduction();
|
||||
Production ReadProductionById(int id);
|
||||
void CreateProduction(Production production);
|
||||
void UpdateProduction(Production production);
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
public class ClientRepository : IClientRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<ClientRepository> _logger;
|
||||
public ClientRepository(IConnectionString connectionString, ILogger<ClientRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateClient(Client client)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Client (Name) VALUES (@Name)";
|
||||
connection.Execute(queryInsert, client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteClient(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Client
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Client ReadClientById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Client
|
||||
WHERE Id=@id";
|
||||
var client = connection.QueryFirst<Client>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(client));
|
||||
return client;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Client> ReadClients()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Client";
|
||||
var clients = connection.Query<Client>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(clients));
|
||||
return clients;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateClient(Client client)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Client
|
||||
SET
|
||||
Name=@Name
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, client);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
internal class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=opticssalon";
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
public class LensRepository : ILensRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<LensRepository> _logger;
|
||||
|
||||
public LensRepository(IConnectionString connectionString, ILogger<LensRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateLens(Lens lens)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(lens));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
var queryInsert = @"INSERT INTO Lens (Dioptres, Astigmatism) VALUES (@Dioptres, @Astigmatism)";
|
||||
connection.Execute(queryInsert, lens);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteLens(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Lens
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Lens> ReadLens()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Lens";
|
||||
var lenses = connection.Query<Lens>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(lenses));
|
||||
return lenses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Lens ReadLensById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Lens
|
||||
WHERE Id=@id";
|
||||
var lens = connection.QueryFirst<Lens>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(lens));
|
||||
return lens;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLens(Lens lens)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(lens));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Lens
|
||||
SET
|
||||
Dioptres=@Dioptres,
|
||||
Astigmatism=@Astigmatism
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, lens);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
public class OrderRepository : IOrderRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
|
||||
private readonly ILogger<OrderRepository> _logger;
|
||||
public OrderRepository(IConnectionString connectionString, ILogger<OrderRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateOrder(MakeOrder order)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO MakeOrder (Price, OrderDate, ClientId, OrderStatus)
|
||||
VALUES (@Price, @OrderDate, @ClientId, @OrderStatus);
|
||||
SELECT MAX(Id) FROM MakeOrder";
|
||||
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
|
||||
var querySubInsert = @"
|
||||
INSERT INTO Order_Product (OrderId, ProductId)
|
||||
VALUES (@OrderId, @ProductId)";
|
||||
foreach (var elem in order.Products)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
orderId,
|
||||
elem.ProductId
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MakeOrder> ReadOrder()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM MakeOrder";
|
||||
var orders = connection.Query<MakeOrder>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(orders));
|
||||
return orders;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
public class ProductRepository : IProductRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<ProductRepository> _logger;
|
||||
public ProductRepository(IConnectionString connectionString, ILogger<ProductRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateProduct(Product product)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Product (ProductType, FrameMaterial, LeftLensId, RightLensId) VALUES (@ProductType, @FrameMaterial, @LeftLensId, @RightLensId)";
|
||||
connection.Execute(queryInsert, product);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteProduct(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Product
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Product ReadProductById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Product
|
||||
WHERE Id=@id";
|
||||
var product = connection.QueryFirst<Product>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(product));
|
||||
return product;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Product> ReadProducts()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Product";
|
||||
var products = connection.Query<Product>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(products));
|
||||
return products;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateProduct(Product product)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Product
|
||||
SET
|
||||
ProductType=@ProductType,
|
||||
FrameMaterial=@FrameMaterial,
|
||||
LeftLensId=@LeftLensId,
|
||||
RightLensId=@RightLensId
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, product);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectOpticsSalon.Entites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectOpticsSalon.Repositories.Implementations;
|
||||
|
||||
public class ProductionRepository : IProductionRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<ProductionRepository> _logger;
|
||||
public ProductionRepository(IConnectionString connectionString, ILogger<ProductionRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateProduction(Production production)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(production));
|
||||
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Production (ComponentsPrice, WorkPrice, ProductId, Date) VALUES (@ComponentsPrice, @WorkPrice, @ProductId, @Date)";
|
||||
connection.Execute(queryInsert, production);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Production> ReadProduction()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Production";
|
||||
var productions = connection.Query<Production>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(productions));
|
||||
return productions;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Production ReadProductionById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Production
|
||||
WHERE Id=@id";
|
||||
var production = connection.QueryFirst<Production>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(production));
|
||||
return production;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateProduction(Production production)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(production));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Production
|
||||
SET
|
||||
ComponentsPrice=@ComponentsPrice,
|
||||
WorkPrice=@WorkPrice,
|
||||
ProductId=@ProductId,
|
||||
Date=@Date
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, production);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/DeleteButton.png
Normal file
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/DeleteButton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/OpticsSalon.jpg
Normal file
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/OpticsSalon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/PenButton.png
Normal file
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/PenButton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/PlusButton.png
Normal file
BIN
ProjectOpticsSalon/ProjectOpticsSalon/Resources/PlusButton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
15
ProjectOpticsSalon/ProjectOpticsSalon/appsettings.json
Normal file
15
ProjectOpticsSalon/ProjectOpticsSalon/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/optics_log.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user