Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------
        public void AppliqueRestrictions(
            CListeRestrictionsUtilisateurSurType lstRestrictions,
            CGestionnaireReadOnlySysteme gestionnaire)
        {
            if (SourceType == null)
            {
                return;
            }
            CRestrictionUtilisateurSurType restriction = lstRestrictions.GetRestriction(SourceType);

            if (restriction != null)
            {
                foreach (KeyValuePair <object, CInfoControle> kv in m_dicControleToInfo)
                {
                    CInfoControle info = kv.Value;
                    if (info.Field.Length > 0)
                    {
                        ERestriction rest = restriction.GetRestriction(info.Field);
                        Control      ctrl = kv.Key as Control;
                        if (ctrl != null)
                        {
                            if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                            {
                                gestionnaire.SetReadOnly(ctrl, true);
                            }
                            else
                            {
                                gestionnaire.SetReadOnly(ctrl, false);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void AppliqueRestrictions(
            Control ctrl,
            CListeRestrictionsUtilisateurSurType lstRestrictions,
            CGestionnaireReadOnlySysteme gestionnaireReadOnly)
        {
            if (ctrl == null)
            {
                return;
            }

            Type tp = ctrl.GetType();

            while (tp != null)
            {
                foreach (FieldInfo info in tp.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField))
                {
                    //cherche les linkFields
                    if (typeof(CExtLinkField).IsAssignableFrom(info.FieldType))
                    {
                        try
                        {
                            CExtLinkField linkField = info.GetValue(ctrl) as CExtLinkField;
                            if (linkField != null)
                            {
                                linkField.AppliqueRestrictions(lstRestrictions, gestionnaireReadOnly);
                            }
                        }
                        catch { }
                    }
                }
                tp = tp.BaseType;
            }
            //Cherche les controles qui sont des IControleAGestionRestriction
            AppliqueRestrictionsSurIControlesAGestionRestrictions(ctrl,
                                                                  lstRestrictions,
                                                                  gestionnaireReadOnly);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------------------
        private static void AppliqueRestrictionsSurIControlesAGestionRestrictions(Control ctrl, CListeRestrictionsUtilisateurSurType lstRestrictions, CGestionnaireReadOnlySysteme gestionnaireReadOnly)
        {
            IControleAGestionRestrictions ctrlRes = ctrl as IControleAGestionRestrictions;

            if (ctrlRes != null)
            {
                ctrlRes.AppliqueRestrictions(lstRestrictions, gestionnaireReadOnly);
            }
            else
            {
                foreach (Control child in ctrl.Controls)
                {
                    AppliqueRestrictionsSurIControlesAGestionRestrictions(child, lstRestrictions, gestionnaireReadOnly);
                }
            }
        }