public static void CreateDoc(PdfInfoClient info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.SpaceAfter = "1cm";
            paragraph.Format.Alignment  = ParagraphAlignment.Center;
            paragraph.Style             = "NormalTitle";
            paragraph = section.AddParagraph($"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}"); paragraph.Format.SpaceAfter = "1cm";
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "Normal";
            var           table   = document.LastSection.AddTable();
            List <string> columns = new List <string> {
                "3cm", "3cm", "4cm", "3cm", "4cm"
            };

            foreach (var elem in columns)
            {
                table.AddColumn(elem);
            }
            CreateRow(new PdfRowParameters
            {
                Table = table,
                Texts = new List <string> {
                    "Вид услуги", "Дата оказания услуги", "Процедуры", "Цена", "Клиент"
                },
                Style = "NormalTitle",
                ParagraphAlignment = ParagraphAlignment.Center
            });
            foreach (var procedure in info.Procedures)
            {
                CreateRow(new PdfRowParameters
                {
                    Table = table,
                    Texts = new List <string> {
                        procedure.TypeOfService, procedure.DateOfService.ToShortDateString(), procedure.ProcedureName, procedure.Price.ToString()
                    },
                    Style = "Normal",
                    ParagraphAlignment = ParagraphAlignment.Left
                });
            }
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }
Example #2
0
        public static void CreateDoc(PdfInfoClient info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "NormalTitle";
            foreach (var order in info.Orders)
            {
                var orderLabel = section.AddParagraph("Заказ №" + order.Id + "от" + order.DateCreate);
                orderLabel.Style = "NormalTitle";
                var CarLabel = section.AddParagraph("Автомобили с комплектацией:");
                CarLabel.Style = "NormalTitle";

                foreach (var cars in order.OrderCars)
                {
                    var           CarTable      = document.LastSection.AddTable();
                    List <string> headerWidths2 = new List <string> {
                        "1cm", "3cm", "3cm", "3cm", "3cm"
                    };
                    foreach (var elem in headerWidths2)
                    {
                        CarTable.AddColumn(elem);
                    }
                    CreateRow(new PdfRowParameters
                    {
                        Table = CarTable,
                        Texts = new List <string> {
                            "№", "Автомобиль", "Год выпуска", "Количество", "Цена"
                        },
                        Style = "NormalTitle",
                        ParagraphAlignment = ParagraphAlignment.Center
                    });
                    CreateRow(new PdfRowParameters
                    {
                        Table = CarTable,
                        Texts = new List <string> {
                            cars.CarId.ToString(), cars.CarName, cars.Year.ToString(), cars.Count.ToString(), cars.Price.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                    foreach (var car in info.Cars)
                    {
                        if (car.Id != cars.CarId)
                        {
                            continue;
                        }

                        var           detailTable   = document.LastSection.AddTable();
                        List <string> headerWidths3 = new List <string> {
                            "1cm", "3cm", "3cm"
                        };
                        foreach (var elem in headerWidths3)
                        {
                            detailTable.AddColumn(elem);
                        }
                        CreateRow(new PdfRowParameters
                        {
                            Table = detailTable,
                            Texts = new List <string> {
                                "№", "Деталь", "Количество"
                            },
                            Style = "NormalTitle",
                            ParagraphAlignment = ParagraphAlignment.Center
                        });

                        foreach (var det in car.CarDetails)
                        {
                            CreateRow(new PdfRowParameters
                            {
                                Table = detailTable,
                                Texts = new List <string> {
                                    det.Key.ToString(), det.Value.Item1, det.Value.Item2.ToString()
                                },
                                Style = "Normal",
                                ParagraphAlignment = ParagraphAlignment.Left
                            });
                        }
                        section.AddParagraph();
                    }
                }
            }
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }
Example #3
0
        public static void CreateDoc(PdfInfoClient info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.SpaceAfter = "1cm";
            paragraph.Format.Alignment  = ParagraphAlignment.Center;
            paragraph.Style             = "NormalTitle";
            paragraph = section.AddParagraph($"с {info.DateFrom.ToShortDateString()} по { info.DateTo.ToShortDateString()}"); paragraph.Format.SpaceAfter = "1cm";
            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "Normal";
            var           table   = document.LastSection.AddTable();
            List <string> columns = new List <string> {
                "3cm", "6cm", "3cm", "2cm", "3cm"
            };

            foreach (var elem in columns)
            {
                table.AddColumn(elem);
            }
            CreateRow(new PdfRowParameters
            {
                Table = table,
                Texts = new List <string> {
                    "Дата заказа", "Изделие", "Количество",
                    "Сумма", "Статус"
                },
                Style = "NormalTitle",
                ParagraphAlignment = ParagraphAlignment.Center
            });
            decimal sumOrder = 0;
            //            foreach (var order in info.Orders)
            //            {
            //                CreateRow(new PdfRowParameters
            //                {
            //                    Table = table,
            //                    Texts = new List<string> { order.DateCreate.ToShortDateString(),
            //order.ManufactureName, order.Count.ToString(), order.Sum.ToString(), order.Status.ToString()
            //},
            //                    Style = "Normal",
            //                    ParagraphAlignment = ParagraphAlignment.Left
            //                });
            //                sumOrder += order.Sum;
            //            }
            Paragraph paragraphSum = section.AddParagraph($"Итого:{sumOrder.ToString()}");

            paragraphSum.Format.SpaceAfter = "4cm";
            paragraphSum.Format.Alignment  = ParagraphAlignment.Right;

            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true,
                                                                   PdfSharp.Pdf.PdfFontEmbedding.Always)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }
Example #4
0
        public static void CreateDoc(PdfInfoClient info)
        {
            Document document = new Document();

            DefineStyles(document);
            Section   section   = document.AddSection();
            Paragraph paragraph = section.AddParagraph(info.Title);

            paragraph.Format.Alignment = ParagraphAlignment.Center;
            paragraph.Style            = "NormalTitle";
            foreach (var order in info.Orders)
            {
                var orderLabel = section.AddParagraph("Заказ №" + order.Id + " от " + order.DateCreate.ToShortDateString());
                orderLabel.Style = "NormalTitle";
                orderLabel.Format.SpaceBefore = "1cm";
                orderLabel.Format.SpaceAfter  = "0,25cm";
                var servicesLabel = section.AddParagraph("Услуги:");
                servicesLabel.Style = "NormalTitle";
                var           serviceTable = document.LastSection.AddTable();
                List <string> headerWidths = new List <string> {
                    "1cm", "3cm", "3cm", "3cm", "3cm"
                };
                foreach (var elem in headerWidths)
                {
                    serviceTable.AddColumn(elem);
                }
                CreateRow(new PdfRowParameters
                {
                    Table = serviceTable,
                    Texts = new List <string> {
                        "№", "Заказ", "Название", "Описание", "Цена"
                    },
                    Style = "NormalTitle",
                    ParagraphAlignment = ParagraphAlignment.Center
                });
                int i = 1;
                foreach (var service in order.OrderServices)
                {
                    CreateRow(new PdfRowParameters
                    {
                        Table = serviceTable,
                        Texts = new List <string> {
                            i.ToString(), service.OrderId.ToString(), service.ServiceName, service.Desc, service.Price.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                    i++;
                }

                CreateRow(new PdfRowParameters
                {
                    Table = serviceTable,
                    Texts = new List <string> {
                        "", "", "", "Итого:", order.Price.ToString()
                    },
                    Style = "Normal",
                    ParagraphAlignment = ParagraphAlignment.Left
                });
                if (order.Status == OrderStatus.Принят)
                {
                    CreateRow(new PdfRowParameters
                    {
                        Table = serviceTable,
                        Texts = new List <string> {
                            "", "", "", "К оплате:", order.Price.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                }
                else
                {
                    CreateRow(new PdfRowParameters
                    {
                        Table = serviceTable,
                        Texts = new List <string> {
                            "", "", "", "К оплате:", (order.Price - order.Sum).ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                }
                if (info.Payments[order.Id].Count == 0)
                {
                    continue;
                }
                var paymentsLabel = section.AddParagraph("Платежи:");
                paymentsLabel.Style = "NormalTitle";
                var paymentTable = document.LastSection.AddTable();
                headerWidths = new List <string> {
                    "1cm", "3cm", "3cm"
                };
                foreach (var elem in headerWidths)
                {
                    paymentTable.AddColumn(elem);
                }
                CreateRow(new PdfRowParameters
                {
                    Table = paymentTable,
                    Texts = new List <string> {
                        "№", "Дата", "Сумма"
                    },
                    Style = "NormalTitle",
                    ParagraphAlignment = ParagraphAlignment.Center
                });
                i = 1;
                foreach (var payment in info.Payments[order.Id])
                {
                    CreateRow(new PdfRowParameters
                    {
                        Table = paymentTable,
                        Texts = new List <string> {
                            i.ToString(), payment.DatePayment.ToString(), payment.Sum.ToString()
                        },
                        Style = "Normal",
                        ParagraphAlignment = ParagraphAlignment.Left
                    });
                    i++;
                }
            }
            PdfDocumentRenderer renderer = new PdfDocumentRenderer(true)
            {
                Document = document
            };

            renderer.RenderDocument();
            renderer.PdfDocument.Save(info.FileName);
        }