Решены конфликты с решением из предыдущей лабы

This commit is contained in:
Данияр Аглиуллов 2023-03-08 20:15:13 +04:00
commit 0cd53c7368
36 changed files with 1944 additions and 271 deletions

View File

@ -14,7 +14,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
/// Создание отчета /// Создание отчета
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
public void CreateReport(ExcelInfo info) public void CreateReportShop(ExcelInfo info)
{ {
CreateExcel(info); CreateExcel(info);
@ -100,6 +100,77 @@ namespace ConfectioneryBusinessLogic.OfficePackage
SaveExcel(info); SaveExcel(info);
} }
public void CreateReportPastry(ExcelInfoPastry info)
{
CreateExcel(new() { FileName = info.FileName });
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var pc in info.PastryComponents)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.PastryName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Pastry, Count) in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Pastry,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = pc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(new());
}
/// <summary> /// <summary>
/// Создание excel-файла /// Создание excel-файла
/// </summary> /// </summary>

View File

@ -41,6 +41,40 @@ namespace ConfectioneryBusinessLogic.OfficePackage
SavePdf(info); SavePdf(info);
} }
public void CreateDocOrders(PdfInfoOrders info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph
{
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "4cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.Orders)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, Convert.ToString(order.OrderStatus), order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
SavePdf(info);
}
/// <summary> /// <summary>
/// Создание doc-файла /// Создание doc-файла
/// </summary> /// </summary>

View File

@ -10,7 +10,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
{ {
public abstract class AbstractSaveToWord public abstract class AbstractSaveToWord
{ {
public void CreateDoc(WordInfo info) public void CreateDocTable(WordInfoTable info)
{ {
CreateWord(info); CreateWord(info);
@ -42,11 +42,45 @@ namespace ConfectioneryBusinessLogic.OfficePackage
SaveWord(info); SaveWord(info);
} }
public void CreateDoc(WordInfo info)
{
CreateWord(new() { FileName = info.FileName });
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var pastry in info.Pastries)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)>
{
(pastry.PastryName , new WordTextProperties { Size = "24", Bold = true}),
(" - цена: " + pastry.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(new());
}
/// <summary> /// <summary>
/// Создание doc-файла /// Создание doc-файла
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
protected abstract void CreateWord(WordInfo info); protected abstract void CreateWord(WordInfoTable info);
/// <summary> /// <summary>
/// Создание абзаца с текстом /// Создание абзаца с текстом
@ -66,6 +100,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage
/// Сохранение файла /// Сохранение файла
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
protected abstract void SaveWord(WordInfo info); protected abstract void SaveWord(WordInfoTable info);
} }
} }

View File

@ -0,0 +1,20 @@
using ConfectioneryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfoPastry
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportPastryComponentViewModel> PastryComponents
{
get;
set;
} = new();
}
}

View File

@ -13,6 +13,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; } public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; } public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new(); public List<ReportGroupOrdersViewModel> Orders { get; set; } = new();
} }
} }

View File

@ -0,0 +1,29 @@
using ConfectioneryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfoOrders
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new();
public static implicit operator PdfInfo(PdfInfoOrders orders)
{
return new PdfInfo()
{
DateFrom = orders.DateFrom,
DateTo = orders.DateTo,
FileName = orders.FileName,
Title = orders.Title
};
}
}
}

View File

@ -1,9 +1,4 @@
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{ {
@ -11,6 +6,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<PastryViewModel> Pastries { get; set; } = new();
public List<ShopViewModel> Shops { get; set; } = new(); public List<ShopViewModel> Shops { get; set; } = new();
} }
} }

View File

@ -0,0 +1,16 @@
using ConfectioneryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{
public class WordInfoTable
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ShopViewModel> Shops { get; set; } = new();
}
}

View File

