pdf_norm
This commit is contained in:
parent
50e56467d7
commit
4c7cd11a02
@ -16,6 +16,7 @@ public partial class App : Application
|
|||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new MainWindow();
|
desktop.MainWindow = new MainWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<TextBlock Text="ШТРИХ-КОД ЗАКАЗА" FontSize="16" FontWeight="Bold"/>
|
<TextBlock Text="ШТРИХ-КОД ЗАКАЗА" FontSize="16" FontWeight="Bold"/>
|
||||||
|
|
||||||
<Border BorderBrush="Black" BorderThickness="1" Padding="15" CornerRadius="5">
|
<Border BorderBrush="Black" BorderThickness="1" Padding="15" CornerRadius="5">
|
||||||
<Canvas x:Name="BarcodeCanvas" Width="300" Height="100"/>
|
<Canvas x:Name="BarcodeCanvas" Width="100" Height="100"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<TextBlock x:Name="BarcodeText" FontFamily="Courier New" FontSize="14" TextAlignment="Center"/>
|
<TextBlock x:Name="BarcodeText" FontFamily="Courier New" FontSize="14" TextAlignment="Center"/>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
Height="600">
|
Height="600">
|
||||||
|
|
||||||
<StackPanel Margin="20">
|
<StackPanel Margin="20">
|
||||||
<!-- Номер заказа -->
|
|
||||||
<StackPanel Margin="0,0,0,15">
|
<StackPanel Margin="0,0,0,15">
|
||||||
<TextBlock Text="Номер заказа:" FontWeight="Bold" FontSize="14"/>
|
<TextBlock Text="Номер заказа:" FontWeight="Bold" FontSize="14"/>
|
||||||
<TextBox x:Name="OrderNumberBox"
|
<TextBox x:Name="OrderNumberBox"
|
||||||
@ -17,7 +17,7 @@
|
|||||||
Padding="5"/>
|
Padding="5"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Клиент -->
|
|
||||||
<StackPanel Margin="0,0,0,15">
|
<StackPanel Margin="0,0,0,15">
|
||||||
<TextBlock Text="Клиент:" FontWeight="Bold" FontSize="14"/>
|
<TextBlock Text="Клиент:" FontWeight="Bold" FontSize="14"/>
|
||||||
<DockPanel LastChildFill="True">
|
<DockPanel LastChildFill="True">
|
||||||
@ -34,7 +34,7 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Услуги -->
|
|
||||||
<StackPanel Margin="0,0,0,15">
|
<StackPanel Margin="0,0,0,15">
|
||||||
<TextBlock Text="Услуги:" FontWeight="Bold" FontSize="14"/>
|
<TextBlock Text="Услуги:" FontWeight="Bold" FontSize="14"/>
|
||||||
<DockPanel LastChildFill="True" Margin="0,0,0,10">
|
<DockPanel LastChildFill="True" Margin="0,0,0,10">
|
||||||
@ -50,7 +50,7 @@
|
|||||||
Padding="5"/>
|
Padding="5"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<!-- Время аренды -->
|
|
||||||
<StackPanel Margin="0,0,0,10" Orientation="Horizontal" VerticalAlignment="Center">
|
<StackPanel Margin="0,0,0,10" Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
<TextBlock Text="Время аренды (минуты):"
|
<TextBlock Text="Время аренды (минуты):"
|
||||||
Margin="0,0,10,0"
|
Margin="0,0,10,0"
|
||||||
@ -61,7 +61,7 @@
|
|||||||
Padding="5"/>
|
Padding="5"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Список выбранных услуг -->
|
|
||||||
<TextBlock Text="Выбранные услуги:"
|
<TextBlock Text="Выбранные услуги:"
|
||||||
Margin="0,0,0,5"
|
Margin="0,0,0,5"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
@ -95,7 +95,7 @@
|
|||||||
</ListBox>
|
</ListBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Кнопка оформления -->
|
|
||||||
<Button Content="Оформить заказ"
|
<Button Content="Оформить заказ"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Margin="0,20,0,0"
|
Margin="0,20,0,0"
|
||||||
@ -106,7 +106,7 @@
|
|||||||
FontSize="14"
|
FontSize="14"
|
||||||
FontWeight="Bold"/>
|
FontWeight="Bold"/>
|
||||||
|
|
||||||
<!-- Статус -->
|
|
||||||
<TextBlock x:Name="StatusText"
|
<TextBlock x:Name="StatusText"
|
||||||
Foreground="Red"
|
Foreground="Red"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
|
@ -216,64 +216,96 @@ public partial class SallerWindow : Window, INotifyPropertyChanged, IReactiveObj
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateOrderPdfDocument(Model.Order order)
|
private void GenerateOrderPdfDocument(Model.Order order)
|
||||||
{
|
{
|
||||||
string documentsDirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
||||||
string pdfFilePath = Path.Combine(documentsDirectoryPath, $"Заказ_{order.OrderCode.Replace("/", "_")}.pdf");
|
string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||||
|
string pdfFilePath = Path.Combine(documentsDirectory, $"Order_{order.OrderCode.Replace("/", "_")}.pdf");
|
||||||
|
|
||||||
using (Document document = new Document(PageSize.A4, 40, 40, 40, 40))
|
using (Document document = new Document(PageSize.A4, 40, 40, 40, 40))
|
||||||
{
|
{
|
||||||
PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(pdfFilePath, FileMode.Create));
|
PdfWriter.GetInstance(document, new FileStream(pdfFilePath, FileMode.Create));
|
||||||
document.Open();
|
document.Open();
|
||||||
|
|
||||||
Font titleFont = FontFactory.GetFont("Arial", 16, Font.BOLD);
|
|
||||||
Font headerFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
|
|
||||||
Font normalFont = FontFactory.GetFont("Arial", 12);
|
|
||||||
|
|
||||||
Paragraph titleParagraph = new Paragraph("Квитанция об оплате", titleFont);
|
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
|
||||||
titleParagraph.Alignment = Element.ALIGN_CENTER;
|
Font titleFont = new Font(bf, 16, Font.BOLD);
|
||||||
titleParagraph.SpacingAfter = 20;
|
Font headerFont = new Font(bf, 12, Font.BOLD);
|
||||||
document.Add(titleParagraph);
|
Font normalFont = new Font(bf, 12);
|
||||||
|
|
||||||
PdfPTable orderInfoTable = new PdfPTable(2);
|
|
||||||
orderInfoTable.WidthPercentage = 100;
|
|
||||||
orderInfoTable.SetWidths(new float[] { 30, 70 });
|
|
||||||
|
|
||||||
AddPdfTableRow(orderInfoTable, "Номер заказа:", order.OrderCode, headerFont, normalFont);
|
var title = new Paragraph("Payment Receipt", titleFont)
|
||||||
AddPdfTableRow(orderInfoTable, "Дата и время:", $"{order.StartDate:dd.MM.yyyy} {order.Time:hh\\:mm}", headerFont, normalFont);
|
|
||||||
AddPdfTableRow(orderInfoTable, "Клиент:", SelectedClient?.Fio ?? "Не указан", headerFont, normalFont);
|
|
||||||
AddPdfTableRow(orderInfoTable, "Статус:", order.Status, headerFont, normalFont);
|
|
||||||
|
|
||||||
document.Add(orderInfoTable);
|
|
||||||
document.Add(new Paragraph(" "));
|
|
||||||
|
|
||||||
Paragraph servicesTitleParagraph = new Paragraph("Оказанные услуги:", headerFont);
|
|
||||||
servicesTitleParagraph.SpacingAfter = 10;
|
|
||||||
document.Add(servicesTitleParagraph);
|
|
||||||
|
|
||||||
PdfPTable servicesTable = new PdfPTable(3);
|
|
||||||
servicesTable.WidthPercentage = 100;
|
|
||||||
servicesTable.SetWidths(new float[] { 60, 20, 20 });
|
|
||||||
|
|
||||||
servicesTable.AddCell(new Phrase("Наименование услуги", headerFont));
|
|
||||||
servicesTable.AddCell(new Phrase("Стоимость/час", headerFont));
|
|
||||||
servicesTable.AddCell(new Phrase("Время (мин)", headerFont));
|
|
||||||
|
|
||||||
foreach (ServiceWithRentTime service in SelectedServices)
|
|
||||||
{
|
{
|
||||||
servicesTable.AddCell(new Phrase(service.ServiceName, normalFont));
|
Alignment = Element.ALIGN_CENTER,
|
||||||
servicesTable.AddCell(new Phrase($"{service.CostPerHour:N2} ₽", normalFont));
|
SpacingAfter = 20f
|
||||||
servicesTable.AddCell(new Phrase(service.RentTime.ToString(), normalFont));
|
};
|
||||||
}
|
document.Add(title);
|
||||||
|
|
||||||
|
|
||||||
|
PdfPTable infoTable = new PdfPTable(2) { WidthPercentage = 100 };
|
||||||
|
infoTable.SetWidths(new float[] { 30f, 70f });
|
||||||
|
AddCell(infoTable, "Order Number:", order.OrderCode, headerFont, normalFont);
|
||||||
|
AddCell(infoTable, "Date & Time:", $"{order.StartDate:dd.MM.yyyy} {order.Time:hh\\:mm}", headerFont, normalFont);
|
||||||
|
AddCell(infoTable, "Customer:", SelectedClient?.Fio ?? "N/A", headerFont, normalFont);
|
||||||
|
AddCell(infoTable, "Status:", order.Status, headerFont, normalFont);
|
||||||
|
document.Add(infoTable);
|
||||||
|
|
||||||
document.Add(servicesTable);
|
|
||||||
document.Add(new Paragraph(" "));
|
document.Add(new Paragraph(" "));
|
||||||
|
|
||||||
decimal totalAmount = SelectedServices.Sum(service => (service.CostPerHour ?? 0) * (service.RentTime / 60m));
|
|
||||||
Paragraph totalParagraph = new Paragraph($"Итого к оплате: {totalAmount:N2} ₽", headerFont);
|
var svcTitle = new Paragraph("Services Rendered:", headerFont)
|
||||||
totalParagraph.Alignment = Element.ALIGN_RIGHT;
|
{
|
||||||
document.Add(totalParagraph);
|
SpacingAfter = 10f
|
||||||
|
};
|
||||||
|
document.Add(svcTitle);
|
||||||
|
|
||||||
|
PdfPTable svcTable = new PdfPTable(3)
|
||||||
|
{
|
||||||
|
WidthPercentage = 100,
|
||||||
|
SpacingBefore = 5f,
|
||||||
|
SpacingAfter = 5f
|
||||||
|
};
|
||||||
|
svcTable.SetWidths(new float[] { 60f, 20f, 20f });
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var hdr in new[] { "Service Name", "Rate/hour", "Duration (min)" })
|
||||||
|
{
|
||||||
|
svcTable.AddCell(new PdfPCell(new Phrase(hdr, headerFont))
|
||||||
|
{
|
||||||
|
HorizontalAlignment = Element.ALIGN_CENTER,
|
||||||
|
BackgroundColor = BaseColor.LIGHT_GRAY,
|
||||||
|
Padding = 5f
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var svc in SelectedServices)
|
||||||
|
{
|
||||||
|
svcTable.AddCell(new PdfPCell(new Phrase(svc.ServiceName, normalFont)) { Padding = 5f });
|
||||||
|
svcTable.AddCell(new PdfPCell(new Phrase($"{svc.CostPerHour:N2} ₽", normalFont))
|
||||||
|
{
|
||||||
|
HorizontalAlignment = Element.ALIGN_RIGHT,
|
||||||
|
Padding = 5f
|
||||||
|
});
|
||||||
|
svcTable.AddCell(new PdfPCell(new Phrase(svc.RentTime.ToString(), normalFont))
|
||||||
|
{
|
||||||
|
HorizontalAlignment = Element.ALIGN_RIGHT,
|
||||||
|
Padding = 5f
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.Add(svcTable);
|
||||||
|
|
||||||
|
|
||||||
|
decimal total = SelectedServices.Sum(s => (s.CostPerHour ?? 0) * (s.RentTime / 60m));
|
||||||
|
var totalPara = new Paragraph($"Total Due: {total:N2} ₽", headerFont)
|
||||||
|
{
|
||||||
|
Alignment = Element.ALIGN_RIGHT,
|
||||||
|
SpacingBefore = 10f
|
||||||
|
};
|
||||||
|
document.Add(totalPara);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(new ProcessStartInfo
|
Process.Start(new ProcessStartInfo
|
||||||
@ -282,15 +314,17 @@ public partial class SallerWindow : Window, INotifyPropertyChanged, IReactiveObj
|
|||||||
UseShellExecute = true
|
UseShellExecute = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
StatusText.Text = $"Ошибка при открытии PDF: {exception.Message}";
|
StatusText.Text = $"Error opening PDF: {ex.Message}";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddPdfTableRow(PdfPTable table, string label, string value, Font labelFont, Font valueFont)
|
|
||||||
{
|
|
||||||
table.AddCell(new Phrase(label, labelFont));
|
|
||||||
table.AddCell(new Phrase(value, valueFont));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void AddCell(PdfPTable table, string label, string value, Font labelFont, Font valueFont)
|
||||||
|
{
|
||||||
|
table.AddCell(new Phrase(label, labelFont));
|
||||||
|
table.AddCell(new Phrase(value, valueFont));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_hard")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("demo_hard")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+69fe9ea9bc91472e247d6c5d565068a4efb0a683")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+50e56467d7d10df36759130ef24997a8c6ea8a33")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("demo_hard")]
|
[assembly: System.Reflection.AssemblyProductAttribute("demo_hard")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("demo_hard")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("demo_hard")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
b558e1c40e2637b7a5437875d3c594c1eda934e9d40f49c41e49dbf89f9df5f0
|
d558e19871cd3b2b9f2f0170e2a01cb1d30cd37918ea9e521a55dc94c303ad3d
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user