ПИбд-22 Боровков М В 4 лабораторная работа #4
@ -32,26 +32,23 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
/// <returns></returns>
|
||||
public List<ReportSushiComponentViewModel> GetSushiComponent()
|
||||
{
|
||||
var components = _componentStorage.GetFullList();
|
||||
var sushis = _sushiStorage.GetFullList();
|
||||
var list = new List<ReportSushiComponentViewModel>();
|
||||
foreach (var component in components)
|
||||
foreach (var sushi in sushis)
|
||||
{
|
||||
var record = new ReportSushiComponentViewModel
|
||||
{
|
||||
ComponentName = component.ComponentName,
|
||||
Sushis = new List<Tuple<string, int>>(),
|
||||
SushiName = sushi.SushiName,
|
||||
Components = new List<Tuple<string, int>>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var sushi in sushis)
|
||||
foreach (var component in sushi.SushiComponents)
|
||||
{
|
||||
if (sushi.SushiComponents.ContainsKey(component.Id))
|
||||
{
|
||||
record.Sushis.Add(new Tuple<string,
|
||||
int>(sushi.SushiName, sushi.SushiComponents[component.Id].Item2));
|
||||
record.TotalCount +=
|
||||
sushi.SushiComponents[component.Id].Item2;
|
||||
}
|
||||
record.Components.Add(new Tuple<string, int>(
|
||||
component.Value.Item1.ComponentName,
|
||||
component.Value.Item2
|
||||
));
|
||||
record.TotalCount += component.Value.Item2;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
@ -66,8 +63,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
{
|
||||
return _orderStorage.GetFilteredList(new OrderSearchModel
|
||||
{
|
||||
DateFrom
|
||||
= model.DateFrom,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportOrdersViewModel
|
||||
@ -75,6 +71,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
Id = x.Id,
|
||||
DateCreate = x.DateCreate,
|
||||
SushiName = x.SushiName,
|
||||
OrderStatus = x.Status.ToString(),
|
||||
Sum = x.Sum
|
||||
})
|
||||
.ToList();
|
||||
@ -88,7 +85,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Title = "Список суши",
|
||||
Sushis = _sushiStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
@ -101,7 +98,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Title = "Список суши",
|
||||
SushiComponents = GetSushiComponent()
|
||||
});
|
||||
}
|
||||
|
@ -25,35 +25,33 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
CellToName = "C1"
|
||||
});
|
||||
uint rowIndex = 2;
|
||||
foreach (var pc in info.SushiComponents)
|
||||
foreach (var sc in info.SushiComponents)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.ComponentName,
|
||||
Text = sc.SushiName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var sushi in pc.Sushis)
|
||||
++rowIndex;
|
||||
foreach (var sushi in sc.Components)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = sushi.Item1,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = sushi.Item2.ToString(),
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
rowIndex++;
|
||||
++rowIndex;
|
||||
}
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
@ -66,10 +64,10 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.TotalCount.ToString(),
|
||||
Text = sc.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
++rowIndex;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
@ -82,8 +80,7 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
/// Добавляем новую ячейку в лист
|
||||
/// </summary>
|
||||
/// <param name="cellParameters"></param>
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters
|
||||
excelParams);
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
/// <summary>
|
||||
/// Объединение ячеек
|
||||
/// </summary>
|
||||
|
@ -25,10 +25,10 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
@ -40,7 +40,9 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
order.Id.ToString(),
|
||||
order.DateCreate.ToShortDateString(),
|
||||
order.SushiName,
|
||||
order.Sum.ToString() },
|
||||
order.Sum.ToString(),
|
||||
order.OrderStatus.ToString()
|
||||
},
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
|
@ -26,7 +26,8 @@ namespace SushiBarBusinessLogic.OfficePackage
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(sushis.SushiName, new WordTextProperties { Size = "24", })
|
||||
(sushis.SushiName, new WordTextProperties { Size = "24", Bold = true }),
|
||||
(" - цена " + sushis.Price.ToString(), new WordTextProperties { Size = "24" })
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
|
@ -193,8 +193,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
// Создаем книгу (в ней хранятся листы)
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook();
|
||||
@ -294,8 +293,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
mergeCells = new MergeCells();
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(mergeCells,
|
||||
_worksheet.Elements<CustomSheetView>().First());
|
||||
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -315,6 +313,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
return;
|
||||
}
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment =
|
||||
GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
protected override void CreateTable(List<string> columns)
|
||||
@ -83,8 +82,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment =
|
||||
GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
properties.AppendChild(new Indentation());
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
@ -114,6 +115,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace SushiBarContracts.ViewModels
|
||||
public DateTime DateCreate { get; set; }
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
public double Sum { get; set; }
|
||||
public string OrderStatus { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ namespace SushiBarContracts.ViewModels
|
||||
{
|
||||
public class ReportSushiComponentViewModel
|
||||
{
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
public string SushiName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<Tuple<string, int>> Sushis { get; set; } = new List<Tuple<string, int>>();
|
||||
public List<Tuple<string, int>> Components { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user