Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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 !");
            }
        }