@ -81,7 +81,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
return properties; return properties;
} }
protected override void CreateWord(WordInfo info) protected override void CreateWord(WordInfoTable info)
{ {
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
@ -119,7 +119,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
_docBody.AppendChild(docParagraph); _docBody.AppendChild(docParagraph);
} }
protected override void SaveWord(WordInfo info) protected override void SaveWord(WordInfoTable info)
{ {
if (_docBody == null || _wordDocument == null) if (_docBody == null || _wordDocument == null)
{ {

View File

@ -15,6 +15,7 @@ namespace ConfectioneryBusinessLogic
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly IShopStorage _shopStorage; private readonly IShopStorage _shopStorage;
private readonly IComponentStorage _componentStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
@ -22,9 +23,10 @@ namespace ConfectioneryBusinessLogic
private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IPastryStorage PastryStorage, IOrderStorage orderStorage, IShopStorage shopStorage, public ReportLogic(IPastryStorage PastryStorage, IOrderStorage orderStorage, IShopStorage shopStorage, IComponentStorage componentStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{ {
_componentStorage = componentStorage;
_pastryStorage = PastryStorage; _pastryStorage = PastryStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopStorage = shopStorage; _shopStorage = shopStorage;
@ -69,16 +71,70 @@ namespace ConfectioneryBusinessLogic
return list; return list;
} }
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
public List<ReportPastryComponentViewModel> GetPastryComponent()
{
var components = _componentStorage.GetFullList();
var pastries = _pastryStorage.GetFullList();
var list = new List<ReportPastryComponentViewModel>();
foreach (var pastry in pastries)
{
var record = new ReportPastryComponentViewModel
{
PastryName = pastry.PastryName,
Components = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var component in components)
{
if (pastry.PastryComponents.ContainsKey(component.Id))
{
record.Components.Add(new(component.ComponentName, pastry.PastryComponents[component.Id].Item2));
record.TotalCount += pastry.PastryComponents[component.Id].Item2;
}
}
list.Add(record);
}
return list;
}
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model) public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
{
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
.Select(x => new ReportOrdersViewModel
{
Id = x.Id,
DateCreate = x.DateCreate,
PastryName = x.PastryName,
OrderStatus = Convert.ToString(x.Status) ?? string.Empty,
Sum = x.Sum
})
.ToList();
}
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<ReportGroupOrdersViewModel> GetGroupOrders(ReportBindingModel model)
{ {
return _orderStorage.GetFullList() return _orderStorage.GetFullList()
.GroupBy(x => x.DateCreate.Date) .GroupBy(x => x.DateCreate.Date)
.Select(x => new ReportOrdersViewModel .Select(x => new ReportGroupOrdersViewModel
{ {
Date = x.Key, Date = x.Key,
Count = x.Count(), Count = x.Count(),
@ -91,9 +147,9 @@ namespace ConfectioneryBusinessLogic
/// Сохранение магазинов в файл-Word /// Сохранение магазинов в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveShopsToWordFile(ReportBindingModel model) public void SaveShopsTableToWordFile(ReportBindingModel model)
{ {
_saveToWord.CreateDoc(new WordInfo _saveToWord.CreateDocTable(new WordInfoTable
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список магазинов", Title = "Список магазинов",
@ -101,13 +157,25 @@ namespace ConfectioneryBusinessLogic
}); });
} }
public void SavePastriesToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список изделий",
Pastries = _pastryStorage.GetFullList()
});
}
/// <summary> /// <summary>
/// Сохранение магазинов с указаеним продуктов в файл-Excel /// Сохранение магазинов с указаеним продуктов в файл-Excel
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveShopPastryToExcelFile(ReportBindingModel model) public void SaveShopPastryToExcelFile(ReportBindingModel model)
{ {
_saveToExcel.CreateReport(new ExcelInfo _saveToExcel.CreateReportShop(new ExcelInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список магазинов", Title = "Список магазинов",
@ -115,20 +183,46 @@ namespace ConfectioneryBusinessLogic
}); });
} }
public void SavePastryComponentToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReportPastry(new ExcelInfoPastry
{
FileName = model.FileName,
Title = "Список изделий по компонентам",
PastryComponents = GetPastryComponent(),
});
}
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
public void SaveGroupOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Список сгруппированных заказов по датам",
DateFrom = model.DateFrom!.Value,
DateTo = model.DateTo!.Value,
Orders = GetGroupOrders(model)
});
}
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveOrdersToPdfFile(ReportBindingModel model) public void SaveOrdersToPdfFile(ReportBindingModel model)
{ {
_saveToPdf.CreateDoc(new PdfInfo _saveToPdf.CreateDocOrders(new PdfInfoOrders
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список заказов", Title = "Список заказов",
DateFrom = model.DateFrom!.Value, DateFrom = model.DateFrom!.Value,
DateTo = model.DateTo!.Value, DateTo = model.DateTo!.Value,
Orders = GetOrders(model) Orders = GetOrders(model),
}); });
} }
} }
} }

View File

