예제 #1
0
        public FormCUBordereauEnvoi(BordereauEnvoi bordereauEnvoi)
        {
            InitializeComponent();

            List <Plan> listPlans = BDDPlan.getAllPlan(sessionUser.projetModif.code_Projet);

            if (bordereauEnvoi == null)
            {
                // Création
                mode = 1;

                this.Text                        = "Ajout d'un bordereau d'envoi";
                lblGestionBE.Text                = "Ajout d'un bordereau d'envoi";
                textBoxNumeroBordereau.Text      = "";
                textBoxDesignationBordereau.Text = "";
                textBoxExemplaireBordereau.Text  = "";
                textBoxVersionBordereau.Text     = "";

                dataGridViewPlan.DataSource = null;
                //dataGridViewPlan.DataSource = BDDPlan.getAllPlan(sessionUser.projetModif.code_Projet);
                if (listPlans.Count() > 0)
                {
                    foreach (Plan plan in listPlans)
                    {
                        this.dataGridViewPlan.Rows.Add(0, plan.Code_Plan, plan.Indice, plan.Code_Projet, plan.Numero_Plan, plan.Libelle_Plan, plan.Designation, plan.Dt_Plan);
                    }
                }
            }
            else
            {
                // Modifcation
                mode = 2;
                be   = bordereauEnvoi;

                this.Text = "Modification d'un bordereau d'envoi";
                textBoxNumeroBordereau.Text      = be.Numero_Bordereau.ToString();
                textBoxDesignationBordereau.Text = be.Designation;
                textBoxExemplaireBordereau.Text  = be.Exemplaire;
                textBoxVersionBordereau.Text     = be.Version;

                dataGridViewPlan.DataSource = null;
                // dataGridViewPlan.DataSource = BDDPlan.getAllPlan(sessionUser.projetModif.code_Projet);
                if (listPlans.Count() > 0)
                {
                    foreach (Plan plan in listPlans)
                    {
                        if (BDDPlan.containsInListPlan(be.ListPlan, plan))
                        {
                            this.dataGridViewPlan.Rows.Add(1, plan.Code_Plan, plan.Indice, plan.Code_Projet, plan.Numero_Plan, plan.Libelle_Plan, plan.Designation, plan.Dt_Plan);
                        }
                        else
                        {
                            this.dataGridViewPlan.Rows.Add(0, plan.Code_Plan, plan.Indice, plan.Code_Projet, plan.Numero_Plan, plan.Libelle_Plan, plan.Designation, plan.Dt_Plan);
                        }
                    }
                }
            }
            this.dataGridViewPlan.Columns[0].ReadOnly = true;
        }
예제 #2
0
 private void LoadPlan()
 {
     // Charge tous les plans dans lstBoxPlan et met a vide toutes les txtBox
     dataGridViewPlan.DataSource = null;
     dataGridViewPlan.DataSource = BDDPlan.getAllPlan(sessionUser.projetModif.code_Projet);
 }
