public UserControlFacturation() { InitializeComponent(); Dictionary <String, String> dicoAR = curseur.chercher("FACTURE"); tBD1.Text = dicoAR["Dimension1"]; tBD2.Text = dicoAR["Dimension2"]; tBD3.Text = dicoAR["Dimension3"]; tBD4.Text = dicoAR["Dimension4"]; tBD5.Text = dicoAR["Dimension5"]; tBD6.Text = dicoAR["Dimension6"]; tBD7.Text = dicoAR["Dimension7"]; tBD8.Text = dicoAR["Dimension8"]; textBox1.Text = ConfigurationManager.AppSettings["CheminPatternFondPageFacturation"]; textBox2.Text = ConfigurationManager.AppSettings["CheminPatternEnteteTableauFacture"]; }
public UserControlBP() { InitializeComponent(); Dictionary <String, String> dicoBP = curseur.chercher("BP"); tBD1.Text = dicoBP["Dimension1"]; tBD2.Text = dicoBP["Dimension2"]; tBD3.Text = dicoBP["Dimension3"]; tBD4.Text = dicoBP["Dimension4"]; tBD5.Text = dicoBP["Dimension5"]; textBox1.Text = ConfigurationManager.AppSettings["CheminLogoABCR"]; textBox2.Text = ConfigurationManager.AppSettings["CheminPatternHautDroiteBp"]; textBox3.Text = ConfigurationManager.AppSettings["CheminPatternTableau"]; textBox4.Text = ConfigurationManager.AppSettings["CheminFilligraneBp"]; textBox5.Text = ConfigurationManager.AppSettings["CheminPatternTot"]; }
public UserControlCF() { InitializeComponent(); Dictionary <String, String> dicoCF = curseur.chercher("CF"); tBD1.Text = dicoCF["Dimension1"]; tBD2.Text = dicoCF["Dimension2"]; tBD3.Text = dicoCF["Dimension3"]; tBD4.Text = dicoCF["Dimension4"]; tBD5.Text = dicoCF["Dimension5"]; tBD6.Text = dicoCF["Dimension6"]; tBD7.Text = dicoCF["Dimension7"]; tBD8.Text = dicoCF["Dimension8"]; textBox1.Text = ConfigurationManager.AppSettings["CheminLogoABCR"]; textBox2.Text = ConfigurationManager.AppSettings["CheminPatternHautDroiteBp"]; textBox3.Text = ConfigurationManager.AppSettings["CheminPatternTableau"]; textBox4.Text = ConfigurationManager.AppSettings["CheminFilligraneCf"]; textBox5.Text = ConfigurationManager.AppSettings["CheminPatternTotBl"]; textBox6.Text = ConfigurationManager.AppSettings["TexteBasCartouche"]; }
public UserControlDevis() { InitializeComponent(); Dictionary <String, String> dicodevis = curseur.chercher("Devis"); tBD1.Text = dicodevis["Dimension1"]; tBD2.Text = dicodevis["Dimension2"]; tBD3.Text = dicodevis["Dimension3"]; tBD4.Text = dicodevis["Dimension4"]; tBD5.Text = dicodevis["Dimension5"]; tBD6.Text = dicodevis["Dimension6"]; tBD7.Text = dicodevis["Dimension7"]; tBD8.Text = dicodevis["Dimension8"]; tBD9.Text = dicodevis["Dimension9"]; textBox1.Text = ConfigurationManager.AppSettings["CheminLogoABCR"]; textBox2.Text = ConfigurationManager.AppSettings["CheminPatternHautDroiteDevis"]; textBox3.Text = ConfigurationManager.AppSettings["CheminPatternTableau"]; textBox4.Text = ConfigurationManager.AppSettings["CheminFilligraneDevis"]; textBox5.Text = ConfigurationManager.AppSettings["CheminPatternTot"]; }
public void miseEnForm(string typeDoc) { int incCopie = 0; int nbCopie = int.Parse(donneEntete["Nombre_copies"]); string cheminDocFinaux = ConfigurationManager.AppSettings["CheminDocFinaux"].ToString(); string cheminRessources = ConfigurationManager.AppSettings["CheminRessources"].ToString(); while (incCopie < nbCopie) { bool drapReliquat = false; string chemin = cheminDocFinaux + "\\DocFinaux\\BP\\BP_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; Document nouveauDocument = new Document(PageSize.A4, 20, 20, 12, 20); PdfWriter.GetInstance(nouveauDocument, new FileStream(chemin, FileMode.Create)); //Stockage du document //---------------------------------------- //Constitution document PDF //---------------------------------------- nouveauDocument.Open(); PdfPTable tableau = new PdfPTable(2); tableau.TotalWidth = 550; tableau.LockedWidth = true; //-----------------Ajout Pattern/Image-------------------------------------------------------- Image image2 = Image.GetInstance(ConfigurationManager.AppSettings["CheminPatternHautDroiteBp"]); image2.Alignment = Image.UNDERLYING; image2.SetAbsolutePosition(325, 755); nouveauDocument.Add(image2); Image image5 = Image.GetInstance(ConfigurationManager.AppSettings["CheminFilligraneBp"]); image5.Alignment = Image.UNDERLYING; image5.SetAbsolutePosition(180, 270); nouveauDocument.Add(image5); //------------------------------------------------------------------------------------------------------ Paragraph pLogo = new Paragraph(); Image image = Image.GetInstance(ConfigurationManager.AppSettings["CheminLogoABCR"]); pLogo.Add(image); //Encadré photo PdfPCell celulleHauteGauche = new PdfPCell(image); celulleHauteGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celulleHauteGauche); //Celulle de droite contenant l'adresse de livraison Paragraph pAdl = new Paragraph(); pAdl.Add(new Phrase("Adresse de livraison\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); if (donneEntete["Bon_typvte"] == "EMPORTEE") { pAdl.Add(new Phrase("EMPORTEE\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); /*pAdl.Add(new Phrase(donneEntete["Tiers_adl3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); * pAdl.Add(new Phrase(donneEntete["Tiers_adl4"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); * pAdl.Add(new Phrase(donneEntete["Tiers_adl5"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); * pAdl.Add(new Phrase(donneEntete["Tiers_adlcp"] + " " + donneEntete["Tiers_adl6"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD)));*/ } else { if (donneEntete["Tiers_adl1"] == "") { pAdl.Add(new Phrase(donneEntete["Tiers_adf1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adf2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adf3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adf4"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); //pAdl.Add(new Phrase(donneEntete["Tiers_adf6"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adfcp"] + " " + donneEntete["Tiers_adl6"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); } else { pAdl.Add(new Phrase(donneEntete["Tiers_adl1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adl2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adl3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adl4"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); //pAdl.Add(new Phrase(donneEntete["Tiers_adl5"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(donneEntete["Tiers_adlcp"] + " " + donneEntete["Tiers_adl6"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); } } PdfPCell celulleFinDroite = new PdfPCell(pAdl); celulleFinDroite.Rowspan = 2; celulleFinDroite.Border = PdfPCell.NO_BORDER; celulleFinDroite.PaddingLeft = 35; tableau.AddCell(celulleFinDroite); //Adresse ABCR string tel = donneEntete["Adresse_interne_7"]; string fax = donneEntete["Adresse_interne_8"]; tel = tel.Substring(3, 15); fax = fax.Substring(3, 15); Paragraph p = new Paragraph(); p.Add(new Phrase(donneEntete["Adresse_interne_2"] + " Tél " + tel + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_3"] + " Fax " + fax + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celulleMilieuGauche = new PdfPCell(p); celulleMilieuGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celulleMilieuGauche); //Tableau dans celulle bas gauche du tableau d'entete PdfPTable tabCell = new PdfPTable(3); tabCell.TotalWidth = 230; tabCell.LockedWidth = true; tabCell.AddCell(new Phrase("Client", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase("Date", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase("N° CDE", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase(donneEntete["Client_code"], FontFactory.GetFont(FontFactory.HELVETICA, 9))); tabCell.AddCell(new Phrase(donneEntete["Document_date"], FontFactory.GetFont(FontFactory.HELVETICA, 9))); tabCell.AddCell(new Phrase(donneEntete["Document_numero"], FontFactory.GetFont(FontFactory.HELVETICA, 9))); tabCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; PdfPCell celulleBasGauche = new PdfPCell(tabCell); celulleBasGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celulleBasGauche); //Adresse de facturation Paragraph pAdf = new Paragraph(); pAdf.Add(new Phrase("Adresse de facturation\n" + donneEntete["Tiers_adf1"], FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celulleHauteDroite = new PdfPCell(pAdf); celulleHauteDroite.Border = PdfPCell.NO_BORDER; celulleHauteDroite.HorizontalAlignment = Element.ALIGN_LEFT; celulleHauteDroite.PaddingLeft = 35; tableau.AddCell(celulleHauteDroite); nouveauDocument.Add(tableau); //Récap ref client et numéro de téléphone Paragraph refCli = new Paragraph(); refCli.Add(new Phrase("Référence client " + donneeBody["Bon_rcl1"] + " du " + donneeBody["Bon_datrcl1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); nouveauDocument.Add(refCli); //Recap dessus tableau //Condition de fonctionnement si dictionnaire contient clé commentaire ou non Chunk c; if (donneEntete.ContainsKey("Commentaire_texteentete")) { c = new Chunk("Vous avez été servi par : " + donneEntete["Bon_vendeur_lib"] + " Livrée le " + donneeBody["Bon_datliv1"] + " " + donneEntete["Commentaire_texteentete"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.ITALIC)); nouveauDocument.Add(c); Phrase pPage1; if (donneEntete.ContainsKey("Commentaire_texteentete0")) { pPage1 = new Phrase(donneEntete["Commentaire_texteentete0"] + " Page n° 1\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); } else { pPage1 = new Phrase(" " + donneEntete["Document_type"] + " " + donneEntete["Duplicata"] + " Page n° 1 \n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); } nouveauDocument.Add(pPage1); } else { c = new Chunk("Vous avez été servi par : " + donneEntete["Bon_vendeur_lib"] + " Livrée le " + donneeBody["Bon_datliv1"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.ITALIC)); nouveauDocument.Add(c); Phrase pPage1; pPage1 = new Phrase(" " + donneEntete["Document_type"] + " " + donneEntete["Duplicata"] + " Page n° 1 \n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); nouveauDocument.Add(pPage1); } //-------------------------------------------------------------------------------------------------------- // TABLEAU //--------------------------------------------------------------------------------------------------------- CurseurTemplate ct = new CurseurTemplate(); valeurTemplate = ct.chercher("BP"); float[] largeurs = { int.Parse(valeurTemplate["Dimension1"]), int.Parse(valeurTemplate["Dimension2"]), int.Parse(valeurTemplate["Dimension3"]), int.Parse(valeurTemplate["Dimension4"]), int.Parse(valeurTemplate["Dimension5"]) }; PdfPTable table = new PdfPTable(largeurs); table.TotalWidth = 555; //Chaque colonne crée ci dessus doit être rempli table.LockedWidth = true; PdfPCell cellET1 = new PdfPCell(new Phrase("Article", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET1.Border = PdfPCell.NO_BORDER; //cellET1.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET1); PdfPCell cellET2 = new PdfPCell(new Phrase("Désignation", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET2.Border = PdfPCell.NO_BORDER; //cellET2.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET2); PdfPCell cellET3 = new PdfPCell(new Phrase("UV", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET3.Border = PdfPCell.NO_BORDER; //cellET3.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET3); PdfPCell cellET4 = new PdfPCell(new Phrase("Quantité", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET4.Border = PdfPCell.NO_BORDER; //cellET4.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET4); PdfPCell cellET5 = new PdfPCell(new Phrase("Localisation", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET5.Border = PdfPCell.NO_BORDER; //cellET5.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET5); PdfPCell cellvideDebut = new PdfPCell(new Phrase(" ", FontFactory.GetFont(FontFactory.HELVETICA, 6, Font.BOLD))); cellvideDebut.Colspan = 5; cellvideDebut.Border = PdfPCell.NO_BORDER; table.AddCell(cellvideDebut); Image image3 = Image.GetInstance(ConfigurationManager.AppSettings["CheminPatternTableau"]); image3.Alignment = Image.UNDERLYING; image3.SetAbsolutePosition(20, 597); nouveauDocument.Add(image3); List <string> locPrecedent = new List <string>(); //Liste qui récupère les anciennes clés de localisation afin de ne pas les réintégrer au doc int i; int nbLigne = 0; float resultat = 0; float dimTab = 0; int décrement = 0; int numPage = 0; //Constitution du tableau d'article bool okDési = false; bool okStart = false; for (i = 1; i <= iBody; i++) { //Condition ARTICLE---------------------------------------------------------------------------------------------------------------------- if (donneeBody["Ligne_type" + i] == "ART") { nbLigne++; string sPattern = "libelle" + i + "bis"; PdfPCell cell1 = new PdfPCell(new Phrase(donneeBody["Art_code" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell1.Border = PdfPCell.NO_BORDER; cell1.Border += PdfPCell.RIGHT_BORDER; cell1.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell1); Paragraph pCell2 = new Paragraph(); PdfPCell cell2 = new PdfPCell(pCell2); cell2.Border = PdfPCell.NO_BORDER; cell2.Border += PdfPCell.RIGHT_BORDER; cell2.Border += PdfPCell.LEFT_BORDER; foreach (KeyValuePair <string, string> entry in donneeBody) { if (System.Text.RegularExpressions.Regex.IsMatch(entry.Key, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { if (System.Text.RegularExpressions.Regex.IsMatch(entry.Value, "Localisations secondaires", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { } //Empeche de faire apparaitre la localisation secondaire dans la désignation else { if (okStart == false) { pCell2.Add(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); string clé = entry.Key; if (donneeBody.ContainsKey("Art_lot" + i)) { pCell2.Add(new Phrase("Numéro de lot : " + donneeBody["Art_lot" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); } pCell2.Add(new Phrase(donneeBody[clé] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7.5F, Font.BOLDITALIC))); okStart = true; } else { string clé = entry.Key; pCell2.Add(new Phrase(donneeBody[clé] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7.5F, Font.BOLDITALIC))); } okDési = true; } } } if (okDési == false) { PdfPCell cell3 = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell3.Border = PdfPCell.NO_BORDER; cell3.Border += PdfPCell.RIGHT_BORDER; cell3.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell3); } else { table.AddCell(cell2); } PdfPCell cell4 = new PdfPCell(new Phrase(donneeBody["Art_unite" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell4.Border = PdfPCell.NO_BORDER; cell4.Border += PdfPCell.RIGHT_BORDER; cell4.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell4); PdfPCell cell5 = new PdfPCell(new Phrase(donneeBody["Art_qte" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell5.Border = PdfPCell.NO_BORDER; cell5.Border += PdfPCell.RIGHT_BORDER; cell5.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell5); bool drapLoc = false; string reliquat = ""; foreach (KeyValuePair <string, string> entry in donneeBody) { //string patternReliquat = "Art_reliquat"; if (donneeBody.ContainsKey("Art_reliquat" + i)) { reliquat = "Reliquat"; drapReliquat = true; } //Condition si l'article à une loca secondaire if (drapLoc == false && locPrecedent.Contains(entry.Key) == false && System.Text.RegularExpressions.Regex.IsMatch(entry.Value, "Localisations secondaires", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { string rackSub = donneeBody[entry.Key]; rackSub = rackSub.Substring(27, 2); string etagereSub = donneeBody[entry.Key]; etagereSub = etagereSub.Substring(29, 2); PdfPCell cell6 = new PdfPCell(new Phrase("Zone : " + donneeBody["Art_localisation" + i] + " Rack : " + rackSub + " Etagère : " + etagereSub + " /n" + reliquat, FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell6); okStart = true; drapLoc = true; reliquat = ""; locPrecedent.Add(entry.Key); } //Si il n'en a pas, afficher uniquement la zone if (drapLoc == false && locPrecedent.Contains(entry.Key) == false && donneeBody["Art_type_cde" + i] != "S" && donneeBody["Art_type_cde" + i] != "D") { PdfPCell cell6 = new PdfPCell(new Phrase("Zone : " + donneeBody["Art_localisation" + i] + " " + reliquat, FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell6); okStart = true; drapLoc = true; reliquat = ""; locPrecedent.Add(entry.Key); } //Condition si article est spécial, pas de localisation if (drapLoc == false && locPrecedent.Contains(entry.Key) == false && donneeBody["Art_type_cde" + i] == "S") { PdfPCell cell6 = new PdfPCell(new Phrase("Spécial" + " " + reliquat, FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell6); okStart = true; drapLoc = true; reliquat = ""; locPrecedent.Add(entry.Key); } //Condition si article est direct, pas de localisation if (drapLoc == false && locPrecedent.Contains(entry.Key) == false && donneeBody["Art_type_cde" + i] == "D") { PdfPCell cell6 = new PdfPCell(new Phrase("Direct" + " " + reliquat, FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell6); okStart = true; drapLoc = true; reliquat = ""; locPrecedent.Add(entry.Key); } } if (drapLoc == false) { PdfPCell cell7 = new PdfPCell(new Phrase(" ", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell7.Border = PdfPCell.NO_BORDER; cell7.Border += PdfPCell.LEFT_BORDER; cell7.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell7); } okDési = false; okStart = false; drapLoc = false; } //Condition COMMENTAIRE-------------------------------------------------------------------------------------------------------------------------------- if (donneeBody["Ligne_type" + i] == "COM") { nbLigne++; PdfPCell cellVide = new PdfPCell(new Phrase("" + "\n")); PdfPCell cell = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); PdfPCell cellFin = new PdfPCell(); cellVide.Border = PdfPCell.NO_BORDER; cellVide.Border += PdfPCell.RIGHT_BORDER; cellVide.Border += PdfPCell.LEFT_BORDER; cell.Border = PdfPCell.NO_BORDER; cell.Border += PdfPCell.RIGHT_BORDER; cell.Border += PdfPCell.LEFT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.LEFT_BORDER; cellFin.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cellVide); table.AddCell(cell); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellFin); } // PdfPCell cellEcartDroite = new PdfPCell(new Phrase(" " + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 2, Font.BOLD))); PdfPCell cellEcart = new PdfPCell(new Phrase(" " + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 2, Font.BOLD))); cellEcart.Border = PdfPCell.NO_BORDER; cellEcart.Border += PdfPCell.LEFT_BORDER; cellEcart.Border += PdfPCell.RIGHT_BORDER; cellEcartDroite.Border = PdfPCell.NO_BORDER; cellEcartDroite.Border += PdfPCell.RIGHT_BORDER; cellEcartDroite.Border += PdfPCell.LEFT_BORDER; table.AddCell(cellEcartDroite); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); //--------------------------------------------GESTION DU SAUT DE PAGE------------------------------------------------------------------------------------------- float temp = table.TotalHeight; dimTab = temp; if (dimTab >= 410 && i < iBody) { //Saut de page numPage++; PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheD = new PdfPCell(new Phrase(" ")); cellFin.Colspan = 5; cellBlanche.FixedHeight = (450 - dimTab); cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheD.FixedHeight = (450 - dimTab); cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheD); table.AddCell(cellFin); nouveauDocument.Add(table);//----------------------------------------------------------------------------Repère ligne en dessous-------------------------------------------------- Phrase pReport = new Phrase(" A REPORTER\n\n\n\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); Phrase pPage; if (donneEntete.ContainsKey("Commentaire_texteentete0")) { pPage = new Phrase(donneEntete["Commentaire_texteentete0"] + " Page n° " + (numPage + 1) + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); } else { pPage = new Phrase(" Page n° " + (numPage + 1) + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); } nouveauDocument.Add(pReport); table.DeleteBodyRows(); nouveauDocument.Add(Chunk.NEXTPAGE); nouveauDocument.Add(tableau); //nouveauDocument.Add(p); nouveauDocument.Add(refCli); nouveauDocument.Add(c); nouveauDocument.Add(pPage); nouveauDocument.Add(image2); nouveauDocument.Add(image3); nouveauDocument.Add(image5); table.AddCell(cellET1); table.AddCell(cellET2); table.AddCell(cellET3); table.AddCell(cellET4); table.AddCell(cellET5); table.AddCell(cellvideDebut); dimTab = 0; décrement = (i - 1); } } //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------- if (i > iBody) { PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheD = new PdfPCell(new Phrase(" ")); cellFin.Colspan = 5; resultat = 450 - dimTab; //<<----------450 correspond au nombre de point de la longueur du tableau, c'est la valeur à modifier pour modifier la taille du tableau cellBlanche.FixedHeight = resultat; cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheD.FixedHeight = resultat; cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheD); table.AddCell(cellFin); } nouveauDocument.Add(table); //----------------------------------------Gestion des commentaires de bon------------------------------------- if (donneEntete.ContainsKey("Commentaire_texte")) { Paragraph pComBon = new Paragraph(new Phrase(" " + donneEntete["Commentaire_texte"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); nouveauDocument.Add(pComBon); } nouveauDocument.Close(); incCopie++; //Copie Doc dans GED try { String connectionString = ConfigurationManager.AppSettings["ChaineDeConnexionBase"]; OdbcConnection conn = new OdbcConnection(connectionString); conn.Open(); string requete = "select T1.NOCLI c1 , T1.NOMCL c2 from B00C0ACR.AMAGESTCOM.ACLIENL1 T1 where T1.NOCLI = '" + donneEntete["Client_code"] + "'"; OdbcCommand act = new OdbcCommand(requete, conn); OdbcDataReader act0 = act.ExecuteReader(); string nomADH = ""; while (act0.Read()) { nomADH = (act0.GetString(1)); } conn.Close(); if (!System.IO.Directory.Exists(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM") + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\BP\\")) { System.IO.Directory.CreateDirectory(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\BP\\"); System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\BP\\" + "\\BP_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } else { System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\BP\\" + "\\BP_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } } catch (Exception e) { LogHelper.WriteToFile(e.Message, "ENVOI GED BP"); } //--------------------------------------------------------FIN COPIE------------------------------------------------------ #region ImpressionOld /*myPrinters.SetDefaultPrinter("Imp204"); * Process proc = new Process(); * proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; * proc.StartInfo.Verb = "print"; * * //Define location of adobe reader/command line * //switches to launch adobe in "print" mode * proc.StartInfo.FileName = * @"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"; * proc.StartInfo.Arguments = String.Format(@"/p /h {0}", chemin); * proc.StartInfo.UseShellExecute = false; * proc.StartInfo.CreateNoWindow = true; * * proc.Start(); * proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; * if (proc.HasExited == false) * { * proc.WaitForExit(10000); * } * * proc.EnableRaisingEvents = true; * * proc.Close(); * foreach (Process clsProcess in Process.GetProcesses().Where( * clsProcess => clsProcess.ProcessName.StartsWith("AcroRd32"))) * { * clsProcess.Kill(); * }*/ #endregion //Solution d'impression fonctionnel, API payante---------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------- //----------------Expérimentation, ATTENTION FRAMEWORK EN 4.5--------------------------- int nbImp = 0; int nbImpOK = 0; string[] printer = new string[20]; // tableau qui contient les imprimantes du profil d'impression ProfilImprimante profil = new ProfilImprimante(); profil.chargementXML("BP"); // chargement selon le type de doc string vendeur = ""; try { vendeur = unProfil.Substring(2, 3); } catch { vendeur = unProfil.Substring(2, 2); } vendeur = vendeur.TrimEnd(); var listeProfil = profil.getDonneeProfil(); try { if (drapReliquat) { printer[nbImp] = ConfigurationManager.AppSettings["ImpDefBL"]; nbImp++; } else { foreach (string v in listeProfil[vendeur]) //lecture des imprimantes liée à un profil { printer[nbImp] = v.ToString(); nbImp++; //on incrémente le nombre d'impression à executer } } } catch (Exception e) { LogHelper.WriteToFile(e.Message, "Erreur attribution imprimante par profil " + unProfil.ToString()); printer[nbImp] = "Imp211"; //Imprimante par defaut (essai) nbImp++; } nbImp = nbImp - 1; while (nbImpOK <= nbImp) // boucle tant que le nombre d'impression fait n'à pas atteint le nombre d'impression demander { string printerName = printer[nbImpOK]; string inputFile = String.Format(@"{0}", chemin); try { //Envoi de l'ordre d'impression vers l'imprimante, les "switches" sont des arguments de la ligne de script "processor" de type GhostscriptProcessor using (GhostscriptProcessor processor = new GhostscriptProcessor()) { List <string> switches = new List <string>(); switches.Add("-empty"); switches.Add("-dPrinted"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOSAFER"); switches.Add("-dNumCopies=1"); switches.Add("-sDEVICE=ljet4"); switches.Add("-sOutputFile=%printer%" + printerName); switches.Add("-f"); switches.Add(inputFile); processor.StartProcessing(switches.ToArray(), null); } nbImpOK++; } catch (Exception e) { LogHelper.WriteToFile(e.Message, "ParseurBP" + donneEntete["Document_numero"].Trim()); } // incrément à chaque impression terminée } } }
public void miseEnForm(string typeDoc) { string cheminDocFinaux = ConfigurationManager.AppSettings["CheminDocFinaux"].ToString(); string cheminRessources = ConfigurationManager.AppSettings["CheminRessources"].ToString(); string chemin = cheminDocFinaux + "\\DocFinaux\\DEVIS\\DEVIS_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; Document nouveauDocument = new Document(PageSize.A4, 20, 20, 12, 20); PdfWriter.GetInstance(nouveauDocument, new FileStream(chemin, FileMode.Create)); //Stockage du document nouveauDocument.Open(); Image image4 = Image.GetInstance(ConfigurationManager.AppSettings["CheminPatternTot"]); image4.Alignment = Image.UNDERLYING; image4.SetAbsolutePosition(385, 70); //----------------------------------------------------------------------------------------------------Filligrane----------------------------------------------- Image image5 = Image.GetInstance(ConfigurationManager.AppSettings["CheminFilligraneDevis"]); image5.Alignment = Image.UNDERLYING; image5.SetAbsolutePosition(200, 250); nouveauDocument.Add(image5); //---------------------------------------- //Constitution document PDF //---------------------------------------- PdfPTable tableau = new PdfPTable(2); tableau.TotalWidth = 550; tableau.LockedWidth = true; Image image6 = Image.GetInstance(ConfigurationManager.AppSettings["CheminLogoABCRDevis"]); image6.ScaleAbsolute(PageSize.A4); image6.ScaleToFit(175, 180); image6.SetAbsolutePosition(13, 715); nouveauDocument.Add(image6); Paragraph pLogo = new Paragraph(); //Image image = Image.GetInstance(ConfigurationManager.AppSettings["CheminLogoABCRDevis"]); // pLogo.Add(image); //Encadré photo pLogo.Add(new Phrase("")); PdfPCell celulleHauteGauche = new PdfPCell(pLogo); celulleHauteGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celulleHauteGauche); //Encadré info devis Paragraph pDoc = new Paragraph(); Image image2 = Image.GetInstance(ConfigurationManager.AppSettings["CheminPatternHautDroiteDevis"]); image2.Alignment = Image.UNDERLYING; image2.SetAbsolutePosition(335, 740); nouveauDocument.Add(image2); pDoc.Alignment = Element.ALIGN_RIGHT; pDoc.Add(new Phrase("Devis n° " + donneeBody["Bon_numero1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pDoc.Add(new Phrase("Date : " + donneeBody["Bon_datrcl1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8))); pDoc.Add(new Phrase("Référence client : " + donneeBody["Bon_rcl1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, BaseColor.RED))); pDoc.Add(new Phrase("Code client: " + donneEntete["Client_code"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8))); pDoc.Add(new Phrase(donneEntete["Tiers_tel"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8))); pDoc.Add(new Phrase(donneEntete["Tiers_fax"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8))); pDoc.Add(new Phrase(donneEntete["Tiers_adf5"], FontFactory.GetFont(FontFactory.HELVETICA, 8))); PdfPCell celulleHauteDroite = new PdfPCell(pDoc); celulleHauteDroite.Border = PdfPCell.NO_BORDER; celulleHauteDroite.HorizontalAlignment = Element.ALIGN_CENTER; tableau.AddCell(celulleHauteDroite); //Encadré "ABCR" Paragraph p = new Paragraph(); p.Add(new Phrase(donneEntete["Adresse_interne_2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_4"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_5"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_6"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_7"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_8"] + "\n" + "\n" + "\n" + "\n" + "\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celluleBasGauche = new PdfPCell(p); celluleBasGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celluleBasGauche); //Encadré client Paragraph pClient = new Paragraph(); if (donneEntete["Tiers_adl1"] == "") { pClient.Add(new Phrase("\n" + "\n" + donneEntete["Tiers_adf1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adf2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adf3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adf4"] + "\n" + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adfcp"] + " " + donneEntete["Tiers_adf6"], FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); } else { pClient.Add(new Phrase("\n" /*+"\n"*/ + donneEntete["Tiers_adl1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adl2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adl3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adl4"] + "\n" + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); pClient.Add(new Phrase(donneEntete["Tiers_adlcp"] + " " + donneEntete["Tiers_adl6"], FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); } PdfPCell celluleBasDroite = new PdfPCell(pClient); celluleBasDroite.Border = PdfPCell.NO_BORDER; tableau.AddCell(celluleBasDroite); nouveauDocument.Add(tableau); //Dessus tableau Paragraph pRécap = new Paragraph(); Chunk contact = null; contact = new Chunk("Votre contact : " + donneEntete["Bon_vendeur_lib"] + "\n " + donneEntete["Duplicata"], FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.ITALIC));//FontFactory pour changer la police Chunk delai = new Chunk("Livraison : " + donneEntete["Tiers_adf1"] + " - " + donneEntete["Tiers_adf2"] + " - " + donneEntete["Tiers_adfcp"] + " " + donneEntete["Tiers_adf6"] + "\n" + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.ITALIC)).SetUnderline(2, 2); Chunk ligneEspace = new Chunk("\n", FontFactory.GetFont(FontFactory.HELVETICA, 1, Font.ITALIC)); pRécap.Add(contact); pRécap.Add(delai); pRécap.Add(ligneEspace); nouveauDocument.Add(pRécap); CurseurTemplate ct = new CurseurTemplate(); valeurTemplate = ct.chercher("Devis"); float[] largeurs = { int.Parse(valeurTemplate["Dimension1"]), int.Parse(valeurTemplate["Dimension2"]), int.Parse(valeurTemplate["Dimension3"]), int.Parse(valeurTemplate["Dimension4"]), int.Parse(valeurTemplate["Dimension5"]), int.Parse(valeurTemplate["Dimension6"]), int.Parse(valeurTemplate["Dimension7"]), int.Parse(valeurTemplate["Dimension8"]), int.Parse(valeurTemplate["Dimension9"]) }; // Dimension tableau body PdfPTable table = new PdfPTable(largeurs); table.TotalWidth = 555; //Chaque colonne crée ci dessus doit être rempli table.LockedWidth = true; PdfPCell cellET1 = new PdfPCell(new Phrase("Article", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET1.Border = PdfPCell.NO_BORDER; //cellET1.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET1); PdfPCell cellET2 = new PdfPCell(new Phrase("Désignation", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET2.Border = PdfPCell.NO_BORDER; //cellET2.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET2); PdfPCell cellET3 = new PdfPCell(new Phrase("UV", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET3.Border = PdfPCell.NO_BORDER; //cellET3.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET3); PdfPCell cellET4 = new PdfPCell(new Phrase("Quantité", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET4.Border = PdfPCell.NO_BORDER; //cellET4.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET4); PdfPCell cellET5 = new PdfPCell(new Phrase("Prix remisé", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET5.Border = PdfPCell.NO_BORDER; //cellET5.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET5); PdfPCell cellET6 = new PdfPCell(new Phrase("Remise", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET6.Border = PdfPCell.NO_BORDER; //cellET6.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET6); PdfPCell cellET7 = new PdfPCell(new Phrase("Prix net", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET7.Border = PdfPCell.NO_BORDER; //cellET7.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET7); PdfPCell cellET8 = new PdfPCell(new Phrase("Montant HT", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET8.Border = PdfPCell.NO_BORDER; //cellET8.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET8); PdfPCell cellET9 = new PdfPCell(new Phrase("TVA", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellET9.Border = PdfPCell.NO_BORDER; //cellET9.Border += PdfPCell.BOTTOM_BORDER; table.AddCell(cellET9); Image image3 = Image.GetInstance(ConfigurationManager.AppSettings["CheminPatternTableau"]); image3.Alignment = Image.UNDERLYING; image3.SetAbsolutePosition(20, 567); nouveauDocument.Add(image3); int i; int nbLigne = 0; float resultat = 0; float dimTab = 0; int décrement = 0; int numPage = 0; //Constitution du tableau d'article bool okDési = false; bool okStart = false; for (i = 1; i <= iBody; i++) { //Condition ARTICLE---------------------------------------------------------------------------------------------------------------------- if (donneeBody["Ligne_type" + i] == "ART") { nbLigne++; string sPattern = "libelle" + i + "bis"; PdfPCell cell1 = new PdfPCell(new Phrase(donneeBody["Art_code" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell1.Border = PdfPCell.NO_BORDER; cell1.Border += PdfPCell.RIGHT_BORDER; cell1.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell1); Paragraph pCell2 = new Paragraph(); PdfPCell cell2 = new PdfPCell(pCell2); cell2.Border = PdfPCell.NO_BORDER; cell2.Border += PdfPCell.RIGHT_BORDER; cell2.Border += PdfPCell.LEFT_BORDER; foreach (KeyValuePair <string, string> entry in donneeBody) { if (System.Text.RegularExpressions.Regex.IsMatch(entry.Key, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { if (okStart == false) { pCell2.Add(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); string clé = entry.Key; pCell2.Add(new Phrase(donneeBody[clé] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); okStart = true; } else { string clé = entry.Key; pCell2.Add(new Phrase(donneeBody[clé] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); } okDési = true; } } if (okDési == false) { PdfPCell cell3 = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell3.Border = PdfPCell.NO_BORDER; cell3.Border += PdfPCell.RIGHT_BORDER; cell3.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell3); } else { table.AddCell(cell2); } PdfPCell cell4 = new PdfPCell(new Phrase(donneeBody["Art_unite" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell4.Border = PdfPCell.NO_BORDER; cell4.Border += PdfPCell.RIGHT_BORDER; cell4.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell4); PdfPCell cell5 = new PdfPCell(new Phrase(donneeBody["Art_qte" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell5.Border = PdfPCell.NO_BORDER; cell5.Border += PdfPCell.RIGHT_BORDER; cell5.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell5); PdfPCell cell6 = new PdfPCell(new Phrase(donneeBody["Art_remise2" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell6); PdfPCell cell7 = new PdfPCell(new Phrase(donneeBody["Art_remise1" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell7.Border = PdfPCell.NO_BORDER; cell7.Border += PdfPCell.RIGHT_BORDER; cell7.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell7); if (donneeBody["Art_prinet" + i] != "") { PdfPCell cell8 = new PdfPCell(new Phrase(double.Parse(donneeBody["Art_prinet" + i]).ToString("N2") + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell8.Border = PdfPCell.NO_BORDER; cell8.Border += PdfPCell.RIGHT_BORDER; cell8.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell8); } else { PdfPCell cell8 = new PdfPCell(new Phrase(donneeBody["Art_prinet" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell8.Border = PdfPCell.NO_BORDER; cell8.Border += PdfPCell.RIGHT_BORDER; cell8.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell8); } PdfPCell cell9 = new PdfPCell(new Phrase(donneeBody["Art_monht" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell9.Border = PdfPCell.NO_BORDER; cell9.Border += PdfPCell.RIGHT_BORDER; cell9.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell9); PdfPCell cell10 = new PdfPCell(new Phrase("0" + donneeBody["Art_tva_code" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell10.Border = PdfPCell.NO_BORDER; cell10.Border += PdfPCell.RIGHT_BORDER; cell10.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell10); okDési = false; okStart = false; } //Condition ARTICLE GRATUIT----------------------------------------------------------------------------------------------------------------------------- if (donneeBody["Ligne_type" + i] == "GRA") { nbLigne++; string sPattern = "libelle" + i + "bis"; PdfPCell cell1 = new PdfPCell(new Phrase(donneeBody["Art_code" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell1.Border = PdfPCell.NO_BORDER; cell1.Border += PdfPCell.RIGHT_BORDER; cell1.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell1); foreach (KeyValuePair <string, string> entry in donneeBody) { if (System.Text.RegularExpressions.Regex.IsMatch(entry.Key, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { PdfPCell cell2 = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n" + donneeBody["Libelle" + i + "bis"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell2.Border = PdfPCell.NO_BORDER; cell2.Border += PdfPCell.RIGHT_BORDER; cell2.Border += PdfPCell.LEFT_BORDER; okDési = true; table.AddCell(cell2); } } if (okDési == false) { PdfPCell cell3 = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell3.Border = PdfPCell.NO_BORDER; cell3.Border += PdfPCell.RIGHT_BORDER; cell3.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell3); } PdfPCell cell4 = new PdfPCell(new Phrase(donneeBody["Art_unite" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell4.Border = PdfPCell.NO_BORDER; cell4.Border += PdfPCell.RIGHT_BORDER; cell4.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell4); PdfPCell cell5 = new PdfPCell(new Phrase(donneeBody["Art_qte" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell5.Border = PdfPCell.NO_BORDER; cell5.Border += PdfPCell.RIGHT_BORDER; cell5.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell5); PdfPCell cell6 = new PdfPCell(new Phrase("" + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell6); table.AddCell(cell6); table.AddCell(cell6); PdfPCell cell7 = new PdfPCell((new Phrase(donneeBody["Lib_rempl_mt" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD)))); cell7.Border = PdfPCell.NO_BORDER; cell7.Border += PdfPCell.RIGHT_BORDER; cell7.Border += PdfPCell.LEFT_BORDER; table.AddCell(cell7); PdfPCell cell8 = new PdfPCell(new Phrase("" + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cell8.Border = PdfPCell.NO_BORDER; cell8.Border += PdfPCell.LEFT_BORDER; cell8.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cell8); } //Condition COMMENTAIRE-------------------------------------------------------------------------------------------------------------------------------- if (donneeBody["Ligne_type" + i] == "COM") { nbLigne++; PdfPCell cellVide = new PdfPCell(new Phrase("" + "\n")); PdfPCell cell = new PdfPCell(new Phrase(donneeBody["Libelle" + i] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); PdfPCell cellFin = new PdfPCell(); cellVide.Border = PdfPCell.NO_BORDER; cellVide.Border += PdfPCell.RIGHT_BORDER; cellVide.Border += PdfPCell.LEFT_BORDER; cell.Border = PdfPCell.NO_BORDER; cell.Border += PdfPCell.RIGHT_BORDER; cell.Border += PdfPCell.LEFT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.LEFT_BORDER; cellFin.Border += PdfPCell.RIGHT_BORDER; table.AddCell(cellVide); table.AddCell(cell); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellVide); table.AddCell(cellFin); } PdfPCell cellEcartDroite = new PdfPCell(new Phrase(" " + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 2, Font.BOLD))); PdfPCell cellEcart = new PdfPCell(new Phrase(" " + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 2, Font.BOLD))); cellEcart.Border = PdfPCell.NO_BORDER; cellEcart.Border += PdfPCell.LEFT_BORDER; cellEcart.Border += PdfPCell.RIGHT_BORDER; cellEcartDroite.Border = PdfPCell.NO_BORDER; cellEcartDroite.Border += PdfPCell.RIGHT_BORDER; cellEcartDroite.Border += PdfPCell.LEFT_BORDER; table.AddCell(cellEcartDroite); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); table.AddCell(cellEcart); //--------------------------------------------GESTION DU SAUT DE PAGE------------------------------------------------------------------------------------------- //float temp = table.GetRowHeight(i-1-décrement); float temp = table.TotalHeight; dimTab = temp; if (dimTab >= 410 && i < iBody) { //Saut de page numPage++; PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheD = new PdfPCell(new Phrase(" ")); cellFin.Colspan = 9; cellBlanche.FixedHeight = (450 - dimTab); cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheD.FixedHeight = (450 - dimTab); cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheD); table.AddCell(cellFin); nouveauDocument.Add(table);//----------------------------------------------------------------------------Repère ligne en dessous-------------------------------------------------- Phrase pReport = new Phrase(" A REPORTER\n\n\n\n\n Page n° " + numPage, FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); nouveauDocument.Add(pReport); table.DeleteBodyRows(); nouveauDocument.Add(Chunk.NEXTPAGE); nouveauDocument.Add(tableau); nouveauDocument.Add(pRécap); nouveauDocument.Add(image2); nouveauDocument.Add(image3); nouveauDocument.Add(image5); table.AddCell(cellET1); table.AddCell(cellET2); table.AddCell(cellET3); table.AddCell(cellET4); table.AddCell(cellET5); table.AddCell(cellET6); table.AddCell(cellET7); table.AddCell(cellET8); table.AddCell(cellET9); dimTab = 0; décrement = (i - 1); } //---------------------------------------------------------------------------------------------------------------------------------------------------------------------- } int b; //---------------------------------------------------------------- for (b = 0; b <= i; b++) // { // Compteur dimension du tableau float temp = table.TotalHeight; // resultat = temp; // } //------------------------------------------------------------------- if (i > iBody) { PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheD = new PdfPCell(new Phrase(" ")); cellFin.Colspan = 9; resultat = 450 - resultat; //<<----------450 correspond au nombre de point de la longueur du tableau, c'est la valeur à modifier pour modifier la taille du tableau cellBlanche.FixedHeight = resultat; cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheD.FixedHeight = resultat; cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheD); table.AddCell(cellFin); } nouveauDocument.Add(table); // Constitution tableau pied de page PdfPTable tableauPied = new PdfPTable(3); tableauPied.TotalWidth = 555; tableauPied.LockedWidth = true; Paragraph pTVA = new Paragraph(); pTVA.Add(new Phrase("Offre de prix valable jusqu'au : " + donneEntete["Date_val"], FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD, BaseColor.RED))); int iF = 0; foreach (KeyValuePair <string, string> entry in donneeFoot) { if (System.Text.RegularExpressions.Regex.IsMatch(entry.Value, "TVA", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { pTVA.Add(new Phrase("\nTVA " + donneeFoot.ElementAt(iF - 1).Value + " = " + entry.Value, FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); } iF++; } PdfPCell cellulePied = new PdfPCell(pTVA); cellulePied.Colspan = 2; cellulePied.Border = PdfPCell.NO_BORDER; tableauPied.AddCell(cellulePied); nouveauDocument.Add(image4); PdfPTable tableauTot = new PdfPTable(1); PdfPCell cellTTot = new PdfPCell(new Phrase("Total HT : " + donneeFoot["Base_tva_mht"] + " €", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellTTot.Border = PdfPCell.NO_BORDER; cellTTot.Border = PdfPCell.BOTTOM_BORDER; tableauTot.AddCell(cellTTot); PdfPCell cellTVA = new PdfPCell(new Phrase("Total TVA : " + donneeFoot["Base_tva_mtva"] + " €", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellTVA.Border = PdfPCell.NO_BORDER; cellTVA.Border = PdfPCell.BOTTOM_BORDER; tableauTot.AddCell(cellTVA); PdfPCell cellTTC = new PdfPCell(new Phrase("Total TTC : " + donneeFoot["Base_tva_mttc"] + " €", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.BOLD))); cellTTC.Border = PdfPCell.NO_BORDER; tableauTot.AddCell(cellTTC); PdfPCell cellTot = new PdfPCell(tableauTot); cellTot.Border = PdfPCell.NO_BORDER; tableauPied.AddCell(cellTot); nouveauDocument.Add(tableauPied); Phrase maPhrase = new Phrase(); maPhrase.Add(new Chunk("\nBon pour accord ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); maPhrase.Add(new Chunk("\n Fait à: le: Signature", FontFactory.GetFont(FontFactory.HELVETICA, 8))); nouveauDocument.Add(maPhrase); if (numPage > 0) { Phrase PageFinal = new Phrase(" Page n° " + (1 + numPage), FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); nouveauDocument.Add(PageFinal); } nouveauDocument.Close(); //Copie Doc dans GED try { String connectionString = ConfigurationManager.AppSettings["ChaineDeConnexionBase"]; OdbcConnection conn = new OdbcConnection(connectionString); conn.Open(); string requete = "select T1.NOCLI c1 , T1.NOMCL c2 from B00C0ACR.AMAGESTCOM.ACLIENL1 T1 where T1.NOCLI = '" + donneEntete["Client_code"] + "'"; OdbcCommand act = new OdbcCommand(requete, conn); OdbcDataReader act0 = act.ExecuteReader(); string nomADH = ""; while (act0.Read()) { nomADH = (act0.GetString(1)); } conn.Close(); if (!System.IO.Directory.Exists(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM") + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Devis\\")) { System.IO.Directory.CreateDirectory(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Devis\\"); System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Devis\\" + "\\DEVIS_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } else { System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneEntete["Client_code"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Devis\\" + "\\DEVIS_" + nomDoc + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } } catch { } //--------------------------------------------------------FIN COPIE---------------------------------------------------------------------------------------------------------- int nbImp = 0; int nbImpOK = 0; string[] printer = new string[20]; // tableau qui contient les imprimantes du profil d'impression ProfilImprimante profil = new ProfilImprimante(); profil.chargementXML("Dev"); // chargement selon le type de doc string vendeur = unProfil.Substring(2, 3); vendeur = vendeur.TrimEnd(); var listeProfil = profil.getDonneeProfil(); try { foreach (string v in listeProfil[vendeur]) //lecture des imprimantes liée à un profil { printer[nbImp] = v.ToString(); nbImp++; //on incrémente le nombre d'impression à executer } } catch { printer[nbImp] = ConfigurationManager.AppSettings["ImpDef"]; //Imprimante par defaut (essai) nbImp++; } nbImp = nbImp - 1; while (nbImpOK <= nbImp) // boucle tant que le nombre d'impression fait n'à pas atteint le nombre d'impression demander { string printerName = printer[nbImpOK]; string inputFile = String.Format(@"{0}", chemin); try { using (GhostscriptProcessor processor = new GhostscriptProcessor()) { List <string> switches = new List <string>(); switches.Add("-empty"); switches.Add("-dPrinted"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOSAFER"); switches.Add("-dNumCopies=" + ConfigurationManager.AppSettings["NbCopieGC"]); switches.Add("-sDEVICE=" + ConfigurationManager.AppSettings["PiloteImpressionGC"]); switches.Add("-sOutputFile=%printer%" + printerName); switches.Add("-f"); switches.Add(inputFile); processor.StartProcessing(switches.ToArray(), null); } nbImpOK++; } catch (Exception e) { LogHelper.WriteToFile(e.Message, "ParseurBP" + donneEntete["Document_numero"].Trim()); } } /*Mail m = new Mail(); * m.remplirDictionnaire(); * m.comparerDocument(donneEntete["Client_code"]);*/ }
public void miseEnForm(string typeDoc) { int incCopie = 0; int nbCopie = 1; string cheminDocFinaux = ConfigurationManager.AppSettings["CheminDocFinaux"].ToString(); string cheminRessources = ConfigurationManager.AppSettings["CheminRessources"].ToString(); while (incCopie < nbCopie) { /*ND 23 10 2015*/ string chemin = ""; /* if (!System.IO.Directory.Exists(cheminDocFinaux + "\\DocFinaux\\Releve\\" + donneEntete["Tiers_nocpt"].Substring(3,6))) { System.IO.Directory.CreateDirectory(cheminDocFinaux + "\\DocFinaux\\Releve\\" + donneEntete["Tiers_nocpt"].Substring(3, 6)); chemin = cheminDocFinaux + "\\DocFinaux\\Releve\\" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "\\" + nomDoc + "_" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; }*/ if (!System.IO.Directory.Exists(cheminDocFinaux + "\\DocFinaux\\Facturation\\" + donneEntete["Tiers_nocpt"].Substring(3, 6))) { System.IO.Directory.CreateDirectory(cheminDocFinaux + "\\DocFinaux\\Facturation\\" + donneEntete["Tiers_nocpt"].Substring(3, 6)); chemin = cheminDocFinaux + "\\DocFinaux\\Facturation\\" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "\\RELEVE" + nomDoc + "_" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; } else { /*ND 23 10 2015*/ //chemin = cheminDocFinaux + "\\DocFinaux\\Releve\\" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "\\" + nomDoc + "_" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; chemin = cheminDocFinaux + "\\DocFinaux\\Facturation\\" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "\\RELEVE" + nomDoc + "_" + donneEntete["Tiers_nocpt"].Substring(3, 6) + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"; } Document nouveauDocument = new Document(PageSize.A4, 20, 20, 12, 2); PdfWriter writer = PdfWriter.GetInstance(nouveauDocument, new FileStream(chemin, FileMode.Create)); //Stockage du document //--------------------------------------------------------------------------------------------------------------------------- //Constitution document PDF //--------------------------------------------------------------------------------------------------------------------------- nouveauDocument.Open(); PdfPTable tableau = new PdfPTable(2); tableau.TotalWidth = 550; tableau.LockedWidth = true; //------------------------------------------------------------------------------------------------- //Encadré ABCR Paragraph p = new Paragraph(); p.Add(new Phrase(donneEntete["Adresse_interne_1"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_2"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_3"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); p.Add(new Phrase(donneEntete["Adresse_interne_4"] + "\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celulleHauteGauche = new PdfPCell(p); celulleHauteGauche.Border = PdfPCell.NO_BORDER; tableau.AddCell(celulleHauteGauche); //Celulle de droite contenant l'adresse de livraison Paragraph pAdl = new Paragraph(); pAdl.Add(new Phrase("\n\n \n")); pAdl.Add(new Phrase("\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase("\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase("\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase("\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdl.Add(new Phrase(" ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celulleFinDroite = new PdfPCell(pAdl); celulleFinDroite.Bottom = PdfPCell.ALIGN_BOTTOM; celulleFinDroite.Border = PdfPCell.NO_BORDER; celulleFinDroite.PaddingLeft = 35; tableau.AddCell(celulleFinDroite); //Tableau dans celulle bas gauche du tableau d'entete PdfPCell celulleBasGauche = new PdfPCell(); Paragraph ptest = new Paragraph(); ptest.Add(new Phrase("\n Relevé de facture(s)\n\n",FontFactory.GetFont(FontFactory.HELVETICA, 12, Font.BOLD))); celulleBasGauche.AddElement(ptest); PdfPTable tabCell = new PdfPTable(3); tabCell.TotalWidth = 230; tabCell.LockedWidth = true; tabCell.AddCell(new Phrase("COMPTE", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase("DATE", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase("NO RELEVE", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCell.AddCell(new Phrase(donneEntete["Tiers_nocpt"], FontFactory.GetFont(FontFactory.HELVETICA, 10))); tabCell.AddCell(new Phrase(donneEntete["Rel_datrel"], FontFactory.GetFont(FontFactory.HELVETICA, 10))); tabCell.AddCell(new Phrase(donneEntete["Document_numero"], FontFactory.GetFont(FontFactory.HELVETICA, 10))); tabCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; celulleBasGauche.AddElement(tabCell); celulleBasGauche.Border = PdfPCell.NO_BORDER; celulleBasGauche.Bottom = PdfPCell.ALIGN_BOTTOM; tableau.AddCell(celulleBasGauche); //Adresse facturation Paragraph pAdf = new Paragraph(); // REGLER INDENTATION DU PARAGRAPHE pAdf.Add(new Phrase("\n\n\n\n" + donneEntete["Tiers_adf1"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdf.Add(new Phrase(donneEntete["Tiers_adf2"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdf.Add(new Phrase(donneEntete["Tiers_adf3"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdf.Add(new Phrase(donneEntete["Tiers_adf4"] + "\n", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); pAdf.Add(new Phrase(donneEntete["Tiers_adfcp"] + " " + donneEntete["Tiers_adf6"] + "\n\n\n\n ", FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); PdfPCell celulleHauteDroite = new PdfPCell(pAdf); celulleHauteGauche.HorizontalAlignment = Element.ALIGN_RIGHT; celulleHauteDroite.Border = PdfPCell.NO_BORDER; celulleHauteDroite.PaddingLeft = 80; tableau.AddCell(celulleHauteDroite); nouveauDocument.Add(tableau); //-------------------------------------------------------------------------------------------------------- // TABLEAU //------------------------------------------------------------------------------------------------------- CurseurTemplate ct = new CurseurTemplate(); valeurTemplate = ct.chercher("RELEVE"); float[] largeurs = { int.Parse(valeurTemplate["Dimension1"]), int.Parse(valeurTemplate["Dimension2"]), int.Parse(valeurTemplate["Dimension3"]), int.Parse(valeurTemplate["Dimension4"]), int.Parse(valeurTemplate["Dimension5"]), int.Parse(valeurTemplate["Dimension6"]), }; PdfPTable table = new PdfPTable(largeurs); table.TotalWidth = 565; //Chaque colonne crée ci dessus doit être rempli table.LockedWidth = true; PdfPCell cellET1 = new PdfPCell(new Phrase("Date", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET1.SetLeading(2f, 1.2f); cellET1.PaddingBottom = 7f; table.AddCell(cellET1); PdfPCell cellET2 = new PdfPCell(new Phrase("Type Pièce", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET2.SetLeading(2f, 1.2f); cellET2.PaddingBottom = 7f; table.AddCell(cellET2); PdfPCell cellET3 = new PdfPCell(new Phrase("Référence", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET3.SetLeading(2f, 1.2f); cellET3.PaddingBottom = 7f; table.AddCell(cellET3); PdfPCell cellET4 = new PdfPCell(new Phrase("T.V.A", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET4.HorizontalAlignment = Element.ALIGN_RIGHT; cellET4.PaddingBottom = 7f; cellET4.SetLeading(2f, 1.2f); table.AddCell(cellET4); PdfPCell cellET5 = new PdfPCell(new Phrase("Avoir", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET5.HorizontalAlignment = Element.ALIGN_RIGHT; cellET5.PaddingBottom = 7f; cellET5.SetLeading(2f, 1.2f); table.AddCell(cellET5); PdfPCell cellET6 = new PdfPCell(new Phrase("Facture", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD))); cellET6.HorizontalAlignment = Element.ALIGN_RIGHT; cellET6.PaddingBottom = 7f; cellET6.SetLeading(2f, 1.2f); table.AddCell(cellET6); int i; int nbLigne = 0; float resultat = 0; float dimTab = 0; int décrement = 0; int numPage = 0; //Constitution du tableau /*ND DEBUT 19 10 2015*/ // bool okDési = false; /*ND FIN 19 10 2015*/ /* ND debut 19 10 2015*/ //bool okStart = false; /*ND FIN 19 10 2015*/ double tempoTOT = 0; for (i = 0; i < iBody; i++) { nbLigne++; PdfPCell cell1 = new PdfPCell(new Phrase(donneeBody["Rel_datfac" + i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell1.Border = PdfPCell.NO_BORDER; cell1.Border += PdfPCell.RIGHT_BORDER; cell1.Border += PdfPCell.LEFT_BORDER; cell1.SetLeading(5f, 1.2f); table.AddCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(donneeBody["Rel_libavofac" + i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell2.Border = PdfPCell.NO_BORDER; cell2.Border += PdfPCell.RIGHT_BORDER; cell2.Border += PdfPCell.LEFT_BORDER; cell2.SetLeading(5f, 1.2f); table.AddCell(cell2); PdfPCell cell3 = new PdfPCell(new Phrase(donneeBody["Rel_nofac" + i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell3.Border = PdfPCell.NO_BORDER; cell3.Border += PdfPCell.RIGHT_BORDER; cell3.Border += PdfPCell.LEFT_BORDER; cell3.SetLeading(5f, 1.2f); table.AddCell(cell3); PdfPCell cell4 = new PdfPCell(new Phrase(donneeBody["Rel_mtva" + i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell4.Border = PdfPCell.NO_BORDER; cell4.Border += PdfPCell.RIGHT_BORDER; cell4.Border += PdfPCell.LEFT_BORDER; cell4.HorizontalAlignment = Element.ALIGN_RIGHT; cell4.SetLeading(5f, 1.2f); table.AddCell(cell4); PdfPCell cell5 = new PdfPCell(new Phrase(donneeBody["Rel_mttavo"+i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell5.Border = PdfPCell.NO_BORDER; cell5.Border += PdfPCell.RIGHT_BORDER; cell5.Border += PdfPCell.LEFT_BORDER; cell5.HorizontalAlignment = Element.ALIGN_RIGHT; cell5.SetLeading(5f, 1.2f); table.AddCell(cell5); PdfPCell cell6 = new PdfPCell(new Phrase(donneeBody["Rel_mtfac" + i], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cell6.Border = PdfPCell.NO_BORDER; cell6.Border += PdfPCell.RIGHT_BORDER; cell6.Border += PdfPCell.LEFT_BORDER; cell6.HorizontalAlignment = Element.ALIGN_RIGHT; cell6.SetLeading(5f, 1.2f); table.AddCell(cell6); //--------------------------------------------GESTION DU SAUT DE PAGE------------------------------------------------------------------------------------------- float temp = table.TotalHeight; dimTab = temp; if (dimTab >= 380 && i < iBody) //if (dimTab >= 380 && i <= iBody) { //Saut de page numPage++; PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheDA = new PdfPCell(new Phrase("\n\nA Reporter", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.ITALIC))); PdfPCell cellBlancheD = new PdfPCell(new Phrase("\n\n" + tempoTOT.ToString(), FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.ITALIC))); cellFin.Colspan = 8; cellBlancheDA.Bottom = PdfPCell.ALIGN_BOTTOM; cellBlancheD.Bottom = PdfPCell.ALIGN_BOTTOM; cellBlanche.FixedHeight = (440 - dimTab); cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheDA.FixedHeight = (440 - dimTab); cellBlancheDA.Border = PdfPCell.NO_BORDER; cellBlancheDA.Border += PdfPCell.LEFT_BORDER; cellBlancheDA.Border += PdfPCell.RIGHT_BORDER; cellBlancheD.FixedHeight = (440 - dimTab); cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheDA); table.AddCell(cellBlancheD); table.AddCell(cellFin); nouveauDocument.Add(table);//----------------------------------------------------------------------------Repère ligne en dessous-------------------------------------------------- Phrase pReport = new Phrase(" A REPORTER\n\n\n\n\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)); /*10 12 15 ND correction bug saut de page donnée entete innexistante*/ // Phrase pPage = new Phrase("\n " + donneEntete["Document_type"] + " " + donneEntete["Duplicata"] + " Page n° " + (numPage + 1) + " ", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD)); Phrase pPage = new Phrase("\n " + donneEntete["Document_type"] + " Page n° " + (numPage + 1) + " ", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD)); pPage.Leading = 15; nouveauDocument.Add(pReport); table.DeleteBodyRows(); nouveauDocument.Add(Chunk.NEXTPAGE); nouveauDocument.Add(tableau); nouveauDocument.Add(pPage); table.AddCell(cellET1); table.AddCell(cellET2); table.AddCell(cellET3); table.AddCell(cellET4); table.AddCell(cellET5); table.AddCell(cellET6); dimTab = 0; décrement = (i - 1); } //FinGestionSautPage } //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- int b; //---------------------------------------------------------------- for (b = 0; b <= i; b++) // { // Compteur dimension du tableau float temp = table.TotalHeight; // resultat = temp; // } //------------------------------------------------------------------- if (i >= iBody) { PdfPCell cellFin = new PdfPCell(new Phrase(" ")); PdfPCell cellBlanche = new PdfPCell(new Phrase(" ")); PdfPCell cellBlancheD = new PdfPCell(new Phrase(" ")); cellFin.Colspan = 8; resultat = 300 - resultat; //<<----------450 correspond au nombre de point de la longueur du tableau, c'est la valeur à modifier pour modifier la taille du tableau cellBlanche.FixedHeight = resultat; cellBlanche.Border = PdfPCell.NO_BORDER; cellBlanche.Border += PdfPCell.RIGHT_BORDER; cellBlanche.Border += PdfPCell.LEFT_BORDER; cellBlancheD.FixedHeight = resultat; cellBlancheD.Border = PdfPCell.NO_BORDER; cellBlancheD.Border += PdfPCell.LEFT_BORDER; cellBlancheD.Border += PdfPCell.RIGHT_BORDER; cellFin.Border = PdfPCell.NO_BORDER; cellFin.Border += PdfPCell.TOP_BORDER; table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlanche); table.AddCell(cellBlancheD); table.AddCell(cellFin); } table.SpacingAfter = -15F; nouveauDocument.Add(table); //----------------------------------------------------Tableau récap----------------------------------------- PdfPTable tabTot = new PdfPTable(3); tabTot.TotalWidth = 565; tabTot.LockedWidth = true; PdfPCell cellHT = new PdfPCell(new Phrase("HT " + donneeFoot["Tot_ht"], FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); cellHT.Border = PdfPCell.NO_BORDER; PdfPCell cellTVA = new PdfPCell(new Phrase("TVA " + donneeFoot["Tot_tva"], FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); cellTVA.Border = PdfPCell.NO_BORDER; PdfPCell cellTot = new PdfPCell(new Phrase(donneeFoot["Tot_rel"], FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLD))); cellTot.Border = PdfPCell.NO_BORDER; cellHT.HorizontalAlignment = Element.ALIGN_RIGHT; cellTVA.HorizontalAlignment = Element.ALIGN_RIGHT; cellTot.HorizontalAlignment = Element.ALIGN_RIGHT; tabTot.AddCell(cellHT); tabTot.AddCell(cellTVA); tabTot.AddCell(cellTot); PdfPCell cellType = new PdfPCell(new Phrase("\nDate d'échéance : " + donneeFoot["Tot_datech"]+"\n\n"+donneeFoot["Tot_libtraite"], FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.NORMAL))); cellType.Border = PdfPCell.NO_BORDER; cellType.Colspan = 2; PdfPTable tabReleve = new PdfPTable(1); tabReleve.TotalWidth = 138; tabReleve.LockedWidth = true; tabReleve.AddCell(new PdfPCell(new Phrase("TOTAL RELEVE", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD)))); PdfPCell tabCellTot = new PdfPCell(new Phrase("\n"+donneeFoot["Tot_rel"]+" EUR", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD))); tabCellTot.HorizontalAlignment = Element.ALIGN_RIGHT; tabReleve.AddCell(tabCellTot); PdfPCell cellTabReleve = new PdfPCell(); cellTabReleve.Border = PdfPCell.NO_BORDER; cellTabReleve.PaddingLeft= 50; cellTabReleve.VerticalAlignment = Element.ALIGN_BOTTOM; cellTabReleve.AddElement(tabReleve); tabTot.AddCell(cellType); tabTot.AddCell(cellTabReleve); nouveauDocument.Add(tabTot); Phrase pTiré = new Phrase("\n------------------------------------------------------------------------------------------------------------------------------------------"); pTiré.SetLeading(0f, 0.5f); nouveauDocument.Add(pTiré); //--------------------------------------FIN TABLEAU RECAP------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if (donneeFoot["Tot_libreg"] == "") // Condition si réglement par traites { PdfPTable tableauTraiteHaut = new PdfPTable(3); tableauTraiteHaut.TotalWidth = 565; tableauTraiteHaut.LockedWidth = true; PdfPCell cellBlancheTraite = new PdfPCell(); cellBlancheTraite.Border = PdfPCell.NO_BORDER; tableauTraiteHaut.AddCell(cellBlancheTraite); PdfPCell cellTraiteHaut = new PdfPCell(); cellTraiteHaut.SetLeading(1f, 0.5f); PdfPCell cellTraiteHautD = new PdfPCell(); cellTraiteHautD.SetLeading(1f, 0.5f); cellTraiteHaut.Border = PdfPCell.NO_BORDER; cellTraiteHautD.Border = PdfPCell.NO_BORDER; cellTraiteHaut.AddElement(new Phrase("Contre cette LETTRE de CHANGE stipulée SANS FRAIS veuillez payer la somme indiquée ci-dessous à l'ordre de :", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); tableauTraiteHaut.AddCell(cellTraiteHaut); cellTraiteHautD.AddElement(new Phrase(" " + donneeFoot["Tra_libacc"] + " " + donneeFoot["Tra_lcr"], FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); tableauTraiteHaut.AddCell(cellTraiteHautD); tableauTraiteHaut.SpacingAfter = -10f; nouveauDocument.Add(tableauTraiteHaut); //--------------------------Tableau Traite principal------------------------------------------------------------------------------------------------------- PdfPTable tableauTraite = new PdfPTable(3); //tableauTraite.SpacingBefore = -10f; tableauTraite.TotalWidth = 565; tableauTraite.LockedWidth = true; PdfPCell cellTraiteMiG = new PdfPCell(); cellTraiteMiG.Border = PdfPCell.NO_BORDER; Paragraph pcellTraiteHG = new Paragraph(); pcellTraiteHG.Add(new Phrase("\nA " + donneeFoot["Tra_lieucr"]+"\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); pcellTraiteHG.Add(new Phrase("Montant pour controle Date de création\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); pcellTraiteHG.Add(new Phrase("|"+donneeFoot["Tra_montae"] + "| |" + donneeFoot["Tra_datrel"]+"|", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); pcellTraiteHG.Add(new Phrase("\n| ", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.UNDERLINE))); pcellTraiteHG.Add(new Phrase("|\n RIB du tiré .", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.UNDERLINE))); cellTraiteMiG.AddElement(pcellTraiteHG); cellTraiteMiG.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; PdfPCell cellTraiteMiM = new PdfPCell(); cellTraiteMiM.Border = PdfPCell.NO_BORDER; Paragraph pcellTraiteHM = new Paragraph(); pcellTraiteHM.Add(new Phrase("\n\nEchéance\n ", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); pcellTraiteHM.Add(new Phrase("| " + donneeFoot["Tra_datech"] + " |", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); pcellTraiteHM.Add(new Phrase(" |" + donneeFoot["Tra_cocpt"] + "|\n", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); pcellTraiteHM.Add(new Phrase(" Ref.tiré ", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteMiM.AddElement(pcellTraiteHM); cellTraiteMiM.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; PdfPCell cellTraiteMiD = new PdfPCell(); cellTraiteMiD.Border = PdfPCell.NO_BORDER; cellTraiteMiD.AddElement(new Phrase("\n CODE MONNAIE ISO\n",FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteMiD.AddElement(new Phrase(" EUR\n", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteMiD.AddElement(new Phrase("Montant\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteMiD.AddElement(new Phrase(" *****" + donneeFoot["Tra_montae"] + "***", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteMiD.PaddingLeft = 70; tableauTraite.AddCell(cellTraiteMiG); tableauTraite.AddCell(cellTraiteMiM); tableauTraite.AddCell(cellTraiteMiD); //------------FIN LIGNE MILEU TABLEAU--------------- PdfPCell cellTraiteBasG = new PdfPCell(); cellTraiteBasG.Border = PdfPCell.NO_BORDER; cellTraiteBasG.AddElement(new Phrase("|" + donneeFoot["Tra_banque"] + " | " + donneeFoot["Tra_guichet"] + " | " + donneeFoot["Tra_cptco"] + " | " + donneeFoot["Tra_rib"]+"|\n", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteBasG.AddElement(new Phrase("Code établ. Code guichet N°de Compte Clé RIB\n", FontFactory.GetFont(FontFactory.HELVETICA, 6, Font.NORMAL))); cellTraiteBasG.AddElement(new Phrase("Valeur en:", FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.NORMAL))); cellTraiteBasG.AddElement(new Phrase("ACCEPTATION OU AVAL", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteBasG.AddElement(new Phrase(" NOM\n et ADRESSE", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteBasG.AddElement(new Phrase("\nN° SIREN du TIRE "+donneeFoot["Tra_siren"],FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); PdfPCell cellTraiteBasM = new PdfPCell(); cellTraiteBasM.Border = PdfPCell.NO_BORDER; cellTraiteBasM.AddElement(new Phrase(" "+donneeFoot["Tra_tiers_adf1"]+"\n",FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteBasM.AddElement(new Phrase(" " + donneeFoot["Tra_tiers_adf2"] + "\n\n\n\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteBasM.AddElement(new Phrase(" " + donneeFoot["Tra_tiers_adfcp"] + " " + donneeFoot["Tra_tiers_adf6"], FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); PdfPCell cellTraiteBasD = new PdfPCell(); cellTraiteBasD.Border = PdfPCell.NO_BORDER; cellTraiteBasD.AddElement(new Phrase(" DOMICILIATION .\n", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.UNDERLINE))); cellTraiteBasD.AddElement(new Phrase("| " + donneeFoot["Tra_domic1"] + " |\n", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteBasD.AddElement(new Phrase("| " + donneeFoot["Tra_domic2"] + " |\n", FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); cellTraiteBasD.AddElement(new Phrase(" Signature ", FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL))); cellTraiteBasD.AddElement(new Phrase("\n\nCLIENT N° " + donneeFoot["Tra_nocli"] + " RELEVE N° " + donneeFoot["Tra_numrel"], FontFactory.GetFont(FontFactory.COURIER, 8, Font.NORMAL))); tableauTraite.AddCell(cellTraiteBasG);tableauTraite.AddCell(cellTraiteBasM);tableauTraite.AddCell(cellTraiteBasD); nouveauDocument.Add(tableauTraite); } nouveauDocument.Close(); incCopie++; //--------------------------------------------------COPIE GED-------------------------------------------------------- string nomADH = ""; string numcli = ""; try { String connectionString = ConfigurationManager.AppSettings["ChaineDeConnexionBase"]; OdbcConnection conn = new OdbcConnection(connectionString); conn.Open(); //string requete = "select T1.NOCLI c1 , T1.NOMCL c2 from B00C0ACR.AMAGESTCOM.ACLIENL1 T1 where T1.NOCLI = '" + donneeFoot["Tra_nocli"] + "'"; numcli = donneEntete["Tiers_nocpt"].Substring(3, 6); string requete = "select T1.NOCLI c1 , T1.NOMCL c2 from B00C0ACR.AMAGESTCOM.ACLIENL1 T1 where T1.NOCLI = '" + numcli + "'"; OdbcCommand act = new OdbcCommand(requete, conn); OdbcDataReader act0 = act.ExecuteReader(); //string nomADH = ""; //act0.Read(); while (act0.Read()) { nomADH = (act0.GetString(1)); nomADH = nomADH.Trim(); /*test recup nom*/ // LogHelper.WriteToFile("requete : ", requete + "-" + numcli); } conn.Close(); /*if (!System.IO.Directory.Exists(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneeFoot["Tra_nocli"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM") + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\")) { System.IO.Directory.CreateDirectory(ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneeFoot["Tra_nocli"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\"); System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneeFoot["Tra_nocli"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\RELEVE" + "\\" + nomDoc + "_" + donneeFoot["Tra_nocli"] + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } else { System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + donneeFoot["Tra_nocli"] + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\RELEVE" + nomDoc + "_" + donneeFoot["Tra_nocli"] + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); }*/ if (!System.IO.Directory.Exists(ConfigurationManager.AppSettings["cheminGED"] + "\\" + numcli + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM") + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\")) { System.IO.Directory.CreateDirectory(ConfigurationManager.AppSettings["cheminGED"] + "\\" + numcli + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\"); System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + numcli + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\RELEVE" + "\\" + nomDoc + "_" + donneeFoot["Tra_nocli"] + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } else { System.IO.File.Copy(chemin, ConfigurationManager.AppSettings["cheminGED"] + "\\" + numcli + " - " + nomADH + "\\" + DateTime.Now.Year.ToString() + "\\" + DateTime.Now.ToString("MM").ToUpperInvariant() + "-" + DateTime.Now.ToString("MMMM").First().ToString().ToUpper() + String.Join("", DateTime.Now.ToString("MMMM").Skip(1)) + "\\Facturation\\RELEVE" + nomDoc + "_" + donneeFoot["Tra_nocli"] + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".pdf"); } } catch (Exception e) { LogHelper.WriteToFile(e.Message, "nomAdh : " + nomADH + "-"+ numcli + "ENVOI GED Releve"); } //----------------------------------------------FIN COPIE---------------------------------------------------------- //Requette qui retourne le champ "OUI/NON" envoi mail facture String connectionString2 = ConfigurationManager.AppSettings["ChaineDeConnexionBase"]; OdbcConnection conn2 = new OdbcConnection(connectionString2); conn2.Open(); //Requete de séléction sur le champ "envoi facture par mail" string requete2 = "select T1.NOCLI c1 , T1.CLID5 c2 , T1.RENDI c3 , T1.PROFE c4 from B00C0ACR.AMAGESTCOM.ACLIENL1 T1 where T1.CLID5 = 'OUI'"; OdbcCommand act2 = new OdbcCommand(requete2, conn2); OdbcDataReader act20 = null; bool effectuerImpression = true; string numCli =""; try { act20 = act2.ExecuteReader(); while (act20.Read()) { numCli = donneEntete["Tiers_nocpt"].Substring(3, 6); /*ND 27 10 15 correction erreur généré recherche facture oui ou non donnée entete inexistante car code compte*/ // if(act20.GetString(0) == donneEntete["Client_code"])// Si le code client est égale au résultat de la requete sur la ligne lu "NOCLI" if (act20.GetString(0) == numCli)// Si le code client est égale au résultat de la requete sur la ligne lu "NOCLI" { if(act20.GetString(1) == "OUI") //Si la ligne de l'enrigistrement dans la base est à OUI pour cet ID, alors ne pas imprimer { effectuerImpression = false; } } } } catch (Exception e) { LogHelper.WriteToFile(e.Message, "Erreur de connexion à la base, rupture d'impression"); } if (effectuerImpression == true) { int nbImp = 0; int nbImpOK = 0; string[] printer = new string[20]; // tableau qui contient les imprimantes du profil d'impression ProfilImprimante profil = new ProfilImprimante(); profil.chargementXML("Facture"); // chargement selon le type de doc string vendeur = unProfil.Substring(2, 3); vendeur = vendeur.TrimEnd(); var listeProfil = profil.getDonneeProfil(); try { foreach (string v in listeProfil[vendeur]) //lecture des imprimantes liée à un profil { printer[nbImp] = v.ToString(); nbImp++; //on incrémente le nombre d'impression à executer } } catch { printer[nbImp] = ConfigurationManager.AppSettings["ImpDef"]; //Imprimante par defaut (essai) nbImp++; } nbImp = nbImp - 1; while (nbImpOK <= nbImp) // boucle tant que le nombre d'impression fait n'à pas atteint le nombre d'impression demander { string printerName = printer[nbImpOK]; string inputFile = String.Format(@"{0}", chemin); try { //Envoi de l'ordre d'impression vers l'imprimante, les "switches" sont des arguments de la ligne de script "processor" de type GhostscriptProcessor using (GhostscriptProcessor processor = new GhostscriptProcessor()) { List<string> switches = new List<string>(); switches.Add("-empty"); switches.Add("-dPrinted"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOSAFER"); switches.Add("-dNumCopies=" + ConfigurationManager.AppSettings["NbCopieGC"]); switches.Add("-sDEVICE=" + ConfigurationManager.AppSettings["PiloteImpressionFacture"]); //switches.Add("-r360x360");//Pilote d'impression switches.Add("-sOutputFile=%printer%" + printerName); switches.Add("-f"); switches.Add(inputFile); processor.StartProcessing(switches.ToArray(), null); } nbImpOK++; } catch (Exception e) { //LogHelper.WriteToFile(e.Message, "ParseurBP" + donneEntete["Document_numero"].Trim()); LogHelper.WriteToFile(e.Message, "relevé" +donneEntete["Tiers_nocpt"].Trim()); } // incrément à chaque impression terminée } } } }