Exemple #1
0
 //-----------------------------------------------
 public void AppliqueRestrictions(
     CListeRestrictionsUtilisateurSurType restrictions,
     IGestionnaireReadOnlySysteme gestionnaireReadOnly)
 {
     if (ElementEdite != null)
     {
         CRestrictionUtilisateurSurType restriction = restrictions.GetRestriction(ElementEdite.GetType());
         restriction.ApplyToObjet(ElementEdite);
         foreach (IControleWndFor2iWnd ctrl in m_controlesPrincipaux)
         {
             ctrl.AppliqueRestriction(
                 restriction,
                 restrictions,
                 gestionnaireReadOnly);
         }
     }
 }
Exemple #2
0
        /// //////////////////////////////////////////////////////////////////
        public CRestrictionUtilisateurSurType GetRestrictionsSurObjet(object objet, int?nIdVersion)
        {
            if (objet == null)
            {
                return(GetRestrictionsSur(typeof(int), nIdVersion));                  //Aucune restriction !!
            }
            Type tp = objet.GetType();

            IConteneurObjetARestriction conteneur = objet as IConteneurObjetARestriction;

            if (conteneur != null)
            {
                tp = conteneur.TypePourRestriction;
            }

            CRestrictionUtilisateurSurType rest = (CRestrictionUtilisateurSurType)GetInfosRestrictions(nIdVersion).ListeRestrictions.GetRestriction(tp).Clone();

            rest.ApplyToObjet(objet);
            return(rest);
        }
