private void btn_ModificationPlan_Click(object sender, EventArgs e) { Plan plan; int maxIndice = 0, nbLigne = 0; if (dataGridViewPlan.Rows.Count > 0) { plan = new Plan(dataGridViewPlan.CurrentRow.Cells[0].Value.ToString(), Convert.ToInt32(dataGridViewPlan.CurrentRow.Cells[1].Value), dataGridViewPlan.CurrentRow.Cells[2].Value.ToString(), Convert.ToInt32(dataGridViewPlan.CurrentRow.Cells[3].Value), dataGridViewPlan.CurrentRow.Cells[4].Value.ToString(), dataGridViewPlan.CurrentRow.Cells[5].Value.ToString(), Convert.ToDateTime(dataGridViewPlan.CurrentRow.Cells[6].Value)); maxIndice = BDDPlan.RecupereDernierIndice(plan.Code_Plan); if (maxIndice > 0) { maxIndice = maxIndice + 1; nbLigne = BDDPlan.CreatePlan(plan.Code_Plan, maxIndice.ToString(), plan.Code_Projet, plan.Numero_Plan.ToString(), plan.Libelle_Plan, plan.Designation, plan.Dt_Plan.ToString()); if (nbLigne != 0) { MessageBox.Show("Le plan à bien été ajouté !"); } else { MessageBox.Show("Erreur lors de l'ajout du plan."); } } else { MessageBox.Show("Erreur dans la recherche de l'indice."); } LoadPlan(); } }
private void btn_SuppressionPlan_Click(object sender, EventArgs e) { //Plan plan; //int maxIndice = 0, nbLigne = 0; //if (lstBoxPlan.Items.Count > 0) //{ // plan = (Plan)lstBoxPlan.SelectedItem; // maxIndice = BDDPlan.RecupereDernierIndice(plan.Code_Plan); // if (maxIndice > 0) // { // nbLigne = BDDPlan.DeletePlan(plan.Code_Plan, maxIndice.ToString()); // if (nbLigne != 0) // { // MessageBox.Show("Le plan à bien été Supprimé !"); // } // else // { // MessageBox.Show("Erreur lors de la suppression du plan."); // } // } // else // { // MessageBox.Show("Erreur dans la recherche de l'indice."); // } // LoadPlan(); Plan plan; int maxIndice = 0, nbLigne = 0; if (dataGridViewPlan.Rows.Count > 0) { plan = new Plan(dataGridViewPlan.CurrentRow.Cells[0].Value.ToString(), Convert.ToInt32(dataGridViewPlan.CurrentRow.Cells[1].Value), dataGridViewPlan.CurrentRow.Cells[2].Value.ToString(), Convert.ToInt32(dataGridViewPlan.CurrentRow.Cells[3].Value), dataGridViewPlan.CurrentRow.Cells[4].Value.ToString(), dataGridViewPlan.CurrentRow.Cells[5].Value.ToString(), Convert.ToDateTime(dataGridViewPlan.CurrentRow.Cells[6].Value)); maxIndice = BDDPlan.RecupereDernierIndice(plan.Code_Plan); if (maxIndice > 0) { nbLigne = BDDPlan.DeletePlan(plan.Code_Plan, maxIndice.ToString()); if (nbLigne != 0) { MessageBox.Show("Le plan à bien été Supprimé !"); } else { MessageBox.Show("Erreur lors de la suppression du plan."); } } else { MessageBox.Show("Erreur dans la recherche de l'indice."); } LoadPlan(); } }
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; }
private void buttonValiderPlan_Click(object sender, EventArgs e) { string sNumPlan = "", libellePlan = "", designationPlan = "", codePlan = "", messErreur = ""; int numPlan = 0, nbLigne = 0; DateTime datePlan; Plan plan; sNumPlan = textBoxLibellePlan.Text; libellePlan = textBoxLibellePlan.Text; designationPlan = textBoxDesignation.Text; datePlan = dateTimePickerDatePlan.Value; if (sNumPlan != "" && libellePlan != "" && designationPlan != "" && datePlan != null) { try { numPlan = Convert.ToInt32(textBoxNumeroPlan.Text); } catch (Exception err) { messErreur = (err.Message); } if (messErreur == "") { // Traitement codePlan = sessionUser.projetModif.code_Projet + numPlan.ToString(); plan = BDDPlan.DejaExistePlan(codePlan, 1, sessionUser.projetModif.code_Projet); if (plan == null) { nbLigne = BDDPlan.CreatePlan(codePlan, "1", sessionUser.projetModif.code_Projet, numPlan.ToString(), libellePlan, designationPlan, datePlan.ToString()); } if (nbLigne != 0) { MessageBox.Show("Le plan à bien été ajouté !"); this.Close(); } else { MessageBox.Show("Erreur lors de l'ajout du plan."); } } else { MessageBox.Show(messErreur); messErreur = ""; } } else { MessageBox.Show("Veuillez remplir tout les champs !"); } }
private void btn_ValidationBE_Click(object sender, EventArgs e) { BordereauEnvoi be; if (dataGridViewBE.Rows.Count > 0) { be = new BordereauEnvoi(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[1].Value), dataGridViewBE.CurrentRow.Cells[2].Value.ToString(), dataGridViewBE.CurrentRow.Cells[4].Value.ToString(), dataGridViewBE.CurrentRow.Cells[5].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[6].Value), BDDPlan.getAllPlanBE(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), sessionUser.projetModif.code_Projet)); if (be.Etat == 1) { // Validation bordereau envoi BDDBordereauEnvoi.UpdateBordereauEnvoiValidation(be.Code_Bordereau, 2); foreach (Plan plan in be.ListPlan) { // Valid_Archi BDDValidArchi.CreateVA(be.Code_Bordereau, plan.Code_Plan, plan.Indice, 1); // Valid_BC BDDValidBC.CreateVBC(be.Code_Bordereau, plan.Code_Plan, plan.Indice, 1); } LoadBE(); } else { MessageBox.Show("Le bordereau " + be.Code_Bordereau + " a déjà été validé !"); } } }
private void btn_EditionPDF_Click(object sender, EventArgs e) { BordereauEnvoi be = new BordereauEnvoi(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[1].Value), dataGridViewBE.CurrentRow.Cells[2].Value.ToString(), dataGridViewBE.CurrentRow.Cells[4].Value.ToString(), dataGridViewBE.CurrentRow.Cells[5].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[6].Value), BDDPlan.getAllPlanBE(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), sessionUser.projetModif.code_Projet)); FormAdresseBordereau fAd = new FormAdresseBordereau(be); fAd.ShowDialog(); }
private void btn_ModificationBE_Click(object sender, EventArgs e) { BordereauEnvoi be; if (dataGridViewBE.Rows.Count > 0) { be = new BordereauEnvoi(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[1].Value), dataGridViewBE.CurrentRow.Cells[2].Value.ToString(), dataGridViewBE.CurrentRow.Cells[4].Value.ToString(), dataGridViewBE.CurrentRow.Cells[5].Value.ToString(), Convert.ToInt32(dataGridViewBE.CurrentRow.Cells[6].Value), BDDPlan.getAllPlanBE(dataGridViewBE.CurrentRow.Cells[0].Value.ToString(), sessionUser.projetModif.code_Projet)); if (be.Etat == 1) { FormCUBordereauEnvoi f1 = new FormCUBordereauEnvoi(be); this.Hide(); f1.ShowDialog(); LoadBE(); this.Show(); } else { MessageBox.Show("Le bordereau " + be.Code_Bordereau + " a été validé et ne peut plus être modifié !"); } } }
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); }
private void btn_ListeDernierIndice_Click(object sender, EventArgs e) { dataGridViewPlan.DataSource = null; dataGridViewPlan.DataSource = BDDPlan.GetPlanWithMaxIndice(sessionUser.projetModif.code_Projet); }
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 !"); } }
private void buttonValiderBE_Click(object sender, EventArgs e) { string codeBordereau = "", designation = "", exemplaire = "", version = "", messErreur = ""; int numeroBordereau = 0, nbLigne = 0, nbdtgv = 0; List <Plan> listPlan = new List <Plan>(); if (textBoxNumeroBordereau.Text != "" && textBoxDesignationBordereau.Text != "" && textBoxExemplaireBordereau.Text != "" && textBoxVersionBordereau.Text != "") { try { numeroBordereau = Convert.ToInt32(textBoxNumeroBordereau.Text); } catch (Exception err) { messErreur = (err.Message); } foreach (DataGridViewRow row in dataGridViewPlan.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { //nbLigne = BDDBordPlan.CreateBordPlan(codeBordereau, row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value)); Plan plan = new Plan(row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value), row.Cells[3].Value.ToString(), Convert.ToInt32(row.Cells[4].Value), row.Cells[5].Value.ToString(), row.Cells[6].Value.ToString(), Convert.ToDateTime(row.Cells[7].Value)); listPlan.Add(plan); } } foreach (DataGridViewRow row in dataGridViewPlan.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Plan plan = new Plan(row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value), row.Cells[3].Value.ToString(), Convert.ToInt32(row.Cells[4].Value), row.Cells[5].Value.ToString(), row.Cells[6].Value.ToString(), Convert.ToDateTime(row.Cells[7].Value)); if (BDDPlan.containsInListPlanByCode(listPlan, plan)) { messErreur += "Veuillez à ne pas cocher le même plan : '" + plan.Code_Plan + "' !\n"; } } } if (messErreur == "") { designation = textBoxDesignationBordereau.Text; exemplaire = textBoxExemplaireBordereau.Text; version = textBoxVersionBordereau.Text; if (this.mode == 1) { // On créé le bordereau_envoi codeBordereau = BDDBordereauEnvoi.GenerateCodeBE(sessionUser.projetModif.code_Projet); nbLigne = BDDBordereauEnvoi.CreateBordereauEnvoi(sessionUser.projetModif.code_Projet, codeBordereau, numeroBordereau, designation, exemplaire, version, 1); if (nbLigne != 0) { // On créé le bord_projet nbLigne = BDDBordProjet.CreateBordereauProjet(sessionUser.projetModif.code_Projet, codeBordereau); // On créé le bord_plan foreach (DataGridViewRow row in dataGridViewPlan.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { nbLigne = BDDBordPlan.CreateBordPlan(codeBordereau, row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value)); } } MessageBox.Show("Le bordereau à bien été ajouté !"); this.Close(); } else { MessageBox.Show("Erreur lors de l'ajout du bordereau."); } } else { // On modifie le bordereau_envoi codeBordereau = this.be.Code_Bordereau; // Update BE nbLigne = BDDBordereauEnvoi.UpdateBordereauEnvoi(sessionUser.projetModif.code_Projet, codeBordereau, numeroBordereau, designation, exemplaire, version); // Update Bord_Plan foreach (DataGridViewRow row in dataGridViewPlan.Rows) { Plan plan = new Plan(row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value), row.Cells[3].Value.ToString(), Convert.ToInt32(row.Cells[4].Value), row.Cells[5].Value.ToString(), row.Cells[6].Value.ToString(), Convert.ToDateTime(row.Cells[7].Value)); // Si le plan est coché if (Convert.ToBoolean(row.Cells[0].Value)) { if (!BDDPlan.containsInListPlan(be.ListPlan, plan)) { // On ajoute un bord plan nbLigne = BDDBordPlan.CreateBordPlan(codeBordereau, row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value)); } } else { if (BDDPlan.containsInListPlan(be.ListPlan, plan)) { // DELETE nbLigne = BDDBordPlan.DeleteBordPlan(codeBordereau, row.Cells[1].Value.ToString(), Convert.ToInt32(row.Cells[2].Value)); } } } MessageBox.Show("Le bordereau à bien été modifié !"); this.Close(); } } else { MessageBox.Show(messErreur); messErreur = ""; } } else { MessageBox.Show("Veuillez remplir tout les champs !"); } }