Beispiel #1
0
        public void CozdSchetWriter(string push, int ID)
        {
            DB5  db   = new DB5(kursach.Program.Pole.pole);
            DB16 db2  = new DB16(kursach.Program.Pole.pole);
            DB1  db1  = new DB1(kursach.Program.Pole.pole);
            DB14 db14 = new DB14(kursach.Program.Pole.pole);
            DB13 db13 = new DB13(kursach.Program.Pole.pole);

            Mapping.DB17 db17 = new Mapping.DB17(kursach.Program.Pole.pole);
            var          ec   = from n in db.JurnalRabot
                                where n.ID == Convert.ToInt32(ID)
                                select n;
            int temp = 0;

            foreach (var i in ec)
            {
                temp = i.IDZapisi;
            }
            var ec2 = from n in db2.Zapis
                      where n.ID == temp
                      select n;
            var Firma = from n in db17.Firma
                        where n.ID == 1
                        select n;
            string temp2 = "";

            foreach (var i in ec2)
            {
                temp2 = i.Data;
            }
            unoidl.com.sun.star.uno.XComponentContext     localContext        = uno.util.Bootstrap.bootstrap();
            unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
            XComponentLoader componentLoader = (XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
            XComponent       xComponent      = componentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);

            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().setString("Счет №" + ID + Environment.NewLine);

            unoidl.com.sun.star.text.XTextRange x = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x, "от " + temp2 + "г." + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);
            unoidl.com.sun.star.text.XTextRange xi = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd(); // в конец
            foreach (var i in Firma)
            {
                ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(xi, "ИНН " + i.INN + " КПП " + i.KPP + Environment.NewLine + "Получатель " + i.Name + " № Счета " + i.Schet + Environment.NewLine + "Банк получателя " + i.Bank + " № Счета банка " + i.SchetBank + Environment.NewLine, true);
            }

            DB11 db11       = new DB11(kursach.Program.Pole.pole);
            var  Raspisanie = from n in db11.Raspisanie
                              where n.ID == temp
                              select n;

            foreach (var i in Raspisanie)
            {
                temp = i.IDVrach;
            }
            var Vrach = from n in db14.Vrach
                        where n.ID == temp
                        select n;

            foreach (var i in Vrach)
            {
                temp2 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x2 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x2, "Исполнитель: " + temp2 + Environment.NewLine, true);

            foreach (var i in ec2)
            {
                temp = i.IDPacienta;
            }
            var ec3 = from n in db1.Pacient
                      where n.ID == temp
                      select n;

            foreach (var i in ec3)
            {
                temp2 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x3 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x3, "Заказчик: " + temp2 + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);

            //Таблица
            XFrame          frame           = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getCurrentController().getFrame();
            XDispatchHelper xDispatchHelper = (XDispatchHelper)multiServiceFactory.createInstance("com.sun.star.frame.DispatchHelper");

            unoidl.com.sun.star.beans.PropertyValue[] tableArgs = new unoidl.com.sun.star.beans.PropertyValue[4];
            tableArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[1]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[2]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[3]       = new unoidl.com.sun.star.beans.PropertyValue();
            tableArgs[0].Name  = "TableName";
            tableArgs[0].Value = new uno.Any("Акт");
            tableArgs[1].Name  = "Columns";
            tableArgs[1].Value = new uno.Any(4);
            tableArgs[2].Name  = "Rows";
            tableArgs[2].Value = new uno.Any(2);
            tableArgs[3].Name  = "Flags";
            tableArgs[3].Value = new uno.Any(9);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Наименование Услуги");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertTable", "", 0, tableArgs);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs2 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Цена");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs3 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Скидка");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs3);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs4 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any("Итого");
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs4);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec2)
            {
                temp = i.IDUslugi;
            }
            var ec5 = from n in db13.Uslugi
                      where n.ID == temp
                      select n;

            foreach (var i in ec5)
            {
                temp2 = i.Name;
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs5 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs5);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Cena.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs6 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs6);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Skidka.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs7 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs7);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);
            foreach (var i in ec)
            {
                temp2 = i.Itog.ToString();
            }
            unoidl.com.sun.star.beans.PropertyValue[] cellTextArgs8 =
                new unoidl.com.sun.star.beans.PropertyValue[1];
            cellTextArgs[0]       = new unoidl.com.sun.star.beans.PropertyValue();
            cellTextArgs[0].Name  = "Text";
            cellTextArgs[0].Value = new uno.Any(temp2);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs8);

            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);
            xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);

            unoidl.com.sun.star.text.XTextRange x4 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x4, "Всего оказано услуг на сумму: " + temp2 + "рублей " + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine, true);
            string temp3 = "";

            foreach (var i in Vrach)
            {
                temp2 = i.FIO;
            }
            foreach (var i in ec3)
            {
                temp3 = i.FIO;
            }
            unoidl.com.sun.star.text.XTextRange x5 = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().getEnd();  // в конец
            foreach (var i in Firma)
            {
                ((unoidl.com.sun.star.text.XTextDocument)xComponent).getText().insertString(x5, "Исполнитель:__________________ " + temp2 + Environment.NewLine + "Бухгалтер:__________________" + i.Buh, true);
            }
            ((XStorable)xComponent).storeToURL(@"file:///" + push.Replace(@"\", "/"), new unoidl.com.sun.star.beans.PropertyValue[0]);
            xComponent.dispose();
        }
Beispiel #2
0
        public void CozdSchetPdf(string push, int ID)
        {
            try
            {
                DB5          db   = new DB5(kursach.Program.Pole.pole);
                DB16         db2  = new DB16(kursach.Program.Pole.pole);
                DB1          db1  = new DB1(kursach.Program.Pole.pole);
                DB14         db14 = new DB14(kursach.Program.Pole.pole);
                DB13         db13 = new DB13(kursach.Program.Pole.pole);
                Mapping.DB17 db17 = new Mapping.DB17(kursach.Program.Pole.pole);
                var          ec   = from n in db.JurnalRabot
                                    where n.ID == Convert.ToInt32(ID)
                                    select n;
                int temp = 0;
                foreach (var i in ec)
                {
                    temp = i.IDZapisi;
                }
                var ec2 = from n in db2.Zapis
                          where n.ID == temp
                          select n;
                var Firma = from n in db17.Firma
                            where n.ID == 1
                            select n;
                string temp2 = "";
                foreach (var i in ec2)
                {
                    temp2 = i.Data;
                }
                var doc = new Document();
                PdfWriter.GetInstance(doc, new FileStream(push, FileMode.Create));
                doc.Open();
                BaseFont basefont        = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Phrase j = new Phrase("Счет №" + ID, new iTextSharp.text.Font(basefont, 16, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black)));
                Paragraph a1             = new Paragraph(j);
                a1.Add(Environment.NewLine);
                a1.Alignment    = Element.ALIGN_CENTER;
                a1.SpacingAfter = 5;
                doc.Add(a1);
                Paragraph a2 = new Paragraph();
                a2.Add(new Phrase("от " + temp2 + "г.", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                a2.Alignment    = Element.ALIGN_RIGHT;
                a2.SpacingAfter = 5;
                a2.Add(Environment.NewLine);
                a2.Add(Environment.NewLine);
                a2.Add(Environment.NewLine);
                a2.Add(Environment.NewLine);
                doc.Add(a2);
                PdfPTable table2 = new PdfPTable(3);
                table2.WidthPercentage = 100;
                foreach (var i in Firma)
                {
                    PdfPCell cell8 = new PdfPCell(new Phrase("ИНН " + i.INN, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    cell8.BackgroundColor     = new BaseColor(Color.White);
                    cell8.HorizontalAlignment = Element.ALIGN_CENTER;
                    PdfPCell cell9  = new PdfPCell(new Phrase("КПП " + i.KPP, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell10 = new PdfPCell(new Phrase("", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    table2.AddCell(cell8);
                    table2.AddCell(cell9);
                    table2.AddCell(cell10);
                    PdfPCell cell11 = new PdfPCell(new Phrase("Получатель " + i.Name, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell12 = new PdfPCell(new Phrase("Счет №", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell13 = new PdfPCell(new Phrase(i.Schet, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell14 = new PdfPCell(new Phrase("Банк получателя " + i.Bank, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell15 = new PdfPCell(new Phrase("Счет № ", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    PdfPCell cell16 = new PdfPCell(new Phrase(i.SchetBank, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                    table2.AddCell(cell11);
                    table2.AddCell(cell12);
                    table2.AddCell(cell13);
                    table2.AddCell(cell14);
                    table2.AddCell(cell15);
                    table2.AddCell(cell16);
                }

                doc.Add(table2);
                Paragraph a3         = new Paragraph();
                DB11      db11       = new DB11(kursach.Program.Pole.pole);
                var       Raspisanie = from n in db11.Raspisanie
                                       where n.ID == temp
                                       select n;
                foreach (var i in Raspisanie)
                {
                    temp = i.IDVrach;
                }
                var Vrach = from n in db14.Vrach
                            where n.ID == temp
                            select n;
                foreach (var i in Vrach)
                {
                    temp2 = i.FIO;
                }
                a3.Add(new Phrase("Исполнитель: " + temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                a3.Alignment    = Element.ALIGN_LEFT;
                a3.SpacingAfter = 5;
                a3.Add(Environment.NewLine);
                foreach (var i in ec2)
                {
                    temp = i.IDPacienta;
                }
                var ec3 = from n in db1.Pacient
                          where n.ID == temp
                          select n;
                foreach (var i in ec3)
                {
                    temp2 = i.FIO;
                }
                a3.Add(new Phrase("Заказчик: " + temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                a3.Add(Environment.NewLine);
                a3.Add(Environment.NewLine);
                a3.Add(Environment.NewLine);
                a3.Add(Environment.NewLine);
                doc.Add(a3);
                PdfPTable table = new PdfPTable(4);
                table.WidthPercentage = 100;
                PdfPCell cell = new PdfPCell(new Phrase("Наименование услуги", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                cell.BackgroundColor     = new BaseColor(Color.White);
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                PdfPCell cell1 = new PdfPCell(new Phrase("Цена", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                PdfPCell cell2 = new PdfPCell(new Phrase("Скидка", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                PdfPCell cell3 = new PdfPCell(new Phrase("Итого", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.BOLD, new BaseColor(Color.Black))));
                table.AddCell(cell);
                table.AddCell(cell1);
                table.AddCell(cell2);
                table.AddCell(cell3);
                foreach (var i in ec2)
                {
                    temp = i.IDUslugi;
                }
                var ec5 = from n in db13.Uslugi
                          where n.ID == temp
                          select n;
                foreach (var i in ec5)
                {
                    temp2 = i.Name;
                }
                PdfPCell cell4 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                foreach (var i in ec)
                {
                    temp2 = i.Cena.ToString();
                }
                PdfPCell cell5 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                foreach (var i in ec)
                {
                    temp2 = i.Skidka.ToString();
                }
                PdfPCell cell6 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
                foreach (var i in ec)
                {
                    temp2 = i.Itog.ToString();
                }
                PdfPCell cell7 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.BOLD, new BaseColor(Color.Black))));
                table.AddCell(cell4);
                table.AddCell(cell5);
                table.AddCell(cell6);
                table.AddCell(cell7);
                doc.Add(table);
                Paragraph a4 = new Paragraph();
                a4.Add(Environment.NewLine);
                a4.Add(new Phrase("Всего оказано услуг на сумму: " + temp2 + "рублей ", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
                a4.Alignment    = Element.ALIGN_LEFT;
                a4.SpacingAfter = 5;
                a4.Add(Environment.NewLine);
                a4.Add(Environment.NewLine);
                a4.Add(Environment.NewLine);
                a4.Add(Environment.NewLine);
                string temp3 = "";
                foreach (var i in Vrach)
                {
                    temp2 = i.FIO;
                }
                foreach (var i in ec3)
                {
                    temp3 = i.FIO;
                }
                foreach (var i in Firma)
                {
                    a4.Add(new Phrase("Исполнитель:________________________ " + temp2 + Environment.NewLine + Environment.NewLine + "Бухгалтер: ________________________" + i.Buh, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
                }
                a4.Add(Environment.NewLine);
                doc.Add(a4);
                doc.Close();
            }
            catch { }
        }
Beispiel #3
0
 public void CozdAktPdf(string push, int ID)
 {
     try
     {
         DB5  db   = new DB5(kursach.Program.Pole.pole);
         DB16 db2  = new DB16(kursach.Program.Pole.pole);
         DB1  db1  = new DB1(kursach.Program.Pole.pole);
         DB14 db14 = new DB14(kursach.Program.Pole.pole);
         DB13 db13 = new DB13(kursach.Program.Pole.pole);
         var  ec   = from n in db.JurnalRabot
                     where n.ID == Convert.ToInt32(ID)
                     select n;
         int temp = 0;
         foreach (var i in ec)
         {
             temp = i.IDZapisi;
         }
         var ec2 = from n in db2.Zapis
                   where n.ID == temp
                   select n;
         string temp2 = "";
         foreach (var i in ec2)
         {
             temp2 = i.Data;
         }
         var doc = new Document();
         PdfWriter.GetInstance(doc, new FileStream(push, FileMode.Create));
         doc.Open();
         BaseFont basefont        = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
         iTextSharp.text.Phrase j = new Phrase("Акт №" + ID, new iTextSharp.text.Font(basefont, 16, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black)));
         Paragraph a1             = new Paragraph(j);
         a1.Add(Environment.NewLine);
         a1.Add(new Phrase("о приемке оказанных услуг", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         a1.Add(Environment.NewLine);
         a1.Alignment    = Element.ALIGN_CENTER;
         a1.SpacingAfter = 5;
         doc.Add(a1);
         Paragraph a2 = new Paragraph();
         a2.Add(new Phrase("от " + temp2 + "г.", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         a2.Alignment    = Element.ALIGN_RIGHT;
         a2.SpacingAfter = 5;
         a2.Add(Environment.NewLine);
         a2.Add(Environment.NewLine);
         a2.Add(Environment.NewLine);
         a2.Add(Environment.NewLine);
         doc.Add(a2);
         Paragraph a3 = new Paragraph();
         foreach (var i in ec2)
         {
             temp = i.IDRaspisania;
         }
         DB11 db11       = new DB11(kursach.Program.Pole.pole);
         var  Raspisanie = from n in db11.Raspisanie
                           where n.ID == temp
                           select n;
         foreach (var i in Raspisanie)
         {
             temp = i.IDVrach;
         }
         var Vrach = from n in db14.Vrach
                     where n.ID == temp
                     select n;
         foreach (var i in Vrach)
         {
             temp2 = i.FIO;
         }
         a3.Add(new Phrase("Исполнитель: " + temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         a3.Alignment    = Element.ALIGN_LEFT;
         a3.SpacingAfter = 5;
         a3.Add(Environment.NewLine);
         foreach (var i in ec2)
         {
             temp = i.IDPacienta;
         }
         var ec3 = from n in db1.Pacient
                   where n.ID == temp
                   select n;
         foreach (var i in ec3)
         {
             temp2 = i.FIO;
         }
         a3.Add(new Phrase("Заказчик: " + temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         a3.Add(Environment.NewLine);
         a3.Add(Environment.NewLine);
         a3.Add(Environment.NewLine);
         a3.Add(Environment.NewLine);
         doc.Add(a3);
         PdfPTable table = new PdfPTable(4);
         table.WidthPercentage = 100;
         PdfPCell cell = new PdfPCell(new Phrase("Наименование услуги", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         cell.BackgroundColor     = new BaseColor(Color.White);
         cell.HorizontalAlignment = Element.ALIGN_CENTER;
         PdfPCell cell1 = new PdfPCell(new Phrase("Цена", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         PdfPCell cell2 = new PdfPCell(new Phrase("Скидка", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         PdfPCell cell3 = new PdfPCell(new Phrase("Итого", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.BOLD, new BaseColor(Color.Black))));
         table.AddCell(cell);
         table.AddCell(cell1);
         table.AddCell(cell2);
         table.AddCell(cell3);
         foreach (var i in ec2)
         {
             temp = i.IDUslugi;
         }
         var ec5 = from n in db13.Uslugi
                   where n.ID == temp
                   select n;
         foreach (var i in ec5)
         {
             temp2 = i.Name;
         }
         PdfPCell cell4 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         foreach (var i in ec)
         {
             temp2 = i.Cena.ToString();
         }
         PdfPCell cell5 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         foreach (var i in ec)
         {
             temp2 = i.Skidka.ToString();
         }
         PdfPCell cell6 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.NORMAL, new BaseColor(Color.Black))));
         foreach (var i in ec)
         {
             temp2 = i.Itog.ToString();
         }
         PdfPCell cell7 = new PdfPCell(new Phrase(temp2, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.BOLD, new BaseColor(Color.Black))));
         table.AddCell(cell4);
         table.AddCell(cell5);
         table.AddCell(cell6);
         table.AddCell(cell7);
         doc.Add(table);
         Paragraph a4 = new Paragraph();
         a4.Add(Environment.NewLine);
         a4.Add(new Phrase("Всего оказано услуг на сумму: " + temp2 + "рублей ", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
         a4.Alignment    = Element.ALIGN_LEFT;
         a4.SpacingAfter = 5;
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(new Phrase("Вышеперечисленные работы (услуги) выполнены полностью и в срок. Заказчик претензий по объему, качеству и срокам оказания услуг претензий не имеет. ", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         string temp3 = "";
         foreach (var i in Vrach)
         {
             temp2 = i.FIO;
         }
         foreach (var i in ec3)
         {
             temp3 = i.FIO;
         }
         a4.Add(new Phrase("Исполнитель: " + temp2 + "                                          Заказчик: " + temp3, new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
         a4.Add(Environment.NewLine);
         a4.Add(new Phrase("                       ______________                                         _____________", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
         a4.Add(Environment.NewLine);
         a4.Add(Environment.NewLine);
         a4.Add(new Phrase("                                   М.П.                                                                    М.П.", new iTextSharp.text.Font(basefont, 14, iTextSharp.text.Font.ITALIC, new BaseColor(Color.Black))));
         doc.Add(a4);
         doc.Close();
     }
     catch { }
 }