From 8044cadda1340474a75e9feb715ec7c68cd5998f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Wed, 8 Mar 2023 14:40:41 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F,=20=D1=81=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D1=8F=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... => 20230307072144_add_client.Designer.cs} | 4 +- ...client.cs => 20230307072144_add_client.cs} | 3 +- .../ConfectioneryDatabaseModelSnapshot.cs | 154 +++++++++--------- 3 files changed, 81 insertions(+), 80 deletions(-) rename ConfectioneryDatabaseImplement/Migrations/{20230304103151_add_entity_client.Designer.cs => 20230307072144_add_client.Designer.cs} (98%) rename ConfectioneryDatabaseImplement/Migrations/{20230304103151_add_entity_client.cs => 20230307072144_add_client.cs} (95%) diff --git a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs similarity index 98% rename from ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs rename to ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs index d19d47f..9491b2a 100644 --- a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs +++ b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ConfectioneryDatabaseImplement.Migrations { [DbContext(typeof(ConfectioneryDatabase))] - [Migration("20230304103151_add_entity_client")] - partial class add_entity_client + [Migration("20230307072144_add_client")] + partial class add_client { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs similarity index 95% rename from ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs rename to ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs index 262ea63..df8a7e2 100644 --- a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs +++ b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs @@ -5,11 +5,12 @@ namespace ConfectioneryDatabaseImplement.Migrations { /// - public partial class add_entity_client : Migration + public partial class add_client : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.Sql("DELETE FROM Orders"); migrationBuilder.AddColumn( name: "ClientId", table: "Orders", diff --git a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs index 2ca4154..a109493 100644 --- a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs +++ b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs @@ -10,17 +10,17 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ConfectioneryDatabaseImplement.Migrations { - [DbContext(typeof(ConfectioneryDatabase))] - partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { + [DbContext(typeof(ConfectioneryDatabase))] + partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + modelBuilder + .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => { @@ -28,7 +28,7 @@ namespace ConfectioneryDatabaseImplement.Migrations .ValueGeneratedOnAdd() .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ClientFIO") .IsRequired() @@ -59,21 +59,21 @@ namespace ConfectioneryDatabaseImplement.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Cost") - .HasColumnType("float"); + b.Property("Cost") + .HasColumnType("float"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Components"); - }); + b.ToTable("Components"); + }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("ClientId") .HasColumnType("int"); @@ -81,75 +81,75 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Property("Count") .HasColumnType("int"); - b.Property("DateCreate") - .HasColumnType("datetime2"); + b.Property("DateCreate") + .HasColumnType("datetime2"); - b.Property("DateImplement") - .HasColumnType("datetime2"); + b.Property("DateImplement") + .HasColumnType("datetime2"); - b.Property("PastryId") - .HasColumnType("int"); + b.Property("PastryId") + .HasColumnType("int"); - b.Property("Status") - .HasColumnType("int"); + b.Property("Status") + .HasColumnType("int"); - b.Property("Sum") - .HasColumnType("float"); + b.Property("Sum") + .HasColumnType("float"); - b.HasKey("Id"); + b.HasKey("Id"); b.HasIndex("ClientId"); b.HasIndex("PastryId"); - b.ToTable("Orders"); - }); + b.ToTable("Orders"); + }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("PastryName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("PastryName") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Price") - .HasColumnType("float"); + b.Property("Price") + .HasColumnType("float"); - b.HasKey("Id"); + b.HasKey("Id"); b.ToTable("Pastries"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ComponentId") - .HasColumnType("int"); + b.Property("ComponentId") + .HasColumnType("int"); - b.Property("Count") - .HasColumnType("int"); + b.Property("Count") + .HasColumnType("int"); - b.Property("PastryId") - .HasColumnType("int"); + b.Property("PastryId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ComponentId"); + b.HasIndex("ComponentId"); - b.HasIndex("PastryId"); + b.HasIndex("PastryId"); - b.ToTable("PastryComponents"); - }); + b.ToTable("PastryComponents"); + }); modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => { @@ -178,16 +178,16 @@ namespace ConfectioneryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") - .WithMany("Components") - .HasForeignKey("PastryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") + .WithMany("Components") + .HasForeignKey("PastryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Component"); - b.Navigation("Pastry"); - }); + b.Navigation("Pastry"); + }); modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => { @@ -199,13 +199,13 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("PastryComponents"); }); - modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => - { - b.Navigation("Components"); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => + { + b.Navigation("Components"); - b.Navigation("Orders"); - }); + b.Navigation("Orders"); + }); #pragma warning restore 612, 618 - } - } + } + } } From 97b76f3ba67447511befdc70e852f2f515fea12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Wed, 8 Mar 2023 14:42:10 +0400 Subject: [PATCH 2/5] =?UTF-8?q?delete=20=D0=BD=D0=B0=20truncate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Migrations/20230307072144_add_client.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs index df8a7e2..d125130 100644 --- a/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs +++ b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs @@ -10,7 +10,7 @@ namespace ConfectioneryDatabaseImplement.Migrations /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.Sql("DELETE FROM Orders"); + migrationBuilder.Sql("TRUNCATE Orders"); migrationBuilder.AddColumn( name: "ClientId", table: "Orders", From e083191f4a5d11770ccd1b7856b1d63d49f6699a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Wed, 8 Mar 2023 16:05:07 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BE=D1=82=D1=87=D0=B5=D1=82=D1=8B=20=D0=B8=D0=B7=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=87=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OfficePackage/AbstractSaveToExcel.cs | 73 ++- .../OfficePackage/AbstractSaveToPdf.cs | 34 ++ .../OfficePackage/AbstractSaveToWord.cs | 40 +- .../HelperModels/ExcelInfoPastry.cs | 20 + .../OfficePackage/HelperModels/PdfInfo.cs | 2 +- .../HelperModels/PdfInfoOrders.cs | 29 + .../OfficePackage/HelperModels/WordInfo.cs | 6 +- .../HelperModels/WordInfoTable.cs | 16 + .../OfficePackage/Implements/SaveToWord.cs | 4 +- ConfectionaryBusinessLogic/ReportLogic.cs | 108 +++- Confectionery/ConfectioneryView.csproj | 5 +- Confectionery/FormMain.Designer.cs | 509 +++++++++--------- Confectionery/FormMain.cs | 419 +++++++------- .../FormReportGroupOrders.Designer.cs | 141 +++++ Confectionery/FormReportGroupOrders.cs | 91 ++++ Confectionery/FormReportGroupOrders.resx | 120 +++++ .../FormReportPastryComponents.Designer.cs | 113 ++++ Confectionery/FormReportPastryComponents.cs | 79 +++ Confectionery/FormReportPastryComponents.resx | 60 +++ Confectionery/Program.cs | 2 + Confectionery/ReportGroupOrders.rdlc | 463 ++++++++++++++++ Confectionery/ReportOrders.rdlc | 187 ++++++- .../BusinessLogicsContracts/IReportLogic.cs | 38 +- .../ViewModels/ReportGroupOrdersViewModel.cs | 17 + .../ViewModels/ReportOrdersViewModel.cs | 7 +- .../ReportPastryComponentViewModel.cs | 15 + 26 files changed, 2105 insertions(+), 493 deletions(-) create mode 100644 ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfoPastry.cs create mode 100644 ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfoOrders.cs create mode 100644 ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfoTable.cs create mode 100644 Confectionery/FormReportGroupOrders.Designer.cs create mode 100644 Confectionery/FormReportGroupOrders.cs create mode 100644 Confectionery/FormReportGroupOrders.resx create mode 100644 Confectionery/FormReportPastryComponents.Designer.cs create mode 100644 Confectionery/FormReportPastryComponents.cs create mode 100644 Confectionery/FormReportPastryComponents.resx create mode 100644 Confectionery/ReportGroupOrders.rdlc create mode 100644 ConfectioneryContracts/ViewModels/ReportGroupOrdersViewModel.cs create mode 100644 ConfectioneryContracts/ViewModels/ReportPastryComponentViewModel.cs diff --git a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 0ad8d41..6936437 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -14,7 +14,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage /// Создание отчета /// /// - public void CreateReport(ExcelInfo info) + public void CreateReportShop(ExcelInfo info) { CreateExcel(info); @@ -100,6 +100,77 @@ namespace ConfectioneryBusinessLogic.OfficePackage SaveExcel(info); } + public void CreateReportPastry(ExcelInfoPastry info) + { + CreateExcel(new() { FileName = info.FileName }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 1, + Text = info.Title, + StyleInfo = ExcelStyleInfoType.Title + }); + + MergeCells(new ExcelMergeParameters + { + CellFromName = "A1", + CellToName = "C1" + }); + + uint rowIndex = 2; + foreach (var pc in info.PastryComponents) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.PastryName, + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + + foreach (var (Pastry, Count) in pc.Components) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = Pastry, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = Count.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + rowIndex++; + } + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Итого", + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + + SaveExcel(new()); + } + /// /// Создание excel-файла /// diff --git a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 3086250..61699c5 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -41,6 +41,40 @@ namespace ConfectioneryBusinessLogic.OfficePackage SavePdf(info); } + public void CreateDocOrders(PdfInfoOrders info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); + CreateParagraph(new PdfParagraph + { + Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + CreateTable(new List { "2cm", "3cm", "6cm", "4cm", "3cm" }); + + CreateRow(new PdfRowParameters + { + Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + + foreach (var order in info.Orders) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PastryName, Convert.ToString(order.OrderStatus), order.Sum.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth }); + + SavePdf(info); + } + /// /// Создание doc-файла /// diff --git a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 1e72c44..605f9b7 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -10,7 +10,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { - public void CreateDoc(WordInfo info) + public void CreateDocTable(WordInfoTable info) { CreateWord(info); @@ -42,11 +42,45 @@ namespace ConfectioneryBusinessLogic.OfficePackage SaveWord(info); } + public void CreateDoc(WordInfo info) + { + CreateWord(new() { FileName = info.FileName }); + + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Center + } + }); + + foreach (var pastry in info.Pastries) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { + (pastry.PastryName , new WordTextProperties { Size = "24", Bold = true}), + (" - цена: " + pastry.Price.ToString(), new WordTextProperties { Size = "24" }) + }, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + + SaveWord(new()); + } + /// /// Создание doc-файла /// /// - protected abstract void CreateWord(WordInfo info); + protected abstract void CreateWord(WordInfoTable info); /// /// Создание абзаца с текстом @@ -66,6 +100,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage /// Сохранение файла /// /// - protected abstract void SaveWord(WordInfo info); + protected abstract void SaveWord(WordInfoTable info); } } diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfoPastry.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfoPastry.cs new file mode 100644 index 0000000..0ff7fa4 --- /dev/null +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/ExcelInfoPastry.cs @@ -0,0 +1,20 @@ +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels +{ + public class ExcelInfoPastry + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List PastryComponents + { + get; + set; + } = new(); + } +} diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 8808b04..5e1ca7d 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -13,6 +13,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; public DateTime DateFrom { get; set; } public DateTime DateTo { get; set; } - public List Orders { get; set; } = new(); + public List Orders { get; set; } = new(); } } diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfoOrders.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfoOrders.cs new file mode 100644 index 0000000..373da43 --- /dev/null +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/PdfInfoOrders.cs @@ -0,0 +1,29 @@ +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels +{ + public class PdfInfoOrders + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public DateTime DateFrom { get; set; } + public DateTime DateTo { get; set; } + public List Orders { get; set; } = new(); + + public static implicit operator PdfInfo(PdfInfoOrders orders) + { + return new PdfInfo() + { + DateFrom = orders.DateFrom, + DateTo = orders.DateTo, + FileName = orders.FileName, + Title = orders.Title + }; + } + } +} diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index b3846a7..9ed9df6 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -1,9 +1,4 @@ using ConfectioneryContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels { @@ -11,6 +6,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; + public List Pastries { get; set; } = new(); public List Shops { get; set; } = new(); } } diff --git a/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfoTable.cs b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfoTable.cs new file mode 100644 index 0000000..32f9502 --- /dev/null +++ b/ConfectionaryBusinessLogic/OfficePackage/HelperModels/WordInfoTable.cs @@ -0,0 +1,16 @@ +using ConfectioneryContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels +{ + public class WordInfoTable + { + public string FileName { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public List Shops { get; set; } = new(); + } +} diff --git a/ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToWord.cs index af6a547..f733b5c 100644 --- a/ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/ConfectionaryBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -81,7 +81,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements return properties; } - protected override void CreateWord(WordInfo info) + protected override void CreateWord(WordInfoTable info) { _wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document); MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart(); @@ -119,7 +119,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage.Implements _docBody.AppendChild(docParagraph); } - protected override void SaveWord(WordInfo info) + protected override void SaveWord(WordInfoTable info) { if (_docBody == null || _wordDocument == null) { diff --git a/ConfectionaryBusinessLogic/ReportLogic.cs b/ConfectionaryBusinessLogic/ReportLogic.cs index e21732c..35427e3 100644 --- a/ConfectionaryBusinessLogic/ReportLogic.cs +++ b/ConfectionaryBusinessLogic/ReportLogic.cs @@ -15,6 +15,7 @@ namespace ConfectioneryBusinessLogic private readonly IOrderStorage _orderStorage; private readonly IShopStorage _shopStorage; + private readonly IComponentStorage _componentStorage; private readonly AbstractSaveToExcel _saveToExcel; @@ -22,9 +23,10 @@ namespace ConfectioneryBusinessLogic private readonly AbstractSaveToPdf _saveToPdf; - public ReportLogic(IPastryStorage PastryStorage, IOrderStorage orderStorage, IShopStorage shopStorage, + public ReportLogic(IPastryStorage PastryStorage, IOrderStorage orderStorage, IShopStorage shopStorage, IComponentStorage componentStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { + _componentStorage = componentStorage; _pastryStorage = PastryStorage; _orderStorage = orderStorage; _shopStorage = shopStorage; @@ -69,16 +71,70 @@ namespace ConfectioneryBusinessLogic return list; } + /// + /// Получение списка компонент с указанием, в каких изделиях используются + /// + /// + public List GetPastryComponent() + { + var components = _componentStorage.GetFullList(); + + var pastries = _pastryStorage.GetFullList(); + + var list = new List(); + + foreach (var pastry in pastries) + { + var record = new ReportPastryComponentViewModel + { + PastryName = pastry.PastryName, + Components = new List>(), + TotalCount = 0 + }; + foreach (var component in components) + { + if (pastry.PastryComponents.ContainsKey(component.Id)) + { + record.Components.Add(new(component.ComponentName, pastry.PastryComponents[component.Id].Item2)); + record.TotalCount += pastry.PastryComponents[component.Id].Item2; + } + } + + list.Add(record); + } + + return list; + } + /// /// Получение списка заказов за определенный период /// /// /// public List GetOrders(ReportBindingModel model) + { + return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) + .Select(x => new ReportOrdersViewModel + { + Id = x.Id, + DateCreate = x.DateCreate, + PastryName = x.PastryName, + OrderStatus = Convert.ToString(x.Status) ?? string.Empty, + Sum = x.Sum + }) + .ToList(); + } + + /// + /// Получение списка заказов за определенный период + /// + /// + /// + public List GetGroupOrders(ReportBindingModel model) { return _orderStorage.GetFullList() .GroupBy(x => x.DateCreate.Date) - .Select(x => new ReportOrdersViewModel + .Select(x => new ReportGroupOrdersViewModel { Date = x.Key, Count = x.Count(), @@ -91,9 +147,9 @@ namespace ConfectioneryBusinessLogic /// Сохранение магазинов в файл-Word /// /// - public void SaveShopsToWordFile(ReportBindingModel model) + public void SaveShopsTableToWordFile(ReportBindingModel model) { - _saveToWord.CreateDoc(new WordInfo + _saveToWord.CreateDocTable(new WordInfoTable { FileName = model.FileName, Title = "Список магазинов", @@ -101,13 +157,25 @@ namespace ConfectioneryBusinessLogic }); } + public void SavePastriesToWordFile(ReportBindingModel model) + { + _saveToWord.CreateDoc(new WordInfo + { + FileName = model.FileName, + Title = "Список изделий", + Pastries = _pastryStorage.GetFullList() + }); + } + + + /// /// Сохранение магазинов с указаеним продуктов в файл-Excel /// /// public void SaveShopPastryToExcelFile(ReportBindingModel model) { - _saveToExcel.CreateReport(new ExcelInfo + _saveToExcel.CreateReportShop(new ExcelInfo { FileName = model.FileName, Title = "Список магазинов", @@ -115,20 +183,46 @@ namespace ConfectioneryBusinessLogic }); } + public void SavePastryComponentToExcelFile(ReportBindingModel model) + { + _saveToExcel.CreateReportPastry(new ExcelInfoPastry + { + FileName = model.FileName, + Title = "Список изделий по компонентам", + PastryComponents = GetPastryComponent(), + }); + } + + /// + /// Сохранение заказов в файл-Pdf + /// + /// + public void SaveGroupOrdersToPdfFile(ReportBindingModel model) + { + _saveToPdf.CreateDoc(new PdfInfo + { + FileName = model.FileName, + Title = "Список сгруппированных заказов по датам", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Orders = GetGroupOrders(model) + }); + } /// /// Сохранение заказов в файл-Pdf /// /// public void SaveOrdersToPdfFile(ReportBindingModel model) { - _saveToPdf.CreateDoc(new PdfInfo + _saveToPdf.CreateDocOrders(new PdfInfoOrders { FileName = model.FileName, Title = "Список заказов", DateFrom = model.DateFrom!.Value, DateTo = model.DateTo!.Value, - Orders = GetOrders(model) + Orders = GetOrders(model), }); } + } } diff --git a/Confectionery/ConfectioneryView.csproj b/Confectionery/ConfectioneryView.csproj index 463a255..4b33b8e 100644 --- a/Confectionery/ConfectioneryView.csproj +++ b/Confectionery/ConfectioneryView.csproj @@ -27,9 +27,12 @@ - + PreserveNewest + + Always + \ No newline at end of file diff --git a/Confectionery/FormMain.Designer.cs b/Confectionery/FormMain.Designer.cs index be4ea31..df667a4 100644 --- a/Confectionery/FormMain.Designer.cs +++ b/Confectionery/FormMain.Designer.cs @@ -1,249 +1,276 @@ namespace ConfectioneryView { - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class FormMain + { + /// + /// 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); - } + /// + /// 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 + #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() - { - menuStrip1 = new MenuStrip(); - справочникиToolStripMenuItem = new ToolStripMenuItem(); - pastryToolStripMenuItem = new ToolStripMenuItem(); - componentToolStripMenuItem = new ToolStripMenuItem(); - ShopsToolStripMenuItem = new ToolStripMenuItem(); - reportsToolStripMenuItem = new ToolStripMenuItem(); - reportShopsToolStripMenuItem = new ToolStripMenuItem(); - ShopPastriesToolStripMenuItem = new ToolStripMenuItem(); - ordersToolStripMenuItem = new ToolStripMenuItem(); - dataGridView = new DataGridView(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - button2 = new Button(); - button3 = new Button(); - button4 = new Button(); - buttonAddPastryInShop = new Button(); - buttonSellPastry = new Button(); - menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // menuStrip1 - // - menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, reportsToolStripMenuItem }); - menuStrip1.Location = new Point(0, 0); - menuStrip1.Name = "menuStrip1"; - menuStrip1.Size = new Size(783, 24); - menuStrip1.TabIndex = 0; - menuStrip1.Text = "menuStrip1"; - // - // справочникиToolStripMenuItem - // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem, ShopsToolStripMenuItem }); - справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - справочникиToolStripMenuItem.Size = new Size(94, 20); - справочникиToolStripMenuItem.Text = "Справочники"; - // - // pastryToolStripMenuItem - // - pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; - pastryToolStripMenuItem.Size = new Size(145, 22); - pastryToolStripMenuItem.Text = "Изделия"; - pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click; - // - // componentToolStripMenuItem - // - componentToolStripMenuItem.Name = "componentToolStripMenuItem"; - componentToolStripMenuItem.Size = new Size(145, 22); - componentToolStripMenuItem.Text = "Компоненты"; - componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; - // - // ShopsToolStripMenuItem - // - ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem"; - ShopsToolStripMenuItem.Size = new Size(145, 22); - ShopsToolStripMenuItem.Text = "Магазины"; - ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; - // - // reportsToolStripMenuItem - // - reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, ShopPastriesToolStripMenuItem, ordersToolStripMenuItem }); - reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; - reportsToolStripMenuItem.Size = new Size(60, 20); - reportsToolStripMenuItem.Text = "Отчеты"; - // - // reportShopsToolStripMenuItem - // - reportShopsToolStripMenuItem.Name = "reportShopsToolStripMenuItem"; - reportShopsToolStripMenuItem.Size = new Size(202, 22); - reportShopsToolStripMenuItem.Text = "Список магазинов"; - reportShopsToolStripMenuItem.Click += ReportShopsToolStripMenuItem_Click; - // - // ShopPastriesToolStripMenuItem - // - ShopPastriesToolStripMenuItem.Name = "ShopPastriesToolStripMenuItem"; - ShopPastriesToolStripMenuItem.Size = new Size(202, 22); - ShopPastriesToolStripMenuItem.Text = "Магазины с изделиями"; - ShopPastriesToolStripMenuItem.Click += ShopPastriesToolStripMenuItem_Click; - // - // ordersToolStripMenuItem - // - ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; - ordersToolStripMenuItem.Size = new Size(202, 22); - ordersToolStripMenuItem.Text = "Список заказов"; - ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; - // - // dataGridView - // - dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(12, 27); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(606, 399); - dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonCreateOrder.Location = new Point(624, 39); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(147, 32); - buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = true; - buttonCreateOrder.Click += ButtonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonTakeOrderInWork.Location = new Point(624, 98); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(147, 32); - buttonTakeOrderInWork.TabIndex = 3; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = true; - buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; - // - // button2 - // - button2.Anchor = AnchorStyles.Top | AnchorStyles.Right; - button2.Location = new Point(624, 157); - button2.Name = "button2"; - button2.Size = new Size(147, 32); - button2.TabIndex = 4; - button2.Text = "Заказ готов"; - button2.UseVisualStyleBackColor = true; - button2.Click += ButtonOrderReady_Click; - // - // button3 - // - button3.Anchor = AnchorStyles.Top | AnchorStyles.Right; - button3.Location = new Point(624, 215); - button3.Name = "button3"; - button3.Size = new Size(147, 32); - button3.TabIndex = 5; - button3.Text = "Заказ выдан"; - button3.UseVisualStyleBackColor = true; - button3.Click += ButtonIssuedOrder_Click; - // - // button4 - // - button4.Anchor = AnchorStyles.Top | AnchorStyles.Right; - button4.Location = new Point(624, 274); - button4.Name = "button4"; - button4.Size = new Size(147, 32); - button4.TabIndex = 6; - button4.Text = "Обновить список"; - button4.UseVisualStyleBackColor = true; - button4.Click += ButtonRef_Click; - // - // buttonAddPastryInShop - // - buttonAddPastryInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonAddPastryInShop.Location = new Point(624, 384); - buttonAddPastryInShop.Name = "buttonAddPastryInShop"; - buttonAddPastryInShop.Size = new Size(147, 31); - buttonAddPastryInShop.TabIndex = 7; - buttonAddPastryInShop.Text = "Пополнение магазина"; - buttonAddPastryInShop.UseVisualStyleBackColor = true; - buttonAddPastryInShop.Click += ButtonAddPastryInShop_Click; - // - // buttonSellPastry - // - buttonSellPastry.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonSellPastry.Location = new Point(624, 331); - buttonSellPastry.Name = "buttonSellPastry"; - buttonSellPastry.Size = new Size(147, 31); - buttonSellPastry.TabIndex = 8; - buttonSellPastry.Text = "Продать изделие"; - buttonSellPastry.UseVisualStyleBackColor = true; - buttonSellPastry.Click += ButtonSellPastry_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(783, 438); - Controls.Add(buttonSellPastry); - Controls.Add(buttonAddPastryInShop); - Controls.Add(button4); - Controls.Add(button3); - Controls.Add(button2); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(dataGridView); - Controls.Add(menuStrip1); - MainMenuStrip = menuStrip1; - Name = "FormMain"; - Text = "Кондитерская"; - Load += FormMain_Load; - menuStrip1.ResumeLayout(false); - menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + pastryToolStripMenuItem = new ToolStripMenuItem(); + componentToolStripMenuItem = new ToolStripMenuItem(); + ShopsToolStripMenuItem = new ToolStripMenuItem(); + reportsToolStripMenuItem = new ToolStripMenuItem(); + reportShopsToolStripMenuItem = new ToolStripMenuItem(); + ShopPastriesToolStripMenuItem = new ToolStripMenuItem(); + groupOrdersToolStripMenuItem = new ToolStripMenuItem(); + pastriesToolStripMenuItem = new ToolStripMenuItem(); + pastryComponentsToolStripMenuItem = new ToolStripMenuItem(); + ordersToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + button2 = new Button(); + button3 = new Button(); + button4 = new Button(); + buttonAddPastryInShop = new Button(); + buttonSellPastry = new Button(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, reportsToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(783, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem, ShopsToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // pastryToolStripMenuItem + // + pastryToolStripMenuItem.Name = "pastryToolStripMenuItem"; + pastryToolStripMenuItem.Size = new Size(145, 22); + pastryToolStripMenuItem.Text = "Изделия"; + pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click; + // + // componentToolStripMenuItem + // + componentToolStripMenuItem.Name = "componentToolStripMenuItem"; + componentToolStripMenuItem.Size = new Size(145, 22); + componentToolStripMenuItem.Text = "Компоненты"; + componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; + // + // ShopsToolStripMenuItem + // + ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem"; + ShopsToolStripMenuItem.Size = new Size(145, 22); + ShopsToolStripMenuItem.Text = "Магазины"; + ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; + // + // reportsToolStripMenuItem + // + reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { reportShopsToolStripMenuItem, ShopPastriesToolStripMenuItem, groupOrdersToolStripMenuItem, pastriesToolStripMenuItem, pastryComponentsToolStripMenuItem, ordersToolStripMenuItem }); + reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + reportsToolStripMenuItem.Size = new Size(60, 20); + reportsToolStripMenuItem.Text = "Отчеты"; + // + // reportShopsToolStripMenuItem + // + reportShopsToolStripMenuItem.Name = "reportShopsToolStripMenuItem"; + reportShopsToolStripMenuItem.Size = new Size(215, 22); + reportShopsToolStripMenuItem.Text = "Список магазинов"; + reportShopsToolStripMenuItem.Click += ReportShopsToolStripMenuItem_Click; + // + // ShopPastriesToolStripMenuItem + // + ShopPastriesToolStripMenuItem.Name = "ShopPastriesToolStripMenuItem"; + ShopPastriesToolStripMenuItem.Size = new Size(215, 22); + ShopPastriesToolStripMenuItem.Text = "Магазины с изделиями"; + ShopPastriesToolStripMenuItem.Click += ShopPastriesToolStripMenuItem_Click; + // + // groupOrdersToolStripMenuItem + // + groupOrdersToolStripMenuItem.Name = "groupOrdersToolStripMenuItem"; + groupOrdersToolStripMenuItem.Size = new Size(215, 22); + groupOrdersToolStripMenuItem.Text = "Список групп заказов"; + groupOrdersToolStripMenuItem.Click += GroupOrdersToolStripMenuItem_Click; + // + // pastriesToolStripMenuItem + // + pastriesToolStripMenuItem.Name = "pastriesToolStripMenuItem"; + pastriesToolStripMenuItem.Size = new Size(215, 22); + pastriesToolStripMenuItem.Text = "Список изделий"; + pastriesToolStripMenuItem.Click += PastriesToolStripMenuItem_Click; + // + // pastryComponentsToolStripMenuItem + // + pastryComponentsToolStripMenuItem.Name = "pastryComponentsToolStripMenuItem"; + pastryComponentsToolStripMenuItem.Size = new Size(215, 22); + pastryComponentsToolStripMenuItem.Text = "Изделия с компонентами"; + pastryComponentsToolStripMenuItem.Click += PastryComponentsToolStripMenuItem_Click; + // + // ordersToolStripMenuItem + // + ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + ordersToolStripMenuItem.Size = new Size(215, 22); + ordersToolStripMenuItem.Text = "Список заказов"; + ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(12, 27); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(606, 399); + dataGridView.TabIndex = 1; + // + // buttonCreateOrder + // + buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonCreateOrder.Location = new Point(624, 39); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(147, 32); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonTakeOrderInWork.Location = new Point(624, 98); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(147, 32); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + // + // button2 + // + button2.Anchor = AnchorStyles.Top | AnchorStyles.Right; + button2.Location = new Point(624, 157); + button2.Name = "button2"; + button2.Size = new Size(147, 32); + button2.TabIndex = 4; + button2.Text = "Заказ готов"; + button2.UseVisualStyleBackColor = true; + button2.Click += ButtonOrderReady_Click; + // + // button3 + // + button3.Anchor = AnchorStyles.Top | AnchorStyles.Right; + button3.Location = new Point(624, 215); + button3.Name = "button3"; + button3.Size = new Size(147, 32); + button3.TabIndex = 5; + button3.Text = "Заказ выдан"; + button3.UseVisualStyleBackColor = true; + button3.Click += ButtonIssuedOrder_Click; + // + // button4 + // + button4.Anchor = AnchorStyles.Top | AnchorStyles.Right; + button4.Location = new Point(624, 274); + button4.Name = "button4"; + button4.Size = new Size(147, 32); + button4.TabIndex = 6; + button4.Text = "Обновить список"; + button4.UseVisualStyleBackColor = true; + button4.Click += ButtonRef_Click; + // + // buttonAddPastryInShop + // + buttonAddPastryInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonAddPastryInShop.Location = new Point(624, 384); + buttonAddPastryInShop.Name = "buttonAddPastryInShop"; + buttonAddPastryInShop.Size = new Size(147, 31); + buttonAddPastryInShop.TabIndex = 7; + buttonAddPastryInShop.Text = "Пополнение магазина"; + buttonAddPastryInShop.UseVisualStyleBackColor = true; + buttonAddPastryInShop.Click += ButtonAddPastryInShop_Click; + // + // buttonSellPastry + // + buttonSellPastry.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonSellPastry.Location = new Point(624, 331); + buttonSellPastry.Name = "buttonSellPastry"; + buttonSellPastry.Size = new Size(147, 31); + buttonSellPastry.TabIndex = 8; + buttonSellPastry.Text = "Продать изделие"; + buttonSellPastry.UseVisualStyleBackColor = true; + buttonSellPastry.Click += ButtonSellPastry_Click; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(783, 438); + Controls.Add(buttonSellPastry); + Controls.Add(buttonAddPastryInShop); + Controls.Add(button4); + Controls.Add(button3); + Controls.Add(button2); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "Кондитерская"; + Load += FormMain_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip1; - private ToolStripMenuItem справочникиToolStripMenuItem; - private DataGridView dataGridView; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button button2; - private Button button3; - private Button button4; - private ToolStripMenuItem pastryToolStripMenuItem; - private ToolStripMenuItem componentToolStripMenuItem; - private ToolStripMenuItem reportsToolStripMenuItem; - private ToolStripMenuItem reportShopsToolStripMenuItem; - private ToolStripMenuItem ShopPastriesToolStripMenuItem; - private ToolStripMenuItem ordersToolStripMenuItem; - private ToolStripMenuItem ShopsToolStripMenuItem; - private Button buttonAddPastryInShop; - private Button buttonSellPastry; - } + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private DataGridView dataGridView; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button button2; + private Button button3; + private Button button4; + private ToolStripMenuItem pastryToolStripMenuItem; + private ToolStripMenuItem componentToolStripMenuItem; + private ToolStripMenuItem reportsToolStripMenuItem; + private ToolStripMenuItem reportShopsToolStripMenuItem; + private ToolStripMenuItem ShopPastriesToolStripMenuItem; + private ToolStripMenuItem groupOrdersToolStripMenuItem; + private ToolStripMenuItem ShopsToolStripMenuItem; + private Button buttonAddPastryInShop; + private Button buttonSellPastry; + private ToolStripMenuItem pastriesToolStripMenuItem; + private ToolStripMenuItem pastryComponentsToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; + } } \ No newline at end of file diff --git a/Confectionery/FormMain.cs b/Confectionery/FormMain.cs index 24994e7..1285ef5 100644 --- a/Confectionery/FormMain.cs +++ b/Confectionery/FormMain.cs @@ -7,207 +7,236 @@ using System.Windows.Forms; namespace ConfectioneryView { - public partial class FormMain : Form - { - private readonly ILogger _logger; - private readonly IOrderLogic _orderLogic; - private readonly IReportLogic _reportLogic; + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly 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) - { - LoadData(); - } - private void LoadData() - { - try - { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].HeaderText = " "; - dataGridView.Columns["PastryId"].Visible = false; - dataGridView.Columns["PastryName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; - } - _logger.LogInformation(" "); - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - private void ComponentsToolStripMenuItem_Click(object sender, EventArgs - e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); - if (service is FormComponents form) - { - form.ShowDialog(); - } - } - private void PastryToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormViewPastry)); - if (service is FormViewPastry form) - { - form.ShowDialog(); - } - } + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + _reportLogic = reportLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].HeaderText = " "; + dataGridView.Columns["PastryId"].Visible = false; + dataGridView.Columns["PastryName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation(" "); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs + e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void PastryToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewPastry)); + if (service is FormViewPastry form) + { + form.ShowDialog(); + } + } - private void ButtonCreateOrder_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); - if (service is FormCreateOrder form) - { - form.ShowDialog(); - LoadData(); - } - } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } - private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation(" No{id}. ' '", id); - try - { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); - if (!operationResult) - { - throw new Exception(" . ."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void ButtonOrderReady_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - OrderStatus orderStatus = (OrderStatus)dataGridView.SelectedRows[0].Cells["Status"].Value; - _logger.LogInformation(" No{id}. ''", id); - try - { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id, - Status = orderStatus - }); - if (!operationResult) - { - throw new Exception(" . ."); - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - private void ButtonIssuedOrder_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation(" No{id}. ''", id); - try - { - var operationResult = _orderLogic.DeliveryOrder(new - OrderBindingModel - { Id = id }); - if (!operationResult) - { - throw new Exception(" . ."); - } - _logger.LogInformation(" No{id} ", id); - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, " "); - MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation(" No{id}. ' '", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); + if (!operationResult) + { + throw new Exception(" . ."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + OrderStatus orderStatus = (OrderStatus)dataGridView.SelectedRows[0].Cells["Status"].Value; + _logger.LogInformation(" No{id}. ''", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + Status = orderStatus + }); + if (!operationResult) + { + throw new Exception(" . ."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation(" No{id}. ''", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception(" . ."); + } + _logger.LogInformation(" No{id} ", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } - private void ReportShopsToolStripMenuItem_Click(object sender, EventArgs e) - { - using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; - if (dialog.ShowDialog() == DialogResult.OK) - { - _reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); - MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } + private void ReportShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveShopsTableToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } - private void ShopPastriesToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportShopPastries)); - if (service is FormReportShopPastries form) - { - form.ShowDialog(); - } - } + private void PastriesToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePastriesToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("", "", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } - private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } - private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormViewShops)); - if (service is FormViewShops form) - { - form.ShowDialog(); - } - } + private void ShopPastriesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportShopPastries)); + if (service is FormReportShopPastries form) + { + form.ShowDialog(); + } + } - private void ButtonAddPastryInShop_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormAddPastryInShop)); - if (service is FormAddPastryInShop form) - { - form.ShowDialog(); - } - } + private void PastryComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents)); + if (service is FormReportPastryComponents form) + { + form.ShowDialog(); + } + } - private void ButtonSellPastry_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormSellPastry)); - if (service is FormSellPastry form) - { - form.ShowDialog(); - } - } - } + private void GroupOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupOrders)); + if (service is FormReportGroupOrders form) + { + form.ShowDialog(); + } + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + + private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormViewShops)); + if (service is FormViewShops form) + { + form.ShowDialog(); + } + } + + private void ButtonAddPastryInShop_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAddPastryInShop)); + if (service is FormAddPastryInShop form) + { + form.ShowDialog(); + } + } + + private void ButtonSellPastry_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSellPastry)); + if (service is FormSellPastry form) + { + form.ShowDialog(); + } + } + } } \ No newline at end of file diff --git a/Confectionery/FormReportGroupOrders.Designer.cs b/Confectionery/FormReportGroupOrders.Designer.cs new file mode 100644 index 0000000..ef8c4ee --- /dev/null +++ b/Confectionery/FormReportGroupOrders.Designer.cs @@ -0,0 +1,141 @@ +namespace ConfectioneryView +{ + partial class FormReportGroupOrders + { + /// + /// 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.panel = new System.Windows.Forms.Panel(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.labelTo = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.labelFrom = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.labelTo); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.labelFrom); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1031, 40); + this.panel.TabIndex = 0; + // + // buttonToPdf + // + this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToPdf.Location = new System.Drawing.Point(878, 8); + this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(139, 27); + this.buttonToPdf.TabIndex = 5; + this.buttonToPdf.Text = "В Pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(476, 8); + this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(139, 27); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7); + this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerTo.TabIndex = 3; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(208, 10); + this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(21, 15); + this.labelTo.TabIndex = 2; + this.labelTo.Text = "по"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7); + this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerFrom.TabIndex = 1; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(14, 10); + this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(15, 15); + this.labelFrom.TabIndex = 0; + this.labelFrom.Text = "С"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1031, 647); + this.Controls.Add(this.panel); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "FormReportOrders"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button buttonToPdf; + private System.Windows.Forms.Button buttonMake; + private System.Windows.Forms.DateTimePicker dateTimePickerTo; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.DateTimePicker dateTimePickerFrom; + private System.Windows.Forms.Label labelFrom; + } +} \ No newline at end of file diff --git a/Confectionery/FormReportGroupOrders.cs b/Confectionery/FormReportGroupOrders.cs new file mode 100644 index 0000000..d290793 --- /dev/null +++ b/Confectionery/FormReportGroupOrders.cs @@ -0,0 +1,91 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace ConfectioneryView +{ + public partial class FormReportGroupOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportGroupOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetGroupOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", + $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/Confectionery/FormReportGroupOrders.resx b/Confectionery/FormReportGroupOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Confectionery/FormReportGroupOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/FormReportPastryComponents.Designer.cs b/Confectionery/FormReportPastryComponents.Designer.cs new file mode 100644 index 0000000..c03df90 --- /dev/null +++ b/Confectionery/FormReportPastryComponents.Designer.cs @@ -0,0 +1,113 @@ +namespace ConfectioneryView +{ + partial class FormReportPastryComponents + { + /// + /// 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() + { + dataGridView = new DataGridView(); + buttonSaveToExcel = new Button(); + ColumnPastry = new DataGridViewTextBoxColumn(); + ColumnComponent = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToOrderColumns = true; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnPastry, ColumnComponent, ColumnCount }); + dataGridView.Dock = DockStyle.Bottom; + dataGridView.Location = new Point(0, 47); + dataGridView.Margin = new Padding(4, 3, 4, 3); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.Size = new Size(616, 510); + dataGridView.TabIndex = 0; + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(14, 14); + buttonSaveToExcel.Margin = new Padding(4, 3, 4, 3); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(186, 27); + buttonSaveToExcel.TabIndex = 1; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += ButtonSaveToExcel_Click; + // + // ColumnPastry + // + ColumnPastry.HeaderText = "Изделие"; + ColumnPastry.Name = "ColumnPastry"; + ColumnPastry.ReadOnly = true; + ColumnPastry.Width = 200; + // + // ColumnComponent + // + ColumnComponent.HeaderText = "Компонент"; + ColumnComponent.Name = "ColumnComponent"; + ColumnComponent.ReadOnly = true; + ColumnComponent.Width = 200; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + // + // FormReportPastryComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(616, 557); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView); + Margin = new Padding(4, 3, 4, 3); + Name = "FormReportPastryComponents"; + Text = "Изделия с компонентами"; + Load += FormReportPastryComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView; + private System.Windows.Forms.Button buttonSaveToExcel; + private DataGridViewTextBoxColumn ColumnPastry; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/Confectionery/FormReportPastryComponents.cs b/Confectionery/FormReportPastryComponents.cs new file mode 100644 index 0000000..16d7a9a --- /dev/null +++ b/Confectionery/FormReportPastryComponents.cs @@ -0,0 +1,79 @@ +using ConfectioneryContracts.BindingModels; +using ConfectioneryContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ConfectioneryView +{ + public partial class FormReportPastryComponents : Form + { + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportPastryComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportPastryComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetPastryComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" }); + foreach (var listElem in elem.Components) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка изделий по компонентам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SavePastryComponentToExcelFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка изделий по компонентам"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/Confectionery/FormReportPastryComponents.resx b/Confectionery/FormReportPastryComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Confectionery/FormReportPastryComponents.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/Program.cs b/Confectionery/Program.cs index 68f2245..8d26250 100644 --- a/Confectionery/Program.cs +++ b/Confectionery/Program.cs @@ -63,6 +63,8 @@ namespace ConfectioneryView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); } } diff --git a/Confectionery/ReportGroupOrders.rdlc b/Confectionery/ReportGroupOrders.rdlc new file mode 100644 index 0000000..5977266 --- /dev/null +++ b/Confectionery/ReportGroupOrders.rdlc @@ -0,0 +1,463 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + ConfectioneryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + Date + System.DateTime + + + Count + System.Int32 + + + Sum + System.Double + + + + ConfectioneryContracts.ViewModels + ReportOrdersViewModel + ConfectioneryContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 12.40104cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 12.40104cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.21438cm + + + 3.53188cm + + + 4.35209cm + + + + + 0.6cm + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество заказов + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Date.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 11.09835cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 6.6508cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 9.1508cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm + @@ -99,7 +103,7 @@ 1cm - 12.40104cm + 21cm 1 + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -170,7 +212,7 @@ - Количество заказов + Изделие @@ -193,6 +235,38 @@ + + + + true + true + + + + + Статус заказа + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -232,23 +306,21 @@ - + true true - =Fields!Date.Value - + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + @@ -331,6 +466,8 @@ + + @@ -347,7 +484,7 @@ 2.48391cm 0.55245cm 1.2cm - 11.09835cm + 19.84713cm 2