diff --git a/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToExcel.cs b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToExcel.cs new file mode 100644 index 0000000..0cab419 --- /dev/null +++ b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToExcel.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Enums; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Models; + +namespace VetClinicBusinessLogic.BusinessLogic.OfficePackage +{ + public abstract class ReportToExcel + { + public void CreateReportVisitService(ExcelInfoVisitService 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 pc in info.VisitServices) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.VisitDate.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var Component in pc.Services) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = Component, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + rowIndex++; + } + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + SaveExcel(info); + } + public void CreateReportServiceVisit(ExcelInfoServiceVisit 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 pc in info.VisitServices) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = pc.Name.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var Component in pc.Visits) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = Component.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + rowIndex++; + } + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = pc.TotalCount.ToString(), + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + SaveExcel(info); + } + /// + /// Создание excel-файла + /// + /// + protected abstract void CreateExcel(ExcelInfoVisitService info); + /// + /// Добавляем новую ячейку в лист + /// + /// + protected abstract void InsertCellInWorksheet(ExcelCellParameters + excelParams); + /// + /// Объединение ячеек + /// + /// + protected abstract void MergeCells(ExcelMergeParameters excelParams); + /// + /// Сохранение файла + /// + /// + protected abstract void SaveExcel(ExcelInfoVisitService info); + protected abstract void SaveExcel(ExcelInfoServiceVisit info); + protected abstract void CreateExcel(ExcelInfoServiceVisit info); + } +} diff --git a/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToPdf.cs b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToPdf.cs new file mode 100644 index 0000000..86f95ad --- /dev/null +++ b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToPdf.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Enums; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Models; + +namespace VetClinicBusinessLogic.BusinessLogic.OfficePackage +{ + public abstract class ReportToPdf + { + public void CreateDoc(PdfInfo info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle" + }); + CreateParagraph(new PdfParagraph + { + Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal" + }); + CreateTable(new List { "6cm", "6cm", "6cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Дата визита", "Сумма", "Имя клиента", }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var order in info.Visits) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.DateCreate.ToShortDateString(),order.Sum.ToString(), order.ClientName + }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + SavePdf(info); + } + public void CreateDocService(PdfInfoService info) + { + CreatePdf(info); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle" + }); + CreateParagraph(new PdfParagraph + { + Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal" + }); + CreateTable(new List { "8cm", "8cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Услуга", "Количество" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var order in info.Services.Services) + { + CreateRow(new PdfRowParameters + { + Texts = new List { order.Key,order.Value.ToString() + }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + } + CreateParagraph(new PdfParagraph + { + Text = $"Оплачено за период: {info.Services.Sum}", + Style = "Normal" + }); + SavePdf(info); + } + protected abstract void CreatePdf(PdfInfo info); + protected abstract void CreatePdf(PdfInfoService info); + protected abstract void CreateParagraph(PdfParagraph paragraph); + protected abstract void CreateTable(List columns); + protected abstract void CreateRow(PdfRowParameters rowParameters); + protected abstract void SavePdf(PdfInfo info); + protected abstract void SavePdf(PdfInfoService info); + } +} diff --git a/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToWord.cs b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToWord.cs new file mode 100644 index 0000000..af00be9 --- /dev/null +++ b/VetClinic/VetClinicBusinessLogic/BusinessLogic/OfficePackage/ReportToWord.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Enums; +using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Models; + +namespace VetClinicBusinessLogic.BusinessLogic.OfficePackage +{ + public abstract class ReportToWord + { + public void CreateDocVisitService(WordInfoVisitService 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 computer in info.VisitServices) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + (computer.VisitDate + ": ", new WordTextProperties { + Size = "24", + Bold = true + })}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + for (int i = 0; i < computer.Services.Count; i++) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + (" "+(i+1)+")"+computer.Services[i], new WordTextProperties { + Size = "24", + Bold = true + })}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + } + SaveWord(info); + } + public void CreateDocServiceVisit(WordInfoServiceVisit 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 computer in info.VisitServices) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + (computer.Name + ": ", new WordTextProperties { + Size = "24", + Bold = true + })}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + for (int i = 0; i < computer.Visits.Count; i++) + { + CreateParagraph(new WordParagraph + { + Texts = new List<(string, WordTextProperties)> { + (" "+(i+1)+")"+computer.Visits[i], new WordTextProperties { + Size = "24", + Bold = true + })}, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } + } + SaveWord(info); + } + protected abstract void CreateWord(WordInfoVisitService info); + protected abstract void CreateWord(WordInfoServiceVisit info); + protected abstract void SaveWord(WordInfoVisitService info); + protected abstract void CreateParagraph(WordParagraph paragraph); + protected abstract void SaveWord(WordInfoServiceVisit info); + } +} diff --git a/VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs b/VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs index 993ed2b..e1fdb69 100644 --- a/VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs +++ b/VetClinic/VetClinicDatabaseImplement/Implement/PaymentStorage.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.EntityFrameworkCore; +using System; using System.Collections.Generic; using System.Linq; using System.Text;