From 9a603ace5ff488b6759ed8c0ff066dfd62e28f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Fri, 7 Apr 2023 01:24:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20AbstractSave=20=D0=B2=20HotelBusinessLogic.OfficePacka?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractSaveToExcelHeadwaitre.cs | 80 +++++++++++++++++++ .../AbstractSaveToPdfHeadwaitre.cs | 58 ++++++++++++++ .../AbstractSaveToWordHeadwaitre.cs | 62 ++++++++++++++ .../ReportConferenceBindingRoomsViewModel.cs | 2 +- 4 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToExcelHeadwaitre.cs create mode 100644 Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfHeadwaitre.cs create mode 100644 Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToExcelHeadwaitre.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToExcelHeadwaitre.cs new file mode 100644 index 0000000..d492cdd --- /dev/null +++ b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToExcelHeadwaitre.cs @@ -0,0 +1,80 @@ +using HotelBusinessLogic.OfficePackage.HelperEnums; +using HotelBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HotelBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToExcelHeadwaitre + { + public void CreateReport(ExcelInfoHeadwaiter info) + { + CreateExcel(info); + + 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 mc in info.MealPlanDinner) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = mc.DinnerName, + StyleInfo = ExcelStyleInfoType.Text + }); + + rowIndex++; + + foreach (var mealPlan in mc.MealPlans) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = mealPlan.Item1, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = mealPlan.Item2.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + + rowIndex++; + } + + rowIndex++; + } + + SaveExcel(info); + } + + protected abstract void CreateExcel(ExcelInfoHeadwaiter info); + + protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); + + protected abstract void MergeCells(ExcelMergeParameters excelParams); + + protected abstract void SaveExcel(ExcelInfoHeadwaiter info); + } +} diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfHeadwaitre.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfHeadwaitre.cs new file mode 100644 index 0000000..e1df11c --- /dev/null +++ b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToPdfHeadwaitre.cs @@ -0,0 +1,58 @@ +using HotelBusinessLogic.OfficePackage.HelperEnums; +using HotelBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HotelBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToPdfHeadwaitre + { + public void CreateDoc(PdfInfoHeadwaiter 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", "3cm", "3cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Название команты", "Корпус комнтаы", "Цена комнаты" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var conferenceBindingRooms in info.ConferenceBindingRooms) + { + CreateRow(new PdfRowParameters + { + Texts = new List { conferenceBindingRooms.Id.ToString(), conferenceBindingRooms.RoomName, conferenceBindingRooms.RoomFrame, conferenceBindingRooms.RoomPrice.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Итого: {info.ConferenceBindingRooms.Sum(x => x.RoomPrice)}\t", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + SavePdf(info); + } + protected abstract void CreatePdf(PdfInfoHeadwaiter info); + protected abstract void CreateParagraph(PdfParagraph paragraph); + protected abstract void CreateTable(List columns); + protected abstract void CreateRow(PdfRowParameters rowParameters); + protected abstract void SavePdf(PdfInfoHeadwaiter info); + } +} diff --git a/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs new file mode 100644 index 0000000..d96fa9d --- /dev/null +++ b/Hotel/HotelBusinessLogic/OfficePackage/AbstractSaveToWordHeadwaitre.cs @@ -0,0 +1,62 @@ +using HotelBusinessLogic.OfficePackage.HelperEnums; +using HotelBusinessLogic.OfficePackage.HelperModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HotelBusinessLogic.OfficePackage +{ + public abstract class AbstractSaveToWordHeadwaitre + { + public void CreateDoc(WordInfoHeadwaiter info) + { + CreateWord(info); + + 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 mc in info.MealPlanDinner) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (mc.DinnerName+" - ", new WordTextProperties { Size = "24", Bold=true})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + + foreach (var mealPlan in mc.MealPlans) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> + { (mealPlan.Item1 + " - ", new WordTextProperties { Size = "20", Bold=false}), + (mealPlan.Item2.ToShortDateString(), new WordTextProperties { Size = "20", Bold=false})}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + } + SaveWord(info); + } + + protected abstract void CreateWord(WordInfoHeadwaiter info); + protected abstract void CreateParagraph(WordParagraph paragraph); + protected abstract void SaveWord(WordInfoHeadwaiter info); + } +} diff --git a/Hotel/HotelContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs b/Hotel/HotelContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs index 7d6b15a..6e26c26 100644 --- a/Hotel/HotelContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/ReportConferenceBindingRoomsViewModel.cs @@ -10,7 +10,7 @@ namespace HotelContracts.ViewModels { public int Id { get; set; } public string RoomName { get; set; } = string.Empty; - public string RoomPrice { get; set; } = string.Empty; + public double RoomPrice { get; set; } public string RoomFrame { get; set; } = string.Empty; }