4 базовая

This commit is contained in:
Inohara 2023-03-14 10:30:13 +04:00
parent 2f7b71f1f8
commit 391beb9c32
32 changed files with 611 additions and 356 deletions

View File

@ -43,7 +43,7 @@ namespace IceCreamBusinessLogic.BusinessLogics
/// Получение списка компонент с указанием, в каких изделиях используются /// Получение списка компонент с указанием, в каких изделиях используются
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ReportIceCreamComponentViewModel> GetProductComponent() public List<ReportIceCreamComponentViewModel> GetIceCreamComponent()
{ {
var components = _componentStorage.GetFullList(); var components = _componentStorage.GetFullList();
@ -51,20 +51,20 @@ namespace IceCreamBusinessLogic.BusinessLogics
var list = new List<ReportIceCreamComponentViewModel>(); var list = new List<ReportIceCreamComponentViewModel>();
foreach (var component in components) foreach (var icecream in iceCreams)
{ {
var record = new ReportIceCreamComponentViewModel var record = new ReportIceCreamComponentViewModel
{ {
ComponentName = component.ComponentName, IceCreamName = icecream.IceCreamName,
IceCreams = new List<(string, int)>(), Components = new List<(string, int)>(),
TotalCount = 0 TotalCount = 0
}; };
foreach (var product in iceCreams) foreach (var component in components)
{ {
if (product.IceCreamComponents.ContainsKey(component.Id)) if (icecream.IceCreamComponents.ContainsKey(component.Id))
{ {
record.IceCreams.Add(new(product.IceCreamName, product.IceCreamComponents[component.Id].Item2)); record.Components.Add(new(component.ComponentName, icecream.IceCreamComponents[component.Id].Item2));
record.TotalCount += product.IceCreamComponents[component.Id].Item2; record.TotalCount += icecream.IceCreamComponents[component.Id].Item2;
} }
} }
@ -87,6 +87,7 @@ namespace IceCreamBusinessLogic.BusinessLogics
Id = x.Id, Id = x.Id,
DateCreate = x.DateCreate, DateCreate = x.DateCreate,
IceCreamName = x.IceCreamName, IceCreamName = x.IceCreamName,
OrderStatus = Convert.ToString(x.Status) ?? String.Empty,
Sum = x.Sum Sum = x.Sum
}) })
.ToList(); .ToList();
@ -96,13 +97,13 @@ namespace IceCreamBusinessLogic.BusinessLogics
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model) public void SaveIceCreamsToWordFile(ReportBindingModel model)
{ {
_saveToWord.CreateDoc(new WordInfo _saveToWord.CreateDoc(new WordInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список изделий",
Components = _componentStorage.GetFullList() IceCreams = _iceCreamStorage.GetFullList()
}); });
} }
@ -110,13 +111,13 @@ namespace IceCreamBusinessLogic.BusinessLogics
/// Сохранение компонент с указаеним продуктов в файл-Excel /// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
public void SaveProductComponentToExcelFile(ReportBindingModel model) public void SaveIceCreamComponentToExcelFile(ReportBindingModel model)
{ {
_saveToExcel.CreateReport(new ExcelInfo _saveToExcel.CreateReport(new ExcelInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список изделий",
ProductComponents = GetProductComponent() IceCreamComponents = GetIceCreamComponent()
}); });
} }

View File

@ -28,18 +28,18 @@ namespace IceCreamBusinessLogic.OfficePackage
}); });
uint rowIndex = 2; uint rowIndex = 2;
foreach (var pc in info.ProductComponents) foreach (var pc in info.IceCreamComponents)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = pc.ComponentName, Text = pc.IceCreamName,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var (IceCream, Count) in pc.IceCreams) foreach (var (IceCream, Count) in pc.Components)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {

View File

@ -14,13 +14,15 @@ namespace IceCreamBusinessLogic.OfficePackage
{ {
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); 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 }); CreateParagraph(new PdfParagraph {
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" }); CreateTable(new List<string> { "2cm", "3cm", "6cm", "4cm", "3cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" }, Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
@ -29,7 +31,7 @@ namespace IceCreamBusinessLogic.OfficePackage
{ {
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.IceCreamName, order.Sum.ToString() }, Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.IceCreamName, Convert.ToString(order.OrderStatus), order.Sum.ToString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left ParagraphAlignment = PdfParagraphAlignmentType.Left
}); });

View File

@ -19,11 +19,14 @@ namespace IceCreamBusinessLogic.OfficePackage
} }
}); });
foreach (var component in info.Components) foreach (var iceCream in info.IceCreams)
{ {
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) }, Texts = new List<(string, WordTextProperties)> {
(iceCream.IceCreamName, new WordTextProperties { Size = "24", Bold = true}),
(" - цена " + iceCream.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",

View File

@ -8,6 +8,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportIceCreamComponentViewModel> ProductComponents { get; set; } = new(); public List<ReportIceCreamComponentViewModel> IceCreamComponents { get; set; } = new();
} }
} }

View File

@ -8,6 +8,6 @@ namespace IceCreamBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new(); public List<IceCreamViewModel> IceCreams { get; set; } = new();
} }
} }

View File

