Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
113be1af22 | ||
|
56812e25df | ||
|
70b60799da | ||
|
51d95da83b | ||
|
a0db0595f1 | ||
|
0d89c1f012 | ||
|
95d2100685 | ||
|
09557899c2 | ||
|
ab83e06788 | ||
|
26c76e03d3 |
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class AccessoiresOrder
|
||||||
|
{
|
||||||
|
public int OrderId { get; private set; }
|
||||||
|
|
||||||
|
public int AccessoriesId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static AccessoiresOrder CreateElement(int orderId, int count, int accessoriesId)
|
||||||
|
{
|
||||||
|
return new AccessoiresOrder { OrderId = orderId, Count = count, AccessoriesId = accessoriesId };
|
||||||
|
}
|
||||||
|
}
|
33
ProjectCompRepair/ProjectCompRepair/Entities/Accessories.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class Accessories
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public AccessoriesType AccessoriesType { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public float Price { get; private set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, int count, float price, DateTime date)
|
||||||
|
{
|
||||||
|
return new Accessories
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
AccessoriesType = accessoriesType,
|
||||||
|
Count = count,
|
||||||
|
Price = price,
|
||||||
|
Date = date
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities.Enums;
|
||||||
|
|
||||||
|
|
||||||
|
public enum AccessoriesType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
Processor = 1,
|
||||||
|
|
||||||
|
AccessMemory = 2,
|
||||||
|
|
||||||
|
VideoCard = 3,
|
||||||
|
|
||||||
|
Cooler = 4
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities.Enums;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum ServiceType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
Replacement = 1,
|
||||||
|
|
||||||
|
Installation = 2,
|
||||||
|
|
||||||
|
Repair = 4
|
||||||
|
}
|
22
ProjectCompRepair/ProjectCompRepair/Entities/Master.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class Master
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public static Master CreateEntity(int id, string name)
|
||||||
|
{
|
||||||
|
return new Master
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
54
ProjectCompRepair/ProjectCompRepair/Entities/Order.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class Order
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public string Coment { get; private set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public int MasterID { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<AccessoiresOrder> AccessoiresOrders { get; private set; } = [];
|
||||||
|
|
||||||
|
public IEnumerable<ServicesOrder> ServicesOrders { get; private set; } = [];
|
||||||
|
|
||||||
|
|
||||||
|
public static Order CreateElement(int id, string name,DateTime date, string coment, int masterId, IEnumerable<AccessoiresOrder> accessoiresOrders, IEnumerable<ServicesOrder> servicesOrder)
|
||||||
|
{
|
||||||
|
return new Order()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name,
|
||||||
|
Coment = coment,
|
||||||
|
Date = date,
|
||||||
|
MasterID = masterId,
|
||||||
|
AccessoiresOrders = accessoiresOrders,
|
||||||
|
ServicesOrders = servicesOrder
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Order CreateElement(TempAccessoriesOrder tempAccessoriesOrder, IEnumerable<AccessoiresOrder> accessoiresOrder)
|
||||||
|
{
|
||||||
|
return new Order
|
||||||
|
{
|
||||||
|
Id = tempAccessoriesOrder.Id,
|
||||||
|
Name = tempAccessoriesOrder.Name,
|
||||||
|
Coment = tempAccessoriesOrder.Coment,
|
||||||
|
Date = tempAccessoriesOrder.Date,
|
||||||
|
MasterID = tempAccessoriesOrder.MasterID,
|
||||||
|
AccessoiresOrders = accessoiresOrder,
|
||||||
|
ServicesOrders = tempAccessoriesOrder.ServicesOrders
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
27
ProjectCompRepair/ProjectCompRepair/Entities/Service.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class Service
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public ServiceType ServiceType { get; private set; }
|
||||||
|
|
||||||
|
public float Price { get; private set; }
|
||||||
|
|
||||||
|
public static Service CreateEntity(int id, ServiceType serviceType, float price)
|
||||||
|
{
|
||||||
|
return new Service
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
ServiceType = serviceType,
|
||||||
|
Price = price
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class ServicesOrder
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int OrderId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public static ServicesOrder CreateElement(int id, int orderId, int count)
|
||||||
|
{
|
||||||
|
return new ServicesOrder { Id = id, OrderId = orderId, Count = count };
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class TempAccessoriesOrder
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public string Coment { get; private set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public int MasterID { get; private set; }
|
||||||
|
|
||||||
|
public int AccessoriesId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public IEnumerable<AccessoiresOrder> AccessoiresOrders { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<ServicesOrder> ServicesOrders { get; private set; }
|
||||||
|
}
|
130
ProjectCompRepair/ProjectCompRepair/Form1.Designer.cs
generated
@ -1,6 +1,6 @@
|
|||||||
namespace ProjectCompRepair
|
namespace ProjectCompRepair
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class FormCompRepair
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -28,12 +28,132 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
menuStrip = new MenuStrip();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
справочникToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
AccossoriesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
this.Text = "Form1";
|
MasterToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ServiceToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
OrderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
документСоСправочникамиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
excelToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
TypeOfAccessoriesToolStripMenuItem = 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.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip.Size = new Size(896, 30);
|
||||||
|
menuStrip.TabIndex = 0;
|
||||||
|
menuStrip.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// справочникToolStripMenuItem
|
||||||
|
//
|
||||||
|
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AccossoriesToolStripMenuItem, MasterToolStripMenuItem, ServiceToolStripMenuItem });
|
||||||
|
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
||||||
|
справочникToolStripMenuItem.Size = new Size(117, 24);
|
||||||
|
справочникToolStripMenuItem.Text = "Справочники";
|
||||||
|
//
|
||||||
|
// AccossoriesToolStripMenuItem
|
||||||
|
//
|
||||||
|
AccossoriesToolStripMenuItem.Name = "AccossoriesToolStripMenuItem";
|
||||||
|
AccossoriesToolStripMenuItem.Size = new Size(207, 26);
|
||||||
|
AccossoriesToolStripMenuItem.Text = "Комплектующие";
|
||||||
|
AccossoriesToolStripMenuItem.Click += AccossoriesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// MasterToolStripMenuItem
|
||||||
|
//
|
||||||
|
MasterToolStripMenuItem.Name = "MasterToolStripMenuItem";
|
||||||
|
MasterToolStripMenuItem.Size = new Size(207, 26);
|
||||||
|
MasterToolStripMenuItem.Text = "Мастер";
|
||||||
|
MasterToolStripMenuItem.Click += MasterToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ServiceToolStripMenuItem
|
||||||
|
//
|
||||||
|
ServiceToolStripMenuItem.Name = "ServiceToolStripMenuItem";
|
||||||
|
ServiceToolStripMenuItem.Size = new Size(207, 26);
|
||||||
|
ServiceToolStripMenuItem.Text = "Услуга";
|
||||||
|
ServiceToolStripMenuItem.Click += ServiceToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// операцииToolStripMenuItem
|
||||||
|
//
|
||||||
|
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrderToolStripMenuItem });
|
||||||
|
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||||
|
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||||
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
|
//
|
||||||
|
// OrderToolStripMenuItem
|
||||||
|
//
|
||||||
|
OrderToolStripMenuItem.Name = "OrderToolStripMenuItem";
|
||||||
|
OrderToolStripMenuItem.Size = new Size(130, 26);
|
||||||
|
OrderToolStripMenuItem.Text = "Заказ";
|
||||||
|
OrderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// отчетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem, excelToolStripMenuItem, TypeOfAccessoriesToolStripMenuItem });
|
||||||
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
|
//
|
||||||
|
// документСоСправочникамиToolStripMenuItem
|
||||||
|
//
|
||||||
|
документСоСправочникамиToolStripMenuItem.Name = "документСоСправочникамиToolStripMenuItem";
|
||||||
|
документСоСправочникамиToolStripMenuItem.Size = new Size(348, 26);
|
||||||
|
документСоСправочникамиToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
|
документСоСправочникамиToolStripMenuItem.Click += DirecotryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// excelToolStripMenuItem
|
||||||
|
//
|
||||||
|
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
||||||
|
excelToolStripMenuItem.Size = new Size(348, 26);
|
||||||
|
excelToolStripMenuItem.Text = "Поток комплектующих";
|
||||||
|
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// TypeOfAccessoriesToolStripMenuItem
|
||||||
|
//
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Name = "TypeOfAccessoriesToolStripMenuItem";
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Size = new Size(348, 26);
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Text = "Отчет о потраченых комплектующих";
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Click += TypeOfAccessoriesToolStripMenuItem_Click_1;
|
||||||
|
//
|
||||||
|
// FormCompRepair
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackgroundImage = Properties.Resources.morskie_kamni_raznocvetnaya_galka;
|
||||||
|
BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
ClientSize = new Size(896, 548);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormCompRepair";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Фирма по ремонту техники";
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem справочникToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AccossoriesToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem OrderToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem MasterToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ServiceToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem документСоСправочникамиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem excelToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem TypeOfAccessoriesToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,102 @@
|
|||||||
|
using ProjectCompRepair.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectCompRepair
|
namespace ProjectCompRepair
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class FormCompRepair : Form
|
||||||
{
|
{
|
||||||
public Form1()
|
private readonly IUnityContainer _container;
|
||||||
|
public FormCompRepair(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AccossoriesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessories>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MasterToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormMasters>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServiceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormServices>().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 DirecotryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void excelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessoriesReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void TypeOfAccessoriesToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessoriesOrderReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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>
|
</root>
|
172
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessorie.Designer.cs
generated
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormAccessorie
|
||||||
|
{
|
||||||
|
/// <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>
|
||||||
|
|
||||||
|
#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()
|
||||||
|
{
|
||||||
|
labelType = new Label();
|
||||||
|
labelCount = new Label();
|
||||||
|
labelPrice = new Label();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
numericUpDownCount = new NumericUpDown();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
comboBoxType = new ComboBox();
|
||||||
|
labelDate = new Label();
|
||||||
|
dateTimePickerAccessories = new DateTimePicker();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelType
|
||||||
|
//
|
||||||
|
labelType.Anchor = AnchorStyles.Right;
|
||||||
|
labelType.AutoSize = true;
|
||||||
|
labelType.Location = new Point(47, 56);
|
||||||
|
labelType.Name = "labelType";
|
||||||
|
labelType.Size = new Size(128, 15);
|
||||||
|
labelType.TabIndex = 0;
|
||||||
|
labelType.Text = "Вид комплектующего";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
labelCount.Anchor = AnchorStyles.Right;
|
||||||
|
labelCount.AutoSize = true;
|
||||||
|
labelCount.Location = new Point(47, 114);
|
||||||
|
labelCount.Name = "labelCount";
|
||||||
|
labelCount.Size = new Size(79, 15);
|
||||||
|
labelCount.TabIndex = 2;
|
||||||
|
labelCount.Text = "Колличество";
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
labelPrice.Anchor = AnchorStyles.Right;
|
||||||
|
labelPrice.AutoSize = true;
|
||||||
|
labelPrice.Location = new Point(47, 173);
|
||||||
|
labelPrice.Name = "labelPrice";
|
||||||
|
labelPrice.Size = new Size(35, 15);
|
||||||
|
labelPrice.TabIndex = 4;
|
||||||
|
labelPrice.Text = "Цена";
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.Anchor = AnchorStyles.Right;
|
||||||
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
|
numericUpDownPrice.Location = new Point(220, 176);
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(104, 23);
|
||||||
|
numericUpDownPrice.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// numericUpDownCount
|
||||||
|
//
|
||||||
|
numericUpDownCount.Anchor = AnchorStyles.Right;
|
||||||
|
numericUpDownCount.Location = new Point(220, 117);
|
||||||
|
numericUpDownCount.Name = "numericUpDownCount";
|
||||||
|
numericUpDownCount.Size = new Size(104, 23);
|
||||||
|
numericUpDownCount.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.AllowDrop = true;
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.Location = new Point(46, 313);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(86, 25);
|
||||||
|
buttonCreate.TabIndex = 8;
|
||||||
|
buttonCreate.Text = "Сохранить";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(271, 312);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(88, 23);
|
||||||
|
buttonCancel.TabIndex = 10;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// comboBoxType
|
||||||
|
//
|
||||||
|
comboBoxType.FormattingEnabled = true;
|
||||||
|
comboBoxType.Location = new Point(219, 58);
|
||||||
|
comboBoxType.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxType.Name = "comboBoxType";
|
||||||
|
comboBoxType.Size = new Size(133, 23);
|
||||||
|
comboBoxType.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(47, 234);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(68, 15);
|
||||||
|
labelDate.TabIndex = 12;
|
||||||
|
labelDate.Text = "Поступили";
|
||||||
|
//
|
||||||
|
// dateTimePickerAccessories
|
||||||
|
//
|
||||||
|
dateTimePickerAccessories.Location = new Point(220, 234);
|
||||||
|
dateTimePickerAccessories.Name = "dateTimePickerAccessories";
|
||||||
|
dateTimePickerAccessories.Size = new Size(132, 23);
|
||||||
|
dateTimePickerAccessories.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// FormAccessorie
|
||||||
|
//
|
||||||
|
AllowDrop = true;
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
AutoValidate = AutoValidate.EnableAllowFocusChange;
|
||||||
|
ClientSize = new Size(392, 358);
|
||||||
|
Controls.Add(dateTimePickerAccessories);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(comboBoxType);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(numericUpDownCount);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(labelPrice);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Controls.Add(labelType);
|
||||||
|
Name = "FormAccessorie";
|
||||||
|
Text = "Комплектующое";
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelType;
|
||||||
|
private Label labelCount;
|
||||||
|
private Label labelPrice;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private NumericUpDown numericUpDownCount;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxType;
|
||||||
|
private Label labelDate;
|
||||||
|
private DateTimePicker dateTimePickerAccessories;
|
||||||
|
}
|
||||||
|
}
|
87
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessorie.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
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 ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAccessorie : Form
|
||||||
|
{
|
||||||
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
|
||||||
|
private int? _accessorieId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var accessorie = _accessoriesRepository.ReadAccessoriesById(value);
|
||||||
|
if (accessorie == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(accessorie));
|
||||||
|
}
|
||||||
|
|
||||||
|
dateTimePickerAccessories.Value = accessorie.Date;
|
||||||
|
numericUpDownCount.Value = accessorie.Count;
|
||||||
|
numericUpDownPrice.Value = (int)accessorie.Price;
|
||||||
|
_accessorieId = value;
|
||||||
|
comboBoxType.SelectedItem = accessorie.AccessoriesType;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormAccessorie(IAccessoriesRepository accessoriesRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_accessoriesRepository = accessoriesRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(accessoriesRepository));
|
||||||
|
comboBoxType.DataSource = Enum.GetValues(typeof(AccessoriesType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (comboBoxType.SelectedIndex < 1 || numericUpDownPrice.Value == 0 || numericUpDownCount.Value == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_accessorieId.HasValue)
|
||||||
|
{
|
||||||
|
_accessoriesRepository.UpdateAccessories(CreateAccessories(_accessorieId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_accessoriesRepository.CreateAccessories(CreateAccessories(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Accessories CreateAccessories(int id) => Accessories.CreateEntity(id, (AccessoriesType)comboBoxType.SelectedItem! , (int)numericUpDownCount.Value, (float)numericUpDownPrice.Value, dateTimePickerAccessories.Value);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessorie.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>
|
117
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.Designer.cs
generated
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormAccessories
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
panelButtons = new Panel();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(645, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 450);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(800, 450);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// FormAccessories
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormAccessories";
|
||||||
|
Text = "Комплектующие";
|
||||||
|
Load += FormAccessories_Load;
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panelButtons;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
115
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.cs
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
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.Xml.Linq;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAccessories : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
|
||||||
|
public FormAccessories(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_accessoriesRepository = accessoriesRepository
|
||||||
|
?? throw new ArgumentException(nameof(accessoriesRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAccessories_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessorie>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormAccessorie>();
|
||||||
|
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 (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_accessoriesRepository.DeleteAccessories(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _accessoriesRepository.ReadAccessories();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.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>
|
130
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessoriesOrderReport.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormAccessoriesOrderReport
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
labelFileName = new Label();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
labelDate = new Label();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
comboBoxAccessories = new ComboBox();
|
||||||
|
labelAccessories = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSelectFileName
|
||||||
|
//
|
||||||
|
buttonSelectFileName.Location = new Point(12, 25);
|
||||||
|
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||||
|
buttonSelectFileName.Size = new Size(94, 29);
|
||||||
|
buttonSelectFileName.TabIndex = 0;
|
||||||
|
buttonSelectFileName.Text = "Выбрать";
|
||||||
|
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||||
|
//
|
||||||
|
// labelFileName
|
||||||
|
//
|
||||||
|
labelFileName.AutoSize = true;
|
||||||
|
labelFileName.Location = new Point(136, 29);
|
||||||
|
labelFileName.Name = "labelFileName";
|
||||||
|
labelFileName.Size = new Size(45, 20);
|
||||||
|
labelFileName.TabIndex = 1;
|
||||||
|
labelFileName.Text = "Файл";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(67, 97);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(250, 27);
|
||||||
|
dateTimePicker.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(19, 100);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(44, 20);
|
||||||
|
labelDate.TabIndex = 3;
|
||||||
|
labelDate.Text = "Дата:";
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.Location = new Point(178, 178);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(198, 29);
|
||||||
|
buttonCreate.TabIndex = 4;
|
||||||
|
buttonCreate.Text = "Сформировать";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// comboBoxAccessories
|
||||||
|
//
|
||||||
|
comboBoxAccessories.FormattingEnabled = true;
|
||||||
|
comboBoxAccessories.Location = new Point(376, 100);
|
||||||
|
comboBoxAccessories.Name = "comboBoxAccessories";
|
||||||
|
comboBoxAccessories.Size = new Size(151, 28);
|
||||||
|
comboBoxAccessories.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// labelAccessories
|
||||||
|
//
|
||||||
|
labelAccessories.AutoSize = true;
|
||||||
|
labelAccessories.Location = new Point(387, 66);
|
||||||
|
labelAccessories.Name = "labelAccessories";
|
||||||
|
labelAccessories.Size = new Size(124, 20);
|
||||||
|
labelAccessories.TabIndex = 6;
|
||||||
|
labelAccessories.Text = "Комплектующие";
|
||||||
|
//
|
||||||
|
// FormAccessoriesOrderReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(539, 219);
|
||||||
|
Controls.Add(labelAccessories);
|
||||||
|
Controls.Add(comboBoxAccessories);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(labelFileName);
|
||||||
|
Controls.Add(buttonSelectFileName);
|
||||||
|
Name = "FormAccessoriesOrderReport";
|
||||||
|
Text = "FormAccessoriesType";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSelectFileName;
|
||||||
|
private Label labelFileName;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private Label labelDate;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private ComboBox comboBoxAccessories;
|
||||||
|
private Label labelAccessories;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
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 ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Reports;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAccessoriesOrderReport : Form
|
||||||
|
{
|
||||||
|
private string _fileName = string.Empty;
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormAccessoriesOrderReport(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
|
comboBoxAccessories.ValueMember = "Id";
|
||||||
|
comboBoxAccessories.DisplayMember = "AccessoriesType";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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, (int)comboBoxAccessories.SelectedValue!))
|
||||||
|
{
|
||||||
|
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>
|
169
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessoriesReport.Designer.cs
generated
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormAccessoriesReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dateTimePickerDateEnd = new DateTimePicker();
|
||||||
|
dateTimePickerDateBegin = new DateTimePicker();
|
||||||
|
textBoxFilePath = new TextBox();
|
||||||
|
buttonSelectFilePath = new Button();
|
||||||
|
comboBoxAccessories = new ComboBox();
|
||||||
|
labelFile = new Label();
|
||||||
|
labelNameAccessories = new Label();
|
||||||
|
labelBeginTime = new Label();
|
||||||
|
labelEndTime = new Label();
|
||||||
|
buttonMakeReport = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePickerDateEnd
|
||||||
|
//
|
||||||
|
dateTimePickerDateEnd.Location = new Point(198, 309);
|
||||||
|
dateTimePickerDateEnd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||||
|
dateTimePickerDateEnd.Size = new Size(228, 27);
|
||||||
|
dateTimePickerDateEnd.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateBegin
|
||||||
|
//
|
||||||
|
dateTimePickerDateBegin.Location = new Point(198, 256);
|
||||||
|
dateTimePickerDateBegin.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||||
|
dateTimePickerDateBegin.Size = new Size(228, 27);
|
||||||
|
dateTimePickerDateBegin.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(198, 108);
|
||||||
|
textBoxFilePath.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.Size = new Size(191, 27);
|
||||||
|
textBoxFilePath.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonSelectFilePath
|
||||||
|
//
|
||||||
|
buttonSelectFilePath.Location = new Point(397, 108);
|
||||||
|
buttonSelectFilePath.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||||
|
buttonSelectFilePath.Size = new Size(30, 31);
|
||||||
|
buttonSelectFilePath.TabIndex = 3;
|
||||||
|
buttonSelectFilePath.Text = "...";
|
||||||
|
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
|
//
|
||||||
|
// comboBoxAccessories
|
||||||
|
//
|
||||||
|
comboBoxAccessories.FormattingEnabled = true;
|
||||||
|
comboBoxAccessories.Location = new Point(198, 184);
|
||||||
|
comboBoxAccessories.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxAccessories.Name = "comboBoxAccessories";
|
||||||
|
comboBoxAccessories.Size = new Size(228, 28);
|
||||||
|
comboBoxAccessories.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// labelFile
|
||||||
|
//
|
||||||
|
labelFile.AutoSize = true;
|
||||||
|
labelFile.Location = new Point(69, 112);
|
||||||
|
labelFile.Name = "labelFile";
|
||||||
|
labelFile.Size = new Size(41, 20);
|
||||||
|
labelFile.TabIndex = 5;
|
||||||
|
labelFile.Text = "Путь";
|
||||||
|
//
|
||||||
|
// labelNameAccessories
|
||||||
|
//
|
||||||
|
labelNameAccessories.AutoSize = true;
|
||||||
|
labelNameAccessories.Location = new Point(47, 187);
|
||||||
|
labelNameAccessories.Name = "labelNameAccessories";
|
||||||
|
labelNameAccessories.Size = new Size(145, 20);
|
||||||
|
labelNameAccessories.TabIndex = 6;
|
||||||
|
labelNameAccessories.Text = "id комплектующего";
|
||||||
|
//
|
||||||
|
// labelBeginTime
|
||||||
|
//
|
||||||
|
labelBeginTime.AutoSize = true;
|
||||||
|
labelBeginTime.Location = new Point(47, 261);
|
||||||
|
labelBeginTime.Name = "labelBeginTime";
|
||||||
|
labelBeginTime.Size = new Size(134, 20);
|
||||||
|
labelBeginTime.TabIndex = 7;
|
||||||
|
labelBeginTime.Text = "Начальное время";
|
||||||
|
//
|
||||||
|
// labelEndTime
|
||||||
|
//
|
||||||
|
labelEndTime.AutoSize = true;
|
||||||
|
labelEndTime.Location = new Point(47, 314);
|
||||||
|
labelEndTime.Name = "labelEndTime";
|
||||||
|
labelEndTime.Size = new Size(126, 20);
|
||||||
|
labelEndTime.TabIndex = 8;
|
||||||
|
labelEndTime.Text = "Конечное время";
|
||||||
|
//
|
||||||
|
// buttonMakeReport
|
||||||
|
//
|
||||||
|
buttonMakeReport.Location = new Point(175, 423);
|
||||||
|
buttonMakeReport.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonMakeReport.Name = "buttonMakeReport";
|
||||||
|
buttonMakeReport.Size = new Size(134, 31);
|
||||||
|
buttonMakeReport.TabIndex = 9;
|
||||||
|
buttonMakeReport.Text = "Сформировать";
|
||||||
|
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||||
|
//
|
||||||
|
// FormAccessoriesReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(535, 600);
|
||||||
|
Controls.Add(buttonMakeReport);
|
||||||
|
Controls.Add(labelEndTime);
|
||||||
|
Controls.Add(labelBeginTime);
|
||||||
|
Controls.Add(labelNameAccessories);
|
||||||
|
Controls.Add(labelFile);
|
||||||
|
Controls.Add(comboBoxAccessories);
|
||||||
|
Controls.Add(buttonSelectFilePath);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(dateTimePickerDateBegin);
|
||||||
|
Controls.Add(dateTimePickerDateEnd);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormAccessoriesReport";
|
||||||
|
Text = "FormAccessoriesReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePickerDateEnd;
|
||||||
|
private DateTimePicker dateTimePickerDateBegin;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private Button buttonSelectFilePath;
|
||||||
|
private ComboBox comboBoxAccessories;
|
||||||
|
private Label labelFile;
|
||||||
|
private Label labelNameAccessories;
|
||||||
|
private Label labelBeginTime;
|
||||||
|
private Label labelEndTime;
|
||||||
|
private Button buttonMakeReport;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
using ProjectCompRepair.Reports;
|
||||||
|
using ProjectCompRepair.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 ProjectCompRepair.Forms;
|
||||||
|
|
||||||
|
public partial class FormAccessoriesReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormAccessoriesReport(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
|
comboBoxAccessories.DisplayMember = "Name";
|
||||||
|
comboBoxAccessories.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 (comboBoxAccessories.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран корм");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAccessories.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.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>
|
99
ProjectCompRepair/ProjectCompRepair/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
namespace ProjectCompRepair.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()
|
||||||
|
{
|
||||||
|
checkBoxMasters = new CheckBox();
|
||||||
|
checkBoxServices = new CheckBox();
|
||||||
|
checkBoxAccessories = new CheckBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// checkBoxMasters
|
||||||
|
//
|
||||||
|
checkBoxMasters.AutoSize = true;
|
||||||
|
checkBoxMasters.Location = new Point(15, 24);
|
||||||
|
checkBoxMasters.Name = "checkBoxMasters";
|
||||||
|
checkBoxMasters.Size = new Size(73, 19);
|
||||||
|
checkBoxMasters.TabIndex = 0;
|
||||||
|
checkBoxMasters.Text = "Мастера";
|
||||||
|
checkBoxMasters.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxServices
|
||||||
|
//
|
||||||
|
checkBoxServices.AutoSize = true;
|
||||||
|
checkBoxServices.Location = new Point(15, 70);
|
||||||
|
checkBoxServices.Name = "checkBoxServices";
|
||||||
|
checkBoxServices.Size = new Size(64, 19);
|
||||||
|
checkBoxServices.TabIndex = 1;
|
||||||
|
checkBoxServices.Text = "Услуги";
|
||||||
|
checkBoxServices.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxAccessories
|
||||||
|
//
|
||||||
|
checkBoxAccessories.AutoSize = true;
|
||||||
|
checkBoxAccessories.Location = new Point(15, 118);
|
||||||
|
checkBoxAccessories.Name = "checkBoxAccessories";
|
||||||
|
checkBoxAccessories.Size = new Size(120, 19);
|
||||||
|
checkBoxAccessories.TabIndex = 2;
|
||||||
|
checkBoxAccessories.Text = "Комплектующие";
|
||||||
|
checkBoxAccessories.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(155, 66);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(101, 23);
|
||||||
|
buttonBuild.TabIndex = 3;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// FormDirectoryReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(290, 166);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(checkBoxAccessories);
|
||||||
|
Controls.Add(checkBoxServices);
|
||||||
|
Controls.Add(checkBoxMasters);
|
||||||
|
Name = "FormDirectoryReport";
|
||||||
|
Text = "FormDirectoryReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckBox checkBoxMasters;
|
||||||
|
private CheckBox checkBoxServices;
|
||||||
|
private CheckBox checkBoxAccessories;
|
||||||
|
private Button buttonBuild;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
using ProjectCompRepair.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 ProjectCompRepair.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 (!checkBoxMasters.Checked && !checkBoxServices.Checked && !checkBoxAccessories.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, checkBoxMasters.Checked, checkBoxServices.Checked, checkBoxAccessories.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>
|
104
ProjectCompRepair/ProjectCompRepair/Forms/FormMaster.Designer.cs
generated
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormMaster
|
||||||
|
{
|
||||||
|
/// <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.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(87, 73);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(39, 20);
|
||||||
|
labelName.TabIndex = 0;
|
||||||
|
labelName.Text = "Имя";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
textBoxName.Location = new Point(160, 73);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(114, 27);
|
||||||
|
textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonSave.Location = new Point(31, 273);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(97, 31);
|
||||||
|
buttonSave.TabIndex = 2;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(208, 275);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(86, 31);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormMaster
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(331, 337);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormMaster";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Мастер";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
79
ProjectCompRepair/ProjectCompRepair/Forms/FormMaster.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms;
|
||||||
|
|
||||||
|
public partial class FormMaster : Form
|
||||||
|
{
|
||||||
|
private readonly IMasterRepository _masterRepository;
|
||||||
|
|
||||||
|
private int? _masterId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var master = _masterRepository.ReadMasterById(value);
|
||||||
|
if (master == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(master));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxName.Text = master.Name;
|
||||||
|
_masterId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormMaster(IMasterRepository masterRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_masterRepository = masterRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(masterRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_masterId.HasValue)
|
||||||
|
{
|
||||||
|
_masterRepository.UpdateMaster(CreateMaster(_masterId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_masterRepository.CreateMaster(CreateMaster(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Master CreateMaster(int id) => Master.CreateEntity(id, textBoxName.Text);
|
||||||
|
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormMaster.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>
|
118
ProjectCompRepair/ProjectCompRepair/Forms/FormMasters.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormMasters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons = new Panel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(551, 403);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(551, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 403);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// FormMasters
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(706, 403);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormMasters";
|
||||||
|
Text = "Мастера";
|
||||||
|
Load += FormMasters_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Panel panelButtons;
|
||||||
|
}
|
||||||
|
}
|
111
ProjectCompRepair/ProjectCompRepair/Forms/FormMasters.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using ProjectCompRepair.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 ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormMasters : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IMasterRepository _masterRepository;
|
||||||
|
|
||||||
|
public FormMasters(IUnityContainer container, IMasterRepository masterRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_masterRepository = masterRepository
|
||||||
|
?? throw new ArgumentException(nameof(masterRepository));
|
||||||
|
}
|
||||||
|
private void FormMasters_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormMaster>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormMaster>();
|
||||||
|
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(!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_masterRepository.DeleteMaster(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _masterRepository.ReadMaster();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if(dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormMasters.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>
|
272
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
namespace ProjectCompRepair.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()
|
||||||
|
{
|
||||||
|
labelName = new Label();
|
||||||
|
labelComent = new Label();
|
||||||
|
textBoxComent = new TextBox();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
labelDate = new Label();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
comboBoxMaster = new ComboBox();
|
||||||
|
labelMaster = new Label();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
dataGridViewAccessories = new DataGridView();
|
||||||
|
ColumnAccessories = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
groupBoxServices = new GroupBox();
|
||||||
|
dataGridViewServices = new DataGridView();
|
||||||
|
ColumnService = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCountServ = new DataGridViewTextBoxColumn();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).BeginInit();
|
||||||
|
groupBoxServices.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewServices).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(17, 26);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(59, 15);
|
||||||
|
labelName.TabIndex = 0;
|
||||||
|
labelName.Text = "Название";
|
||||||
|
//
|
||||||
|
// labelComent
|
||||||
|
//
|
||||||
|
labelComent.AutoSize = true;
|
||||||
|
labelComent.Location = new Point(17, 82);
|
||||||
|
labelComent.Name = "labelComent";
|
||||||
|
labelComent.Size = new Size(62, 15);
|
||||||
|
labelComent.TabIndex = 1;
|
||||||
|
labelComent.Text = "Описание";
|
||||||
|
//
|
||||||
|
// textBoxComent
|
||||||
|
//
|
||||||
|
textBoxComent.Location = new Point(182, 61);
|
||||||
|
textBoxComent.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
textBoxComent.Multiline = true;
|
||||||
|
textBoxComent.Name = "textBoxComent";
|
||||||
|
textBoxComent.Size = new Size(110, 55);
|
||||||
|
textBoxComent.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(182, 21);
|
||||||
|
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(110, 23);
|
||||||
|
textBoxName.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(17, 144);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(142, 15);
|
||||||
|
labelDate.TabIndex = 4;
|
||||||
|
labelDate.Text = "Дата регистрации заказа";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(182, 144);
|
||||||
|
dateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(168, 23);
|
||||||
|
dateTimePicker.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// comboBoxMaster
|
||||||
|
//
|
||||||
|
comboBoxMaster.FormattingEnabled = true;
|
||||||
|
comboBoxMaster.Location = new Point(182, 190);
|
||||||
|
comboBoxMaster.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxMaster.Name = "comboBoxMaster";
|
||||||
|
comboBoxMaster.Size = new Size(133, 23);
|
||||||
|
comboBoxMaster.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// labelMaster
|
||||||
|
//
|
||||||
|
labelMaster.AutoSize = true;
|
||||||
|
labelMaster.Location = new Point(18, 196);
|
||||||
|
labelMaster.Name = "labelMaster";
|
||||||
|
labelMaster.Size = new Size(48, 15);
|
||||||
|
labelMaster.TabIndex = 7;
|
||||||
|
labelMaster.Text = "Мастер";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(31, 292);
|
||||||
|
buttonSave.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(82, 22);
|
||||||
|
buttonSave.TabIndex = 8;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(942, 292);
|
||||||
|
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(82, 22);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(dataGridViewAccessories);
|
||||||
|
groupBox1.Location = new Point(393, 26);
|
||||||
|
groupBox1.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Size = new Size(270, 183);
|
||||||
|
groupBox1.TabIndex = 10;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Комплектующие";
|
||||||
|
//
|
||||||
|
// dataGridViewAccessories
|
||||||
|
//
|
||||||
|
dataGridViewAccessories.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewAccessories.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessories, ColumnCount });
|
||||||
|
dataGridViewAccessories.Dock = DockStyle.Fill;
|
||||||
|
dataGridViewAccessories.Location = new Point(3, 18);
|
||||||
|
dataGridViewAccessories.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
dataGridViewAccessories.Name = "dataGridViewAccessories";
|
||||||
|
dataGridViewAccessories.RowHeadersWidth = 51;
|
||||||
|
dataGridViewAccessories.Size = new Size(264, 163);
|
||||||
|
dataGridViewAccessories.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnAccessories
|
||||||
|
//
|
||||||
|
ColumnAccessories.HeaderText = "Экземпляр";
|
||||||
|
ColumnAccessories.MinimumWidth = 6;
|
||||||
|
ColumnAccessories.Name = "ColumnAccessories";
|
||||||
|
ColumnAccessories.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.MinimumWidth = 6;
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.Width = 125;
|
||||||
|
//
|
||||||
|
// groupBoxServices
|
||||||
|
//
|
||||||
|
groupBoxServices.Controls.Add(dataGridViewServices);
|
||||||
|
groupBoxServices.Location = new Point(690, 26);
|
||||||
|
groupBoxServices.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
groupBoxServices.Name = "groupBoxServices";
|
||||||
|
groupBoxServices.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBoxServices.Size = new Size(271, 185);
|
||||||
|
groupBoxServices.TabIndex = 11;
|
||||||
|
groupBoxServices.TabStop = false;
|
||||||
|
groupBoxServices.Text = "Услуги";
|
||||||
|
//
|
||||||
|
// dataGridViewServices
|
||||||
|
//
|
||||||
|
dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewServices.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnCountServ });
|
||||||
|
dataGridViewServices.Dock = DockStyle.Fill;
|
||||||
|
dataGridViewServices.Location = new Point(3, 18);
|
||||||
|
dataGridViewServices.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
dataGridViewServices.Name = "dataGridViewServices";
|
||||||
|
dataGridViewServices.RowHeadersWidth = 51;
|
||||||
|
dataGridViewServices.Size = new Size(265, 165);
|
||||||
|
dataGridViewServices.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnService
|
||||||
|
//
|
||||||
|
ColumnService.HeaderText = "Услуга";
|
||||||
|
ColumnService.MinimumWidth = 6;
|
||||||
|
ColumnService.Name = "ColumnService";
|
||||||
|
ColumnService.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnCountServ
|
||||||
|
//
|
||||||
|
ColumnCountServ.HeaderText = "Количество";
|
||||||
|
ColumnCountServ.MinimumWidth = 6;
|
||||||
|
ColumnCountServ.Name = "ColumnCountServ";
|
||||||
|
ColumnCountServ.Width = 125;
|
||||||
|
//
|
||||||
|
// FormOrder
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1035, 322);
|
||||||
|
Controls.Add(groupBoxServices);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(labelMaster);
|
||||||
|
Controls.Add(comboBoxMaster);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(textBoxComent);
|
||||||
|
Controls.Add(labelComent);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormOrder";
|
||||||
|
Text = "Заказ";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).EndInit();
|
||||||
|
groupBoxServices.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewServices).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelComent;
|
||||||
|
private TextBox textBoxComent;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelDate;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private ComboBox comboBoxMaster;
|
||||||
|
private Label labelMaster;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private DataGridView dataGridViewAccessories;
|
||||||
|
private GroupBox groupBoxServices;
|
||||||
|
private DataGridView dataGridViewServices;
|
||||||
|
private DataGridViewComboBoxColumn ColumnAccessories;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
private DataGridViewComboBoxColumn ColumnService;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCountServ;
|
||||||
|
}
|
||||||
|
}
|
119
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms;
|
||||||
|
|
||||||
|
public partial class FormOrder : Form
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
private int _orderId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var order = _orderRepository.ReadOrderById(value);
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(order));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxName.Text = order.Name;
|
||||||
|
textBoxComent.Text = order.Coment;
|
||||||
|
dateTimePicker.Value = order.Date;
|
||||||
|
_orderId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormOrder(IOrderRepository orderRepository, IMasterRepository masterRepository, IAccessoriesRepository accessoriesRepository, IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_orderRepository = orderRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
|
||||||
|
comboBoxMaster.DataSource = masterRepository.ReadMaster();
|
||||||
|
comboBoxMaster.ValueMember = "Id";
|
||||||
|
comboBoxMaster.DisplayMember = "Name";
|
||||||
|
|
||||||
|
ColumnAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
|
ColumnAccessories.DisplayMember = "AccessoriesType";
|
||||||
|
ColumnAccessories.ValueMember = "Id";
|
||||||
|
|
||||||
|
ColumnService.DataSource = serviceRepository.ReadService();
|
||||||
|
ColumnService.DisplayMember = "ServiceType";
|
||||||
|
ColumnService.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(dataGridViewAccessories.RowCount < 1 || comboBoxMaster.SelectedIndex < 0 || dataGridViewServices.RowCount < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненые поля");
|
||||||
|
}
|
||||||
|
_orderRepository.CreateOrder(Order.CreateElement(0, textBoxName.Text,dateTimePicker.Value, textBoxComent.Text, (int)comboBoxMaster.SelectedValue!, CreateListAccessoiresOrderFromDataGrid(), CreateListServicesOrderFromDataGrid()));
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private List<AccessoiresOrder> CreateListAccessoiresOrderFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<AccessoiresOrder>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewAccessories.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnAccessories"].Value == null ||
|
||||||
|
row.Cells["ColumnCount"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(AccessoiresOrder.CreateElement(
|
||||||
|
0,
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCount"].Value), Convert.ToInt32(row.Cells["ColumnAccessories"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ServicesOrder> CreateListServicesOrderFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<ServicesOrder>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewServices.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnService"].Value == null ||
|
||||||
|
row.Cells["ColumnCountServ"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(ServicesOrder.CreateElement(0,
|
||||||
|
Convert.ToInt32(row.Cells["ColumnService"].Value),
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCountServ"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
132
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.resx
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="ColumnAccessories.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnService.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCountServ.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
103
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
namespace ProjectCompRepair.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()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons = new Panel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 173);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(545, 400);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(545, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 400);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// FormOrders
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(700, 400);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Name = "FormOrders";
|
||||||
|
Text = "Заказы";
|
||||||
|
Load += FormOrder_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Panel panelButtons;
|
||||||
|
}
|
||||||
|
}
|
114
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
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 ProjectCompRepair.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 ArgumentException(nameof(container));
|
||||||
|
_orderRepository = orderRepository
|
||||||
|
?? throw new ArgumentException(nameof(orderRepository));
|
||||||
|
}
|
||||||
|
private void FormOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOrder>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormOrder>();
|
||||||
|
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 (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_orderRepository.DeleteOrder(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrder();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
120
ProjectCompRepair/ProjectCompRepair/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>
|
122
ProjectCompRepair/ProjectCompRepair/Forms/FormService.Designer.cs
generated
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormService
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelType = new Label();
|
||||||
|
labelPrice = new Label();
|
||||||
|
checkedListBoxType = new CheckedListBox();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelType
|
||||||
|
//
|
||||||
|
labelType.AutoSize = true;
|
||||||
|
labelType.Location = new Point(38, 70);
|
||||||
|
labelType.Name = "labelType";
|
||||||
|
labelType.Size = new Size(83, 20);
|
||||||
|
labelType.TabIndex = 0;
|
||||||
|
labelType.Text = "Тип услуги";
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
labelPrice.AutoSize = true;
|
||||||
|
labelPrice.Location = new Point(38, 217);
|
||||||
|
labelPrice.Name = "labelPrice";
|
||||||
|
labelPrice.Size = new Size(45, 20);
|
||||||
|
labelPrice.TabIndex = 1;
|
||||||
|
labelPrice.Text = "Цена";
|
||||||
|
//
|
||||||
|
// checkedListBoxType
|
||||||
|
//
|
||||||
|
checkedListBoxType.FormattingEnabled = true;
|
||||||
|
checkedListBoxType.Location = new Point(145, 49);
|
||||||
|
checkedListBoxType.Name = "checkedListBoxType";
|
||||||
|
checkedListBoxType.Size = new Size(230, 114);
|
||||||
|
checkedListBoxType.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
|
numericUpDownPrice.Location = new Point(145, 217);
|
||||||
|
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(230, 27);
|
||||||
|
numericUpDownPrice.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(38, 324);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(94, 29);
|
||||||
|
buttonSave.TabIndex = 5;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(281, 324);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 6;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormService
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(424, 393);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(checkedListBoxType);
|
||||||
|
Controls.Add(labelPrice);
|
||||||
|
Controls.Add(labelType);
|
||||||
|
Name = "FormService";
|
||||||
|
Text = "Услуга";
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelType;
|
||||||
|
private Label labelPrice;
|
||||||
|
private CheckedListBox checkedListBoxType;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormService.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormService : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
|
||||||
|
private int? _service;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var service = _serviceRepository.ReadServiceById(value);
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(service));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach(ServiceType elem in Enum.GetValues(typeof(ServiceType)))
|
||||||
|
{
|
||||||
|
if((elem & service.ServiceType) != 0)
|
||||||
|
{
|
||||||
|
checkedListBoxType.SetItemChecked(checkedListBoxType.Items.IndexOf(elem), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_service = value;
|
||||||
|
numericUpDownPrice.Value = (int)service.Price;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormService(IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceRepository = serviceRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
|
||||||
|
foreach(var elem in Enum.GetValues(typeof(ServiceType)))
|
||||||
|
{
|
||||||
|
checkedListBoxType.Items.Add(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormService(IServiceRepository serviceRepository, int id) : this(serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var service = _serviceRepository.ReadServiceById(id);
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (checkedListBoxType.CheckedItems.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_service.HasValue)
|
||||||
|
{
|
||||||
|
_serviceRepository.UpdateService(CreateService(_service.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceRepository.CreateService(CreateService(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Service CreateService(int id)
|
||||||
|
{
|
||||||
|
ServiceType serviceType = ServiceType.None;
|
||||||
|
foreach(var elem in checkedListBoxType.CheckedItems)
|
||||||
|
{
|
||||||
|
serviceType |= (ServiceType)elem;
|
||||||
|
}
|
||||||
|
return Service.CreateEntity(id, serviceType, (float)numericUpDownPrice.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormService.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>
|
118
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormServices
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
panelButtons = new Panel();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(536, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 450);
|
||||||
|
panelButtons.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(536, 450);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormServices
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(691, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Name = "FormServices";
|
||||||
|
SizeGripStyle = SizeGripStyle.Hide;
|
||||||
|
Text = "Услуги";
|
||||||
|
Load += FormService_Load;
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panelButtons;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
111
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using ProjectCompRepair.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 ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormServices : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
|
||||||
|
public FormServices(IUnityContainer container, IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_serviceRepository = serviceRepository
|
||||||
|
?? throw new ArgumentException(nameof(serviceRepository));
|
||||||
|
}
|
||||||
|
private void FormService_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormService>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormService>();
|
||||||
|
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 (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_serviceRepository.DeleteService(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _serviceRepository.ReadService();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.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,16 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
using Unity;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
using Unity.Lifetime;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ProjectCompRepair
|
namespace ProjectCompRepair
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -11,7 +24,37 @@ namespace ProjectCompRepair
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(CreateContainer().Resolve<FormCompRepair>());
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IUnityContainer CreateContainer()
|
||||||
|
{
|
||||||
|
var container = new UnityContainer();
|
||||||
|
|
||||||
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||||
|
|
||||||
|
container.RegisterType<IAccessoriesRepository, AccessoriesRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IMasterRepository, MasterRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IOrderRepository, OrderRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IServiceRepository, ServiceRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IConnectionString, ConnectionString >(new TransientLifetimeManager());
|
||||||
|
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LoggerFactory CreateLoggerFactory()
|
||||||
|
{
|
||||||
|
var loggerFactory = new LoggerFactory();
|
||||||
|
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.Build())
|
||||||
|
.CreateLogger());
|
||||||
|
return loggerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,4 +8,37 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||||
|
<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>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
103
ProjectCompRepair/ProjectCompRepair/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.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("ProjectCompRepair.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 morskie_kamni_raznocvetnaya_galka {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("morskie-kamni-raznocvetnaya-galka", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap pngwing_com__6_ {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("pngwing.com (6)", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap pngwing_com__7_ {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("pngwing.com (7)", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap pngwing_com__8_ {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("pngwing.com (8)", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
ProjectCompRepair/ProjectCompRepair/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="morskie-kamni-raznocvetnaya-galka" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\morskie-kamni-raznocvetnaya-galka.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="pngwing.com (8)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\pngwing.com (8).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="pngwing.com (7)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\pngwing.com (7).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="pngwing.com (6)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\pngwing.com (6).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
55
ProjectCompRepair/ProjectCompRepair/Reports/ChartReport.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
using RegistrationOfPatients.Reports;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Reports;
|
||||||
|
|
||||||
|
internal class ChartReport
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
private readonly ILogger<ChartReport> _logger;
|
||||||
|
|
||||||
|
public ChartReport(IOrderRepository orderRepository, ILogger<ChartReport> logger)
|
||||||
|
{
|
||||||
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChart(string filePath, DateTime dateTime, int accessoriesId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PdfBuilder(filePath)
|
||||||
|
.AddHeader("Комплектующие")
|
||||||
|
.AddPieChart("потраченные комплектующие", GetData(dateTime, accessoriesId))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<(string Caption, double Value)> GetData(DateTime dateTime, int accessoriesId)
|
||||||
|
{
|
||||||
|
return _orderRepository
|
||||||
|
.ReadOrder()
|
||||||
|
.Where(x => x.Date.Date == dateTime.Date && x.AccessoiresOrders.Any(y => y.AccessoriesId == accessoriesId))
|
||||||
|
.GroupBy(x => x.Id, (key, group) => new
|
||||||
|
{
|
||||||
|
Id = key,
|
||||||
|
Count = group.Sum(x => x.AccessoiresOrders.FirstOrDefault(y => y.AccessoriesId == accessoriesId)?.Count ?? 0)
|
||||||
|
})
|
||||||
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
79
ProjectCompRepair/ProjectCompRepair/Reports/DocReport.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Reports;
|
||||||
|
|
||||||
|
internal class DocReport
|
||||||
|
{
|
||||||
|
private readonly IMasterRepository _masterRepository;
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
private readonly ILogger<DocReport> _logger;
|
||||||
|
public DocReport(IMasterRepository masterRepository, IServiceRepository serviceRepository, IAccessoriesRepository accessoriesRepository, ILogger<DocReport> logger)
|
||||||
|
{
|
||||||
|
_masterRepository = masterRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(masterRepository));
|
||||||
|
_serviceRepository = serviceRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
_accessoriesRepository = accessoriesRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(accessoriesRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateDoc(string filePath, bool includeMaster, bool includeService, bool includeAccessories)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||||
|
|
||||||
|
if (includeMaster)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Мастера").AddTable([2400], GetMaster());
|
||||||
|
}
|
||||||
|
if (includeService)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Услуги").AddTable([2400,2400], GetService());
|
||||||
|
}
|
||||||
|
if (includeAccessories)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Комплектующие").AddTable([2400,2400,2400], AccessoriesGet());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<string[]> GetMaster()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Имя мастера"], .. _masterRepository.ReadMaster().Select(x => new string[] {x.Name}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
private List<string[]> GetService()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Тип услуги", "Цена"], .. _serviceRepository.ReadService().Select(x => new string[] {x.ServiceType.ToString(), x.Price.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
private List<string[]> AccessoriesGet()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Тип комплектующего", "Кол-во", "Цена"], .. _accessoriesRepository.ReadAccessories().Select
|
||||||
|
(x => new string[] {x.AccessoriesType.ToString(), x.Count.ToString(), x.Price.ToString()})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
332
ProjectCompRepair/ProjectCompRepair/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RegistrationOfPatients.Reports;
|
||||||
|
|
||||||
|
internal 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)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// TODO добавить шрифт с жирным
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Default Fill
|
||||||
|
var fills = new Fills() { Count = 1 };
|
||||||
|
fills.Append(new Fill
|
||||||
|
{
|
||||||
|
PatternFill = new PatternFill()
|
||||||
|
{
|
||||||
|
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fills);
|
||||||
|
|
||||||
|
// Default Border
|
||||||
|
var borders = new Borders() { Count = 2 };
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder(),
|
||||||
|
RightBorder = new RightBorder(),
|
||||||
|
TopBorder = new TopBorder(),
|
||||||
|
BottomBorder = new BottomBorder(),
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
// TODO добавить настройку с границами
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Default cell format and a date cell format
|
||||||
|
var cellFormats = new CellFormats() { Count = 4 };
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// TODO дополнить форматы
|
||||||
|
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,
|
||||||
|
// TODO дополнить стили
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
91
ProjectCompRepair/ProjectCompRepair/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RegistrationOfPatients.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 style = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||||
|
style.Font.Bold = true;
|
||||||
|
style.Font.Size = 14;
|
||||||
|
style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||||
|
}
|
||||||
|
}
|
66
ProjectCompRepair/ProjectCompRepair/Reports/TableReport.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using RegistrationOfPatients.Reports;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Reports;
|
||||||
|
|
||||||
|
internal class TableReport
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
private readonly ILogger<TableReport> _logger;
|
||||||
|
|
||||||
|
internal static readonly string[] item = ["Дата", "вход", "выход"];
|
||||||
|
|
||||||
|
public TableReport(IOrderRepository orderRepository, IAccessoriesRepository accessoriesRepository, ILogger<TableReport> logger)
|
||||||
|
{
|
||||||
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
_accessoriesRepository = accessoriesRepository ?? throw new ArgumentNullException(nameof(accessoriesRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTable(string filePath, int accessoriesId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new ExcelBuilder(filePath)
|
||||||
|
.AddHeader("Поставка комплектующих", 0, 3)
|
||||||
|
.AddParagraph("за период", 0)
|
||||||
|
.AddTable([10, 15, 15], GetData(accessoriesId, startDate, endDate))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetData(int accessoriesId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
var data = _orderRepository.ReadOrder()
|
||||||
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.AccessoiresOrders.Any(y => y.AccessoriesId == accessoriesId))
|
||||||
|
.Select(x => new {Date = x.Date, CountIn = (int?)null, CountOut = x.AccessoiresOrders.FirstOrDefault(y => y.AccessoriesId == accessoriesId)?.Count, })
|
||||||
|
.Union(
|
||||||
|
_accessoriesRepository
|
||||||
|
.ReadAccessories()
|
||||||
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.Id == accessoriesId)
|
||||||
|
.Select(x => new {Date = x.Date, CountIn = (int?)x.Count, CountOut = (int?)null }))
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
return new List<string[]>() { item }
|
||||||
|
.Union(
|
||||||
|
data
|
||||||
|
.Select(x => new string[] { x.Date.ToString("yyyy-MM-dd"), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||||
|
.Union(
|
||||||
|
[["Всего", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
100
ProjectCompRepair/ProjectCompRepair/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Document = DocumentFormat.OpenXml.Wordprocessing.Document;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Reports;
|
||||||
|
|
||||||
|
internal class WordBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
|
||||||
|
private readonly Document _document;
|
||||||
|
|
||||||
|
private readonly Body _body;
|
||||||
|
|
||||||
|
public WordBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath)) {
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
_body = _document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
public WordBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new RunProperties(new Bold()));
|
||||||
|
run.AppendChild(new Text(header));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public WordBuilder AddParagraph(string text)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new Text(text));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (widths == null || widths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(widths));
|
||||||
|
}
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
if (data.Any(x => x.Length != widths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = new Table();
|
||||||
|
table.AppendChild(new TableProperties(new TableBorders(
|
||||||
|
new TopBorder(){ Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12},
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12},
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12},
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12},
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12},
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12}
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
var tr = new TableRow();
|
||||||
|
for (var j = 0; j < widths.Length; ++j)
|
||||||
|
{
|
||||||
|
tr.Append(new TableCell(
|
||||||
|
new TableCellProperties(new TableCellWidth(){ Width = widths[j].ToString()}),
|
||||||
|
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||||
|
}
|
||||||
|
table.Append(tr);
|
||||||
|
|
||||||
|
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||||
|
_body.Append(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
|
||||||
|
var mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = _document;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories;
|
||||||
|
|
||||||
|
public interface IAccessoriesRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Accessories> ReadAccessories();
|
||||||
|
|
||||||
|
Accessories ReadAccessoriesById(int id);
|
||||||
|
|
||||||
|
void CreateAccessories(Accessories accessories);
|
||||||
|
|
||||||
|
void UpdateAccessories(Accessories accessories);
|
||||||
|
|
||||||
|
void DeleteAccessories(int id);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories;
|
||||||
|
|
||||||
|
public interface IConnectionString
|
||||||
|
{
|
||||||
|
public string ConnectionString {get;}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories;
|
||||||
|
|
||||||
|
public interface IMasterRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Master> ReadMaster();
|
||||||
|
|
||||||
|
Master ReadMasterById(int id);
|
||||||
|
|
||||||
|
void CreateMaster(Master Master);
|
||||||
|
|
||||||
|
void UpdateMaster(Master master);
|
||||||
|
|
||||||
|
void DeleteMaster(int id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories;
|
||||||
|
|
||||||
|
public interface IOrderRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Order> ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null, int? masterId = null, int? accessoriesId = null, int? serviceId = null);
|
||||||
|
|
||||||
|
Order ReadOrderById(int id);
|
||||||
|
|
||||||
|
void CreateOrder(Order order);
|
||||||
|
|
||||||
|
void DeleteOrder(int id);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories;
|
||||||
|
|
||||||
|
public interface IServiceRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Service> ReadService();
|
||||||
|
|
||||||
|
Service ReadServiceById(int id);
|
||||||
|
|
||||||
|
void CreateService(Service service);
|
||||||
|
|
||||||
|
void UpdateService(Service service);
|
||||||
|
|
||||||
|
void DeleteService(int id);
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
using System;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using Dapper;
|
||||||
|
using Npgsql;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
|
||||||
|
public class AccessoriesRepository : IAccessoriesRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AccessoriesRepository> _logger;
|
||||||
|
|
||||||
|
public AccessoriesRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateAccessories(Accessories accessories)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(accessories));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Accessories (AccessoriesType, Count, Price, Date)
|
||||||
|
VALUES (@AccessoriesType, @Count, @Price, @Date)";
|
||||||
|
connection.Execute(queryInsert, accessories);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateAccessories(Accessories accessories)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(accessories));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryUpdate = @"UPDATE Accessories
|
||||||
|
SET
|
||||||
|
AccessoriesType = @AccessoriesType,
|
||||||
|
Count = @Count,
|
||||||
|
Price = @Price,
|
||||||
|
Date = @Date
|
||||||
|
WHERE ID = @Id;";
|
||||||
|
connection.Execute(queryUpdate, accessories);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void DeleteAccessories(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Accessories
|
||||||
|
WHERE ID = @id
|
||||||
|
"
|
||||||
|
;
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Accessories ReadAccessoriesById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Accessories
|
||||||
|
WHERE ID = @id
|
||||||
|
";
|
||||||
|
var accessories = connection.QueryFirst<Accessories>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(accessories));
|
||||||
|
return accessories;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Accessories> ReadAccessories()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"SELECT * FROM Accessories";
|
||||||
|
var accessories = connection.Query<Accessories>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(accessories));
|
||||||
|
return accessories;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
public class ConnectionString : IConnectionString
|
||||||
|
{
|
||||||
|
string IConnectionString.ConnectionString => "host=localhost;port=5432;username=postgres;password=123;Database=otp;";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,136 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
|
||||||
|
public class MasterRepository : IMasterRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AccessoriesRepository> _logger;
|
||||||
|
|
||||||
|
public MasterRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
public void CreateMaster(Master master)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(master));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Master (Name)
|
||||||
|
VALUES (@Name)";
|
||||||
|
connection.Execute(queryInsert, master);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void DeleteMaster(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Master
|
||||||
|
WHERE ID = @id
|
||||||
|
"
|
||||||
|
;
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Master> ReadMaster()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"SELECT * FROM Master";
|
||||||
|
var master = connection.Query<Master>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(master));
|
||||||
|
return master;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Master ReadMasterById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Master
|
||||||
|
WHERE ID = @id
|
||||||
|
";
|
||||||
|
var master = connection.QueryFirst<Master>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(master));
|
||||||
|
return master;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateMaster(Master master)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(master));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryUpdate = @"UPDATE Master
|
||||||
|
SET
|
||||||
|
Name = @Name
|
||||||
|
WHERE ID = @Id;";
|
||||||
|
connection.Execute(queryUpdate, master);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,154 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
|
||||||
|
public class OrderRepository : IOrderRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AccessoriesRepository> _logger;
|
||||||
|
|
||||||
|
public OrderRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
public void CreateOrder(Order order)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(order));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Orderl (Name, Coment, Date, MasterId)
|
||||||
|
VALUES (@Name, @Coment, @Date, @MasterId);
|
||||||
|
SELECT MAX(ID) FROM Orderl";
|
||||||
|
|
||||||
|
|
||||||
|
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
|
||||||
|
|
||||||
|
var querySubInsertAccessories = @"
|
||||||
|
INSERT INTO AccessoriesOrder (AccessoriesId, OrderId, Count)
|
||||||
|
VALUES (@AccessoriesId,@OrderId, @Count)";
|
||||||
|
|
||||||
|
foreach (var elem in order.AccessoiresOrders)
|
||||||
|
{
|
||||||
|
connection.Execute(querySubInsertAccessories, new
|
||||||
|
{
|
||||||
|
elem.AccessoriesId,
|
||||||
|
orderId,
|
||||||
|
elem.Count
|
||||||
|
}, transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
var querySubInsertServices = @"
|
||||||
|
INSERT INTO ServicesOrder (OrderId, Count)
|
||||||
|
VALUES (@OrderId, @Count)";
|
||||||
|
|
||||||
|
foreach (var elem in order.ServicesOrders)
|
||||||
|
{
|
||||||
|
connection.Execute(querySubInsertServices, new
|
||||||
|
{
|
||||||
|
OrderId = orderId,
|
||||||
|
elem.Count
|
||||||
|
}, transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteOrder(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Orderl
|
||||||
|
WHERE ID = @id
|
||||||
|
"
|
||||||
|
;
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Order ReadOrderById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Orderl
|
||||||
|
WHERE ID = @id
|
||||||
|
";
|
||||||
|
var order = connection.QueryFirst<Order>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(order));
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Order> ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null, int? masterId = null, int? accessoriesId = null, int? serviceId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"SELECT o.*, ao.AccessoriesId, ao.Count
|
||||||
|
FROM Orderl o
|
||||||
|
INNER JOIN AccessoriesOrder ao ON ao.OrderId = o.ID;";
|
||||||
|
var order = connection.Query<TempAccessoriesOrder>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(order));
|
||||||
|
return order.GroupBy(x => x.Id, y => y,
|
||||||
|
(key, value) => Order.CreateElement(value.First(),
|
||||||
|
value.Select(z => AccessoiresOrder.CreateElement(0, z.Count, z.AccessoriesId)))).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
|
||||||
|
public class ServiceRepository : IServiceRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AccessoriesRepository> _logger;
|
||||||
|
|
||||||
|
public ServiceRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
public void CreateService(Service service)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(service));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Service (ServiceType, Price)
|
||||||
|
VALUES (@ServiceType, @Price)";
|
||||||
|
connection.Execute(queryInsert, service);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateService(Service service)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(service));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryUpdate = @"UPDATE Service
|
||||||
|
SET
|
||||||
|
ServiceType = @ServiceType,
|
||||||
|
Price = @Price
|
||||||
|
WHERE ID = @Id;";
|
||||||
|
connection.Execute(queryUpdate, service);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteService(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Service
|
||||||
|
WHERE ID = @id
|
||||||
|
"
|
||||||
|
;
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Service ReadServiceById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект : {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Service
|
||||||
|
WHERE ID = @id
|
||||||
|
";
|
||||||
|
var service = connection.QueryFirst<Service>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(service));
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Service> ReadService()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var querySelect = @"SELECT * FROM Service";
|
||||||
|
var service = connection.Query<Service>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(service));
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 770 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 8.3 KiB |
BIN
ProjectCompRepair/pngwing.com (6).png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
ProjectCompRepair/pngwing.com (7).png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ProjectCompRepair/pngwing.com (8).png
Normal file
After Width: | Height: | Size: 8.3 KiB |