@ -36,9 +36,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="ReportOrders.rdlc"> <None Update="ReportGroupOrders.rdlc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="ReportOrders.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -33,19 +33,24 @@
pastryToolStripMenuItem = new ToolStripMenuItem(); pastryToolStripMenuItem = new ToolStripMenuItem();
componentToolStripMenuItem = new ToolStripMenuItem(); componentToolStripMenuItem = new ToolStripMenuItem();
ShopsToolStripMenuItem = new ToolStripMenuItem(); ShopsToolStripMenuItem = new ToolStripMenuItem();
clientsToolStripMenuItem = new ToolStripMenuItem();
reportsToolStripMenuItem = new ToolStripMenuItem(); reportsToolStripMenuItem = new ToolStripMenuItem();
reportShopsToolStripMenuItem = new ToolStripMenuItem(); reportShopsToolStripMenuItem = new ToolStripMenuItem();
ShopPastriesToolStripMenuItem = new ToolStripMenuItem(); ShopPastriesToolStripMenuItem = new ToolStripMenuItem();
groupOrdersToolStripMenuItem = new ToolStripMenuItem();
pastriesToolStripMenuItem = new ToolStripMenuItem();
pastryComponentsToolStripMenuItem = new ToolStripMenuItem();
ordersToolStripMenuItem = new ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonCreateOrder = new Button(); buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
button2 = new Button();
button3 = new Button(); button3 = new Button();
button4 = new Button(); button4 = new Button();
buttonAddPastryInShop = new Button(); buttonAddPastryInShop = new Button();
ImplementersToolStripMenuItem = new ToolStripMenuItem(); ImplementersToolStripMenuItem = new ToolStripMenuItem();
DoWorkToolStripMenuItem = new ToolStripMenuItem(); DoWorkToolStripMenuItem = new ToolStripMenuItem();
buttonSellPastry = new Button(); buttonSellPastry = new Button();
clientsToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
@ -61,7 +66,7 @@
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ShopsToolStripMenuItem, pastryToolStripMenuItem, componentToolStripMenuItem, clientsToolStripMenuItem }); справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem, ShopsToolStripMenuItem, clientsToolStripMenuItem, ImplementersToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20); справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Text = "Справочники";
@ -69,14 +74,14 @@
// pastryToolStripMenuItem // pastryToolStripMenuItem
// //
pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
pastryToolStripMenuItem.Size = new Size(145, 22); pastryToolStripMenuItem.Size = new Size(180, 22);
pastryToolStripMenuItem.Text = "Изделия"; pastryToolStripMenuItem.Text = "Изделия";
pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click; pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click;
// //
// componentToolStripMenuItem // componentToolStripMenuItem
// //
componentToolStripMenuItem.Name = "componentToolStripMenuItem"; componentToolStripMenuItem.Name = "componentToolStripMenuItem";
componentToolStripMenuItem.Size = new Size(145, 22); componentToolStripMenuItem.Size = new Size(180, 22);
componentToolStripMenuItem.Text = "Компоненты"; componentToolStripMenuItem.Text = "Компоненты";
componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
// //
@ -87,16 +92,9 @@
ShopsToolStripMenuItem.Text = "Магазины"; ShopsToolStripMenuItem.Text = "Магазины";
ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
// //
// clientsToolStripMenuItem
//
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
clientsToolStripMenuItem.Size = new Size(145, 22);
clientsToolStripMenuItem.Text = "Клиенты";
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// reportsToolStripMenuItem // reportsToolStripMenuItem
// //
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, ShopPastriesToolStripMenuItem, ordersToolStripMenuItem }); reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, ShopPastriesToolStripMenuItem, groupOrdersToolStripMenuItem, pastriesToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem });
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
reportsToolStripMenuItem.Size = new Size(60, 20); reportsToolStripMenuItem.Size = new Size(60, 20);
reportsToolStripMenuItem.Text = "Отчеты"; reportsToolStripMenuItem.Text = "Отчеты";
@ -114,6 +112,27 @@
ShopPastriesToolStripMenuItem.Size = new Size(202, 22); ShopPastriesToolStripMenuItem.Size = new Size(202, 22);
ShopPastriesToolStripMenuItem.Text = "Магазины с изделиями"; ShopPastriesToolStripMenuItem.Text = "Магазины с изделиями";
ShopPastriesToolStripMenuItem.Click += ShopPastriesToolStripMenuItem_Click; ShopPastriesToolStripMenuItem.Click += ShopPastriesToolStripMenuItem_Click;
//
// groupOrdersToolStripMenuItem
//
groupOrdersToolStripMenuItem.Name = "groupOrdersToolStripMenuItem";
groupOrdersToolStripMenuItem.Size = new Size(215, 22);
groupOrdersToolStripMenuItem.Text = "Список групп заказов";
groupOrdersToolStripMenuItem.Click += GroupOrdersToolStripMenuItem_Click;
//
// pastriesToolStripMenuItem
//
pastriesToolStripMenuItem.Name = "pastriesToolStripMenuItem";
pastriesToolStripMenuItem.Size = new Size(215, 22);
pastriesToolStripMenuItem.Text = "Список изделий";
pastriesToolStripMenuItem.Click += PastriesToolStripMenuItem_Click;
//
// pastryComponentsToolStripMenuItem
//
pastryComponentsToolStripMenuItem.Name = "pastryComponentsToolStripMenuItem";
pastryComponentsToolStripMenuItem.Size = new Size(215, 22);
pastryComponentsToolStripMenuItem.Text = "Изделия с компонентами";
pastryComponentsToolStripMenuItem.Click += PastryComponentsToolStripMenuItem_Click;
// //
// ordersToolStripMenuItem // ordersToolStripMenuItem
// //
@ -143,10 +162,32 @@
buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click; buttonCreateOrder.Click += ButtonCreateOrder_Click;
// //
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonTakeOrderInWork.Location = new Point(624, 98);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(147, 32);
buttonTakeOrderInWork.TabIndex = 3;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
//
// button2
//
button2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
button2.Location = new Point(624, 157);
button2.Name = "button2";
button2.Size = new Size(147, 32);
button2.TabIndex = 4;
button2.Text = "Заказ готов";
button2.UseVisualStyleBackColor = true;
button2.Click += ButtonOrderReady_Click;
//
// button3 // button3
// //
button3.Anchor = AnchorStyles.Top | AnchorStyles.Right; button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
button3.Location = new Point(624, 91); button3.Location = new Point(624, 215);
button3.Name = "button3"; button3.Name = "button3";
button3.Size = new Size(147, 32); button3.Size = new Size(147, 32);
button3.TabIndex = 5; button3.TabIndex = 5;
@ -157,7 +198,7 @@
// button4 // button4
// //
button4.Anchor = AnchorStyles.Top | AnchorStyles.Right; button4.Anchor = AnchorStyles.Top | AnchorStyles.Right;
button4.Location = new Point(624, 150); button4.Location = new Point(624, 274);
button4.Name = "button4"; button4.Name = "button4";
button4.Size = new Size(147, 32); button4.Size = new Size(147, 32);
button4.TabIndex = 6; button4.TabIndex = 6;
@ -168,7 +209,7 @@
// buttonAddPastryInShop // buttonAddPastryInShop
// //
buttonAddPastryInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonAddPastryInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonAddPastryInShop.Location = new Point(624, 260); buttonAddPastryInShop.Location = new Point(624, 384);
buttonAddPastryInShop.Name = "buttonAddPastryInShop"; buttonAddPastryInShop.Name = "buttonAddPastryInShop";
buttonAddPastryInShop.Size = new Size(147, 31); buttonAddPastryInShop.Size = new Size(147, 31);
buttonAddPastryInShop.TabIndex = 7; buttonAddPastryInShop.TabIndex = 7;
@ -193,7 +234,7 @@
// buttonSellPastry // buttonSellPastry
// //
buttonSellPastry.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonSellPastry.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonSellPastry.Location = new Point(624, 207); buttonSellPastry.Location = new Point(624, 331);
buttonSellPastry.Name = "buttonSellPastry"; buttonSellPastry.Name = "buttonSellPastry";
buttonSellPastry.Size = new Size(147, 31); buttonSellPastry.Size = new Size(147, 31);
buttonSellPastry.TabIndex = 8; buttonSellPastry.TabIndex = 8;
@ -201,6 +242,13 @@
buttonSellPastry.UseVisualStyleBackColor = true; buttonSellPastry.UseVisualStyleBackColor = true;
buttonSellPastry.Click += ButtonSellPastry_Click; buttonSellPastry.Click += ButtonSellPastry_Click;
// //
// clientsToolStripMenuItem
//
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
clientsToolStripMenuItem.Size = new Size(180, 22);
clientsToolStripMenuItem.Text = "Клиенты";
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
@ -210,6 +258,8 @@
Controls.Add(buttonAddPastryInShop); Controls.Add(buttonAddPastryInShop);
Controls.Add(button4); Controls.Add(button4);
Controls.Add(button3); Controls.Add(button3);
Controls.Add(button2);
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder); Controls.Add(buttonCreateOrder);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(menuStrip1); Controls.Add(menuStrip1);
@ -239,11 +289,14 @@
private ToolStripMenuItem reportsToolStripMenuItem; private ToolStripMenuItem reportsToolStripMenuItem;
private ToolStripMenuItem reportShopsToolStripMenuItem; private ToolStripMenuItem reportShopsToolStripMenuItem;
private ToolStripMenuItem ShopPastriesToolStripMenuItem; private ToolStripMenuItem ShopPastriesToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem groupOrdersToolStripMenuItem;
private ToolStripMenuItem ShopsToolStripMenuItem; private ToolStripMenuItem ShopsToolStripMenuItem;
private ToolStripMenuItem pastriesToolStripMenuItem;
private ToolStripMenuItem pastryComponentsToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem clientsToolStripMenuItem;
private Button buttonAddPastryInShop; private Button buttonAddPastryInShop;
private Button buttonSellPastry; private Button buttonSellPastry;
private ToolStripMenuItem clientsToolStripMenuItem;
private ToolStripMenuItem ImplementersToolStripMenuItem; private ToolStripMenuItem ImplementersToolStripMenuItem;
private ToolStripMenuItem DoWorkToolStripMenuItem; private ToolStripMenuItem DoWorkToolStripMenuItem;
} }