@ -28,170 +28,173 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
buttonUpdate = new Button(); this.buttonUpdate = new System.Windows.Forms.Button();
buttonSetToFinish = new Button(); this.buttonSetToFinish = new System.Windows.Forms.Button();
buttonSetToDone = new Button(); this.buttonSetToDone = new System.Windows.Forms.Button();
buttonSetToWork = new Button(); this.buttonSetToWork = new System.Windows.Forms.Button();
buttonCreateOrder = new Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
dataGridView = new DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
menuStrip = new MenuStrip(); this.menuStrip = new System.Windows.Forms.MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem(); this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
мороженоеToolStripMenuItem = new ToolStripMenuItem(); this.мороженоеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem(); this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem(); this.iceCreamComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
componentIceCreamsToolStripMenuItem = new ToolStripMenuItem(); this.iceCreamToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
ordersToolStripMenuItem = new ToolStripMenuItem(); this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
SuspendLayout(); this.SuspendLayout();
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(878, 294); this.buttonUpdate.Location = new System.Drawing.Point(1003, 392);
buttonUpdate.Margin = new Padding(3, 2, 3, 2); this.buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Name = "buttonUpdate"; this.buttonUpdate.Size = new System.Drawing.Size(194, 49);
buttonUpdate.Size = new Size(170, 37); this.buttonUpdate.TabIndex = 13;
buttonUpdate.TabIndex = 13; this.buttonUpdate.Text = "Обновить";
buttonUpdate.Text = "Обновить"; this.buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
buttonUpdate.Click += buttonUpdate_Click;
// //
// buttonSetToFinish // buttonSetToFinish
// //
buttonSetToFinish.Location = new Point(878, 225); this.buttonSetToFinish.Location = new System.Drawing.Point(1003, 300);
buttonSetToFinish.Margin = new Padding(3, 2, 3, 2); this.buttonSetToFinish.Name = "buttonSetToFinish";
buttonSetToFinish.Name = "buttonSetToFinish"; this.buttonSetToFinish.Size = new System.Drawing.Size(194, 49);
buttonSetToFinish.Size = new Size(170, 37); this.buttonSetToFinish.TabIndex = 12;
buttonSetToFinish.TabIndex = 12; this.buttonSetToFinish.Text = "Заказ выдан";
buttonSetToFinish.Text = "Заказ выдан"; this.buttonSetToFinish.UseVisualStyleBackColor = true;
buttonSetToFinish.UseVisualStyleBackColor = true; this.buttonSetToFinish.Click += new System.EventHandler(this.buttonSetToFinish_Click);
buttonSetToFinish.Click += buttonSetToFinish_Click;
// //
// buttonSetToDone // buttonSetToDone
// //
buttonSetToDone.Location = new Point(878, 160); this.buttonSetToDone.Location = new System.Drawing.Point(1003, 213);
buttonSetToDone.Margin = new Padding(3, 2, 3, 2); this.buttonSetToDone.Name = "buttonSetToDone";
buttonSetToDone.Name = "buttonSetToDone"; this.buttonSetToDone.Size = new System.Drawing.Size(194, 49);
buttonSetToDone.Size = new Size(170, 37); this.buttonSetToDone.TabIndex = 11;
buttonSetToDone.TabIndex = 11; this.buttonSetToDone.Text = "Заказ готов";
buttonSetToDone.Text = "Заказ готов"; this.buttonSetToDone.UseVisualStyleBackColor = true;
buttonSetToDone.UseVisualStyleBackColor = true; this.buttonSetToDone.Click += new System.EventHandler(this.buttonSetToDone_Click);
buttonSetToDone.Click += buttonSetToDone_Click;
// //
// buttonSetToWork // buttonSetToWork
// //
buttonSetToWork.Location = new Point(878, 93); this.buttonSetToWork.Location = new System.Drawing.Point(1003, 124);
buttonSetToWork.Margin = new Padding(3, 2, 3, 2); this.buttonSetToWork.Name = "buttonSetToWork";
buttonSetToWork.Name = "buttonSetToWork"; this.buttonSetToWork.Size = new System.Drawing.Size(194, 49);
buttonSetToWork.Size = new Size(170, 37); this.buttonSetToWork.TabIndex = 10;
buttonSetToWork.TabIndex = 10; this.buttonSetToWork.Text = "Отдать на выполнение";
buttonSetToWork.Text = "Отдать на выполнение"; this.buttonSetToWork.UseVisualStyleBackColor = true;
buttonSetToWork.UseVisualStyleBackColor = true; this.buttonSetToWork.Click += new System.EventHandler(this.buttonSetToWork_Click);
buttonSetToWork.Click += buttonSetToWork_Click;
// //
// buttonCreateOrder // buttonCreateOrder
// //
buttonCreateOrder.Location = new Point(878, 26); this.buttonCreateOrder.Location = new System.Drawing.Point(1003, 35);
buttonCreateOrder.Margin = new Padding(3, 2, 3, 2); this.buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Name = "buttonCreateOrder"; this.buttonCreateOrder.Size = new System.Drawing.Size(194, 49);
buttonCreateOrder.Size = new Size(170, 37); this.buttonCreateOrder.TabIndex = 9;
buttonCreateOrder.TabIndex = 9; this.buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.UseVisualStyleBackColor = true; this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
buttonCreateOrder.Click += buttonCreateOrder_Click;
// //
// dataGridView // dataGridView
// //
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 26); this.dataGridView.Location = new System.Drawing.Point(14, 35);
dataGridView.Margin = new Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView";
dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51;
dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29;
dataGridView.RowTemplate.Height = 29; this.dataGridView.Size = new System.Drawing.Size(969, 407);
dataGridView.Size = new Size(848, 305); this.dataGridView.TabIndex = 8;
dataGridView.TabIndex = 8;
// //
// menuStrip // menuStrip
// //
menuStrip.ImageScalingSize = new Size(20, 20); this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
menuStrip.Location = new Point(0, 0); this.справочникиToolStripMenuItem,
menuStrip.Name = "menuStrip"; this.отчетыToolStripMenuItem});
menuStrip.Padding = new Padding(5, 2, 0, 2); this.menuStrip.Location = new System.Drawing.Point(0, 0);
menuStrip.Size = new Size(1072, 24); this.menuStrip.Name = "menuStrip";
menuStrip.TabIndex = 7; this.menuStrip.Padding = new System.Windows.Forms.Padding(6, 3, 0, 3);
menuStrip.Text = "Справочники"; this.menuStrip.Size = new System.Drawing.Size(1225, 30);
this.menuStrip.TabIndex = 7;
this.menuStrip.Text = "Справочники";
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, мороженоеToolStripMenuItem }); this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.компонентыToolStripMenuItem,
справочникиToolStripMenuItem.Size = new Size(94, 20); this.мороженоеToolStripMenuItem});
справочникиToolStripMenuItem.Text = "Справочники"; this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.справочникиToolStripMenuItem.Text = "Справочники";
// //
// компонентыToolStripMenuItem // компонентыToolStripMenuItem
// //
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(145, 22); this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
// //
// мороженоеToolStripMenuItem // мороженоеToolStripMenuItem
// //
мороженоеToolStripMenuItem.Name = ороженоеToolStripMenuItem"; this.мороженоеToolStripMenuItem.Name = ороженоеToolStripMenuItem";
мороженоеToolStripMenuItem.Size = new Size(145, 22); this.мороженоеToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
мороженоеToolStripMenuItem.Text = "Мороженое"; this.мороженоеToolStripMenuItem.Text = "Мороженое";
мороженоеToolStripMenuItem.Click += мороженоеToolStripMenuItem_Click; this.мороженоеToolStripMenuItem.Click += new System.EventHandler(this.мороженоеToolStripMenuItem_Click);
// //
// отчетыToolStripMenuItem // отчетыToolStripMenuItem
// //
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, componentIceCreamsToolStripMenuItem, ordersToolStripMenuItem }); this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; this.iceCreamComponentsToolStripMenuItem,
отчетыToolStripMenuItem.Size = new Size(60, 20); this.iceCreamToolStripMenuItem,
отчетыToolStripMenuItem.Text = "Отчеты"; this.ordersToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
this.отчетыToolStripMenuItem.Text = "Отчеты";
// //
// componentsToolStripMenuItem // iceCreamComponentsToolStripMenuItem
// //
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; this.iceCreamComponentsToolStripMenuItem.Name = "iceCreamComponentsToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(235, 22); this.iceCreamComponentsToolStripMenuItem.Size = new System.Drawing.Size(299, 26);
componentsToolStripMenuItem.Text = "Список компонентов"; this.iceCreamComponentsToolStripMenuItem.Text = "Список мороженых";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; this.iceCreamComponentsToolStripMenuItem.Click += new System.EventHandler(this.IceCreamsToolStripMenuItem_Click);
// //
// componentIceCreamsToolStripMenuItem // iceCreamToolStripMenuItem
// //
componentIceCreamsToolStripMenuItem.Name = "componentIceCreamsToolStripMenuItem"; this.iceCreamToolStripMenuItem.Name = "iceCreamToolStripMenuItem";
componentIceCreamsToolStripMenuItem.Size = new Size(235, 22); this.iceCreamToolStripMenuItem.Size = new System.Drawing.Size(299, 26);
componentIceCreamsToolStripMenuItem.Text = "Компоненты по мороженым"; this.iceCreamToolStripMenuItem.Text = "Мороженые с компонентами";
componentIceCreamsToolStripMenuItem.Click += ComponentIceCreamsToolStripMenuItem_Click; this.iceCreamToolStripMenuItem.Click += new System.EventHandler(this.IceCreamComponentsToolStripMenuItem_Click);
// //
// ordersToolStripMenuItem // ordersToolStripMenuItem
// //
ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
ordersToolStripMenuItem.Size = new Size(235, 22); this.ordersToolStripMenuItem.Size = new System.Drawing.Size(299, 26);
ordersToolStripMenuItem.Text = "Список заказов"; this.ordersToolStripMenuItem.Text = "Список заказов";
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
// //
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(1072, 347); this.ClientSize = new System.Drawing.Size(1225, 463);
Controls.Add(buttonUpdate); this.Controls.Add(this.buttonUpdate);
Controls.Add(buttonSetToFinish); this.Controls.Add(this.buttonSetToFinish);
Controls.Add(buttonSetToDone); this.Controls.Add(this.buttonSetToDone);
Controls.Add(buttonSetToWork); this.Controls.Add(this.buttonSetToWork);
Controls.Add(buttonCreateOrder); this.Controls.Add(this.buttonCreateOrder);
Controls.Add(dataGridView); this.Controls.Add(this.dataGridView);
Controls.Add(menuStrip); this.Controls.Add(this.menuStrip);
Name = "FormMain"; this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
Text = "Магазин мороженого"; this.Name = "FormMain";
Load += FormMain_Load; this.Text = "Магазин мороженого";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); this.Load += new System.EventHandler(this.FormMain_Load);
menuStrip.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
menuStrip.PerformLayout(); this.menuStrip.ResumeLayout(false);
ResumeLayout(false); this.menuStrip.PerformLayout();
PerformLayout(); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
@ -207,8 +210,8 @@
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem мороженоеToolStripMenuItem; private ToolStripMenuItem мороженоеToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem; private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem iceCreamComponentsToolStripMenuItem;
private ToolStripMenuItem componentIceCreamsToolStripMenuItem; private ToolStripMenuItem iceCreamToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem;
} }
} }