Exemple #3
0
        //---------------------------------------------------
        protected override CResultAErreur MyInitChamps(CCustomizableListItem item)
        {
            CResultAErreur result = base.MyInitChamps(item);

            if (item != null && item.Tag != null)
            {
                m_panelSousFormulaire.SetElementEdite(item.Tag);

                if (m_restriction != null && !IsCreatingImage)
                {
                    CRestrictionUtilisateurSurType rest = m_restriction.Clone() as CRestrictionUtilisateurSurType;
                    rest.ApplyToObjet(item.Tag);
                    m_panelSousFormulaire.AppliqueRestrictions(
                        rest,
                        m_listeRestrictions,
                        m_gestionnaireReadonlySystem);
                }


                //Stock l'aspect du formulaire à l'initialisation
                if (m_donneesAInitialisation == null)
                {
                    m_donneesAInitialisation = new CDonneesSpecifiquesControleDansCustomList();
                    CUtilDonneesSpecifiquesDansCustomList.SaveDonneesControle(this, m_donneesAInitialisation);
                }
                if (item.DonneesControles == null || item.DonneesControles.IsEmpty)
                {
                    item.DonneesControles = m_donneesAInitialisation;
                }
            }
            if (IsCreatingImage)
            {
                m_panelSousFormulaire.BackColor = ColorInactive;
            }
            else
            {
                m_panelSousFormulaire.BackColor = BackColor;
            }
            return(result);
        }
 //--------------------------------------------------------------
 public void PrepareEditingControlForEdit(bool selectAll)
 {
     try
     {
         m_wndEdition.SetElementEdite(ElementEdite);
         if (m_createurFormulaires != null && m_wndEdition != null && m_wndEdition.Control != null)
         {
             m_createurFormulaires.UpdateVisibilityEtEnable(m_wndEdition, ElementEdite);
         }
         if (m_listeRestrictions != null && ElementEdite != null)
         {
             CRestrictionUtilisateurSurType rest = m_listeRestrictions.GetRestriction(ElementEdite.GetType());
             if (rest != null)
             {
                 rest.ApplyToObjet(ElementEdite);
                 m_wndEdition.AppliqueRestriction(rest, m_listeRestrictions, new CGestionnaireReadOnlySysteme());
             }
         }
         m_wndEdition.SelectAll();
     }
     catch { }
 }
        ///////////////////////////////////////////////////
        public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte)
        {
            CResultAErreur result = base.TraitementAvantSauvegarde(contexte);

            CSessionClient session = CSessionClient.GetSessionForIdSession(IdSession);
            //Annule les modifications sur les champs interdits en modification
            DataTable table = contexte.Tables[GetNomTable()];
            //Objet témoin pour vérifier les valeurs non affectées
            CRelationElementAChamp_ChampCustom relTemoin = null;

            if (IdVersionDeTravail != null)            //Dans les versions, on ne stocke pas les créations de valeurs nulles
            {
                relTemoin = (CRelationElementAChamp_ChampCustom)contexte.GetNewObjetForTable(table);
                relTemoin.CreateNewInCurrentContexte();
            }
            if (table != null && session != null)
            {
                IInfoUtilisateur user = session.GetInfoUtilisateur();
                if (user != null)
                {
                    ArrayList       lst     = new ArrayList(table.Rows);
                    IElementAChamps lastElt = null;
                    CRestrictionUtilisateurSurType restDeBase    = null;
                    CRestrictionUtilisateurSurType restAppliquee = null;
                    foreach (DataRow row in lst)
                    {
                        CRelationElementAChamp_ChampCustom rel = (CRelationElementAChamp_ChampCustom)contexte.GetNewObjetForRow(row);
                        if (row.RowState == DataRowState.Added && relTemoin != null)
                        {
                            if (relTemoin.Valeur != null && relTemoin.Valeur.Equals(rel.Valeur) ||
                                relTemoin.Valeur == null && relTemoin.Valeur == null)
                            {
                                rel.CancelCreate();
                            }
                        }


                        if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added)
                        {
                            if (restDeBase == null)
                            {
                                Type tp = rel.ElementAChamps.GetType();
                                restDeBase = user.GetRestrictionsSur(tp, contexte.IdVersionDeTravail);
                            }
                            if (restDeBase != null && rel.ElementAChamps.Equals(lastElt))
                            {
                                restAppliquee = restDeBase.Clone() as CRestrictionUtilisateurSurType;
                            }
                            //Vérifie qu'on a le droit
                            if (!rel.ElementAChamps.Equals(lastElt) && restAppliquee != null)
                            {
                                restAppliquee.ApplyToObjet(rel.ElementAChamps);
                            }
                            lastElt = rel.ElementAChamps;
                            if (restAppliquee != null)
                            {
                                ERestriction restChamp = restAppliquee.GetRestriction(rel.ChampCustom.CleRestriction);
                                if ((restChamp & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                                {
                                    row.RejectChanges();
                                }
                            }
                        }
                    }
                }
            }
            if (relTemoin != null)
            {
                relTemoin.CancelCreate();
            }
            return(result);
        }
        /// ///////////////////////////////////////////////////
        public void AppliqueRestrictions(CListeRestrictionsUtilisateurSurType restrictions, IGestionnaireReadOnlySysteme gestionnaireReadOnly)
        {
            if (restrictions == null || gestionnaireReadOnly == null)
            {
                return;
            }
            m_listeRestrictions    = restrictions.Clone() as CListeRestrictionsUtilisateurSurType;
            m_gestionnaireReadOnly = gestionnaireReadOnly;

            //Gère la visibilité des formulaires
            if (m_elementEdite != null)
            {
                CRestrictionUtilisateurSurType rest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                rest.ApplyToObjet(m_elementEdite);
                if (rest.HasRestrictions)
                {
                    foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, int> kv in m_tablePageToIdFormulaire)
                    {
                        CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee);
                        if (formulaire.ReadIfExists(kv.Value))
                        {
                            ERestriction r = rest.GetRestriction(formulaire.CleRestriction);
                            if ((r & ERestriction.Hide) == ERestriction.Hide)
                            {
                                if (TabPages.Contains(kv.Key))
                                {
                                    TabPages.Remove(kv.Key);
                                    m_tablePagesInit[kv.Key] = false;
                                }
                            }
                        }
                    }
                }
            }


            //Update les pages initialisées
            foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, bool> kv in m_tablePagesInit)
            {
                if (kv.Value)
                {
                    CCreateur2iFormulaireObjetDonnee createur = null;
                    if (m_tableCreateurs.TryGetValue(kv.Key, out createur))
                    {
                        CRestrictionUtilisateurSurType oldRest = null;

                        if (m_elementEdite != null)
                        {
                            CRestrictionUtilisateurSurType restriction = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                            oldRest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                            restriction.ApplyToObjet(m_elementEdite);
                            int nIdFormulaire;
                            if (m_tablePageToIdFormulaire.TryGetValue(kv.Key, out nIdFormulaire))
                            {
                                CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee);
                                if (formulaire.ReadIfExists(nIdFormulaire))
                                {
                                    ERestriction rest = restriction.GetRestriction(formulaire.CleRestriction);
                                    if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                                    {
                                        restriction.AddRestrictionsHorsPriorite(new CRestrictionUtilisateurSurType(restriction.TypeAssocie, ERestriction.ReadOnly));
                                        //force readonly sur tous les contrôles
                                        restriction.RestrictionUtilisateur = ERestriction.ReadOnly;
                                        m_listeRestrictions.SetRestriction(restriction);
                                    }
                                }
                            }
                        }
                        createur.AppliqueRestrictions(m_listeRestrictions, m_gestionnaireReadOnly);
                        if (oldRest != null)
                        {
                            m_listeRestrictions.SetRestriction(oldRest);
                        }
                    }
                }
            }
        }