Сдано
This commit is contained in:
parent
d1a577e5d3
commit
d31a0e155a
@ -8,6 +8,7 @@ using Library15Gerimovich.OfficePackage.HelperModels;
|
||||
using Library15Gerimovich;
|
||||
using WinFormsLibrary1;
|
||||
using WinFormsLibrary1.Models;
|
||||
using View.ViewModels;
|
||||
|
||||
namespace Laba3
|
||||
{
|
||||
@ -114,6 +115,8 @@ namespace Laba3
|
||||
// Создаем PDF-документ
|
||||
pdfImg.CreatePdfDocument(fileName, documentTitle, images);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("PDF document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -134,25 +137,29 @@ namespace Laba3
|
||||
{
|
||||
// Создаем объекты MergeCell и Column
|
||||
var mergeCells = new List<MergeCell>
|
||||
{
|
||||
new MergeCell("Product Information", new int[] { 0, 1, 2, 3 })
|
||||
};
|
||||
{
|
||||
new MergeCell("Product", new int[] {1, 2})
|
||||
};
|
||||
|
||||
var columns = new List<Column>
|
||||
{
|
||||
new Column("ID", "Id", 10),
|
||||
new Column("Name", "Name", 20),
|
||||
new Column("Manufacturer", "ManufacturerName", 20),
|
||||
new Column("Delivery Date", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
{
|
||||
new Column("Id", "Id", 10),
|
||||
new Column("Name", "Name", 20),
|
||||
new Column("ManufacturerName", "ManufacturerName", 20),
|
||||
new Column("DeliveryDate", "DeliveryDate", 20)
|
||||
};
|
||||
|
||||
// Создаем компонент ComponentTable
|
||||
var componentTable = new ComponentTable();
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(saveFileDialogExel.FileName, "Product Report", mergeCells, columns, products);
|
||||
// Конвертируем продукты в представление для таблицы
|
||||
var tableItems = ProductTableItem.ConvertProductsToTableItems(products);
|
||||
|
||||
// Создаем документ Excel
|
||||
componentTable.CreateDocument(saveFileDialogExel.FileName, "Product Report", mergeCells, columns, tableItems);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Excel document created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -187,6 +194,9 @@ namespace Laba3
|
||||
|
||||
// Создаем диаграмму в Word
|
||||
wordDiagramComponent.CreateDiagram(diagramInfo);
|
||||
|
||||
// Уведомление об успешной загрузке
|
||||
MessageBox.Show("Word document with chart created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -195,6 +205,8 @@ namespace Laba3
|
||||
}
|
||||
}
|
||||
|
||||
// бизнес логика
|
||||
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control)
|
||||
|
27
Laba3/ViewModels/ProductTableItem.cs
Normal file
27
Laba3/ViewModels/ProductTableItem.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Data.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace View.ViewModels
|
||||
{
|
||||
public class ProductTableItem
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ManufacturerName { get; set; }
|
||||
public string DeliveryDate { get; set; }
|
||||
public static List<ProductTableItem> ConvertProductsToTableItems(List<Product> products)
|
||||
{
|
||||
return products.Select(p => new ProductTableItem
|
||||
{
|
||||
Id = p.Id.ToString(),
|
||||
Name = p.Name,
|
||||
ManufacturerName = p.ManufacturerName,
|
||||
DeliveryDate = p.DeliveryDate.ToShortDateString()
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user