View File

@ -166,7 +166,17 @@ namespace ConfectioneryView
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
_reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); _reportLogic.SaveShopsTableToWordFile(new ReportBindingModel { FileName = dialog.FileName });
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void PastriesToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SavePastriesToWordFile(new ReportBindingModel { FileName = dialog.FileName });
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
@ -180,6 +190,24 @@ namespace ConfectioneryView
} }
} }
private void PastryComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents));
if (service is FormReportPastryComponents form)
{
form.ShowDialog();
}
}
private void GroupOrdersToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupOrders));
if (service is FormReportGroupOrders form)
{
form.ShowDialog();
}
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
@ -188,6 +216,7 @@ namespace ConfectioneryView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormViewShops)); var service = Program.ServiceProvider?.GetService(typeof(FormViewShops));

View File

@ -0,0 +1,141 @@
namespace ConfectioneryView
{
partial class FormReportGroupOrders
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel = new System.Windows.Forms.Panel();
this.buttonToPdf = new System.Windows.Forms.Button();
this.buttonMake = new System.Windows.Forms.Button();
this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
this.labelTo = new System.Windows.Forms.Label();
this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
this.labelFrom = new System.Windows.Forms.Label();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// panel
//
this.panel.Controls.Add(this.buttonToPdf);
this.panel.Controls.Add(this.buttonMake);
this.panel.Controls.Add(this.dateTimePickerTo);
this.panel.Controls.Add(this.labelTo);
this.panel.Controls.Add(this.dateTimePickerFrom);
this.panel.Controls.Add(this.labelFrom);
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
this.panel.Location = new System.Drawing.Point(0, 0);
this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(1031, 40);
this.panel.TabIndex = 0;
//
// buttonToPdf
//
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonToPdf.Location = new System.Drawing.Point(878, 8);
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonToPdf.Name = "buttonToPdf";
this.buttonToPdf.Size = new System.Drawing.Size(139, 27);
this.buttonToPdf.TabIndex = 5;
this.buttonToPdf.Text = "В Pdf";
this.buttonToPdf.UseVisualStyleBackColor = true;
this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
//
// buttonMake
//
this.buttonMake.Location = new System.Drawing.Point(476, 8);
this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonMake.Name = "buttonMake";
this.buttonMake.Size = new System.Drawing.Size(139, 27);
this.buttonMake.TabIndex = 4;
this.buttonMake.Text = "Сформировать";
this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
//
// dateTimePickerTo
//
this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7);
this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.dateTimePickerTo.Name = "dateTimePickerTo";
this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23);
this.dateTimePickerTo.TabIndex = 3;
//
// labelTo
//
this.labelTo.AutoSize = true;
this.labelTo.Location = new System.Drawing.Point(208, 10);
this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelTo.Name = "labelTo";
this.labelTo.Size = new System.Drawing.Size(21, 15);
this.labelTo.TabIndex = 2;
this.labelTo.Text = "по";
//
// dateTimePickerFrom
//
this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7);
this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.dateTimePickerFrom.Name = "dateTimePickerFrom";
this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23);
this.dateTimePickerFrom.TabIndex = 1;
//
// labelFrom
//
this.labelFrom.AutoSize = true;
this.labelFrom.Location = new System.Drawing.Point(14, 10);
this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelFrom.Name = "labelFrom";
this.labelFrom.Size = new System.Drawing.Size(15, 15);
this.labelFrom.TabIndex = 0;
this.labelFrom.Text = "С";
//
// FormReportOrders
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1031, 647);
this.Controls.Add(this.panel);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormReportOrders";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Заказы";
this.panel.ResumeLayout(false);
this.panel.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Button buttonToPdf;
private System.Windows.Forms.Button buttonMake;
private System.Windows.Forms.DateTimePicker dateTimePickerTo;
private System.Windows.Forms.Label labelTo;
private System.Windows.Forms.DateTimePicker dateTimePickerFrom;
private System.Windows.Forms.Label labelFrom;
}
}