View File

@ -167,17 +167,17 @@ namespace IceCreamShopView
LoadData(); LoadData();
} }
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) private void IceCreamsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
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.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); _reportLogic.SaveIceCreamsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
private void ComponentIceCreamsToolStripMenuItem_Click(object sender, EventArgs e) private void IceCreamComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportProductComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormReportProductComponents));
if (service is FormReportProductComponents form) if (service is FormReportProductComponents form)

View File

@ -28,99 +28,103 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
buttonToPdf = new Button(); this.buttonToPdf = new System.Windows.Forms.Button();
panel = new Panel(); this.panel = new System.Windows.Forms.Panel();
buttonMake = new Button(); this.buttonMake = new System.Windows.Forms.Button();
dateTimePickerTo = new DateTimePicker(); this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
labelTo = new Label(); this.labelTo = new System.Windows.Forms.Label();
dateTimePickerFrom = new DateTimePicker(); this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
labelFrom = new Label(); this.labelFrom = new System.Windows.Forms.Label();
panel.SuspendLayout(); this.panel.SuspendLayout();
SuspendLayout(); this.SuspendLayout();
// //
// buttonToPdf // buttonToPdf
// //
buttonToPdf.Anchor = AnchorStyles.Top | AnchorStyles.Right; this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
buttonToPdf.Location = new Point(819, 8); this.buttonToPdf.Location = new System.Drawing.Point(936, 11);
buttonToPdf.Margin = new Padding(4, 3, 4, 3); this.buttonToPdf.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
buttonToPdf.Name = "buttonToPdf"; this.buttonToPdf.Name = "buttonToPdf";
buttonToPdf.Size = new Size(139, 27); this.buttonToPdf.Size = new System.Drawing.Size(159, 36);
buttonToPdf.TabIndex = 6; this.buttonToPdf.TabIndex = 6;
buttonToPdf.Text = "В Pdf"; this.buttonToPdf.Text = "В Pdf";
buttonToPdf.UseVisualStyleBackColor = true; this.buttonToPdf.UseVisualStyleBackColor = true;
this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
// //
// panel // panel
// //
panel.Controls.Add(buttonMake); this.panel.Controls.Add(this.buttonMake);
panel.Controls.Add(buttonToPdf); this.panel.Controls.Add(this.buttonToPdf);
panel.Controls.Add(dateTimePickerTo); this.panel.Controls.Add(this.dateTimePickerTo);
panel.Controls.Add(labelTo); this.panel.Controls.Add(this.labelTo);
panel.Controls.Add(dateTimePickerFrom); this.panel.Controls.Add(this.dateTimePickerFrom);
panel.Controls.Add(labelFrom); this.panel.Controls.Add(this.labelFrom);
panel.Dock = DockStyle.Top; this.panel.Dock = System.Windows.Forms.DockStyle.Top;
panel.Location = new Point(0, 0); this.panel.Location = new System.Drawing.Point(0, 0);
panel.Margin = new Padding(4, 3, 4, 3); this.panel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
panel.Name = "panel"; this.panel.Name = "panel";
panel.Size = new Size(1006, 40); this.panel.Size = new System.Drawing.Size(1150, 53);
panel.TabIndex = 7; this.panel.TabIndex = 7;
// //
// buttonMake // buttonMake
// //
buttonMake.Location = new Point(476, 8); this.buttonMake.Location = new System.Drawing.Point(544, 11);
buttonMake.Margin = new Padding(4, 3, 4, 3); this.buttonMake.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
buttonMake.Name = "buttonMake"; this.buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(139, 27); this.buttonMake.Size = new System.Drawing.Size(159, 36);
buttonMake.TabIndex = 4; this.buttonMake.TabIndex = 4;
buttonMake.Text = "Сформировать"; this.buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true; this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
// //
// dateTimePickerTo // dateTimePickerTo
// //
dateTimePickerTo.Location = new Point(237, 7); this.dateTimePickerTo.Location = new System.Drawing.Point(271, 9);
dateTimePickerTo.Margin = new Padding(4, 3, 4, 3); this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
dateTimePickerTo.Name = "dateTimePickerTo"; this.dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(163, 23); this.dateTimePickerTo.Size = new System.Drawing.Size(186, 27);
dateTimePickerTo.TabIndex = 3; this.dateTimePickerTo.TabIndex = 3;
// //
// labelTo // labelTo
// //
labelTo.AutoSize = true; this.labelTo.AutoSize = true;
labelTo.Location = new Point(208, 10); this.labelTo.Location = new System.Drawing.Point(238, 13);
labelTo.Margin = new Padding(4, 0, 4, 0); this.labelTo.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
labelTo.Name = "labelTo"; this.labelTo.Name = "labelTo";
labelTo.Size = new Size(21, 15); this.labelTo.Size = new System.Drawing.Size(27, 20);
labelTo.TabIndex = 2; this.labelTo.TabIndex = 2;
labelTo.Text = "по"; this.labelTo.Text = "по";
// //
// dateTimePickerFrom // dateTimePickerFrom
// //
dateTimePickerFrom.Location = new Point(37, 7); this.dateTimePickerFrom.Location = new System.Drawing.Point(42, 9);
dateTimePickerFrom.Margin = new Padding(4, 3, 4, 3); this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
dateTimePickerFrom.Name = "dateTimePickerFrom"; this.dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(163, 23); this.dateTimePickerFrom.Size = new System.Drawing.Size(186, 27);
dateTimePickerFrom.TabIndex = 1; this.dateTimePickerFrom.TabIndex = 1;
// //
// labelFrom // labelFrom
// //
labelFrom.AutoSize = true; this.labelFrom.AutoSize = true;
labelFrom.Location = new Point(14, 10); this.labelFrom.Location = new System.Drawing.Point(16, 13);
labelFrom.Margin = new Padding(4, 0, 4, 0); this.labelFrom.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
labelFrom.Name = "labelFrom"; this.labelFrom.Name = "labelFrom";
labelFrom.Size = new Size(15, 15); this.labelFrom.Size = new System.Drawing.Size(18, 20);
labelFrom.TabIndex = 0; this.labelFrom.TabIndex = 0;
labelFrom.Text = "С"; this.labelFrom.Text = "С";
// //
// FormReportOrders // FormReportOrders
// //
AutoScaleDimensions = new SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(1006, 450); this.ClientSize = new System.Drawing.Size(1150, 600);
Controls.Add(panel); this.Controls.Add(this.panel);
Name = "FormReportOrders"; this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
Text = "Заказы"; this.Name = "FormReportOrders";
panel.ResumeLayout(false); this.Text = "Заказы";
panel.PerformLayout(); this.panel.ResumeLayout(false);
ResumeLayout(false); this.panel.PerformLayout();
this.ResumeLayout(false);
} }
#endregion #endregion

