private void PurchaseHistoryReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "PDF файл|*.pdf";
     SFD.Title    = "Сохранить отчет по продажам";
     SFD.FileName = "Отчет по продажам на " + FormatDate.GetNowDate();
     SavingFile   = "PurchaseHistoryReport";
     SFD.ShowDialog();
 }
 private void CreateBackupToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "XML файл|*.xml";
     SFD.Title    = "Сохранить резервную копию";
     SFD.FileName = "Backup" + FormatDate.GetNowDate();
     SavingFile   = "Backup";
     SFD.ShowDialog();
 }
 private void ShipmentReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SFD.Filter   = "PDF файл|*.pdf";
     SFD.Title    = "Сохранить отчет по товарам";
     SFD.FileName = "Отчет по товарам на " + FormatDate.GetNowDate();
     SavingFile   = "ShipmentReport";
     SFD.ShowDialog();
 }
Exemple #4
0
        public static void CreatePurchaseHistoryReport(string file, List <string> Dates, List <int> Counts, List <int> Costs)
        {
            var       doc    = new Document();
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(file, FileMode.Create));

            string   fg         = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Tahoma.TTF");
            BaseFont fgBaseFont = BaseFont.CreateFont(fg, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            Font     Font       = new Font(fgBaseFont, 12, Font.BOLD, BaseColor.BLACK);
            Font     mainFont   = new Font(fgBaseFont, 10, Font.NORMAL, BaseColor.BLACK);

            doc.Open();

            Paragraph p   = new Paragraph();
            Phrase    phr = new Phrase("Отчет по продажам за " + FormatDate.GetNowDate(), Font);

            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            p           = new Paragraph();
            phr         = new Phrase(" ", Font);
            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            PdfPTable Table = new PdfPTable(6);

            PdfPCell cell = new PdfPCell(new Phrase("№", mainFont));

            cell.BorderWidth = 1;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Дата продаж", mainFont));
            cell.BorderWidth = 1;
            cell.Colspan     = 3;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Суммарное количество купленного товара", mainFont));
            cell.BorderWidth = 1;
            Table.AddCell(cell);

            cell             = new PdfPCell(new Phrase("Сумма всех покупок", mainFont));
            cell.BorderWidth = 1;
            Table.AddCell(cell);

            for (int i = 0; i < Dates.Count; i++)
            {
                cell             = new PdfPCell(new Phrase((i + 1).ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Dates[i], mainFont));
                cell.BorderWidth = 1;
                cell.Colspan     = 3;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Counts[i].ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);

                cell             = new PdfPCell(new Phrase(Costs[i].ToString(), mainFont));
                cell.BorderWidth = 1;
                Table.AddCell(cell);
            }

            doc.Add(Table);

            p           = new Paragraph();
            phr         = new Phrase(" ", Font);
            p.Alignment = 1;
            p.Add(phr);
            doc.Add(p);

            p           = new Paragraph();
            phr         = new Phrase("Подпись   _______________", Font);
            p.Alignment = 2;
            p.Add(phr);
            doc.Add(p);

            doc.Close();
            writer.Close();
        }