View File

@ -0,0 +1,91 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
namespace ConfectioneryView
{
public partial class FormReportGroupOrders : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportGroupOrders(ILogger<FormReportGroupOrders> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupOrders.rdlc", FileMode.Open));
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void ButtonMake_Click(object sender, EventArgs e)
{
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var dataSource = _logic.GetGroupOrders(new ReportBindingModel
{
DateFrom = dateTimePickerFrom.Value,
DateTo = dateTimePickerTo.Value
});
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonToPdf_Click(object sender, EventArgs e)
{
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveOrdersToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName,
DateFrom = dateTimePickerFrom.Value,
DateTo = dateTimePickerTo.Value
});
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,113 @@
namespace ConfectioneryView
{
partial class FormReportPastryComponents
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
buttonSaveToExcel = new Button();
ColumnPastry = new DataGridViewTextBoxColumn();
ColumnComponent = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToOrderColumns = true;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnPastry, ColumnComponent, ColumnCount });
dataGridView.Dock = DockStyle.Bottom;
dataGridView.Location = new Point(0, 47);
dataGridView.Margin = new Padding(4, 3, 4, 3);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.Size = new Size(616, 510);
dataGridView.TabIndex = 0;
//
// buttonSaveToExcel
//
buttonSaveToExcel.Location = new Point(14, 14);
buttonSaveToExcel.Margin = new Padding(4, 3, 4, 3);
buttonSaveToExcel.Name = "buttonSaveToExcel";
buttonSaveToExcel.Size = new Size(186, 27);
buttonSaveToExcel.TabIndex = 1;
buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = true;
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
//
// ColumnPastry
//
ColumnPastry.HeaderText = "Изделие";
ColumnPastry.Name = "ColumnPastry";
ColumnPastry.ReadOnly = true;
ColumnPastry.Width = 200;
//
// ColumnComponent
//
ColumnComponent.HeaderText = "Компонент";
ColumnComponent.Name = "ColumnComponent";
ColumnComponent.ReadOnly = true;
ColumnComponent.Width = 200;
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.Name = "ColumnCount";
ColumnCount.ReadOnly = true;
//
// FormReportPastryComponents
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(616, 557);
Controls.Add(buttonSaveToExcel);
Controls.Add(dataGridView);
Margin = new Padding(4, 3, 4, 3);
Name = "FormReportPastryComponents";
Text = "Изделия с компонентами";
Load += FormReportPastryComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.Button buttonSaveToExcel;
private DataGridViewTextBoxColumn ColumnPastry;
private DataGridViewTextBoxColumn ColumnComponent;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,79 @@
using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
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 ConfectioneryView
{
public partial class FormReportPastryComponents : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportPastryComponents(ILogger<FormReportPastryComponents> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormReportPastryComponents_Load(object sender, EventArgs e)
{
try
{
var dict = _logic.GetPastryComponent();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка изделий по компонентам");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SavePastryComponentToExcelFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка изделий по компонентам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -69,6 +69,8 @@ namespace ConfectioneryView
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();
services.AddTransient<FormSellPastry>(); services.AddTransient<FormSellPastry>();
services.AddTransient<FormReportShopPastries>(); services.AddTransient<FormReportShopPastries>();
services.AddTransient<FormReportPastryComponents>();
services.AddTransient<FormReportGroupOrders>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormViewClients>(); services.AddTransient<FormViewClients>();
services.AddTransient<FormViewImplementers>(); services.AddTransient<FormViewImplementers>();

View File

@ -0,0 +1,463 @@
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="ConfectioneryContractsViewModels">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSetOrders">
<Query>
<DataSourceName>ConfectioneryContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="Id">
<DataField>Id</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="Date">
<DataField>Date</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="Count">
<DataField>Count</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Double</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>ConfectioneryContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrdersViewModel</rd:TableName>
<rd:ObjectDataSourceType>ConfectioneryContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<Height>1cm</Height>
<Width>12.40104cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Заказы</Value>
<Style>
<FontSize>16pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Height>1cm</Height>
<Width>12.40104cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>3.21438cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.53188cm</Width>
</TablixColumn>
<TablixColumn>
<Width>4.35209cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Дата создания</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox3">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Количество заказов</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox3</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Date">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Date.Value</Value>
<Style>
<Format>d</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Date</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Count">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Count.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Count</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Sum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Sum.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Sum</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>11.09835cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>Double</Style>
</Border>
</Style>
</Tablix>
<Textbox Name="TextboxTotalSum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Итого:</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>6.6508cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>3</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="SumTotal">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>9.1508cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>4</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</ReportItems>
<Height>5.72875cm</Height>
<Style />
</Body>
<Width>12.40104cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParameters>
<ReportParameter Name="ReportParameterPeriod">
<DataType>String</DataType>
<Nullable>true</Nullable>
<Prompt>ReportParameter1</Prompt>
</ReportParameter>
</ReportParameters>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>ReportParameterPeriod</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
</Report>

View File

@ -21,17 +21,21 @@
<DataField>Id</DataField> <DataField>Id</DataField>
<rd:TypeName>System.Int32</rd:TypeName> <rd:TypeName>System.Int32</rd:TypeName>
</Field> </Field>
<Field Name="Date"> <Field Name="DateCreate">
<DataField>Date</DataField> <DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName> <rd:TypeName>System.DateTime</rd:TypeName>
</Field> </Field>
<Field Name="Count"> <Field Name="PastryName">
<DataField>Count</DataField> <DataField>PastryName</DataField>
<rd:TypeName>System.Int32</rd:TypeName> <rd:TypeName>System.String</rd:TypeName>
</Field> </Field>
<Field Name="Sum"> <Field Name="Sum">
<DataField>Sum</DataField> <DataField>Sum</DataField>
<rd:TypeName>System.Double</rd:TypeName> <rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="OrderStatus">
<DataField>OrderStatus</DataField>
<rd:TypeName>ConfectioneryDataModels.OrderStatus</rd:TypeName>
</Field> </Field>
</Fields> </Fields>
<rd:DataSetInfo> <rd:DataSetInfo>
@ -67,7 +71,7 @@
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName> <rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top> <Top>1cm</Top>
<Height>1cm</Height> <Height>1cm</Height>
<Width>12.40104cm</Width> <Width>21cm</Width>
<Style> <Style>
<Border> <Border>
<Style>None</Style> <Style>None</Style>
@ -99,7 +103,7 @@
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<Height>1cm</Height> <Height>1cm</Height>
<Width>12.40104cm</Width> <Width>21cm</Width>
<ZIndex>1</ZIndex> <ZIndex>1</ZIndex>
<Style> <Style>
<Border> <Border>
@ -115,20 +119,58 @@
<Tablix Name="Tablix1"> <Tablix Name="Tablix1">
<TablixBody> <TablixBody>
<TablixColumns> <TablixColumns>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
<TablixColumn> <TablixColumn>
<Width>3.21438cm</Width> <Width>3.21438cm</Width>
</TablixColumn> </TablixColumn>
<TablixColumn> <TablixColumn>
<Width>3.53188cm</Width> <Width>8.23317cm</Width>
</TablixColumn> </TablixColumn>
<TablixColumn> <TablixColumn>
<Width>4.35209cm</Width> <Width>3.02917cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.87042cm</Width>
</TablixColumn> </TablixColumn>
</TablixColumns> </TablixColumns>
<TablixRows> <TablixRows>
<TablixRow> <TablixRow>
<Height>0.6cm</Height> <Height>0.6cm</Height>
<TablixCells> <TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox5">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Номер</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox5</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="Textbox1"> <Textbox Name="Textbox1">
@ -170,7 +212,7 @@
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>Количество заказов</Value> <Value>Изделие</Value>
<Style> <Style>
<FontWeight>Bold</FontWeight> <FontWeight>Bold</FontWeight>
</Style> </Style>
@ -193,6 +235,38 @@
</Textbox> </Textbox>
</CellContents> </CellContents>
</TablixCell> </TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Статус заказа</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="Textbox7"> <Textbox Name="Textbox7">
@ -232,23 +306,21 @@
<TablixCells> <TablixCells>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="Date"> <Textbox Name="Id">
<CanGrow>true</CanGrow> <CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether> <KeepTogether>true</KeepTogether>
<Paragraphs> <Paragraphs>
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>=Fields!Date.Value</Value> <Value>=Fields!Id.Value</Value>
<Style> <Style />
<Format>d</Format>
</Style>
</TextRun> </TextRun>
</TextRuns> </TextRuns>
<Style /> <Style />
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<rd:DefaultName>Date</rd:DefaultName> <rd:DefaultName>Id</rd:DefaultName>
<Style> <Style>
<Border> <Border>
<Color>LightGrey</Color> <Color>LightGrey</Color>
@ -264,21 +336,23 @@
</TablixCell> </TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="Count"> <Textbox Name="DateCreate">
<CanGrow>true</CanGrow> <CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether> <KeepTogether>true</KeepTogether>
<Paragraphs> <Paragraphs>
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>=Fields!Count.Value</Value> <Value>=Fields!DateCreate.Value</Value>
<Style /> <Style>
<Format>d</Format>
</Style>
</TextRun> </TextRun>
</TextRuns> </TextRuns>
<Style /> <Style />
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<rd:DefaultName>Count</rd:DefaultName> <rd:DefaultName>DateCreate</rd:DefaultName>
<Style> <Style>
<Border> <Border>
<Color>LightGrey</Color> <Color>LightGrey</Color>
@ -292,6 +366,67 @@
</Textbox> </Textbox>
</CellContents> </CellContents>
</TablixCell> </TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="PastryName">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!PastryName.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>PastryName</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="OrderStatus">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!OrderStatus.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>OrderStatus</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="Sum"> <Textbox Name="Sum">
@ -331,6 +466,8 @@
<TablixMember /> <TablixMember />
<TablixMember /> <TablixMember />
<TablixMember /> <TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers> </TablixMembers>
</TablixColumnHierarchy> </TablixColumnHierarchy>
<TablixRowHierarchy> <TablixRowHierarchy>
@ -347,7 +484,7 @@
<Top>2.48391cm</Top> <Top>2.48391cm</Top>
<Left>0.55245cm</Left> <Left>0.55245cm</Left>
<Height>1.2cm</Height> <Height>1.2cm</Height>
<Width>11.09835cm</Width> <Width>19.84713cm</Width>
<ZIndex>2</ZIndex> <ZIndex>2</ZIndex>
<Style> <Style>
<Border> <Border>
@ -374,7 +511,7 @@
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<Top>4cm</Top> <Top>4cm</Top>
<Left>6.6508cm</Left> <Left>15.39958cm</Left>
<Height>0.6cm</Height> <Height>0.6cm</Height>
<Width>2.5cm</Width> <Width>2.5cm</Width>
<ZIndex>3</ZIndex> <ZIndex>3</ZIndex>
@ -407,7 +544,7 @@
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<Top>4cm</Top> <Top>4cm</Top>
<Left>9.1508cm</Left> <Left>17.89958cm</Left>
<Height>0.6cm</Height> <Height>0.6cm</Height>
<Width>2.5cm</Width> <Width>2.5cm</Width>
<ZIndex>4</ZIndex> <ZIndex>4</ZIndex>
@ -425,7 +562,7 @@
<Height>5.72875cm</Height> <Height>5.72875cm</Height>
<Style /> <Style />
</Body> </Body>
<Width>12.40104cm</Width> <Width>21cm</Width>
<Page> <Page>
<PageHeight>29.7cm</PageHeight> <PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth> <PageWidth>21cm</PageWidth>

View File

@ -15,17 +15,37 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
List<ReportShopPastrytViewModel> GetShopPastries(); List<ReportShopPastrytViewModel> GetShopPastries();
/// <summary>
/// Получение списка компонент с указанием, в каких изделиях используются
/// </summary>
/// <returns></returns>
public List<ReportPastryComponentViewModel> GetPastryComponent();
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model); List<ReportGroupOrdersViewModel> GetGroupOrders(ReportBindingModel model);
/// <summary>
/// Получение списка заказов за определенный период
/// </summary>
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveShopsToWordFile(ReportBindingModel model); void SaveShopsTableToWordFile(ReportBindingModel model);
void SavePastriesToWordFile(ReportBindingModel model);
void SavePastryComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel /// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary> /// </summary>
@ -35,6 +55,6 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveGroupOrdersToPdfFile(ReportBindingModel model);
} }
} }

