Beispiel #1
0
        void Valider()
        {
            var CodeUser    = lblCodeUser.Text.Trim();
            var NomUser     = lblNomUser.Text.Trim().ToUpper();
            var PrenomUser  = lblPrenomUser.Text.Trim().ToUpper();
            var Mail        = lblMailUser.Text.Trim();
            var OptActive   = OptActiveUser.Checked;
            var TypeLicence = (TypeLicence)lstLicenceUser.SelectedIndex;
            var TypeUser    = (TypeUtilisateur)lstTypeUser.SelectedIndex;

            if (CodeUser.Length == 0)
            {
                MessageBox.Show("Code d'utilisateur obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            if (NomUser.Length == 0 || PrenomUser.Length == 0)
            {
                MessageBox.Show("Nom et prénom obligatoire", "Erreur", MessageBoxButtons.OK);
                return;
            }

            User.Acces           = Acces;
            User.Code            = CodeUser;
            User.Nom             = NomUser;
            User.Prenom          = PrenomUser;
            User.Mail            = Mail;
            User.TypeUtilisateur = TypeUser;
            User.TypeLicence     = TypeLicence;
            User.Actif           = OptActive;
            User.Direction       = Acces.Trouver_TableValeur_ID("DIRECTION_METIER", lstDirection.Text);

            if (Creation)
            {
                if (!(Acces.Existe_Element(Acces.type_UTILISATEUR, "CODE", CodeUser)))
                {
                    Acces.Ajouter_Element(Acces.type_UTILISATEUR, User);
                }
            }
            else
            {
                Acces.Enregistrer(Acces.type_UTILISATEUR, User);
            }

            this.DialogResult = DialogResult.OK;
        }
Beispiel #2
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);
        }