Ejemplo n.º 1
0
        private void PayslipPrint_Click(object sender, EventArgs e)
        {
            var rp = new Reports();

            rp.ExportToPayslipPDF(Payroll.GetApprovedPayrollsList(new [] { Pay.GID }), true);
        }
Ejemplo n.º 2
0
 private void ExportGuardsSummaryBTN_Click(object sender, EventArgs e)
 {
     var r = new Reports();
     //r.ExporttoExcel('g');
 }
Ejemplo n.º 3
0
        public void FormatPDF(char formOrigin)
        {
            //Default PDF Format


            GReportGRD.DataSource = Reports.GetList(formOrigin);

            String strcheck = "";

            if (formOrigin == 'd')
            {
                for (int x = 0; x < GReportGRD.RowCount; x++)
                {
                    if (GReportGRD.Rows[x].Cells[0].Value.ToString() != strcheck)
                    {
                        strcheck = GReportGRD.Rows[x].Cells[0].Value.ToString();
                    }
                    else
                    {
                        GReportGRD.Rows[x].Cells[0].Value = "";
                    }
                }
            }

            //
            var myfont   = FontFactory.GetFont("Arial", 8, BaseColor.BLACK);
            var pdfTable = new PdfPTable(GReportGRD.ColumnCount);

            pdfTable.SetWidths(Reports.GetPDFFormat(formOrigin));
            pdfTable.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            //pdfTable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            pdfTable.DefaultCell.Padding     = 3;
            pdfTable.WidthPercentage         = 30;
            pdfTable.DefaultCell.BorderWidth = 1;
            pdfTable.HorizontalAlignment     = 1;
            pdfTable.TotalWidth  = 1000f;
            pdfTable.LockedWidth = true;
            PdfPTable pdfReportHeader = new PdfPTable(1);

            pdfReportHeader.DefaultCell.Padding     = 3;
            pdfReportHeader.WidthPercentage         = 30;
            pdfReportHeader.DefaultCell.BorderWidth = 0;
            pdfReportHeader.TotalWidth = 1000f;
            pdfReportHeader.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;

            //Add Headers Here
            pdfTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            Reports r = new Reports();

            pdfReportHeader.AddCell(r.getTitlePhrase(formOrigin));

            pdfTable = AddHeaders(pdfTable, formOrigin);
            //Add Data to PDF


            foreach (DataGridViewRow row in GReportGRD.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    var newcell = new PdfPCell(new Phrase(cell.Value.ToString(), myfont))
                    {
                        PaddingTop    = 5f,
                        PaddingBottom = 8f
                    };
                    if (cell.ColumnIndex != 0 && formOrigin == 's')
                    {
                        newcell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        pdfTable.AddCell(newcell);
                    }
                    else if (formOrigin == 'g')
                    {
                        if (!(cell.ColumnIndex == 0 || cell.ColumnIndex == 1))
                        {
                            newcell.HorizontalAlignment = Element.ALIGN_RIGHT;
                            pdfTable.AddCell(newcell);
                        }
                        else
                        {
                            pdfTable.AddCell(newcell);
                        }
                    }
                    else
                    {
                        newcell.HorizontalAlignment = Element.ALIGN_LEFT;
                        pdfTable.AddCell(newcell);
                    }
                }
            }

            r.ExportToPDF(pdfReportHeader, pdfTable, formOrigin);
        }