View File

@ -29,14 +29,14 @@ namespace IceCreamShopView
{ {
try try
{ {
var dict = _logic.GetProductComponent(); var dict = _logic.GetIceCreamComponent();
if (dict != null) if (dict != null)
{ {
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var elem in dict) foreach (var elem in dict)
{ {
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); dataGridView.Rows.Add(new object[] { elem.IceCreamName, "", "" });
foreach (var listElem in elem.IceCreams) foreach (var listElem in elem.Components)
{ {
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
} }
@ -60,7 +60,7 @@ namespace IceCreamShopView
{ {
try try
{ {
_logic.SaveProductComponentToExcelFile(new ReportBindingModel _logic.SaveIceCreamComponentToExcelFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });

View File

@ -26,4 +26,10 @@
<ProjectReference Include="..\IceCreamShopListImplement\IceCreamShopListImplement.csproj" /> <ProjectReference Include="..\IceCreamShopListImplement\IceCreamShopListImplement.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="ReportOrders.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="IIceCreamLogic" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>IceCreamShopContracts.BusinessLogicsContracts.IIceCreamLogic, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="IOrderLogic" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>IceCreamShopContracts.BusinessLogicsContracts.IOrderLogic, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="IComponentStorage" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>IceCreamShopContracts.StoragesContracts.IComponentStorage, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="IIceCreamStorage" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>IceCreamShopContracts.StoragesContracts.IIceCreamStorage, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="IOrderStorage" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>IceCreamShopContracts.StoragesContracts.IOrderStorage, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -2,18 +2,18 @@
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh> <AutoRefresh>0</AutoRefresh>
<DataSources> <DataSources>
<DataSource Name="AbstractShopContractsViewModels"> <DataSource Name="IceCreamShopContractsViewModels">
<ConnectionProperties> <ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider> <DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString> <ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties> </ConnectionProperties>
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID> <rd:DataSourceID>47cb53f0-7dde-4717-ba03-866a0bc4f4dd</rd:DataSourceID>
</DataSource> </DataSource>
</DataSources> </DataSources>
<DataSets> <DataSets>
<DataSet Name="DataSetOrders"> <DataSet Name="DataSetOrders">
<Query> <Query>
<DataSourceName>AbstractShopContractsViewModels</DataSourceName> <DataSourceName>IceCreamShopContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText> <CommandText>/* Local Query */</CommandText>
</Query> </Query>
<Fields> <Fields>
@ -25,19 +25,23 @@
<DataField>DateCreate</DataField> <DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName> <rd:TypeName>System.DateTime</rd:TypeName>
</Field> </Field>
<Field Name="ProductName"> <Field Name="IceCreamName">
<DataField>ProductName</DataField> <DataField>IceCreamName</DataField>
<rd:TypeName>System.String</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.Decimal</rd:TypeName> <rd:TypeName>System.Decimal</rd:TypeName>
</Field> </Field>
<Field Name="OrderStatus">
<DataField>OrderStatus</DataField>
<rd:TypeName>IceCreamShopDataModels.OrderStatus</rd:TypeName>
</Field>
</Fields> </Fields>
<rd:DataSetInfo> <rd:DataSetInfo>
<rd:DataSetName>AbstractShopContracts.ViewModels</rd:DataSetName> <rd:DataSetName>IceCreamShopContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrdersViewModel</rd:TableName> <rd:TableName>ReportOrderViewModel</rd:TableName>
<rd:ObjectDataSourceType>AbstractShopContracts.ViewModels.ReportOrdersViewModel, AbstractShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType> <rd:ObjectDataSourceType>IceCreamShopContracts.ViewModels.ReportOrderViewModel, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo> </rd:DataSetInfo>
</DataSet> </DataSet>
</DataSets> </DataSets>
@ -127,6 +131,9 @@
<TablixColumn> <TablixColumn>
<Width>2.5cm</Width> <Width>2.5cm</Width>
</TablixColumn> </TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
</TablixColumns> </TablixColumns>
<TablixRows> <TablixRows>
<TablixRow> <TablixRow>
@ -228,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">
@ -336,13 +375,44 @@
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>=Fields!ProductName.Value</Value> <Value>=Fields!IceCreamName.Value</Value>
<Style /> <Style />
</TextRun> </TextRun>
</TextRuns> </TextRuns>
<Style /> <Style />
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<rd:DefaultName>IceCreamName</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> <Style>
<Border> <Border>
<Color>LightGrey</Color> <Color>LightGrey</Color>
@ -397,6 +467,7 @@
<TablixMember /> <TablixMember />
<TablixMember /> <TablixMember />
<TablixMember /> <TablixMember />
<TablixMember />
</TablixMembers> </TablixMembers>
</TablixColumnHierarchy> </TablixColumnHierarchy>
<TablixRowHierarchy> <TablixRowHierarchy>
@ -413,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>16.44755cm</Width> <Width>18.94755cm</Width>
<ZIndex>2</ZIndex> <ZIndex>2</ZIndex>
<Style> <Style>
<Border> <Border>
@ -513,7 +584,7 @@
</ReportParameters> </ReportParameters>
<ReportParametersLayout> <ReportParametersLayout>
<GridLayoutDefinition> <GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns> <NumberOfColumns>5</NumberOfColumns>
<NumberOfRows>2</NumberOfRows> <NumberOfRows>2</NumberOfRows>
<CellDefinitions> <CellDefinitions>
<CellDefinition> <CellDefinition>
@ -525,5 +596,5 @@
</GridLayoutDefinition> </GridLayoutDefinition>
</ReportParametersLayout> </ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType> <rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID> <rd:ReportID>1c0c12af-b9e8-41db-8d1f-26d1acbf91cc</rd:ReportID>
</Report> </Report>

View File

@ -14,7 +14,7 @@ namespace IceCreamShopContracts.BusinessLogicsContracts
/// Получение списка компонент с указанием, в каких изделиях используются /// Получение списка компонент с указанием, в каких изделиях используются
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
List<ReportIceCreamComponentViewModel> GetProductComponent(); List<ReportIceCreamComponentViewModel> GetIceCreamComponent();
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
@ -27,13 +27,13 @@ namespace IceCreamShopContracts.BusinessLogicsContracts
/// Сохранение компонент в файл-Word /// Сохранение компонент в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveComponentsToWordFile(ReportBindingModel model); void SaveIceCreamsToWordFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel /// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveProductComponentToExcelFile(ReportBindingModel model); void SaveIceCreamComponentToExcelFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf

View File

@ -8,10 +8,10 @@ namespace IceCreamShopContracts.ViewModels
{ {
public class ReportIceCreamComponentViewModel public class ReportIceCreamComponentViewModel
{ {
public string ComponentName { get; set; } = string.Empty; public string IceCreamName { get; set; } = string.Empty;
public int TotalCount { get; set; } public int TotalCount { get; set; }
public List<(string IceCream, int Count)> IceCreams { get; set; } = new(); public List<(string IceCream, int Count)> Components { get; set; } = new();
} }
} }

View File

@ -13,6 +13,7 @@ namespace IceCreamShopContracts.ViewModels
public DateTime DateCreate { get; set; } public DateTime DateCreate { get; set; }
public string IceCreamName { get; set; } = string.Empty; public string IceCreamName { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty ;
public double Sum { get; set; } public double Sum { get; set; }
} }

View File

@ -4,6 +4,7 @@ using IceCreamShopContracts.ViewModels;
using IceCreamShopContracts.BindingModels; using IceCreamShopContracts.BindingModels;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using IceCreamShopDatabaseImplement.Models; using IceCreamShopDatabaseImplement.Models;
using System.Reflection.Metadata;
namespace IceCreamShopDatabaseImplement.Implements namespace IceCreamShopDatabaseImplement.Implements
{ {
@ -53,14 +54,29 @@ namespace IceCreamShopDatabaseImplement.Implements
public IceCreamViewModel? Insert(IceCreamBindingModel model) public IceCreamViewModel? Insert(IceCreamBindingModel model)
{ {
using var context = new IceCreamShopDatabase(); using var context = new IceCreamShopDatabase();
var newIceCream = IceCream.Create(context, model); using var transaction = context.Database.BeginTransaction();
if (newIceCream == null)
{ {
return null; try
{
var newIceCream = IceCream.Create(context, model);
if (newIceCream == null)
{
transaction.Rollback();
return null;
}
context.IceCreams.Add(newIceCream);
context.SaveChanges();
context.Database.CommitTransaction();
return newIceCream.GetViewModel;
}
catch (Exception)
{
transaction.Rollback();
return null;
}
} }
context.IceCreams.Add(newIceCream);
context.SaveChanges();
return newIceCream.GetViewModel;
} }
public IceCreamViewModel? Update(IceCreamBindingModel model) public IceCreamViewModel? Update(IceCreamBindingModel model)

View File

@ -3,6 +3,7 @@ using IceCreamShopContracts.SearchModels;
using IceCreamShopContracts.StoragesContracts; using IceCreamShopContracts.StoragesContracts;
using IceCreamShopContracts.ViewModels; using IceCreamShopContracts.ViewModels;
using IceCreamShopDatabaseImplement.Models; using IceCreamShopDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace IceCreamShopDatabaseImplement.Implements namespace IceCreamShopDatabaseImplement.Implements
{ {
@ -33,19 +34,20 @@ namespace IceCreamShopDatabaseImplement.Implements
} }
using var context = new IceCreamShopDatabase(); using var context = new IceCreamShopDatabase();
return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; return context.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (model is null) return new();
using var context = new IceCreamShopDatabase();
if (!model.Id.HasValue) if (!model.Id.HasValue)
{ {
return new(); return context.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).
Select(x => x.GetViewModel).ToList();
} }
using var context = new IceCreamShopDatabase();
return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); return context.Orders.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
} }
@ -70,7 +72,7 @@ namespace IceCreamShopDatabaseImplement.Implements
context.Orders.Add(newOrder); context.Orders.Add(newOrder);
context.SaveChanges(); context.SaveChanges();
return newOrder.GetViewModel; return context.Orders.FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -87,7 +89,7 @@ namespace IceCreamShopDatabaseImplement.Implements
order.Update(model); order.Update(model);
context.SaveChanges(); context.SaveChanges();
return order.GetViewModel; return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
} }
} }
} }

