diff --git a/Confectionery/ConfectionaryContracts/BusinessLogicsContracts/IReportLogic.cs b/Confectionery/ConfectionaryContracts/BusinessLogicsContracts/IReportLogic.cs
index fc6c170..e924ac4 100644
--- a/Confectionery/ConfectionaryContracts/BusinessLogicsContracts/IReportLogic.cs
+++ b/Confectionery/ConfectionaryContracts/BusinessLogicsContracts/IReportLogic.cs
@@ -10,31 +10,10 @@ namespace ConfectioneryContracts.BusinessLogicsContracts
{
public interface IReportLogic
{
- ///
- /// Получение списка компонент с указанием, в каких изделиях используются
- ///
- ///
- List GetProductComponent();
- ///
- /// Получение списка заказов за определенный период
- ///
- ///
- ///
+ List GetPastryComponent();
List GetOrders(ReportBindingModel model);
- ///
- /// Сохранение компонент в файл-Word
- ///
- ///
- void SaveComponentsToWordFile(ReportBindingModel model);
- ///
- /// Сохранение компонент с указаеним продуктов в файл-Excel
- ///
- ///
- void SaveProductComponentToExcelFile(ReportBindingModel model);
- ///
- /// Сохранение заказов в файл-Pdf
- ///
- ///
+ void SavePastriesToWordFile(ReportBindingModel model);
+ void SavePastryComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
}
}
diff --git a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs
index b539acd..89efec5 100644
--- a/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/BusinessLogics/ReportLogic.cs
@@ -17,17 +17,17 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
public class ReportLogic : IReportLogic
{
private readonly IComponentStorage _componentStorage;
- private readonly IPastryStorage _productStorage;
+ private readonly IPastryStorage _pastryStorage;
private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
- public ReportLogic(IPastryStorage productStorage, IComponentStorage
+ public ReportLogic(IPastryStorage pastryStorage, IComponentStorage
componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
AbstractSaveToPdf saveToPdf)
{
- _productStorage = productStorage;
+ _pastryStorage = pastryStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
@@ -38,10 +38,10 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
/// Получение списка компонент с указанием, в каких изделиях используются
///
///
- public List GetProductComponent()
+ public List GetPastryComponent()
{
var components = _componentStorage.GetFullList();
- var products = _productStorage.GetFullList();
+ var pastries = _pastryStorage.GetFullList();
var list = new List();
foreach (var component in components)
{
@@ -51,14 +51,14 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
Pastries = new List>(),
TotalCount = 0
};
- foreach (var product in products)
+ foreach (var pastry in pastries)
{
- if (product.PastryComponents.ContainsKey(component.Id))
+ if (pastry.PastryComponents.ContainsKey(component.Id))
{
record.Pastries.Add(new Tuple(product.PastryName, product.PastryComponents[component.Id].Item2));
+ int>(pastry.PastryName, pastry.PastryComponents[component.Id].Item2));
record.TotalCount +=
- product.PastryComponents[component.Id].Item2;
+ pastry.PastryComponents[component.Id].Item2;
}
}
list.Add(record);
@@ -90,7 +90,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
/// Сохранение компонент в файл-Word
///
///
- public void SaveComponentsToWordFile(ReportBindingModel model)
+ public void SavePastriesToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
@@ -103,13 +103,13 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
/// Сохранение компонент с указаеним продуктов в файл-Excel
///
///
- public void SaveProductComponentToExcelFile(ReportBindingModel model)
+ public void SavePastryComponentToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список компонент",
- ProductComponents = GetProductComponent()
+ PastryComponents = GetPastryComponent()
});
}
///
diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
index 09f232a..5ac8dde 100644
--- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -30,7 +30,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
CellToName = "C1"
});
uint rowIndex = 2;
- foreach (var pc in info.ProductComponents)
+ foreach (var pc in info.PastryComponents)
{
InsertCellInWorksheet(new ExcelCellParameters
{
@@ -40,13 +40,13 @@ namespace ConfectioneryBusinessLogic.OfficePackage
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
- foreach (var product in pc.Pastries)
+ foreach (var pastry in pc.Pastries)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
- Text = product.Item1,
+ Text = pastry.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
@@ -54,7 +54,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
{
ColumnName = "C",
RowIndex = rowIndex,
- Text = product.Item2.ToString(),
+ Text = pastry.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
index ec1abd9..b435731 100644
--- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
@@ -11,7 +11,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
- public List ProductComponents
+ public List PastryComponents
{
get;
set;
diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
index 36e6191..99f04c4 100644
--- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
@@ -350,7 +350,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
- _spreadsheetDocument.Close();
+ _spreadsheetDocument.Dispose();
}
}
}
diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
index 6c07c17..88b646c 100644
--- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
{
- internal class SaveToPdf : AbstractSaveToPdf
+ public class SaveToPdf : AbstractSaveToPdf
{
private Document? _document;
private Section? _section;
diff --git a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToWord.cs
index 4fbde57..54e1a36 100644
--- a/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToWord.cs
+++ b/Confectionery/ConfectioneryBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -6,7 +6,7 @@ using DocumentFormat.OpenXml.Wordprocessing;
namespace ConfectioneryBusinessLogic.OfficePackage.Implements
{
- internal class SaveToWord : AbstractSaveToWord
+ public class SaveToWord : AbstractSaveToWord
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
@@ -118,7 +118,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
- _wordDocument.Close();
+ _wordDocument.Dispose();
}
}
}
diff --git a/Confectionery/ConfectioneryDatabaseImplement/Implements/PastryStorage.cs b/Confectionery/ConfectioneryDatabaseImplement/Implements/PastryStorage.cs
index 9783cb9..80c4c97 100644
--- a/Confectionery/ConfectioneryDatabaseImplement/Implements/PastryStorage.cs
+++ b/Confectionery/ConfectioneryDatabaseImplement/Implements/PastryStorage.cs
@@ -74,17 +74,17 @@ namespace ConfectioneryDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
- var product = context.Pastries.FirstOrDefault(rec =>
+ var pastry = context.Pastries.FirstOrDefault(rec =>
rec.Id == model.Id);
- if (product == null)
+ if (pastry == null)
{
return null;
}
- product.Update(model);
+ pastry.Update(model);
context.SaveChanges();
- product.UpdateComponents(context, model);
+ pastry.UpdateComponents(context, model);
transaction.Commit();
- return product.GetViewModel;
+ return pastry.GetViewModel;
}
catch
{
diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240325181336_InitialCreate.Designer.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240325181336_InitialCreate.Designer.cs
index 82ef147..638599b 100644
--- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240325181336_InitialCreate.Designer.cs
+++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240325181336_InitialCreate.Designer.cs
@@ -20,7 +20,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.17")
+ .HasAnnotation("PastryVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -138,7 +138,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{
b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
- .WithMany("ProductComponents")
+ .WithMany("PastryComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -156,7 +156,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{
- b.Navigation("ProductComponents");
+ b.Navigation("PastryComponents");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
index e7c13d9..c5e30fc 100644
--- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
+++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
@@ -17,7 +17,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "7.0.17")
+ .HasAnnotation("PastryVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -135,7 +135,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{
b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
- .WithMany("ProductComponents")
+ .WithMany("PastryComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -153,7 +153,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{
- b.Navigation("ProductComponents");
+ b.Navigation("PastryComponents");
});
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
diff --git a/Confectionery/ConfectioneryDatabaseImplement/Models/Component.cs b/Confectionery/ConfectioneryDatabaseImplement/Models/Component.cs
index 1e36015..f4c977c 100644
--- a/Confectionery/ConfectioneryDatabaseImplement/Models/Component.cs
+++ b/Confectionery/ConfectioneryDatabaseImplement/Models/Component.cs
@@ -19,7 +19,7 @@ namespace ConfectioneryDatabaseImplement.Models
[Required]
public double Cost { get; set; }
[ForeignKey("ComponentId")]
- public virtual List ProductComponents { get; set; } = new();
+ public virtual List PastryComponents { get; set; } = new();
public static Component? Create(ComponentBindingModel model)
{
if (model == null)
diff --git a/Confectionery/ConfectioneryView/ConfectioneryView.csproj b/Confectionery/ConfectioneryView/ConfectioneryView.csproj
index 2330b6d..1362fea 100644
--- a/Confectionery/ConfectioneryView/ConfectioneryView.csproj
+++ b/Confectionery/ConfectioneryView/ConfectioneryView.csproj
@@ -24,6 +24,7 @@
+
diff --git a/Confectionery/ConfectioneryView/FormMain.Designer.cs b/Confectionery/ConfectioneryView/FormMain.Designer.cs
index a6a7910..5b907ef 100644
--- a/Confectionery/ConfectioneryView/FormMain.Designer.cs
+++ b/Confectionery/ConfectioneryView/FormMain.Designer.cs
@@ -32,16 +32,16 @@
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ButtonCreateOrder = new System.Windows.Forms.Button();
this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
this.ButtonOrderReady = new System.Windows.Forms.Button();
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
this.ButtonRef = new System.Windows.Forms.Button();
- this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@@ -70,17 +70,48 @@
// компонентыToolStripMenuItem
//
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.компонентыToolStripMenuItem.Text = "Компоненты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
//
// изделияToolStripMenuItem
//
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
- this.изделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
+ this.изделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.изделияToolStripMenuItem.Text = "Изделия";
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
//
+ // отчетыToolStripMenuItem
+ //
+ this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.списокКомпонентовToolStripMenuItem,
+ this.компонентыПоИзделиямToolStripMenuItem,
+ this.списокЗаказовToolStripMenuItem});
+ this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
+ this.отчетыToolStripMenuItem.Text = "Отчеты";
+ //
+ // списокКомпонентовToolStripMenuItem
+ //
+ this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
+ this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(267, 26);
+ this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
+ this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.СписокКомпонентовToolStripMenuItem_Click);
+ //
+ // компонентыПоИзделиямToolStripMenuItem
+ //
+ this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
+ this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(267, 26);
+ this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по выпечке";
+ this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыПоВыпечкеToolStripMenuItem_Click);
+ //
+ // списокЗаказовToolStripMenuItem
+ //
+ this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
+ this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(267, 26);
+ this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
+ this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.СписокЗаказовToolStripMenuItem_Click);
+ //
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
@@ -141,34 +172,6 @@
this.ButtonRef.UseVisualStyleBackColor = true;
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
- // отчетыToolStripMenuItem
- //
- this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.списокКомпонентовToolStripMenuItem,
- this.компонентыПоИзделиямToolStripMenuItem,
- this.списокЗаказовToolStripMenuItem});
- this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
- this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
- this.отчетыToolStripMenuItem.Text = "Отчеты";
- //
- // списокКомпонентовToolStripMenuItem
- //
- this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
- this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
- this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
- //
- // компонентыПоИзделиямToolStripMenuItem
- //
- this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
- this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
- this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
- //
- // списокЗаказовToolStripMenuItem
- //
- this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
- this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(276, 26);
- this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
- //
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
diff --git a/Confectionery/ConfectioneryView/FormMain.cs b/Confectionery/ConfectioneryView/FormMain.cs
index a2460ec..8188422 100644
--- a/Confectionery/ConfectioneryView/FormMain.cs
+++ b/Confectionery/ConfectioneryView/FormMain.cs
@@ -17,11 +17,13 @@ namespace ConfectioneryView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
+ private readonly IReportLogic _reportLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
+ _reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
@@ -51,8 +53,7 @@ namespace ConfectioneryView
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
{
- var service =
- Program.ServiceProvider?.GetService(typeof(FormComponents));
+ var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
{
form.ShowDialog();
@@ -68,6 +69,34 @@ namespace ConfectioneryView
}
}
+ private void СписокКомпонентовToolStripMenuItem_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);
+ }
+ }
+
+ private void КомпонентыПоВыпечкеToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents));
+ if (service is FormReportPastryComponents form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void СписокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
+
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
diff --git a/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs b/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs
new file mode 100644
index 0000000..d887692
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormReportOrders.Designer.cs
@@ -0,0 +1,137 @@
+namespace ConfectioneryView
+{
+ partial class FormReportOrders
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSaveToPdf = new System.Windows.Forms.Button();
+ this.panel = new System.Windows.Forms.Panel();
+ this.buttonCreateReport = 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();
+ //
+ // buttonSaveToPdf
+ //
+ this.buttonSaveToPdf.Location = new System.Drawing.Point(863, 13);
+ this.buttonSaveToPdf.Name = "buttonSaveToPdf";
+ this.buttonSaveToPdf.Size = new System.Drawing.Size(131, 34);
+ this.buttonSaveToPdf.TabIndex = 0;
+ this.buttonSaveToPdf.Text = "В Pdf";
+ this.buttonSaveToPdf.UseVisualStyleBackColor = true;
+ this.buttonSaveToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
+ //
+ // panel
+ //
+ this.panel.Controls.Add(this.buttonSaveToPdf);
+ this.panel.Controls.Add(this.buttonCreateReport);
+ 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(5, 4, 5, 4);
+ this.panel.Name = "panel";
+ this.panel.Size = new System.Drawing.Size(1111, 53);
+ this.panel.TabIndex = 1;
+ //
+ // buttonCreateReport
+ //
+ this.buttonCreateReport.Location = new System.Drawing.Point(544, 11);
+ this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
+ this.buttonCreateReport.Name = "buttonCreateReport";
+ this.buttonCreateReport.Size = new System.Drawing.Size(159, 36);
+ this.buttonCreateReport.TabIndex = 4;
+ this.buttonCreateReport.Text = "Сформировать";
+ this.buttonCreateReport.UseVisualStyleBackColor = true;
+ this.buttonCreateReport.Click += new System.EventHandler(this.ButtonMake_Click);
+ //
+ // dateTimePickerTo
+ //
+ this.dateTimePickerTo.Location = new System.Drawing.Point(271, 13);
+ this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
+ this.dateTimePickerTo.Name = "dateTimePickerTo";
+ this.dateTimePickerTo.Size = new System.Drawing.Size(186, 27);
+ this.dateTimePickerTo.TabIndex = 3;
+ //
+ // labelTo
+ //
+ this.labelTo.AutoSize = true;
+ this.labelTo.Location = new System.Drawing.Point(238, 17);
+ this.labelTo.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
+ this.labelTo.Name = "labelTo";
+ this.labelTo.Size = new System.Drawing.Size(27, 20);
+ this.labelTo.TabIndex = 2;
+ this.labelTo.Text = "по";
+ //
+ // dateTimePickerFrom
+ //
+ this.dateTimePickerFrom.Location = new System.Drawing.Point(42, 13);
+ this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
+ this.dateTimePickerFrom.Name = "dateTimePickerFrom";
+ this.dateTimePickerFrom.Size = new System.Drawing.Size(186, 27);
+ this.dateTimePickerFrom.TabIndex = 1;
+ //
+ // labelFrom
+ //
+ this.labelFrom.AutoSize = true;
+ this.labelFrom.Location = new System.Drawing.Point(16, 17);
+ this.labelFrom.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
+ this.labelFrom.Name = "labelFrom";
+ this.labelFrom.Size = new System.Drawing.Size(18, 20);
+ this.labelFrom.TabIndex = 0;
+ this.labelFrom.Text = "С";
+ //
+ // FormReportOrders
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1111, 450);
+ this.Controls.Add(this.panel);
+ this.Name = "FormReportOrders";
+ this.Text = "FormReportOrders";
+ this.panel.ResumeLayout(false);
+ this.panel.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonSaveToPdf;
+ private Panel panel;
+ private Button buttonCreateReport;
+ private DateTimePicker dateTimePickerTo;
+ private Label labelTo;
+ private DateTimePicker dateTimePickerFrom;
+ private Label labelFrom;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormReportOrders.cs b/Confectionery/ConfectioneryView/FormReportOrders.cs
new file mode 100644
index 0000000..8573616
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormReportOrders.cs
@@ -0,0 +1,104 @@
+using ConfectioneryContracts.BusinessLogicsContracts;
+using ConfectioneryContracts.BindingModels;
+using Microsoft.Reporting.WinForms;
+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 FormReportOrders : Form
+ {
+ private readonly ReportViewer reportViewer;
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportOrders(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ reportViewer = new ReportViewer
+ {
+ Dock = DockStyle.Fill
+ };
+ reportViewer.LocalReport.LoadReportDefinition(new
+ FileStream("C:\\Users\\Полина\\source\\repos\\2 курс\\рпп\\PIbd-22_Chubykina_P.P._Confectionery\\Confectionery\\ConfectioneryView\\ReportOrders.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.GetOrders(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);
+ }
+ }
+ }
+ }
+}
diff --git a/Confectionery/ConfectioneryView/FormReportOrders.resx b/Confectionery/ConfectioneryView/FormReportOrders.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/ConfectioneryView/FormReportOrders.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs b/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs
index 61af04a..11c1642 100644
--- a/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs
+++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.Designer.cs
@@ -29,11 +29,11 @@
private void InitializeComponent()
{
this.buttonSaveToExcel = new System.Windows.Forms.Button();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonSaveToExcel
@@ -44,52 +44,54 @@
this.buttonSaveToExcel.TabIndex = 0;
this.buttonSaveToExcel.Text = "Сохранить в Excel";
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
- // dataGridView1
+ // dataGridView
//
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnComponent,
this.ColumnPastry,
this.ColumnCount});
- this.dataGridView1.Location = new System.Drawing.Point(13, 64);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersWidth = 51;
- this.dataGridView1.RowTemplate.Height = 29;
- this.dataGridView1.Size = new System.Drawing.Size(776, 541);
- this.dataGridView1.TabIndex = 1;
+ this.dataGridView.Location = new System.Drawing.Point(13, 64);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(776, 541);
+ this.dataGridView.TabIndex = 1;
//
// ColumnComponent
//
this.ColumnComponent.HeaderText = "Компонент";
this.ColumnComponent.MinimumWidth = 6;
this.ColumnComponent.Name = "ColumnComponent";
- this.ColumnComponent.Width = 125;
+ this.ColumnComponent.Width = 150;
//
// ColumnPastry
//
this.ColumnPastry.HeaderText = "Выпечка";
this.ColumnPastry.MinimumWidth = 6;
this.ColumnPastry.Name = "ColumnPastry";
- this.ColumnPastry.Width = 125;
+ this.ColumnPastry.Width = 150;
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.MinimumWidth = 6;
this.ColumnCount.Name = "ColumnCount";
- this.ColumnCount.Width = 125;
+ this.ColumnCount.Width = 150;
//
// FormReportPastryComponents
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 617);
- this.Controls.Add(this.dataGridView1);
+ this.Controls.Add(this.dataGridView);
this.Controls.Add(this.buttonSaveToExcel);
this.Name = "FormReportPastryComponents";
this.Text = "FormReportPastryComponents";
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+ this.Load += new System.EventHandler(this.FormReportPastryComponents_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
@@ -97,7 +99,7 @@
#endregion
private Button buttonSaveToExcel;
- private DataGridView dataGridView1;
+ private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnComponent;
private DataGridViewTextBoxColumn ColumnPastry;
private DataGridViewTextBoxColumn ColumnCount;
diff --git a/Confectionery/ConfectioneryView/FormReportPastryComponents.cs b/Confectionery/ConfectioneryView/FormReportPastryComponents.cs
index 5da3309..379cc1a 100644
--- a/Confectionery/ConfectioneryView/FormReportPastryComponents.cs
+++ b/Confectionery/ConfectioneryView/FormReportPastryComponents.cs
@@ -7,14 +7,82 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
namespace ConfectioneryView
{
public partial class FormReportPastryComponents : Form
{
- public FormReportPastryComponents()
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportPastryComponents(ILogger 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.ComponentName, "", "" });
+ foreach (var listElem in elem.Pastries)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty