Пример #1
0
        static void Main(string[] args)
        {
            int       count = 0;
            Stopwatch watch = new Stopwatch();

            watch.Start();
            try
            {
                CarteManager.Initialize();

                //on récupère le pdf d'entrée

                //par requete base
                //connexion à la base
                //using (SqlConnection connection = new SqlConnection(ServiceCfg.ConnectionString))
                //{
                //    //ouverture
                //    connection.Open();

                //    //commande sql
                //    SqlCommand command = new SqlCommand("ListerPdfLot", connection);
                //    //délai d'attente requête 3 minute max
                //    command.CommandTimeout = 180;
                //    command.CommandType = CommandType.StoredProcedure;


                //    //execution de la commande
                //    using (SqlDataReader reader = command.ExecuteReader())
                //    {
                //        //si un résultat existe
                //        if (reader.HasRows)
                //        {
                //            //lecture de chaque ligne obtenue
                //            while (reader.Read())
                //            {
                //                if (reader["FichierPDF"] != DBNull.Value)
                //                {
                //                    CarteManager.DoCards(reader["FichierPDF"].ToString());
                //                }
                //            }
                //        }
                //    }
                //}


                //par scrutation de répertoire
                if (PdfManager.CheckFolder(ServiceCfg.InputFolderPath, false))
                {
                    var lot = PdfManager.FindPdfFiles(ServiceCfg.InputFolderPath);

                    if (lot.Any())
                    {
                        foreach (var l in lot)
                        {
                            CarteManager.DoCards(l);
                            Console.Write("count{0}", count++);
                        }

                        //Parallel.ForEach(lot, (l) =>
                        //{
                        //    CarteManager.DoCards(l);
                        //    Console.Clear();
                        //    Console.Write("count{0}", count++);
                        //});
                    }
                }
            }
            catch (Exception e)
            {
                ServiceCfg.Log.Error("Execution : ", e);
            }

            Console.Read();

            watch.Stop();
            Console.WriteLine($"temps d'execution : {watch.ElapsedMilliseconds}");
        }
Пример #2
0
        public SemiFinals()
        {
            InitializeComponent();

            pdf = new PdfManager();
        }