View File

@ -0,0 +1,171 @@
// <auto-generated />
using System;
using IceCreamShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IceCreamShopDatabaseImplement.Migrations
{
[DbContext(typeof(IceCreamShopDatabase))]
[Migration("20230313191542_NewMigration")]
partial class NewMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("IceCreamName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("IceCreams");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("IceCreamId");
b.ToTable("IceCreamComponents");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.ToTable("Orders");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component")
.WithMany("IceCreamComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany("Components")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("IceCream");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany("Orders")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("IceCream");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b =>
{
b.Navigation("IceCreamComponents");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCream", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IceCreamShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class NewMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -108,10 +108,6 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.Property<int>("IceCreamId") b.Property<int>("IceCreamId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("IceCreamName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
@ -120,7 +116,7 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("DocumentId"); b.HasIndex("IceCreamId");
b.ToTable("Orders"); b.ToTable("Orders");
}); });
@ -144,6 +140,17 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.Navigation("IceCream"); b.Navigation("IceCream");
}); });
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany("Orders")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("IceCream");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b => modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("IceCreamComponents"); b.Navigation("IceCreamComponents");

View File

@ -20,7 +20,7 @@ namespace IceCreamShopDatabaseImplement.Models
[ForeignKey("ComponentId")] [ForeignKey("ComponentId")]
public virtual List<IceCreamComponent> IceCreamComponents { get; set; } = new(); public virtual List<IceCreamComponent> IceCreamComponents { get; set; } = new();
public static Component? Create(ComponentBindingModel model) public static Component? Create(ComponentBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
@ -33,16 +33,8 @@ namespace IceCreamShopDatabaseImplement.Models
Cost = model.Cost Cost = model.Cost
}; };
} }
public static Component Create(ComponentViewModel model)
{ public void Update(ComponentBindingModel? model)
return new Component
{
Id = model.Id,
ComponentName = model.ComponentName,
Cost = model.Cost
};
}
public void Update(ComponentBindingModel model)
{ {
if (model == null) if (model == null)
{ {

View File

@ -38,7 +38,7 @@ namespace IceCreamShopDatabaseImplement.Models
[ForeignKey("IceCreamId")] [ForeignKey("IceCreamId")]
public virtual List<Order> Orders { get; set; } = new(); public virtual List<Order> Orders { get; set; } = new();
public static IceCream Create(IceCreamShopDatabase context, IceCreamBindingModel model) public static IceCream? Create(IceCreamShopDatabase context, IceCreamBindingModel model)
{ {
return new IceCream() return new IceCream()
{ {

View File

@ -50,6 +50,7 @@ namespace IceCreamShopDatabaseImplement.Models
return; return;
} }
Status = model.Status; Status = model.Status;
DateImplement = model.DateImplement;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()

View File

@ -26,20 +26,19 @@ namespace IceCreamShopFileImplement.Implements
{ {
return null; return null;
} }
return source.Orders return GetViewModel(source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.Id.HasValue) if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{ {
return new(); return new();
} }
return source.Orders return source.Orders
.Where(x => x.Id == model.Id) .Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
@ -69,7 +68,7 @@ namespace IceCreamShopFileImplement.Implements
} }
order.Update(model); order.Update(model);
source.SaveOrders(); source.SaveOrders();
return order.GetViewModel; return GetViewModel(order);
} }
public OrderViewModel? Delete(OrderBindingModel model) public OrderViewModel? Delete(OrderBindingModel model)
{ {
@ -80,7 +79,18 @@ namespace IceCreamShopFileImplement.Implements
} }
order.Update(model); order.Update(model);
source.SaveOrders(); source.SaveOrders();
return order.GetViewModel; return GetViewModel(order);
}
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
var icecream = source.IceCreams.FirstOrDefault(x => x.Id == order.IceCreamId);
if (icecream != null)
{
viewModel.IceCreamName = icecream.IceCreamName;
}
return viewModel;
} }
} }
} }

