Exemple #1
0
        /// ////////////////////////////////////////////////////
        private void OnClickMenu(object sender, LinkLabelLinkClickedEventArgs args)
        {
            if (DesignMode)
            {
                return;
            }
            if (!(sender is Control))
            {
                return;
            }
            CMenuCustom menu = (CMenuCustom)args.Link.LinkData;

            if (menu.ListeMenusFils.Count == 0)
            {
                CResultAErreur result = CExecuteurActionSur2iLink.ExecuteAction(sender, menu.Action, null);
                if (!result)
                {
                    CFormAlerte.Afficher(result.Erreur);
                }
            }
            else
            {
                //Crée le menu
                CreateSousMenu(m_sousMenu.MenuItems, menu);
                m_sousMenu.Show((Control)sender, new Point(0, ((Control)sender).Height));
            }
        }
Exemple #2
0
        /// ////////////////////////////////////////////////////
        private bool ShouldAffiche(CMenuCustom menu)
        {
            bool bAfficheGroupes = false;
            bool bAfficheProfils = false;
            bool bAffiche        = true;

            CDbKey[] keysGroupes = menu.KeysGroupes;
            if (keysGroupes != null && keysGroupes.Length > 0)
            {
                bAffiche = false;
                //TESTDBKEYOK
                CDbKey[] lstGroupesSession = CTimosApp.SessionClient.GetInfoUtilisateur().ListeKeysGroupes;
                foreach (CDbKey keyVoyant in keysGroupes)
                {
                    foreach (CDbKey key in lstGroupesSession)
                    {
                        if (keyVoyant == key)
                        {
                            bAfficheGroupes = true;
                        }
                    }
                }
            }

            //TESTDBKEYOK
            CDbKey[] keysProfils = menu.KeysProfils;
            if (keysProfils != null && keysProfils.Length > 0)
            {
                bAffiche = false;
                CDonneesActeurUtilisateur user = CDonneesActeurUtilisateur.GetUserForSession(
                    CTimosApp.SessionClient.IdSession,
                    m_menuCustom.ContexteDonnee);
                foreach (CDbKey keyVoyant in keysProfils)
                {
                    CProfilUtilisateur profilVoyant = new CProfilUtilisateur(m_menuCustom.ContexteDonnee);
                    if (profilVoyant.ReadIfExists(keyVoyant))
                    {
                        if (user.IsInProfil(profilVoyant))
                        {
                            bAfficheGroupes = true;
                        }
                    }
                }
            }

            if (!bAffiche)
            {
                return(bAfficheGroupes || bAfficheProfils);
            }

            return(bAffiche);
        }
Exemple #3
0
        /// //////////////////////////////////////
        private void m_btnEdit_Click(object sender, System.EventArgs e)
        {
            if (m_menuCustom == null)
            {
                m_menuCustom = new CMenuCustom(CSc2iWin32DataClient.ContexteCourant);
                m_menuCustom.CreateNew();
                m_menuCustom.Libelle = I.T("Main menu|716");
            }
            CFormEditionMenuCustom form = new CFormEditionMenuCustom(m_menuCustom);

            form.AfterValideModification += new ObjetDonneeEventHandler(AfterModifieMenu);
            CTimosApp.Navigateur.AffichePage(form);
        }
Exemple #4
0
        /// ////////////////////////////////////////////////////
        private void OnClickSousMenu(object sender, EventArgs args)
        {
            if (!(sender is CMenuItemTimos))
            {
                return;
            }
            CMenuCustom    menu   = ((CMenuItemTimos)sender).MenuCustom;
            CResultAErreur result = CExecuteurActionSur2iLink.ExecuteAction(sender, menu.Action, null);

            if (!result)
            {
                CFormAlerte.Afficher(result.Erreur);
            }
        }
Exemple #5
0
        private CMenuCustom AddMenuStandard(CMenuCustom parent, string strLibelle, Type typeForm)
        {
            CMenuCustom menu = new CMenuCustom(parent.ContexteDonnee);

            menu.Libelle    = strLibelle;
            menu.MenuParent = parent;
            menu.NumMenu    = parent.ListeMenusFils.Count;
            if (typeForm != null)
            {
                CActionSur2iLinkAfficherFormulaire action = new CActionSur2iLinkAfficherFormulaire();
                action.TypeFormulaire = typeForm;
                menu.Action           = action;
            }
            return(menu);
        }
Exemple #6
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CMenuCustom menu = (CMenuCustom)objet;

                if (menu.Libelle == "")
                {
                    result.EmpileErreur(I.T("Custom Menu label connot be empty|320"));
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
Exemple #7
0
 /// ////////////////////////////////////////////////////
 private void CreateSousMenu(MenuItem.MenuItemCollection wndMenus, CMenuCustom menu)
 {
     wndMenus.Clear();
     foreach (CMenuCustom menuCustom in menu.ListeMenusFils)
     {
         if (ShouldAffiche(menuCustom))
         {
             MenuItem item = new CMenuItemTimos(menuCustom);
             if (menuCustom.ListeMenusFils.Count != 0)
             {
                 CreateSousMenu(item.MenuItems, menuCustom);
             }
             else
             {
                 item.Click += new EventHandler(OnClickSousMenu);
             }
             wndMenus.Add(item);
         }
     }
 }
Exemple #8
0
        private void AssureMenu( )
        {
            if (DesignMode)
            {
                return;
            }
            if (m_menuCustom == null && !DesignMode)
            {
                IDatabaseRegistre registre = (IDatabaseRegistre)C2iFactory.GetNew2iObjetServeur(typeof(IDatabaseRegistre), CTimosApp.SessionClient.IdSession);
                int nId = (int)registre.GetValeurLong(c_cleRegistre, -1);
                m_menuCustom = new CMenuCustom(CSc2iWin32DataClient.ContexteCourant);
                if (!m_menuCustom.ReadIfExists(nId))
                {
                    // Si l'ID n'éxiste pas alors on cherche par une requette pour être sûr
                    CListeObjetsDonnees listeMenus = new CListeObjetsDonnees(
                        CSc2iWin32DataClient.ContexteCourant,
                        typeof(CMenuCustom),
                        new CFiltreData(CMenuCustom.c_champIdMenuParent + " IS NULL"));

                    if (listeMenus.Count >= 1)
                    {
                        // On a trouvé le premier menu sans parent
                        m_menuCustom = (CMenuCustom)listeMenus[0];
                    }
                    else
                    {
                        //Construction du menu par défaut
                        m_menuCustom.CreateNew();
                        m_menuCustom.Libelle = I.T("Home|714");
                        m_menuCustom.Action  = null;
                        AddMenuStandard(m_menuCustom, I.T("Assets management|1"), typeof(CFormMenuPatrimoine));
                        AddMenuStandard(m_menuCustom, I.T("Organisation|4"), typeof(CFormMenuOrganisation));
                        AddMenuStandard(m_menuCustom, I.T("Maintenance|8"), typeof(CFormMenuMaintenance));
                        AddMenuStandard(m_menuCustom, I.T("Engineering|6"), typeof(CFormMenuIngenierie));
                        AddMenuStandard(m_menuCustom, I.T("Configuration|7"), typeof(CFormMenuConfiguration));
                        m_menuCustom.CommitEdit();
                        registre.SetValeur(c_cleRegistre, m_menuCustom.Id.ToString());
                    }
                }
            }
        }
Exemple #9
0
 public CMenuItemTimos(CMenuCustom menuCustom)
 {
     m_menuCustom = menuCustom;
     Text         = menuCustom.Libelle;
 }