View File

@ -0,0 +1,17 @@
using ConfectioneryDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryContracts.ViewModels
{
public class ReportGroupOrdersViewModel
{
public int Id { get; set; }
public DateTime Date { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
}
}

View File

@ -10,8 +10,9 @@ namespace ConfectioneryContracts.ViewModels
public class ReportOrdersViewModel public class ReportOrdersViewModel
{ {
public int Id { get; set; } public int Id { get; set; }
public DateTime Date { get; set; } public DateTime DateCreate { get; set; }
public int Count { get; set; } public string PastryName { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
public double Sum { get; set; } public double Sum { get; set; }
} }
} }

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryContracts.ViewModels
{
public class ReportPastryComponentViewModel
{
public string PastryName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Components { get; set; } = new();
}
}

View File

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
[DbContext(typeof(ConfectioneryDatabase))] [DbContext(typeof(ConfectioneryDatabase))]
[Migration("20230304103151_add_entity_client")] [Migration("20230307072144_add_client")]
partial class add_entity_client partial class add_client
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,11 +5,12 @@
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class add_entity_client : Migration public partial class add_client : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.Sql("TRUNCATE Orders");
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>(
name: "ClientId", name: "ClientId",
table: "Orders", table: "Orders",

View File

@ -89,10 +89,8 @@ namespace ConfectioneryDatabaseImplement.Models
return new() return new()
{ {
PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty, PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
// ?????? ClientFIO = Client?.ClientFIO ?? string.Empty,
ClientFIO = Client?.ClientFIO ?? context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty, ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
ImplementerFIO = Implementer?.ImplementerFIO ??
context.Implementers.FirstOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty,
PastryId = PastryId, PastryId = PastryId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,

View File

@ -96,5 +96,7 @@ namespace ConfectioneryDatabaseImplement.Models
} }
_pastryComponents = null; _pastryComponents = null;
} }
public static implicit operator ConfectioneryContracts.ViewModels.PastryViewModel(ConfectioneryDatabaseImplement.Models.Pastry model) => model.GetViewModel;
} }
} }

