Exemplo n.º 1
0
        void Valider()
        {
            string LibBudget   = lblLibelle.Text.Trim();
            string CodeBudget  = lblCodePeriode.Text;
            bool   OptActive   = this.OptActive.Checked;
            var    TypePeriode = (TypePeriode)lstTypePeriode.SelectedIndex;

            if (LibBudget.Length == 0)
            {
                MessageBox.Show("Libellé de la période obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodeBudget.Length == 0)
            {
                MessageBox.Show("Code de la période obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            budget_periode.Acces       = Acces;
            budget_periode.Libelle     = LibBudget;
            budget_periode.Code        = CodeBudget;
            budget_periode.TypePeriode = TypePeriode;
            budget_periode.DateDeb     = string.Format("{0:yyyyMMdd}", lblDateDebut.Value);
            budget_periode.DateFin     = string.Format("{0:yyyyMMdd}", lblDateFin.Value);
            budget_periode.Actif       = OptActive;

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_BUDGET_PERIODE, "CODE", CodeBudget)))
                {
                    budget_periode.ID = Acces.Ajouter_Element(Acces.type_BUDGET_PERIODE, budget_periode);
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_BUDGET_PERIODE, budget_periode);

                //Test du changement de code --> Impact sur les liens
                if (lblCodePeriode.Text != lblCodePeriode.Tag.ToString())
                {
                    Lien l = new Lien()
                    {
                        Acces = Acces,
                    };
                    l.MettreAJourCode(Acces.type_BUDGET_PERIODE, budget_periode.ID, budget_periode.Code);
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 2
0
        void Valider()
        {
            string LibEnveloppe  = lblLibelle.Text.Trim();
            string CodeEnveloppe = lblCodeGenere.Text;
            bool   OptActive     = this.OptActive.Checked;
            var    TypeEnveloppe = (TypeEnveloppe)lstTypeEnveloppe.SelectedIndex;

            if (LibEnveloppe.Length == 0)
            {
                MessageBox.Show("Libellé de l'enveloppe obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodeEnveloppe.Length == 0)
            {
                MessageBox.Show("Code de l'enveloppe obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            budget_enveloppe.Acces         = Acces;
            budget_enveloppe.Libelle       = LibEnveloppe;
            budget_enveloppe.Code          = CodeEnveloppe;
            budget_enveloppe.TypeEnveloppe = TypeEnveloppe;
            budget_enveloppe.Actif         = OptActive;

            TypeElement Type_Element = Acces.type_BUDGET_ENVELOPPE;

            if (Creation)
            {
                if (!(Acces.Existe_Element(Type_Element, "CODE", CodeEnveloppe)))
                {
                    budget_enveloppe.ID = Acces.Ajouter_Element(Type_Element, budget_enveloppe);
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(Type_Element, budget_enveloppe);

                //Test du changement de code --> Impact sur les liens
                if (lblCodeGenere.Text != lblCodeGenere.Tag.ToString())
                {
                    Lien l = new Lien()
                    {
                        Acces = Acces,
                    };
                    l.MettreAJourCode(Type_Element, budget_enveloppe.ID, budget_enveloppe.Code);
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        void Valider()
        {
            var LibIndicateur  = lblLibelleIndicateur.Text.Trim();
            var CodeIndicateur = lblCodeIndicateur.Text.Trim().ToUpper();
            var OptActive      = OptActiveIndicateur.Checked;
            var TypeIndicateur = (TypeIndicateur)lstTypeIndicateur.SelectedIndex;

            if (LibIndicateur.Length == 0)
            {
                MessageBox.Show("Libellé de l'indicateur obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodeIndicateur.Length == 0)
            {
                MessageBox.Show("Code de l'indicateur obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            indicateur.Acces          = Acces;
            indicateur.Libelle        = LibIndicateur;
            indicateur.Code           = CodeIndicateur;
            indicateur.TypeIndicateur = TypeIndicateur;
            indicateur.Actif          = OptActive;

            indicateur.Type = ListeType[lstType_6PO.SelectedIndex].ID;
            try { indicateur.Genre = ListeGenre[lstGenre_6PO.SelectedIndex].ID; } catch { }
            try { indicateur.Categorie = ListeCategorie[lstCateg_6PO.SelectedIndex].ID; } catch { }
            indicateur.Repartition = ListeRepartition[lstRepartition_6PO.SelectedIndex].ID;

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_INDICATEUR, "CODE", CodeIndicateur)))
                {
                    indicateur.ID = Acces.Ajouter_Element(Acces.type_INDICATEUR, indicateur);
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_INDICATEUR, indicateur);

                //Test du changement de code --> Impact sur les liens
                if (lblCodeIndicateur.Text != lblCodeIndicateur.Tag.ToString())
                {
                    Lien l = new Lien()
                    {
                        Acces = Acces,
                    };
                    l.MettreAJourCode(Acces.type_INDICATEUR, indicateur.ID, indicateur.Code);
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 4
0
        void Valider()
        {
            var LibPlan    = lblLibellePlan.Text.Trim();
            var EntetePlan = lblEntete.Text.Trim().ToUpper();
            var CodePlan   = lblCodePlan.Text;
            var Abrege     = lblCodeAbrégé.Text;
            var OptActive  = OptActivePlan.Checked;
            var TypePlan   = (TypePlan)lstTypePlan.SelectedIndex;
            var Niveau     = (NiveauPlan)lstNiveau.SelectedIndex;
            var DDeb       = lblDateDebut.Value;
            var DFin       = lblDateFin.Value;
            var OptAG      = OptAnalyseGlobale.Checked;
            var OptCom     = OptCommentaires.Checked;
            var OptGouv    = OptGouvernance.Checked;
            var OptPR      = OptPrioriteRegionale.Checked;

            int Pilote = -1;

            try { Pilote = ListePilote[lstPilote.SelectedIndex].ID; } catch { }

            if (LibPlan.Length == 0)
            {
                MessageBox.Show("Libellé du plan d'actions obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodePlan.Length == 0)
            {
                MessageBox.Show("Code du plan d'actions obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            plan.Acces    = Acces;
            plan.Libelle  = LibPlan;
            plan.Code     = CodePlan;
            plan.TypePlan = TypePlan;
            plan.Abrege   = Abrege;
            plan.Actif    = OptActive;

            plan.Pilote               = Acces.Trouver_Utilisateur(Pilote);
            plan.NiveauPlan           = Niveau;
            plan.DateDebut            = DDeb;
            plan.DateFin              = DFin;
            plan.OptAnalyseGlobale    = OptAG;
            plan.OptCommentaires      = OptCom;
            plan.OptGouvernance       = OptGouv;
            plan.OptPrioriteRegionale = OptPR;
            plan.Equipe               = ChoixEquipe.ListeSelectionId;
            plan.GroupeExterne        = lblGroupeExterne.Text.Trim();

            plan._type = lblEntete.Text;
            if (lblRef1.Text.Length > 0)
            {
                plan._ref1 = lblRef1.Text.Trim().ToUpper();
            }
            if (lblRef2.Text.Length > 0)
            {
                plan._ref2 = string.Format("{0:00}", int.Parse(lblRef2.Text));
            }
            if (lblOS.Text.Length > 0)
            {
                plan._os = string.Format("{0:00}", int.Parse(lblOS.Text));
            }
            if (lblOG.Text.Length > 0)
            {
                plan._og = string.Format("{0:00}", int.Parse(lblOG.Text));
            }

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_PLAN, "CODE", plan.Code)))
                {
                    plan.ID = Acces.Ajouter_Element(Acces.type_PLAN, plan);
                }
                else
                {
                    MessageBox.Show("Plan existant (Code)", "Erreur"); return;
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_PLAN, plan);
            }

            //Test du changement de code --> Impact sur les liens
            if (lblCodePlan.Text != lblCodePlan.Tag.ToString())
            {
                Lien l = new Lien()
                {
                    Acces = Acces,
                };
                l.MettreAJourCode(Acces.type_PLAN, plan.ID, plan.Code);
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        void Valider()
        {
            var LibObjectif  = lblLibelleObjectif.Text.Trim();
            var CodeObjectif = lblCodeObjectif.Text.Trim().ToUpper();
            var OptActive    = OptActiveObjectif.Checked;
            var TypeObjectif = (TypeObjectif)lstTypeObjectif.SelectedIndex;

            string Statut    = lstStatut.Text;
            int    Statut_ID = Acces.Trouver_TableValeur_ID("STATUT", Statut);

            var Meteo = (Meteo)lstMeteo.SelectedIndex;
            var Tx    = (TxAvancement)lstTx.SelectedIndex;

            int Pilote = -1;

            try { Pilote = ListePilote[lstPilote.SelectedIndex].ID; } catch { }
            var DDeb = lblDateDebut.Value;
            var DFin = lblDateFin.Value;

            var Description = lblDescription.Text;
            var Analyse     = lblAnalyseQualitative.Text;

            if (LibObjectif.Length == 0)
            {
                MessageBox.Show("Libellé de l'objectif obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodeObjectif.Length == 0)
            {
                MessageBox.Show("Code du plan d'actions obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            //Vérifie si un utiilisateur n'a pas plusieurs profils
            List <int> ListeChoix = new List <int>();

            foreach (int i in ChoixRole6PO_Copilote.ListeSelectionId)
            {
                ListeChoix.Add(i);
            }
            foreach (int i in ChoixRole6PO_Manager.ListeSelectionId)
            {
                ListeChoix.Add(i);
            }
            foreach (int i in ChoixRole6PO_Consultation.ListeSelectionId)
            {
                ListeChoix.Add(i);
            }

            List <int> distinct = ListeChoix.Distinct().ToList();

            if (ListeChoix.Count() != distinct.Count())
            {
                MessageBox.Show("Un utilisateur ne peut pas posséder 2 rôles dans 6PO pour cet objectif.", "Erreur");
                return;
            }

            objectif.Libelle      = LibObjectif;
            objectif.Code         = CodeObjectif;
            objectif.TypeObjectif = TypeObjectif;
            objectif.Actif        = OptActive;

            objectif.Pilote       = Acces.Trouver_Utilisateur(Pilote);
            objectif.Statut       = Statut_ID;
            objectif.Meteo        = Meteo;
            objectif.TxAvancement = Tx;
            objectif.DateDebut    = DDeb;
            objectif.DateFin      = DFin;

            objectif.Description        = Description;
            objectif.AnalyseQualitative = Analyse;

            objectif.Role_6PO_CoPilote     = ChoixRole6PO_Copilote.ListeSelectionId;
            objectif.Role_6PO_Manager      = ChoixRole6PO_Manager.ListeSelectionId;
            objectif.Role_6PO_Consultation = ChoixRole6PO_Consultation.ListeSelectionId;

            objectif._codeplan = lblPlan.Text;
            if (lblAxe.Text.Length > 0)
            {
                objectif._axe = string.Format("{0:00}", int.Parse(lblAxe.Text));
            }
            if (lblOS.Text.Length > 0)
            {
                objectif._os = string.Format("{0:00}", int.Parse(lblOS.Text));
            }
            if (lblOG.Text.Length > 0)
            {
                objectif._og = string.Format("{0:00}", int.Parse(lblOG.Text));
            }
            if (lblOP.Text.Length > 0)
            {
                objectif._op = string.Format("{0:00}", int.Parse(lblOP.Text));
            }
            objectif._cpl = lblAutre.Text;

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_OBJECTIF, "CODE", CodeObjectif)))
                {
                    objectif.ID = Acces.Ajouter_Element(Acces.type_OBJECTIF, objectif);

                    //Création du lien avec le parent
                    if (!(objectifParent is null))
                    {
                        Lien l = new Lien()
                        {
                            Acces = Acces,
                        };

                        l.element0_type = Acces.type_PLAN.id;
                        l.element0_id   = 1;
                        l.element0_code = "SYSTEME";
                        l.element1_type = Acces.type_OBJECTIF.id;
                        l.element1_id   = objectifParent.ID;
                        l.element1_code = objectifParent.Code;
                        l.element2_type = Acces.type_OBJECTIF.id;
                        l.element2_id   = objectif.ID;
                        l.element2_code = objectif.Code;
                        l.Ajouter();
                        Acces.Ajouter_Lien(l);
                        Creation = false;
                    }
                }
                else
                {
                    MessageBox.Show("L'objectif existe déjà (code identique).", "Erreur"); return;
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_OBJECTIF, objectif);
            }

            //Test du changement de code --> Impact sur les liens
            if (lblCodeObjectif.Text != lblCodeObjectif.Tag.ToString())
            {
                Lien l = new Lien();
                l.Acces = Acces;
                l.MettreAJourCode(Acces.type_OBJECTIF, objectif.ID, objectif.Code);
            }

            OnRaise_Evt_Enregistrer(new evt_Enregistrer(this.Tag.ToString()));
            Creation            = false;
            lblEnregistrer.Text = "Enregistré " + string.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Procédure lancée à l'enregistrement de la fiche
        /// </summary>
        void Valider()
        {
            //Onglet Informations générales
            var LibAction  = lblLibelleAction.Text.Trim();
            var CodeAction = lblCodeAction.Text.Trim().ToUpper();
            var OptActive  = OptActiveAction.Checked;
            var TypeAction = (TypeAction)lstTypeAction.SelectedIndex;

            if (LibAction.Length == 0)
            {
                MessageBox.Show("Libellé de l'action obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (CodeAction.Length < 5)
            {
                MessageBox.Show("Code de l'action obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            string Statut    = lstStatut.Text;
            int    Statut_ID = Acces.Trouver_TableValeur_ID("STATUT", Statut);
            int    Pilote    = -1;

            try { Pilote = ListePilote[lstPilote.SelectedIndex].ID; } catch { }

            action.Libelle          = LibAction;
            action.Code             = CodeAction;
            action.TypeAction       = TypeAction;
            action.Actif            = OptActive;
            action.Pilote           = Acces.Trouver_Utilisateur(Pilote);
            action.Statut           = Statut_ID;
            action.ActionPhare      = optActionPhare.Checked;
            action.OrdreActionPhare = Acces.Trouver_TableValeur_ID("ORDRE_ACTION_PHARE", lstOrdrePriorite.Text.ToString());
            action.Validation       = Acces.Trouver_TableValeur_ID("VALIDATION_INTERNE", lstNiveauValidation.Text);

            action.Description = lblDescription.Text.Trim();

            action._type     = ""; action._codeplan = "";
            action._axe      = ""; action._os = ""; action._og = ""; action._op = "";
            action._cpl      = ""; action._ordreact = "";
            action._annee    = ""; action._direction = ""; action._reference = "";
            action._ordreope = "";

            if ((TypeAction)lstTypeAction.SelectedIndex == TypeAction.DOSSIER)
            {
                action._type = "AXX";
            }
            if ((TypeAction)lstTypeAction.SelectedIndex == TypeAction.ACTION)
            {
                action._type = "ACT";
            }
            if ((TypeAction)lstTypeAction.SelectedIndex == TypeAction.OPERATION)
            {
                action._type = "OPE";
            }

            try
            {
                action._codeplan = lblPlanACT.Text.ToUpper().Trim();
                if (lblAxeACT.Text.Trim().Length > 0)
                {
                    action._axe = string.Format("{0:00}", int.Parse(lblAxeACT.Text));
                }
                if (lblOSACT.Text.Trim().Length > 0)
                {
                    action._os = string.Format("{0:00}", int.Parse(lblOSACT.Text));
                }
                if (lblOGACT.Text.Trim().Length > 0)
                {
                    action._og = string.Format("{0:00}", int.Parse(lblOGACT.Text));
                }
                if (lblOPACT.Text.Trim().Length > 0)
                {
                    action._op = string.Format("{0:00}", int.Parse(lblOPACT.Text));
                }
                if (lblAutreACT.Text.Trim().Length > 0)
                {
                    action._cpl = lblAutreACT.Text;
                }
                if (lblOrdreACT.Text.Trim().Length > 0)
                {
                    action._ordreact = string.Format("{0:000}", int.Parse(lblOrdreACT.Text));
                }

                if (action._type == "OPE")
                {
                    if (lblAnnéeOPE.Text.Trim().Length > 0)
                    {
                        action._annee = lblAnnéeOPE.Text;
                    }
                    if (lblDirectionOPE.Text.Trim().Length > 0)
                    {
                        action._direction = lblDirectionOPE.Text;
                    }
                    if (lblRefOPE.Text.Trim().Length > 0)
                    {
                        action._reference = lblRefOPE.Text;
                    }
                    if (lblOrdreOPE.Text.Trim().Length > 0)
                    {
                        action._ordreope = string.Format("{0:000}", int.Parse(lblOrdreOPE.Text));
                    }
                }
            }
            catch { }

            //Onglet Public, partenaires
            action.PublicCible = ChoixPublicCible.ListeSelectionId;
            action.Territoire  = lblTerritoire.Text.Trim();
            action.Partenaire  = ChoixPartenaireInstitutionnel.ListeSelectionId;
            action.Usager      = ChoixUsager.ListeSelectionId;

            //Onglet Moyens
            action.StructurePorteuse = ChoixStructurePorteuse.ListeSelectionId;
            action.Acteur            = ChoixActeur.ListeSelectionId;
            action.Levier            = ChoixLevier.ListeSelectionId;
            action.CoutFinancier     = lblCoutFinancier.Text.Trim();
            action.FinancementFIR    = optFIR.Checked;
            action.Mt_2018           = lblMontant_2018.Text.Trim();
            action.Mt_2019           = lblMontant_2019.Text.Trim();
            action.Mt_2020           = lblMontant_2020.Text.Trim();
            action.Mt_2021           = lblMontant_2021.Text.Trim();
            action.Mt_2022           = lblMontant_2022.Text.Trim();
            action.Mt_2023           = lblMontant_2023.Text.Trim();
            action.Mt_Total          = lblMontant_Total.Text.Trim();

            //Onglet Suivi et évaluation
            action.ResultatLivrable = lblResultatLivrable.Text.Trim();
            action.NbPersImpact     = lblNbPersImpact.Text.Trim();
            action.NbActeurMobilise = lblNbActeur.Text.Trim();
            action.IndicResultat    = lblIndicResultat.Text.Trim();
            action.IndicMoyen       = lblIndicMoyen.Text.Trim();

            //Onglet Calendrier, responsabilités
            action.AnneeMiseOeuvre  = ChoixAnnee.ListeSelectionId;
            action.DirectionPilote  = ChoixDirectionPilote.ListeSelectionId;
            action.DirectionAssocie = ChoixDirectionAssocie.ListeSelectionId;
            action.Equipe           = ChoixEquipe.ListeSelectionId;

            //Onglet Liens
            action.LienPlan     = ChoixLienPlan.ListeSelectionId;
            action.LienParcours = ChoixLienParcours.ListeSelectionId;
            action.LienSecteur  = ChoixLienSecteur.ListeSelectionId;

            //Onglet Priorités CTS
            action.TSante = ChoixTSANTE.ListeSelectionId;
            List <int> listePrio = new List <int>();

            foreach (int k in ChoixCTS591.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            foreach (int k in ChoixCTS592.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            foreach (int k in ChoixCTS62.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            foreach (int k in ChoixCTS80.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            foreach (int k in ChoixCTS02.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            foreach (int k in ChoixCTS60.ListeSelectionId)
            {
                listePrio.Add(k);
            }
            action.Priorite_CTS = listePrio;

            //Onglet 6PO
            action.DateDebut          = lblDateDebut.Value;
            action.DateFin            = lblDateFin.Value;
            action.Meteo              = (Meteo)lstMeteo.SelectedIndex;
            action.TxAvancement       = (TxAvancement)lstTx.SelectedIndex;
            action.ActionInnovante    = OptActionInnovante.Checked;
            action.AnalyseQualitative = lblAnalyseQualitative.Text.Trim();
            action.ReductionInegalite = lblReductionInegalite.Text.Trim();

            //Onglet Rôle 6PO
            action.Role_6PO_CoPilote     = ChoixRole6PO_Copilote.ListeSelectionId;
            action.Role_6PO_Manager      = ChoixRole6PO_Manager.ListeSelectionId;
            action.Role_6PO_Consultation = ChoixRole6PO_Consultation.ListeSelectionId;

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_ACTION, "CODE", CodeAction)))
                {
                    action.ID = Acces.Ajouter_Element(Acces.type_ACTION, action);

                    if (actionParent != null)
                    {
                        //Création du lien avec le parent
                        Lien l = new Lien()
                        {
                            Acces = Acces,
                        };
                        l.element0_type = Acces.type_PLAN.id;
                        l.element0_id   = 1;
                        l.element0_code = "SYSTEME";
                        l.element1_type = Acces.type_ACTION.id;
                        l.element1_id   = actionParent.ID;
                        l.element1_code = actionParent.Code;
                        l.element2_type = Acces.type_ACTION.id;
                        l.element2_id   = action.ID;
                        l.element2_code = action.Code;
                        l.Ajouter();
                        Acces.Ajouter_Lien(l);
                        Creation = false;
                    }

                    Acces.Enregistrer(Acces.type_ACTION, action);
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_ACTION, action);
            }

            //Test du changement de code --> Impact sur les liens
            if (lblCodeAction.Text != lblCodeAction.Tag.ToString())
            {
                Lien l = new Lien()
                {
                    Acces = Acces
                };
                l.MettreAJourCode(Acces.type_ACTION, action.ID, action.Code);
            }

            OnRaise_Evt_Enregistrer(new evt_Enregistrer(this.Tag.ToString())); //Déclenche l'événement de modification
            Creation            = false;
            lblEnregistrer.Text = "Enregistré " + string.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now);
        }
Exemplo n.º 7
0
        void Valider()
        {
            string LibVersion  = lblLibelleVersion.Text;//= lblLibelle.Text.Trim();
            string CodeVersion = lblCodeGenere.Text;
            var    TypeBudget  = (TypeBudget)lstTypeBudget.SelectedIndex;

            if (LibVersion.Length == 0)
            {
                MessageBox.Show("Libellé de la version obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (lstTypeBudget.SelectedIndex < 0)
            {
                MessageBox.Show("Type de budget obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (lstBudget.SelectedIndex < 0)
            {
                MessageBox.Show("Budget obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (lblRef2.Text.Length == 0)
            {
                MessageBox.Show("Référence de la version obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            Budget budget = listeBudget[lstBudget.SelectedIndex];

            budget_version.Acces      = Acces;
            budget_version.Libelle    = LibVersion;
            budget_version.Code       = CodeVersion;
            budget_version.TypeBudget = (int)TypeBudget;

            budget_version.Budget_ID       = listeBudget[lstBudget.SelectedIndex].ID;
            budget_version.DateDeb         = string.Format("{0:yyyyMMdd}", lblDateDebut.Value);
            budget_version.DateFin         = string.Format("{0:yyyyMMdd}", lblDateFin.Value);
            budget_version.Enveloppe       = budget.Enveloppe;
            budget_version.Periode         = budget.Periode;
            budget_version.DateDeb         = fct.ConvertiDateToString(lblDateDebut.Value);
            budget_version.DateFin         = fct.ConvertiDateToString(lblDateFin.Value);
            budget_version.Actif           = OptActive.Checked;
            budget_version.VersionTravail  = optVersionTravail.Checked;
            budget_version.ReferenceBudget = optReference.Checked;

            TypeElement typeElement = Acces.type_BUDGET_VERSION;

            if (Creation)
            {
                if (!(Acces.Existe_Element(typeElement, "CODE", CodeVersion)))
                {
                    budget_version.ID = Acces.Ajouter_Element(typeElement, budget_version);
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(typeElement, budget_version);

                //Test du changement de code --> Impact sur les liens
                if (lblCodeGenere.Text != lblCodeGenere.Tag.ToString())
                {
                    Lien l = new Lien()
                    {
                        Acces = Acces,
                    };
                    l.MettreAJourCode(typeElement, budget_version.ID, budget_version.Code);
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 8
0
        void Valider()
        {
            if (lstBudget.SelectedIndex < 0)
            {
                MessageBox.Show("Budget ?"); return;
            }
            if (lstORG.SelectedIndex < 0)
            {
                MessageBox.Show("ORG ?"); return;
            }
            if (lstGEO.SelectedIndex < 0)
            {
                MessageBox.Show("GEO ?"); return;
            }
            //if (lstPeriode.SelectedIndex < 0) { MessageBox.Show("Période ?"); return; }

            Budget budget = listeBudget[lstBudget.SelectedIndex];

            int    budget_id    = budget.ID;
            string LibBudget    = lblLibelleBudget.Text.Trim();
            string Codebudget   = lblCodeGenere.Text.Trim().ToUpper();
            int    Enveloppe    = budget.Enveloppe;
            int    Periode      = budget.Periode;
            string DateDeb      = budget.DateDeb;
            string DateFin      = budget.DateFin;
            bool   OptActive    = OptActiveBudget.Checked;
            bool   OptLimitatif = optLimitatif.Checked;
            var    TypeMontant  = (TypeMontant)lstTypeMontant.SelectedIndex;
            var    TypeFlux     = (TypeFlux)lstTypeFlux.SelectedIndex;
            int    ORG          = listeORG[lstORG.SelectedIndex].ID;
            int    GEO          = listeGEO[lstGEO.SelectedIndex].ID;

            if (LibBudget.Length == 0)
            {
                MessageBox.Show("Libellé du budget obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (Codebudget.Length == 0)
            {
                MessageBox.Show("Code du budget obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            budget_ligne.Console     = Console;
            budget_ligne.Acces       = Acces;
            budget_ligne.Budget_ID   = listeBudget[lstBudget.SelectedIndex].ID;
            budget_ligne.Libelle     = LibBudget;
            budget_ligne.Code        = Codebudget;
            budget_ligne.Enveloppe   = Enveloppe;
            budget_ligne.Periode     = Periode;
            budget_ligne.DateDeb     = string.Format("{0:yyyyMMdd}", lblDateDebut.Value);
            budget_ligne.DateFin     = string.Format("{0:yyyyMMdd}", lblDateFin.Value);
            budget_ligne.Actif       = OptActive;
            budget_ligne.Budget_ORG  = ORG;
            budget_ligne.Budget_GEO  = GEO;
            budget_ligne.TypeMontant = TypeMontant;
            budget_ligne.TypeFlux    = TypeFlux;

            List <int> ListeChoix = new List <int>();

            foreach (int i in ChoixCompte.ListeSelectionId)
            {
                ListeChoix.Add(i);
            }
            budget_ligne.ListeCompte = ListeChoix;

            TypeElement typeElement = Acces.type_BUDGET_LIGNE;

            if (Creation)
            {
                if (!(Acces.Existe_Element(typeElement, "CODE", Codebudget)))
                {
                    budget_ligne.ID = Acces.Ajouter_Element(typeElement, budget_ligne);
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(typeElement, budget_ligne);

                //Test du changement de code --> Impact sur les liens
                if (lblCodeGenere.Text != lblCodeGenere.Tag.ToString())
                {
                    Lien l = new Lien()
                    {
                        Acces = Acces,
                    };
                    l.MettreAJourCode(typeElement, budget_ligne.ID, budget_ligne.Code);
                }
            }

            this.DialogResult = DialogResult.OK;
        }