Beispiel #1
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CTypePhase typPhase = (CTypePhase)objet;

                if (typPhase.Libelle == "")
                {
                    result.EmpileErreur(I.T("The phase type label cannot be empty|236"));
                }

                // Vérifie le profil des Utilisateurs (Responsables de Phase) possibles
                if (typPhase.ProfilResponsableTicket != null)
                {
                    if (typPhase.ProfilResponsableTicket.TypeSource != typeof(CPhaseTicket))
                    {
                        result.EmpileErreur(I.T("The element type on the profile of the person in charge is not a 'phase type'|237"));
                    }
                    if (typPhase.ProfilResponsableTicket.TypeElements != typeof(CDonneesActeurUtilisateur))
                    {
                        result.EmpileErreur(I.T("The source type  on the profile of the person in charge is  is not a 'User'|238"));
                    }
                }


                //Recupération des contacts
                List <CActeursSelonProfil> lstContacts = typPhase.ProfilsContacts;
                //Verification de la coohérence des positions des Contacts
                //lstContacts.Tri = CContactsSelonProfil.c_champOrdre;
                for (int i = 0; i < lstContacts.Count; i++)
                {
                    CActeursSelonProfil contact = (CActeursSelonProfil)lstContacts[i];
                    if (contact.Ordre != i)
                    {
                        result.EmpileErreur(I.T("The Contact @1 is at position @2 instead of position @3|203", contact.Profil.Libelle, contact.Ordre.ToString(), i.ToString()));
                    }

                    //Verification qu'il n'y a pas de redondance
                    foreach (CActeursSelonProfil contactcompar in lstContacts)
                    {
                        if (contact.Equals(contactcompar))
                        {
                            continue;
                        }

                        if (contact.Profil == contactcompar.Profil)
                        {
                            result.EmpileErreur(I.T("The Contact Profile @1 already exists|204", contact.Profil.Libelle));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
        //Ajout
        private void m_lnkAjouterProfil_LinkClicked(object sender, EventArgs e)
        {
            if (m_cmbProfils.ElementSelectionne == null)
            {
                CFormAlerte.Afficher(I.T("Select the supplier to add|203"));
                return;
            }

            CProfilElement profselec = (CProfilElement)m_cmbProfils.ElementSelectionne;

            //Test d'unicité
            foreach (ListViewItem itm in m_lvProfils.Items)
            {
                if (itm.SubItems[1].Text == profselec.Libelle)
                {
                    m_lvProfils.SelectedItems.Clear();
                    itm.Selected = true;
                    return;
                }
            }

            CActeursSelonProfil rel = new CActeursSelonProfil(m_typeelem.ContexteDonnee);

            rel.CreateNewInCurrentContexte();
            rel.Profil = profselec;
            if (m_typeelem is CTypePhase)
            {
                rel.TypePhase        = (CTypePhase)m_typeelem;
                rel.TypeIntervention = null;
            }
            else if (m_typeelem is CTypeIntervention)
            {
                rel.TypePhase        = null;
                rel.TypeIntervention = (CTypeIntervention)m_typeelem;
            }

            rel.Ordre = m_lvProfils.Items.Count;


            ListViewItem item = new ListViewItem();

            m_lvProfils.Items.Add(item);
            m_lvProfils.UpdateItemWithObject(item, rel);
            foreach (ListViewItem itemSel in m_lvProfils.SelectedItems)
            {
                itemSel.Selected = false;
            }
            item.Selected = true;
        }
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CActeursSelonProfil ActeursSelonProf = (CActeursSelonProfil)objet;

                CProfilElement prof = ActeursSelonProf.Profil;

                if (prof == null)
                {
                    result.EmpileErreur(I.T("The profile cannot be empty|263"));
                }

                if (prof.TypeElements != typeof(CActeur))
                {
                    result.EmpileErreur(I.T("The profile must return Members|264"));
                }

                if (ActeursSelonProf.TypeIntervention != null)
                {
                    if (prof.TypeSource != typeof(CIntervention))
                    {
                        result.EmpileErreur(I.T("Profile Source Elements must be Interventions|265"));
                    }
                    else if (ActeursSelonProf.TypePhase != null)
                    {
                        if (prof.TypeSource != typeof(CPhaseTicket))
                        {
                            result.EmpileErreur(I.T("Profile Source Elements must be Ticket Phases|266"));
                        }
                        else
                        {
                            result.EmpileErreur(I.T("Profie objetc Type must be defined|267"));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
        //Suppression
        private void m_lnkRemove_LinkClicked(object sender, EventArgs e)
        {
            if (m_lvProfils.SelectedItems.Count != 1)
            {
                return;
            }

            CActeursSelonProfil rel = (CActeursSelonProfil)m_lvProfils.SelectedItems[0].Tag;
            int pos = rel.Ordre;

            m_gestionnaireLstProfils.SetObjetEnCoursToNull();
            CResultAErreur result = rel.Delete();

            if (!result)
            {
                CFormAlerte.Afficher(result.Erreur);
                return;
            }

            //On met à jour les positions des éléments restant
            if (m_lvProfils.SelectedItems.Count == 1)
            {
                if (m_lvProfils.SelectedItems[0] != null)
                {
                    m_lvProfils.SelectedItems[0].Remove();
                }

                while (pos <= m_lvProfils.Items.Count - 1)
                {
                    CActeursSelonProfil reltmp = (CActeursSelonProfil)m_lvProfils.Items[pos].Tag;
                    reltmp.Ordre = pos;
                    pos++;
                }

                //MAJ ListViewItems
                m_gestionnaireLstProfils.ObjetEdite = m_typeelem.ProfilsContacts;
            }
        }
        //------------------------------------------------
        public void Init(CActeursSelonProfil acteursSelonProf, IElementAContacts elemactc)
        {
            m_elemactc                    = elemactc;
            m_acteursSelonProf            = acteursSelonProf;
            m_bAfficherInactif            = false;
            m_chkAfficherInnActif.Checked = false;

            m_lnkProfilIntervenant.Text = m_acteursSelonProf.Profil.Libelle;

            //On récupère les acteurs associés à ce profil en prenant également les innactifs
            m_acteurs = m_acteursSelonProf.GetActeurs(m_elemactc, true);

            //On trie les acteurs par rapport à leur occupation actuelle
            //m_acteurs.Sort(new CActeur_OccupationActuelleComparer());

            //On récupère le modèle si il existe
            CModeleTexte modeleUtilise = acteursSelonProf.TypeElementAActeursPossibles.ModeleTexteContacts;

            //On ne prends que les acteurs qui travaillent actuellement
            int pos = 0;

            m_nInactifs = 0;
            int largeurEtat = 10;

            foreach (CActeur acteur in m_acteurs)
            {
                CControlContact ctrl = new CControlContact();
                ctrl.m_largeurEtat = largeurEtat;
                if (m_frmConteneur != null)
                {
                    ctrl.m_frmConteneur = m_frmConteneur;
                }

                ctrl.Init(acteur, modeleUtilise);
                largeurEtat = ctrl.m_largeurEtat;

                m_nHauteurControl = ctrl.HauteurOptimale;

                if (ctrl.LargeurOptimale > m_largeurOptimale)
                {
                    m_largeurOptimale  = ctrl.LargeurOptimale + 4;
                    m_hauteurOptimale += ctrl.HauteurOptimale;
                }
                else
                {
                    m_hauteurOptimale += ctrl.HauteurOptimale;
                }

                m_panIntervenants.Controls.Add(ctrl);
                ctrl.TabIndex = pos;
                ctrl.Dock     = DockStyle.Top;
                ctrl.BringToFront();

                if (!ctrl.ActeurActif)
                {
                    m_hauteurOptimale -= ctrl.HauteurOptimale;
                    m_nInactifs++;
                    ctrl.Visible = false;
                }
            }
            m_hauteurOptimale -= 2;             //marge
            Size = new Size(m_largeurOptimale, m_hauteurOptimale);
        }