126 lines
3.5 KiB
C#
126 lines
3.5 KiB
C#
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
|
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
namespace ComputerHardwareStoreBusinessLogic.OfficePackage
|
|
{
|
|
public abstract class AbstractSaveToWord
|
|
{
|
|
public void CreateProductBuildReport(WordInfo 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
|
|
}
|
|
});
|
|
|
|
List<WordRow> rows = new List<WordRow>();
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)> {
|
|
("Сборки", new WordTextProperties { Size = "24", Bold = true }),
|
|
("Товары", new WordTextProperties { Size = "24", Bold = true }),
|
|
("Стоимость", new WordTextProperties { Size = "24", Bold = true })
|
|
}
|
|
});
|
|
|
|
var reportRecords = info.ProductBuilds;
|
|
foreach (var reportRecord in reportRecords)
|
|
{
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)>
|
|
{
|
|
(reportRecord.ProductName, new WordTextProperties { Size = "24" }),
|
|
("", new WordTextProperties { }),
|
|
("", new WordTextProperties { })
|
|
}
|
|
});
|
|
for (int i = 0; i < reportRecord.Builds.Count; i++)
|
|
{
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)>
|
|
{
|
|
("", new WordTextProperties { }),
|
|
(reportRecord.Builds[i].Build, new WordTextProperties { Size = "24" }),
|
|
(reportRecord.Builds[i].Price.ToString(), new WordTextProperties { Size = "24" })
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
CreateTable(rows);
|
|
|
|
SaveWord(info);
|
|
}
|
|
|
|
public void CreateBuildProductReport(WordInfo 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
|
|
}
|
|
});
|
|
|
|
List<WordRow> rows = new List<WordRow>();
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)> {
|
|
("Товары", new WordTextProperties { Size = "24", Bold = true }),
|
|
("Сборки", new WordTextProperties { Size = "24", Bold = true }),
|
|
("Стоимость", new WordTextProperties { Size = "24", Bold = true })
|
|
}
|
|
});
|
|
|
|
var reportRecords = info.BuildProducts;
|
|
foreach (var reportRecord in reportRecords)
|
|
{
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)>
|
|
{
|
|
(reportRecord.BuildName, new WordTextProperties { Size = "24" }),
|
|
("", new WordTextProperties { }),
|
|
("", new WordTextProperties { })
|
|
}
|
|
});
|
|
for (int i = 0; i < reportRecord.Products.Count; i++)
|
|
{
|
|
rows.Add(new WordRow
|
|
{
|
|
Rows = new List<(string, WordTextProperties)>
|
|
{
|
|
("", new WordTextProperties { }),
|
|
(reportRecord.Products[i].Product, new WordTextProperties { Size = "24" }),
|
|
(reportRecord.Products[i].Price.ToString(), new WordTextProperties { Size = "24" })
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
CreateTable(rows);
|
|
|
|
SaveWord(info);
|
|
}
|
|
protected abstract void CreateWord(WordInfo info);
|
|
|
|
protected abstract void CreateTable(List<WordRow> rows);
|
|
|
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
|
|
|
protected abstract void SaveWord(WordInfo info);
|
|
}
|
|
}
|