Пример #3
0
        public FileResult PrintVacationFormat(int idFormat,
                                              [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                              [FromServices] SARH.Core.Configuration.IConfigurationManager configManager,
                                              [FromServices] IOrganigramaModelFactory organigramaModelFactory,
                                              [FromServices] INomipaqEmployeeVacationModelFactory nomipaqVacationModelFactory)
        {
            IConfigPdf config = new ConfigPdf()
            {
                FontPathPdf     = configManager.FontPathPdf,
                ImgPathPdf      = configManager.ImgPathPdf,
                FontPathBarCode = configManager.FontPathBarCode
            };
            PdfManager manager = new PdfManager(config);

            var    format    = employeeFormatModelFactory.GetformatInfo(idFormat);
            var    formats   = employeeFormatModelFactory.GetAllFormatsByEmployee(format.EmployeeId);
            string path      = System.IO.Path.GetTempPath();
            string empId     = int.Parse(format.EmployeeId).ToString("00000");
            var    vacations = nomipaqVacationModelFactory.GetEmployeeVacations(int.Parse(format.EmployeeId).ToString("00000"));

            Core.PdfCreator.FormatData.FormatVacationData vacationInfo = new Core.PdfCreator.FormatData.FormatVacationData();

            var empInfo = organigramaModelFactory.GetEmployeeData(format.EmployeeId);

            var sustitute = organigramaModelFactory.GetEmployeeData(format.Suplente);

            if (vacations != null)
            {
                var formatDays = (DateTime.Parse(format.EndDate) - DateTime.Parse(format.StartDate)).TotalDays + 1;
                vacationInfo = new Core.PdfCreator.FormatData.FormatVacationData()
                {
                    AñosCumplidos          = vacations.Antiguedad.ToString("00"),
                    DiasGozado             = vacations.DiasTomados.ToString(),
                    DiasPendinteAñoAnteior = vacations.TotalDias.ToString(),
                    DiasPorAño             = vacations.DiasPorAño.ToString(),
                    DiasPorGozar           = vacations.DiasDisponibles.ToString(),
                    FechaIngreso           = empInfo.GeneralInfo.HireDate,
                    PorGozar        = Math.Round((vacations.DiasDisponibles - formatDays), 0).ToString(),
                    DiasSolicitados = formatDays.ToString("00"),
                    FechaInicial    = format.StartDate,
                    FechaFinal      = format.EndDate
                };
            }

            string fileName = $"{path}FormatNumber{idFormat}.pdf";

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            try
            {
                manager.CreateVacationFormat(new Core.PdfCreator.FormatData.DocumentInfoPdfData()
                {
                    TitleDocumento = "SOLICITUD DE VACACIONES",
                    FormatId       = $"Fecha de Solicitud: {format.FechaSolicitud}",
                    Area           = empInfo.Area,
                    JobTitle       = empInfo.GeneralInfo.JobTitle,
                    EmployeeName   = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                    EmployeInfo    = new Core.PdfCreator.FormatData.EmployeeInfoData()
                    {
                        EmployeeId      = empInfo.GeneralInfo.Id,
                        EmployeeName    = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                        Rfc             = empInfo.GeneralInfo.RFC,
                        Curp            = empInfo.GeneralInfo.CURP,
                        NSS             = empInfo.GeneralInfo.NSS,
                        BrithDate       = empInfo.GeneralInfo.FechaNacimiento,
                        HireDate        = empInfo.GeneralInfo.HireDate,
                        FireDate        = "N/A",
                        PhotoPath       = empInfo.GeneralInfo.Picture,
                        PersonalPhone   = empInfo.PersonalInfo.Phone,
                        CellNumber      = empInfo.PersonalInfo.CellPhone,
                        PersonalEmail   = empInfo.PersonalInfo.Email,
                        Address         = empInfo.PersonalInfo.Address,
                        City            = empInfo.PersonalInfo.City,
                        State           = empInfo.PersonalInfo.State,
                        Cp              = empInfo.PersonalInfo.Zip,
                        ContactName     = empInfo.EmergencyData.Name,
                        ContactRelation = empInfo.EmergencyData.Relacion,
                        ContactPhone    = empInfo.EmergencyData.Phone,
                        JobTitle        = empInfo.GeneralInfo.JobTitle
                    },
                    EmployeeSustitute = new Core.PdfCreator.FormatData.FormatEmployeeSustitute()
                    {
                        Name     = $"{sustitute.GeneralInfo.FirstName} {sustitute.GeneralInfo.LastName} {sustitute.GeneralInfo.LastName2}",
                        JobTitle = sustitute.GeneralInfo.JobTitle
                    },
                    FormatVacationData = vacationInfo
                }, fileName);
            }
            catch (Exception ex)
            {
                byte[] FileBytesError = System.Text.Encoding.UTF8.GetBytes(ex.Message);
                return(File(FileBytesError, "text/plain"));
            }


            byte[] FileBytes = System.IO.File.ReadAllBytes(fileName);
            return(File(FileBytes, "application/pdf"));
        }
Пример #4
0
        public FileResult PrintCurrentFormat(int idFormat,
                                             [FromServices] IEmployeeFormatModelFactory employeeFormatModelFactory,
                                             [FromServices] SARH.Core.Configuration.IConfigurationManager configManager,
                                             [FromServices] IOrganigramaModelFactory organigramaModelFactory)
        {
            IConfigPdf config = new ConfigPdf()
            {
                FontPathPdf     = configManager.FontPathPdf,
                ImgPathPdf      = configManager.ImgPathPdf,
                FontPathBarCode = configManager.FontPathBarCode
            };
            PdfManager manager = new PdfManager(config);

            var    format  = employeeFormatModelFactory.GetformatInfo(idFormat);
            var    formats = employeeFormatModelFactory.GetAllFormatsByEmployee(format.EmployeeId);
            string path    = System.IO.Path.GetTempPath();
            string empId   = int.Parse(format.EmployeeId).ToString("00000");

            var empInfo = organigramaModelFactory.GetEmployeeData(format.EmployeeId);

            var sustitute = organigramaModelFactory.GetEmployeeData(format.Suplente);

            string fileName = $"{path}FormatNumber{idFormat}.pdf";

            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            try
            {
                manager.CreatePermissionFormat(new Core.PdfCreator.FormatData.DocumentInfoPdfData()
                {
                    TitleDocumento = "SOLICITUD DE PERMISOS",
                    FormatId       = $"Fecha de Solicitud: {format.FechaSolicitud}",
                    Area           = empInfo.Area,
                    JobTitle       = empInfo.GeneralInfo.JobTitle,
                    EmployeeName   = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                    EmployeInfo    = new Core.PdfCreator.FormatData.EmployeeInfoData()
                    {
                        EmployeeId      = empInfo.GeneralInfo.Id,
                        EmployeeName    = $"{empInfo.GeneralInfo.FirstName} {empInfo.GeneralInfo.LastName} {empInfo.GeneralInfo.LastName2}",
                        Rfc             = empInfo.GeneralInfo.RFC,
                        Curp            = empInfo.GeneralInfo.CURP,
                        NSS             = empInfo.GeneralInfo.NSS,
                        BrithDate       = empInfo.GeneralInfo.FechaNacimiento,
                        HireDate        = empInfo.GeneralInfo.HireDate,
                        FireDate        = "N/A",
                        PhotoPath       = empInfo.GeneralInfo.Picture,
                        PersonalPhone   = empInfo.PersonalInfo.Phone,
                        CellNumber      = empInfo.PersonalInfo.CellPhone,
                        PersonalEmail   = empInfo.PersonalInfo.Email,
                        Address         = empInfo.PersonalInfo.Address,
                        City            = empInfo.PersonalInfo.City,
                        State           = empInfo.PersonalInfo.State,
                        Cp              = empInfo.PersonalInfo.Zip,
                        ContactName     = empInfo.EmergencyData.Name,
                        ContactRelation = empInfo.EmergencyData.Relacion,
                        ContactPhone    = empInfo.EmergencyData.Phone,
                        JobTitle        = empInfo.GeneralInfo.JobTitle
                    },
                    EmployeeSustitute = new Core.PdfCreator.FormatData.FormatEmployeeSustitute()
                    {
                        Name     = $"{sustitute.GeneralInfo.FirstName} {sustitute.GeneralInfo.LastName} {sustitute.GeneralInfo.LastName2}",
                        JobTitle = sustitute.GeneralInfo.JobTitle
                    },
                    FormatPermission = new Core.PdfCreator.FormatData.FormatPermissionData()
                    {
                        Cause            = format.Comments,
                        DateStart        = format.StartDate,
                        DateEnd          = format.EndDate,
                        TimeStart        = format.StartTime,
                        TimeEnd          = format.EndTime,
                        Comments         = format.AdditionalInfo,
                        TotalPermissions = formats.Count()
                    }
                }, fileName);
            }
            catch (Exception ex)
            {
                byte[] FileBytesError = System.Text.Encoding.UTF8.GetBytes(ex.Message);
                return(File(FileBytesError, "text/plain"));
            }


            byte[] FileBytes = System.IO.File.ReadAllBytes(fileName);
            return(File(FileBytes, "application/pdf"));
        }
Пример #5
0
    public static string ExportInvoicesTemplate(Invoices currentInvoice, string addressFillInInvoice,
        string exportDirectory)
    {
        IPdfManager manager = new PdfManager();
        IPdfDocument document = null;
        IPdfPage page = null;

        document = manager.CreateDocument(Missing.Value);
        page = document.Pages.Add(Missing.Value, Missing.Value, Missing.Value);

        ////////////////Draw logo and template///////////////////////////////////
        IPdfImage verticalLine = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/neos-vertical-line.gif"), Missing.Value);
        IPdfParam verticalParam = manager.CreateParam(Missing.Value);
        verticalParam["x"].Value = 5;
        verticalParam["y"].Value = 0;
        verticalParam["ScaleX"].Value = 0.4f;
        //logoParam1["ScaleY"].Value = 0.8f;

        page.Canvas.DrawImage(verticalLine, verticalParam);

        IPdfImage logoImage = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/logo_neos_new.gif"), Missing.Value);
        IPdfParam logoParam = manager.CreateParam(Missing.Value);
        logoParam["x"].Value = 20;
        logoParam["y"].Value = page.Height - 140;
        logoParam["ScaleX"].Value = 0.8f;
        logoParam["ScaleY"].Value = 0.8f;

        page.Canvas.DrawImage(logoImage, logoParam);

        string imageFooterPath = WebConfig.AbsolutePathImageFooterPath;
        if (!File.Exists(imageFooterPath))
        {
            imageFooterPath = HttpContext.Current.Request.MapPath("~/images/logo-neos-footer.gif");
        }
        IPdfImage footerImage = document.OpenImage(imageFooterPath, Missing.Value);
        IPdfParam footerParam = manager.CreateParam(Missing.Value);
        footerParam["x"].Value = 130;
        footerParam["y"].Value = 10;
        footerParam["ScaleX"].Value = 0.55f;
        footerParam["ScaleY"].Value = 0.55f;

        page.Canvas.DrawImage(footerImage, footerParam);

        string fileName = "C:\\Temp\\Invoice-Template.pdf";
        string strFilename = document.Save(fileName, true);
        //document.SaveHttp(fileName, Missing.Value);
        return fileName;
    }
Пример #6
0
    public static string ExportInvoices(Invoices currentInvoice, string addressFillInInvoice,
        string exportDirectory)
    {
        IPdfManager manager = new PdfManager();
        IPdfDocument document = null;
        IPdfPage page = null;
        if (WebConfig.UsedPredefinedInvoicePaperToPrintInvoice.Trim() == "true")
        {

            document = manager.OpenDocument(WebConfig.AbsolutePathPredefinedInvoicePaper, Missing.Value);
            page = document.Pages[1];
        }
        else
        {
            document = manager.CreateDocument(Missing.Value);
            page = document.Pages.Add(Missing.Value, Missing.Value, Missing.Value);

            ////////////////Draw logo and template///////////////////////////////////
            IPdfImage verticalLine = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/neos-vertical-line.gif"), Missing.Value);
            IPdfParam verticalParam = manager.CreateParam(Missing.Value);
            verticalParam["x"].Value = 5;
            verticalParam["y"].Value = 0;
            verticalParam["ScaleX"].Value = 0.4f;
            //logoParam1["ScaleY"].Value = 0.8f;

            page.Canvas.DrawImage(verticalLine, verticalParam);

            IPdfImage logoImage = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/logo_neos_new.gif"), Missing.Value);
            IPdfParam logoParam = manager.CreateParam(Missing.Value);
            logoParam["x"].Value = 20;
            logoParam["y"].Value = page.Height - 140;
            logoParam["ScaleX"].Value = 0.8f;
            logoParam["ScaleY"].Value = 0.8f;

            page.Canvas.DrawImage(logoImage, logoParam);

            string imageFooterPath = WebConfig.AbsolutePathImageFooterPath;
            if (!File.Exists(imageFooterPath))
            {
                imageFooterPath = HttpContext.Current.Request.MapPath("~/images/logo-neos-footer.gif");
            }
            IPdfImage footerImage = document.OpenImage(imageFooterPath, Missing.Value);
            IPdfParam footerParam = manager.CreateParam(Missing.Value);
            footerParam["x"].Value = 130;
            footerParam["y"].Value = 10;
            footerParam["ScaleX"].Value = 0.55f;
            footerParam["ScaleY"].Value = 0.55f;

            page.Canvas.DrawImage(footerImage, footerParam);
        }

        IPdfParam param = manager.CreateParam(Missing.Value);

        //Get invoice details and payments.
        IList<InvoiceDetails> detailList = new InvoiceDetailsRepository().GetInvoiceDetailsOfInvoice(
                                        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear, null);
        CompanyAddress comAddress = new CompanyAddressRepository().FindOne(
            new CompanyAddress(currentInvoice.RefCustomerNumber.Value));

        //-----Do not show payment----------------//
        //IList<InvoicePayments> paymentList =
        //    new InvoicePaymentsRepository().GetInvoicePaymentsOfInvoice(
        //        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear);
        //double paymentTotal = new InvoicePaymentsRepository().GetSumPaymentOfInvoice(
        //        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear);

        //////////////// Draw Invoice title. ////////////////////////////////////
        //int height = 750;
        string title = currentInvoice.IdTypeInvoice == "I" ? ResourceManager.GetString("lblInvoiceInvoice") : ResourceManager.GetString("lblInvoiceCreditNote");
        title = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 12pt; font-weight: bold; color: black"">{0}</FONT>",
            title);
        page.Canvas.DrawText(title, "x=360, y=720, html=true", document.Fonts["Arial", Missing.Value]);

        ///////////////////////Draw Customers .///////////////////////////////////
        string companyName = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 12pt; font-weight: bold; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Name) ? "" : comAddress.Name));
        page.Canvas.DrawText(companyName, "x=320, y=650, html=true", document.Fonts["Arial", Missing.Value]);

        string coName = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Co) ? "" : comAddress.Co));
        page.Canvas.DrawText(coName, "x=320, y=635, html=true", document.Fonts["Arial", Missing.Value]);

        string companyAddr = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Address) ? "" : comAddress.Address));
        page.Canvas.DrawText(companyAddr, "x=320, y=620, html=true", document.Fonts["Arial", Missing.Value]);

        string companyCity = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.ZipCode) ? "" : comAddress.ZipCode) + " " +
            (string.IsNullOrEmpty(comAddress.City) ? "" : comAddress.City));
        page.Canvas.DrawText(companyCity, "x=320, y=605, html=true", document.Fonts["Arial", Missing.Value]);

        string vatNumber = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceVATNumber") + " : "
            + (string.IsNullOrEmpty(comAddress.VatNumber) ? "" : comAddress.VatNumber));
        page.Canvas.DrawText(vatNumber, "x=320, y=575, html=true", document.Fonts["Arial", Missing.Value]);

        string invoiceNumber = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceNumber") + " : " + currentInvoice.IdFactNumber.ToString());
        page.Canvas.DrawText(invoiceNumber, "x=70, y=560, html=true", document.Fonts["Arial", Missing.Value]);

        string invoiceDate = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceDate") + " : "
            + (currentInvoice.Date.HasValue ? currentInvoice.Date.Value.ToString("dd/MM/yyyy") : string.Empty));
        page.Canvas.DrawText(invoiceDate, "x=320, y=560, html=true", document.Fonts["Arial", Missing.Value]);

        ///////////////////Draw details//////////////////////////////////////
        int heightDetail = 15;
        for (int i = 0; i < detailList.Count; i++)
        {
            heightDetail += CountLineOfString(detailList[i].Description, 33) * 13;
        }

        string rowsDetail = ((int)(detailList.Count + 1)).ToString();
        string detailParam = "width=500;height=" + heightDetail + "; Rows=" + rowsDetail
            + "; Cols=4; cellborder=0.1; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
        IPdfTable tableDetail = document.CreateTable(detailParam);
        tableDetail.Font = document.Fonts["Arial", Missing.Value];
        param.Set("alignment=left; size=10;");

        tableDetail.Rows[1].Cells[1].Width = 330;
        tableDetail.Rows[1].Cells[2].Width = 50;
        tableDetail.Rows[1].Cells[3].Width = 50;
        tableDetail.Rows[1].Cells[4].Width = 70;
        //tableDetail.Rows[1].Cells[5].Width = 50;
        //tableDetail.Rows[1].Cells[5].Width = 40;
        //tableDetail.Rows[1].Cells[6].Width = 50;
        //tableDetail.Rows[1].Cells[7].Width = 50;

        //New requirement (20-11-2009) : not show %VAT, VAT amuount and total
        tableDetail.Rows[1].Cells[1].AddText(ResourceManager.GetString("columnInvoiceDetailDescriptionHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[2].AddText(ResourceManager.GetString("columnInvoiceDetailQuantityHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[3].AddText(ResourceManager.GetString("columnInvoiceDetailUnitPriceHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[4].AddText(ResourceManager.GetString("columnInvoiceDetailAmountHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[5].AddText(ResourceManager.GetString("columnInvoiceDetailCodeVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[5].AddText(ResourceManager.GetString("columnInvoiceDetailPercentVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[6].AddText(ResourceManager.GetString("columnInvoiceDetailAmountVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[7].AddText(ResourceManager.GetString("columnInvoiceDetailTotalAmountHeader"), param, Missing.Value);
        IPdfParam paramLeft = manager.CreateParam(Missing.Value);
        paramLeft.Set("alignment=right; size=10;");
        for (int i = 0; i < detailList.Count; i++)
        {
            InvoiceDetails detail = detailList[i];
            tableDetail.Rows[i + 2].Cells[1].Height = CountLineOfString(detail.Description, 33) * 13;
            tableDetail.Rows[i + 2].Cells[1].AddText(string.IsNullOrEmpty(detail.Description) ? "" : detail.Description, param, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[2].AddText(Get2DigitStringOfDouble(detail.Quantity), paramLeft, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[3].AddText(Get2DigitStringOfDouble(detail.UnitPriceEuro), paramLeft, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[4].AddText(Get2DigitStringOfDouble(detail.AmountEuro), paramLeft, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[5].AddText(detail.VatCode.HasValue ? detail.VatCode.Value.ToString() : "", param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[5].AddText(detail.VatRate.HasValue ? detail.VatRate.Value.ToString() : "", param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[6].AddText(Get2DigitStringOfDouble(detail.AmountVAT), param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[7].AddText(Get2DigitStringOfDouble(detail.TotalAmountVAT), param, document.Fonts["Arial", Missing.Value]);
        }
        page.Canvas.DrawTable(tableDetail, "x=70, y=530");

        //////////////////Draw total of details/////////////////////////////////////////////////
        //string totalHVTA = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
        //    ResourceManager.GetString("lblInvoiceTotalHTVA") + " : "
        //    + (currentInvoice.TotalHtvaEuro.HasValue ? currentInvoice.TotalHtvaEuro.Value.ToString() : "0"));
        //page.Canvas.DrawText(invoiceNumber, "x=70, y=575, html=true", document.Fonts["Arial", Missing.Value]);

        IPdfTable tableTotal = document.CreateTable("width=165;height=50; Rows=3; Cols=2; cellborder=0;  cellspacing=0; cellpadding=0");
        tableTotal.Font = document.Fonts["Arial", Missing.Value];
        param.Set("alignment=left; size=10;");
        tableTotal.Rows[1].Cells[1].Width = 85;
        tableTotal.Rows[1].Cells[2].Width = 80;

        tableTotal.Rows[1].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotalHTVA"), param, Missing.Value);
        tableTotal.Rows[1].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.TotalHtvaEuro)), param, Missing.Value);

        tableTotal.Rows[2].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotalVAT"), param, Missing.Value);
        tableTotal.Rows[2].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.AmountVatEuro)), param, Missing.Value);

        tableTotal.Rows[3].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotal"), param, Missing.Value);
        tableTotal.Rows[3].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.TotalAmountIncludeVatEuro)), param, Missing.Value);

        int totalY = 530 - heightDetail - 20;
        if (!string.IsNullOrEmpty(comAddress.FactoringCode))
        {
            page.Canvas.DrawTable(tableTotal, "x=400, y=200");
        }
        else
        {
            page.Canvas.DrawTable(tableTotal, "x=400, y=145");
        }

        ///////////////Draw factoring code////////////////////////////////////
        if (!string.IsNullOrEmpty(currentInvoice.Remark))
        {
            int remarkHeight = CountLineOfString(currentInvoice.Remark, 33) * 13;
            string remarkParam = "width=300;height=" + remarkHeight + "; Rows=1; Cols=1; cellborder=0.0; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
            IPdfTable tableRemark = document.CreateTable(remarkParam);
            tableRemark.Font = document.Fonts["Arial", Missing.Value];
            param.Set("alignment=left; size=10;");

            tableRemark.Rows[1].Cells[1].AddText(currentInvoice.Remark, param, Missing.Value);

            page.Canvas.DrawTable(tableRemark, "x=70, y=220");
        }

        ///////////////Draw factoring code////////////////////////////////////
        if (!string.IsNullOrEmpty(comAddress.FactoringCode))
        {
            //string factParam = "width=500;height=40; Rows=2; Cols=1; cellborder=0.0; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
            //IPdfTable tableFact = document.CreateTable(factParam);
            //tableFact.Font = document.Fonts["Arial", Missing.Value];
            //param.Set("alignment=left; size=10;");
            string factoringCode1 = ResourceManager.GetString("MessagePrintFactoringCode1");
            string factoringCode2 = ResourceManager.GetString("MessagePrintFactoringCode2");
            factoringCode1 = string.Format(factoringCode1, comAddress.FactoringCode,
                currentInvoice.IdFactNumber, currentInvoice.IdYear.ToString().Substring(2, 2));
            //string factoringCode = ResourceManager.GetString("lblFactoringCode") + " : " + comAddress.FactoringCode.HasValue.ToString()
            //    + currentInvoice.IdFactNumber.ToString();
            //if (currentInvoice.Date.HasValue)
            //{
            //    factoringCode += currentInvoice.Date.Value.Year.ToString().Substring(2);
            //}
            //tableFact.Rows[1].Cells[1].Width = 470;
            //tableFact.Rows[1].Cells[1].AddText(factoringCode1, param, Missing.Value);
            //tableFact.Rows[2].Cells[1].AddText(factoringCode2, param, Missing.Value);
            //totalY = totalY - 100;
            //page.Canvas.DrawTable(tableFact, "x=70, y=140");

            factoringCode1 = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-style: Italic; font-weight: Normal; color: black"">{0}</FONT>",
                                                factoringCode1);
            page.Canvas.DrawText(factoringCode1, "x=70, y=120, html=true", document.Fonts["Arial", Missing.Value]);
            factoringCode2 = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-style: Italic; font-weight: Normal; color: black"">{0}</FONT>",
                                                factoringCode2);
            page.Canvas.DrawText(factoringCode2, "x=70, y=105, html=true", document.Fonts["Arial", Missing.Value]);
        }

        /*
        ////////////////////////////////Draw payments /////////////////////////////////
        totalY = totalY - 25;
        page.Canvas.DrawText(ResourceManager.GetString("tabInvoicePayment"), "x=70, y=" + totalY.ToString() + ", size=15;", document.Fonts["Helvetica", Missing.Value]);

        string heightPayment = ((int)(paymentList.Count * 12 + 20)).ToString();
        string rowsPayment = ((int)(paymentList.Count + 1)).ToString();
        string paymentParam = "width=500;height=" + heightPayment + "; Rows=" + rowsPayment
            + "; Cols=3; cellborder=0.1; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
        IPdfTable tablePayment = document.CreateTable(paymentParam);
        tablePayment.Font = document.Fonts["Helvetica", Missing.Value];
        param.Set("alignment=left; size=10;");

        tablePayment.Rows[1].Cells[1].Width = 300;
        tablePayment.Rows[1].Cells[2].Width = 110;
        tablePayment.Rows[1].Cells[3].Width = 60;

        tablePayment.Rows[1].Cells[1].AddText(ResourceManager.GetString("columnInvoicePaymentRemarkHeader"), param, Missing.Value);
        tablePayment.Rows[1].Cells[2].AddText(ResourceManager.GetString("columnInvoicePaymentDateHeader"), param, Missing.Value);
        tablePayment.Rows[1].Cells[3].AddText(ResourceManager.GetString("columnInvoicePaymentAmountHeader"), param, Missing.Value);

        for (int i = 0; i < paymentList.Count; i++)
        {
            InvoicePayments payment = paymentList[i];
            tablePayment.Rows[i + 2].Cells[1].AddText(string.IsNullOrEmpty(payment.Remark) ? "" : payment.Remark, param, document.Fonts["Arial", Missing.Value]);
            tablePayment.Rows[i + 2].Cells[2].AddText(
                payment.DatePayment.HasValue ? payment.DatePayment.Value.ToString("dd/MM/yyyy") : "",
                param, document.Fonts["Courier", Missing.Value]);
            tablePayment.Rows[i + 2].Cells[3].AddText(
                payment.Amount.HasValue ? payment.Amount.Value.ToString() : "0",
                param, document.Fonts["Courier", Missing.Value]);
        }
        totalY = totalY - 20;
        page.Canvas.DrawTable(tablePayment, "x=70, y=" + totalY.ToString());

        totalY = totalY - int.Parse(heightPayment) - 5;

        ////////////////////Draw total of payment///////////////////////////////////////////
        page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoicePaymentAmount"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        page.Canvas.DrawText(paymentTotal.ToString(), "x=480, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);

        totalY = totalY - 15;
        double remain = 0;
        if (currentInvoice.TotalAmountIncludeVatEuro.HasValue)
        {
            remain = currentInvoice.TotalAmountIncludeVatEuro.Value - paymentTotal;
        }
        else
        {
            remain = -paymentTotal;
        }
        page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoiceRemainAmount"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        page.Canvas.DrawText(remain.ToString(), "x=480, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);

        totalY = totalY - 15;
        if (currentInvoice.Payement.HasValue && currentInvoice.Payement.Value && currentInvoice.DateOfPayement.HasValue)
        {
            page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoicePaid"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
            page.Canvas.DrawText(currentInvoice.DateOfPayement.Value.ToString("dd/MM/yyyy"), "x=370, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        }
        else
        {
            page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoiceUnpaid"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        }
        */

        /////// Save document, the Save method returns generated file name///////////////
        string fileName = exportDirectory + "\\";
        //string fileName = string.Empty;
        if (currentInvoice.IdTypeInvoice == "I")
            fileName += "Invoice";
        else
            fileName += "Credit Note";
        fileName += "-" + currentInvoice.IdFactNumber.ToString() + currentInvoice.IdTypeInvoice + currentInvoice.IdYear;
        fileName += "-" + DateTime.Today.Year;
        if (DateTime.Today.Month < 10)
        {
            fileName += "0";
        }
        fileName += DateTime.Today.Month;
        if (DateTime.Today.Day < 10)
        {
            fileName += "0";
        }
        fileName += DateTime.Today.Day + ".pdf";
        //fileName = "attachment;filename=" + fileName;
        string strFilename = document.Save(fileName, true);
        //document.SaveHttp(fileName, Missing.Value);
        return fileName;
    }
Пример #7
0
        public Finals16()
        {
            InitializeComponent();

            pdf = new PdfManager();
        }