View File

@ -16,7 +16,6 @@ namespace IceCreamShopFileImplement.Models
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int IceCreamId { get; private set; } public int IceCreamId { get; private set; }
public string IceCreamName { get; private set; } = string.Empty;
public int Count { get; private set; } public int Count { get; private set; }
@ -37,7 +36,6 @@ namespace IceCreamShopFileImplement.Models
{ {
Id = model.Id, Id = model.Id,
IceCreamId = model.IceCreamId, IceCreamId = model.IceCreamId,
IceCreamName = model.IceCreamName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -55,7 +53,6 @@ namespace IceCreamShopFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
IceCreamId = Convert.ToInt32(element.Element("IceCreamId")!.Value), IceCreamId = Convert.ToInt32(element.Element("IceCreamId")!.Value),
IceCreamName = element.Element("IceCreamName")!.Value,
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
@ -69,20 +66,13 @@ namespace IceCreamShopFileImplement.Models
{ {
return; return;
} }
Id = model.Id;
IceCreamId = model.IceCreamId;
IceCreamName = model.IceCreamName;
Count = model.Count;
Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
IceCreamId = IceCreamId, IceCreamId = IceCreamId,
IceCreamName = IceCreamName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
@ -93,7 +83,6 @@ namespace IceCreamShopFileImplement.Models
"Order", "Order",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("IceCreamId", IceCreamId.ToString()), new XElement("IceCreamId", IceCreamId.ToString()),
new XElement("IceCreamName", IceCreamName),
new XElement("Count", Count.ToString()), new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()), new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),

