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