예제 #3
0
        public void createLPpdf(string codeProjet)
        {
            List <Plan> plans = BDDPlan.getAllPlan(codeProjet);

            if (plans.Count > 0)
            {
                try
                {
                    label_Affairesuivie.Text = "Affaire suivie par : " + referentAffaire;
                    label_signature.Text     = referentAffaire;

                    FileStream fs = new FileStream("..\\PDF\\Liste_plans.pdf", FileMode.Create);

                    Document  doc    = new Document(PageSize.A4.Rotate());
                    PdfWriter writer = PdfWriter.GetInstance(doc, fs);


                    doc.Open();

                    /* document.AddAuthor("Micke Blomquist");
                     * document.AddCreator("Sample application using iTextSharp");
                     * document.AddKeywords("PDF tutorial education");
                     * document.AddSubject("Document subject - Describing the steps creating a PDF document");
                     * document.AddTitle("Liste des plans");*/

                    PdfContentByte cb   = writer.DirectContent;
                    BaseFont       f_cb = BaseFont.CreateFont("c:\\windows\\fonts\\calibrib.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                    cb.SetFontAndSize(f_cb, 14);

                    float matrixY = 0f;

                    // LOGO
                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(global::TimeProject.Properties.Resources.logo, BaseColor.WHITE);
                    img.ScalePercent(80);
                    matrixY = doc.PageSize.Height - img.Height + 30;
                    img.SetAbsolutePosition(10, matrixY);
                    cb.AddImage(img);
                    matrixY -= 30;

                    // TEXTE
                    cb.BeginText();

                    // PERSONNE EN CHARGE DU DOSSIER
                    cb.SetTextMatrix(30, matrixY);
                    cb.ShowText(label_Affairesuivie.Text);
                    matrixY -= 20;

                    //REFERENCE DU DOSSIER -> Adresse client, afficher boite dialogue pour récupérer addr
                    cb.SetTextMatrix(30, matrixY);
                    cb.ShowText(label_refDossier.Text);
                    matrixY -= 40;

                    // TITRE DE LA TABLE
                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_listePlans.Width / 2), matrixY);
                    cb.ShowText(label_listePlans.Text);

                    // INFOS DE CONTACT
                    cb.SetFontAndSize(f_cb, 10);
                    float contactY = doc.PageSize.Height - (doc.PageSize.Height - (label_contact1.Height + label_contact2.Height
                                                                                   + label_contact3.Height + label_contact4.Height + label_contact5.Height)) + 5;

                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_contact1.Width / 2), contactY);
                    cb.ShowText(label_contact1.Text);
                    contactY -= 10;
                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_contact2.Width / 2), contactY);
                    cb.ShowText(label_contact2.Text);
                    contactY -= 10;
                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_contact3.Width / 2), contactY);
                    cb.ShowText(label_contact3.Text);
                    contactY -= 10;
                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_contact4.Width / 2), contactY);
                    cb.ShowText(label_contact4.Text);
                    contactY -= 10;
                    cb.SetTextMatrix((doc.PageSize.Width / 2) - (label_contact5.Width / 2), contactY);
                    cb.ShowText(label_contact5.Text);
                    contactY -= 10;

                    doc.Add(new Paragraph(" "));

                    float[]   largeurs = { 5, 45, 35, 15 };
                    PdfPTable tableau  = new PdfPTable(4);
                    tableau.SetWidths(largeurs);

                    PdfPCell celluleTitre1 = new PdfPCell(new Paragraph("N°"));
                    celluleTitre1.Colspan = 1;
                    tableau.AddCell(celluleTitre1);

                    PdfPCell celluleTitre2 = new PdfPCell(new Paragraph("DESIGNATION"));
                    celluleTitre2.Colspan = 1;
                    tableau.AddCell(celluleTitre2);

                    PdfPCell celluleTitre3 = new PdfPCell(new Paragraph("DATE"));
                    celluleTitre3.Colspan = 1;
                    tableau.AddCell(celluleTitre3);

                    PdfPCell celluleTitre4 = new PdfPCell(new Paragraph("INDICE"));
                    celluleTitre4.Colspan = 1;
                    tableau.AddCell(celluleTitre4);


                    plans.ForEach(delegate(Plan p){
                        tableau.AddCell(p.Numero_Plan.ToString());
                        tableau.AddCell(p.Designation);
                        tableau.AddCell(p.Dt_Plan.ToShortDateString());
                        tableau.AddCell(p.Indice.ToString());
                    });

                    tableau.SpacingBefore = doc.PageSize.Height - matrixY - 30;
                    tableau.SpacingAfter  = 30;
                    doc.Add(tableau);
                    cb.SetTextMatrix(doc.PageSize.Width - label_signature.Width - 40, doc.PageSize.Height - tableau.TotalHeight + 20);
                    cb.ShowText(label_signature.Text);

                    cb.EndText();
                    doc.Close();
                    writer.Close();
                    fs.Close();
                    MessageBox.Show("Fichier créé !");
                }
                catch (IOException e)
                {
                    MessageBox.Show("Une erreur est survenue, le fichier n'a pas été créé !");
                    Console.WriteLine(e);
                }
            }
            else
            {
                MessageBox.Show("Aucun plan à imprimer !");
            }
        }