update document
This commit is contained in:
parent
9af88075ac
commit
1592002820
@ -11,11 +11,11 @@ namespace BenchtopPDF
|
||||
{
|
||||
public static Image LogoImage { get; } = Image.FromFile("BenchTopLogo.jpg");
|
||||
|
||||
public Sheet Model { get; }
|
||||
public Sheet Sheet { get; }
|
||||
|
||||
public SheetDocument(Sheet model)
|
||||
{
|
||||
Model = model;
|
||||
Sheet = model;
|
||||
}
|
||||
|
||||
public DocumentMetadata GetMetadata() => DocumentMetadata.Default;
|
||||
@ -56,7 +56,7 @@ namespace BenchtopPDF
|
||||
column.Item().Text(text =>
|
||||
{
|
||||
text.Span("Issue date: ").SemiBold();
|
||||
text.Span($"{Model.IssueDate:d}");
|
||||
// text.Span($"{Sheet.IssueDate:d}");
|
||||
});
|
||||
});
|
||||
|
||||
@ -66,24 +66,26 @@ namespace BenchtopPDF
|
||||
|
||||
void ComposeContent(IContainer container)
|
||||
{
|
||||
container.PaddingVertical(40).Column(column =>
|
||||
container.PaddingVertical(40).Column(column =>
|
||||
{
|
||||
column.Spacing(20);
|
||||
|
||||
|
||||
column.Item().Row(row =>
|
||||
{
|
||||
row.RelativeItem().Component(new AddressComponent("From", Model.SellerAddress));
|
||||
row.RelativeItem().Component(new AddressComponent("From"));
|
||||
row.ConstantItem(50);
|
||||
row.RelativeItem().Component(new AddressComponent("For", Model.CustomerAddress));
|
||||
row.RelativeItem().Component(new AddressComponent("For"));
|
||||
});
|
||||
|
||||
column.Item().Element(ComposeTable);
|
||||
foreach (var item in Sheet.Transducers) {
|
||||
column.Item().Element(ComposeTable);
|
||||
}
|
||||
|
||||
var totalPrice = Model.Items.Sum(x => x.Price * x.Quantity);
|
||||
column.Item().PaddingRight(5).AlignRight().Text($"Grand total: {totalPrice:C}").SemiBold();
|
||||
// var totalPrice = Sheet.Items.Sum(x => x.Price * x.Quantity);
|
||||
// column.Item().PaddingRight(5).AlignRight().Text($"Grand total: {totalPrice:C}").SemiBold();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Model.Comments))
|
||||
column.Item().PaddingTop(25).Element(ComposeComments);
|
||||
// if (!string.IsNullOrWhiteSpace(Sheet.Comments))
|
||||
// column.Item().PaddingTop(25).Element(ComposeComments);
|
||||
});
|
||||
}
|
||||
|
||||
@ -95,8 +97,9 @@ namespace BenchtopPDF
|
||||
{
|
||||
table.ColumnsDefinition(columns =>
|
||||
{
|
||||
columns.ConstantColumn(25);
|
||||
columns.RelativeColumn(3);
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
columns.RelativeColumn();
|
||||
@ -104,24 +107,26 @@ namespace BenchtopPDF
|
||||
|
||||
table.Header(header =>
|
||||
{
|
||||
header.Cell().Text("#");
|
||||
header.Cell().Text("Product").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Unit price").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Quantity").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Total").Style(headerStyle);
|
||||
header.Cell().Text("Point #").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Master Value").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Low Limit").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("High Limit").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("DUT").Style(headerStyle);
|
||||
header.Cell().AlignRight().Text("Delta").Style(headerStyle);
|
||||
|
||||
header.Cell().ColumnSpan(5).PaddingTop(5).BorderBottom(1).BorderColor(Colors.Black);
|
||||
header.Cell().ColumnSpan(6).PaddingTop(5).BorderBottom(1).BorderColor(Colors.Black);
|
||||
});
|
||||
|
||||
foreach (var item in Model.Items)
|
||||
foreach (var item in Sheet.Transducers)
|
||||
{
|
||||
var index = Model.Items.IndexOf(item) + 1;
|
||||
var index = Sheet.Transducers.IndexOf(item) + 1;
|
||||
|
||||
table.Cell().Element(CellStyle).Text($"{index}");
|
||||
table.Cell().Element(CellStyle).Text(item.Name);
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.Price:C}");
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.Quantity}");
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.Price * item.Quantity:C}");
|
||||
table.Cell().Element(CellStyle).Text(item.PartNumber);
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.Accuracy}");
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.TransducerName}");
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.VerifyDate}");
|
||||
table.Cell().Element(CellStyle).AlignRight().Text($"{item.VerifyDate}");
|
||||
|
||||
static IContainer CellStyle(IContainer container) => container.BorderBottom(1).BorderColor(Colors.Grey.Lighten2).PaddingVertical(5);
|
||||
}
|
||||
@ -134,7 +139,7 @@ namespace BenchtopPDF
|
||||
{
|
||||
column.Spacing(5);
|
||||
column.Item().Text("Comments").FontSize(14).SemiBold();
|
||||
column.Item().Text(Model.Comments);
|
||||
// column.Item().Text(Sheet.Comments);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -142,12 +147,10 @@ namespace BenchtopPDF
|
||||
public class AddressComponent : IComponent
|
||||
{
|
||||
private string Title { get; }
|
||||
private Address Address { get; }
|
||||
|
||||
public AddressComponent(string title, Address address)
|
||||
|
||||
public AddressComponent(string title)
|
||||
{
|
||||
Title = title;
|
||||
Address = address;
|
||||
}
|
||||
|
||||
public void Compose(IContainer container)
|
||||
@ -155,15 +158,9 @@ namespace BenchtopPDF
|
||||
container.ShowEntire().Column(column =>
|
||||
{
|
||||
column.Spacing(2);
|
||||
|
||||
|
||||
column.Item().Text(Title).SemiBold();
|
||||
column.Item().PaddingBottom(5).LineHorizontal(1);
|
||||
|
||||
column.Item().Text(Address.CompanyName);
|
||||
column.Item().Text(Address.Street);
|
||||
column.Item().Text($"{Address.City}, {Address.State}");
|
||||
column.Item().Text(Address.Email);
|
||||
column.Item().Text(Address.Phone);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user