View File

@ -49,7 +49,7 @@ namespace ConfectioneryRestApi.Controllers
{ {
return _order.ReadList(new OrderSearchModel return _order.ReadList(new OrderSearchModel
{ {
Status = OrderStatus.Принят Statusses = new() { OrderStatus.Принят }
}); });
} }
catch (Exception ex) catch (Exception ex)

View File

@ -2,6 +2,7 @@
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.SearchModels; using ConfectioneryContracts.SearchModels;
using ConfectioneryContracts.ViewModels; using ConfectioneryContracts.ViewModels;
using ConfectioneryDatabaseImplement.Models;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Text.Json; using System.Text.Json;
@ -36,13 +37,41 @@ namespace ConfectioneryRestApi.Controllers
} }
} }
/// <summary>
/// Получает на вход айди магазина и по нему возвращает магазин
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>
/// Кортеж из магазина, итератора с изделиями которые находятся в магазине и итератора с количеством этих изделий.
/// </returns>
/// Почему изделия и их количество не находятся в одном кортеже? потому что тогда он их не сериализует
/// и я не знаю почему.
/// Также, к сожалению, приходится явно присваивать каждое поле из IPastyModel в PastyViewModel, поскольку
/// нельзя сериализовать интерфейс, и при это нельзя его неявно кастануть к PastryViewModel, даже если в
/// истинном типе ConfectioneryDatabaseImplement.Pastry такой каст есть.
/// Сделать же каст в PastryViewModel из IPastryModel нельзя, потому что запрещен каст с интерфейсами.
/// Единственный нормальный вариант создать отдельную сущность, где объединить изделия и их количество,
/// и уже ее хранить в магазине и соответственно ее передавать. Но поскольку для этого нужно перелопатить пол-проекта
/// и получить минус баллы на pr я откажусь от подобной идеи.
[HttpGet] [HttpGet]
public ShopViewModel? GetJsonShop(int id) public Tuple<ShopViewModel, IEnumerable<PastryViewModel>, IEnumerable<int>>? GetShopWithPastries(int id)
{ {
try try
{ {
return _logic.ReadElement(new() { Id = id }); var shop = _logic.ReadElement(new() { Id = id });
if (shop == null)
{
return null;
}
return Tuple.Create(shop,
shop.Pastries.Select(x => new PastryViewModel ()
{
Id = x.Value.Item1.Id,
Price = x.Value.Item1.Price,
PastryName = x.Value.Item1.PastryName,
}),
shop.Pastries.Select(x => x.Value.Item2));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -73,7 +102,7 @@ namespace ConfectioneryRestApi.Controllers
public void DeleteShop(ShopBindingModel model) => CRUDShop(() => _logic.Delete(model)); public void DeleteShop(ShopBindingModel model) => CRUDShop(() => _logic.Delete(model));
[HttpPost] [HttpPost]
public void AddPastryInShop(Tuple<ShopSearchModel, IPastryModel, int> countPastryForShop) public void AddPastryInShop(Tuple<ShopSearchModel, PastryViewModel, int> countPastryForShop)
{ {
CRUDShop(() => _logic.AddPastry(countPastryForShop.Item1, countPastryForShop.Item2, countPastryForShop.Item3)); CRUDShop(() => _logic.AddPastry(countPastryForShop.Item1, countPastryForShop.Item2, countPastryForShop.Item3));
} }

View File

@ -98,13 +98,16 @@ namespace ConfectioneryShopApp.Controllers
} }
[HttpGet] [HttpGet]
public Tuple<string, ShopViewModel?> GetTablePastriesFromShop(int shop) public Tuple<string, ShopViewModel>? GetTablePastriesFromShop(int shop)
{ {
var sh = APIClient.GetRequest<ShopViewModel>($"api/shop/getjsonshop?id={shop}"); var result = APIClient.GetRequest<Tuple<ShopViewModel, IEnumerable<PastryViewModel>, IEnumerable<int>>?>($"api/shop/getshopwithpastries?id={shop}");
if (result == null)
{
return null;
}
var shopModel = result.Item1;
var resultHtml = ""; var resultHtml = "";
if (sh != null) foreach (var (item, count) in result.Item2.Zip(result.Item3))
{
foreach (var (item, count) in sh.Pastries.Values)
{ {
resultHtml += "<tr>"; resultHtml += "<tr>";
resultHtml += $"<td>{item?.PastryName ?? string.Empty}</td>"; resultHtml += $"<td>{item?.PastryName ?? string.Empty}</td>";
@ -112,8 +115,7 @@ namespace ConfectioneryShopApp.Controllers
resultHtml += $"<td>{count}</td>"; resultHtml += $"<td>{count}</td>";
resultHtml += "</tr>"; resultHtml += "</tr>";
} }
} return Tuple.Create(resultHtml, shopModel);
return Tuple.Create(resultHtml, sh);
} }
[HttpGet] [HttpGet]
@ -189,7 +191,7 @@ namespace ConfectioneryShopApp.Controllers
} }
APIClient.PostRequest("api/shop/addpastryinshop", Tuple.Create( APIClient.PostRequest("api/shop/addpastryinshop", Tuple.Create(
new ShopSearchModel() { Id = shop }, new ShopSearchModel() { Id = shop },
new PastryBindingModel() { Id = pastry }, new PastryViewModel() { Id = pastry },
count count
)); ));
Response.Redirect("Index"); Response.Redirect("Index");

View File

@ -7,7 +7,7 @@
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Заказы</h1> <h1 class="display-4">Магазины</h1>
</div> </div>

View File

@ -58,10 +58,13 @@
url: "/Home/GetTablePastriesFromShop", url: "/Home/GetTablePastriesFromShop",
data: { shop: shop }, data: { shop: shop },
success: function (result) { success: function (result) {
if (result != null)
{
$('#name').val(result.item2.name); $('#name').val(result.item2.name);
$('#address').val(result.item2.address); $('#address').val(result.item2.address);
$('#table-pastries').html(result.item1); $('#table-pastries').html(result.item1);
} }
}
}); });
}; };
} }

View File

@ -23,7 +23,7 @@
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Магазины</a>
</li> </li>
</ul> </ul>
</div> </div>