View File

@ -27,7 +27,7 @@ namespace IceCreamShopListImplement.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return element.GetViewModel; return GetViewModel(element);
} }
} }
return null; return null;
@ -39,7 +39,7 @@ namespace IceCreamShopListImplement.Implements
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
return order.GetViewModel; return GetViewModel(order);
} }
return null; return null;
} }
@ -51,8 +51,8 @@ namespace IceCreamShopListImplement.Implements
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (order.Id == model.Id) if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo)
result.Add(order.GetViewModel); result.Add(GetViewModel(order));
} }
return result; return result;
} }
@ -62,7 +62,7 @@ namespace IceCreamShopListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(order.GetViewModel); result.Add(GetViewModel(order));
} }
return result; return result;
} }
@ -83,7 +83,7 @@ namespace IceCreamShopListImplement.Implements
return null; return null;
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return newOrder.GetViewModel; return GetViewModel(newOrder);
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -93,10 +93,24 @@ namespace IceCreamShopListImplement.Implements
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
order.Update(model); order.Update(model);
return order.GetViewModel; return GetViewModel(order);
} }
} }
return null; return null;
} }
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var icecream in _source.iceCreams)
{
if (icecream.Id == order.IceCreamId)
{
viewModel.IceCreamName = icecream.IceCreamName;
break;
}
}
return viewModel;
}
} }
} }

View File

@ -18,8 +18,6 @@ namespace IceCreamShopListImplement.Models
public int IceCreamId { get; private set; } public int IceCreamId { get; private set; }
public string IceCreamName { get; private set; } = string.Empty;
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -37,7 +35,6 @@ namespace IceCreamShopListImplement.Models
{ {
Id = model.Id, Id = model.Id,
IceCreamId = model.IceCreamId, IceCreamId = model.IceCreamId,
IceCreamName = model.IceCreamName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -49,13 +46,7 @@ namespace IceCreamShopListImplement.Models
public void Update(OrderBindingModel? model) public void Update(OrderBindingModel? model)
{ {
if (model == null) return; if (model == null) return;
Id = model.Id;
IceCreamId = model.IceCreamId;
IceCreamName = model.IceCreamName;
Count = model.Count;
Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
@ -63,7 +54,6 @@ namespace IceCreamShopListImplement.Models
{ {
Id = Id, Id = Id,
IceCreamId = IceCreamId, IceCreamId = IceCreamId,
IceCreamName = IceCreamName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,