Beispiel #1
0
        protected override CResultAErreur MyInitChamps(CCustomizableListItem item)
        {
            CResultAErreur result = base.MyInitChamps(item);

            CParametreDroitEditionType.CCoupleFormuleToGroupeRestrictions couple = item != null?item.Tag as CParametreDroitEditionType.CCoupleFormuleToGroupeRestrictions:null;
            if (item != null && couple != null)
            {
                if (!m_bIsInit)
                {
                    m_bIsInit = true;
                    m_txtFormule.Init(m_fournisseur, m_typeObjets);
                    string strField = DescriptionFieldAttribute.GetDescriptionField(m_typeObjets, "DescriptionElement");
                    m_txtGroupe.Init(typeof(CGroupeRestrictionSurType), "Libelle", false);
                    m_txtGroupe.Init(m_typeObjets, strField, false);
                }
                m_lblFormule.Visible = IsCreatingImage;
                m_txtFormule.Visible = !IsCreatingImage;
                m_lblFormule.Text    = couple.Formule != null?couple.Formule.GetString() : "";

                m_txtFormule.Visible = true;
                m_lblFormule.Visible = false;
                m_txtFormule.Formule = couple.Formule;

                m_txtGroupe.ElementSelectionne = couple.GetGroupeRestrictions(CSc2iWin32DataClient.ContexteCourant);
            }
            return(result);
        }
Beispiel #2
0
        private void CExplorateurObjets_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            Rectangle rctTotal = Rectangle.Intersect(ClientRectangle,
                                                     new Rectangle(e.Bounds.Left, e.Bounds.Top, Size.Width, e.Bounds.Height));

            Rectangle rctText = new Rectangle(rctTotal.Left, rctTotal.Top,
                                              m_nFieldSize, rctTotal.Height);

            e.Graphics.DrawString(e.Node.Text, Font, Brushes.Black, rctText);

            CTreeViewData data = e.Node.Tag as CTreeViewData;

            if (data != null)
            {
                if (data.Valeur != null)
                {
                    object val = data.Valeur;
                    if (e.Node.Nodes.Count > 0)//complexe
                    {
                        val = DescriptionFieldAttribute.GetDescription(val);
                    }
                    Rectangle    rct    = new Rectangle(rctText.Right, rctText.Top, rctTotal.Width - rctText.Width, rctTotal.Height);
                    StringFormat format = new StringFormat();
                    e.Graphics.DrawString(val.ToString(), Font, Brushes.Black, rct, format);
                    format.Dispose();
                }
            }
            e.Graphics.DrawLine(Pens.LightGray, 0, rctTotal.Top, Size.Width, rctTotal.Top);
        }
        //---------------------------------------
        public void InitForModule(CModuleParametrage module, CContexteDonnee contexte)
        {
            CTreeViewNodeKeeper keeper = new CTreeViewNodeKeeper(this);

            m_contexte      = contexte;
            m_moduleAffiche = module;
            BeginUpdate();
            Nodes.Clear();
            Dictionary <string, List <CRelationElement_ModuleParametrage> > dicTypeToObjets = new Dictionary <string, List <CRelationElement_ModuleParametrage> >();
            List <string> lstTypes = new List <string>();

            if (m_moduleAffiche != null)
            {
                foreach (CRelationElement_ModuleParametrage rel in m_moduleAffiche.RelationsElements)
                {
                    if (rel.ElementLie != null)
                    {
                        string strType = DynamicClassAttribute.GetNomConvivial(rel.ElementLie.GetType());
                        List <CRelationElement_ModuleParametrage> lst = null;
                        if (!dicTypeToObjets.TryGetValue(strType, out lst))
                        {
                            lstTypes.Add(strType);
                            lst = new List <CRelationElement_ModuleParametrage>();
                            dicTypeToObjets[strType] = lst;
                        }
                        lst.Add(rel);
                    }
                }
                lstTypes.Sort();
                foreach (string strType in lstTypes)
                {
                    TreeNode nodeType = new TreeNode(strType);
                    nodeType.SelectedImageIndex = 0;
                    nodeType.ImageIndex         = 0;
                    nodeType.Tag = null;
                    Nodes.Add(nodeType);
                    List <CRelationElement_ModuleParametrage> lst = null;
                    if (dicTypeToObjets.TryGetValue(strType, out lst))
                    {
                        foreach (CRelationElement_ModuleParametrage rel in lst)
                        {
                            CObjetDonnee obj     = rel.ElementLie;
                            string       strDesc = DescriptionFieldAttribute.GetDescription(obj);
                            if (strDesc.Trim().Length == 0)
                            {
                                strDesc = obj.DescriptionElement;
                            }
                            TreeNode node = new TreeNode(strDesc);
                            node.Tag                = rel;
                            node.ImageIndex         = 1;
                            node.SelectedImageIndex = 1;
                            nodeType.Nodes.Add(node);
                        }
                    }
                }
            }
            EndUpdate();
            keeper.Apply(this);
        }
 public string ConvertObjectValueToStringForGrid(object valeur)
 {
     if (valeur is CObjetDonnee)
     {
         DescriptionFieldAttribute.GetDescription((CObjetDonnee)valeur);
     }
     return("");
 }
Beispiel #5
0
        private void UpdateLibelleElement(IElementAIntervention element)
        {
            string strVal = DescriptionFieldAttribute.GetDescription(element);

            if (strVal == null || strVal == "")
            {
                strVal = element.DescriptionElement;
            }
            m_lnkElementAIntervention.Text = strVal;
        }
        //----------------------------------------------------
        public static void ShowListe(
            string strTitre,
            CListeObjetsDonnees listeAVoir,
            CFormNavigateur navigateurAssocié,
            GLColumnCollection columns,
            string strContexteUtilisation)
        {
            if (listeAVoir == null)
            {
                return;
            }

            //Créer une nouvelle liste dans le contexte de base
            CListeObjetsDonnees lst    = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, listeAVoir.TypeObjets);
            CFiltreData         filtre = CFiltreData.GetAndFiltre(listeAVoir.FiltrePrincipal,
                                                                  listeAVoir.Filtre);

            lst.Filtre = filtre;


            CFormListeExtraiteOld frm = new CFormListeExtraiteOld();

            frm.Text = strTitre;
            frm.m_navigateurAssocié = navigateurAssocié != null?navigateurAssocié:m_navigateurParDefaut;
            Image img = CFormListeStandard.CalculeNewImage(lst.TypeObjets);

            frm.m_listeObjets = lst;
            if (columns != null)
            {
                frm.m_panelListe.AllowSerializePreferences = false;
                foreach (GLColumn col in columns)
                {
                    GLColumn copie = CCloner2iSerializable.Clone(col) as GLColumn;
                    frm.m_panelListe.Columns.Add(copie);
                }
            }
            else
            {
                frm.m_panelListe.AllowSerializePreferences = true;
                if (strContexteUtilisation != null)
                {
                    frm.m_panelListe.ContexteUtilisation = strContexteUtilisation;
                }
                string   strField = DescriptionFieldAttribute.GetDescriptionField(lst.TypeObjets, "DescriptionElement");
                GLColumn col      = new GLColumn("");
                col.Propriete = strField;
                col.Width     = frm.m_panelListe.ClientSize.Width;
                frm.m_panelListe.Columns.Add(col);
            }

            frm.Show();
        }
        public static CEntiteDeMemoryDb SelectionRechercheRapide(
            CMemoryDb dbMemory,
            string strInstructions,
            Type type,
            CFiltreMemoryDb filtreDeBase,
            CFiltreMemoryDb filtreRapide,
            string strTexteRechercheRapide,
            string strChampAffiche,
            string strContexte)
        {
            if (type == null || !type.IsSubclassOf(typeof(CEntiteDeMemoryDb)))
            {
                CFormAlerte.Afficher(I.T("Can not select an element from this type|30035"), EFormAlerteType.Erreur);
                return(null);
            }
            CFormSelectUneEntiteMemoryDb form = new CFormSelectUneEntiteMemoryDb();

            form.m_filtre                = filtreDeBase;
            form.m_strInstructions       = strInstructions;
            form.m_contexteMemoire       = dbMemory;
            form.m_txtRecherche.Text     = strTexteRechercheRapide;
            form.TypeObjets              = type;
            form.m_filtreRechercheRapide = filtreRapide;
            if (strChampAffiche == "")
            {
                strChampAffiche = DescriptionFieldAttribute.GetDescriptionField(type, "Libelle", true);
            }
            form.m_strProprieteAffichee = strChampAffiche;
            form.m_wndListeElements.Columns[0].Propriete = form.m_strProprieteAffichee;
            CEntiteDeMemoryDb objet = null;

            form.RefreshListe();
            bool bOk = true;

            if (form.m_listeObjets == null || form.m_listeObjets.Count() != 1)
            {
                bOk = form.ShowDialog() == DialogResult.OK;
            }
            if (bOk)
            {
                objet = form.ObjetDonnee;
            }
            form.Dispose();
            return(objet);
        }
        //-----------------------------------------------------------
        public void AlloueControl()
        {
            if (m_variable == null)
            {
                return;
            }
            Type        typeElements    = null;
            string      strPropAffichee = "";
            CFiltreData filtre          = null;

            if (m_variable is CVariableDynamiqueSelectionObjetDonnee)
            {
                C2iExpression expression = ((CVariableDynamiqueSelectionObjetDonnee)m_variable).ExpressionAffichee;
                if (expression is C2iExpressionChamp)
                {
                    strPropAffichee = ((C2iExpressionChamp)expression).DefinitionPropriete.NomProprieteSansCleTypeChamp;
                }
                CFiltreDynamique filtreDyn = ((CVariableDynamiqueSelectionObjetDonnee)m_variable).FiltreSelection;
                filtre       = GetFiltre(filtreDyn);
                typeElements = filtreDyn.TypeElements;
            }
            else if (m_variable is CChampCustom)
            {
                CFiltreDynamique filtreDyn = ((CChampCustom)m_variable).FiltreObjetDonnee;
                if (filtreDyn != null)
                {
                    filtre = GetFiltre(filtreDyn);
                }
                typeElements = ((CChampCustom)m_variable).TypeObjetDonnee;
            }

            if (m_control == null)
            {
                m_control = new C2iTextBoxFiltreRapide();
                m_control.ElementSelectionneChanged += new EventHandler(m_control_ElementSelectionneChanged);
            }
            if (strPropAffichee == "")
            {
                strPropAffichee = DescriptionFieldAttribute.GetDescriptionField(typeElements, "DescriptionElement");
            }
            m_control.InitAvecFiltreDeBase(typeElements,
                                           strPropAffichee,
                                           filtre, true);
        }
        public static CObjetDonnee SelectionRechercheRapide(
            string strInstructions,
            Type type,
            CFiltreData filtreDeBase,
            string strTexteRechercheRapide,
            string strChampAffiche,
            string strContexte)
        {
            if (type == null || !type.IsSubclassOf(typeof(CObjetDonnee)))
            {
                CFormAlerte.Afficher(I.T("Can not select an element from this type|30035"), EFormAlerteType.Erreur);
                return(null);
            }
            CFormSelectUnObjetDonnee form = new CFormSelectUnObjetDonnee();

            form.m_filtre          = filtreDeBase;
            form.m_strInstructions = strInstructions;
            InitVariablesDeForm(form, type);
            form.m_txtRecherche.Text     = strTexteRechercheRapide;
            form.TypeObjets              = type;
            form.m_filtreRechercheRapide = CFournisseurFiltreRapide.GetFiltreRapideForType(type);
            if (strChampAffiche == "")
            {
                strChampAffiche = DescriptionFieldAttribute.GetDescriptionField(type, "Libelle", true);
            }
            form.m_strProprieteAffichee = strChampAffiche;
            form.m_wndListeElements.Columns[0].Propriete = form.m_strProprieteAffichee;
            CObjetDonnee objet = null;

            form.RefreshListe();
            bool bOk = true;

            if (form.m_listeObjets == null || form.m_listeObjets.Count != 1)
            {
                bOk = form.ShowDialog() == DialogResult.OK;
            }
            if (bOk)
            {
                objet = form.ObjetDonnee;
            }
            form.Dispose();
            return(objet);
        }
Beispiel #10
0
        public string ConvertObjectValueToStringForGrid(object valeur)
        {
            if (valeur is CObjetDonnee)
            {
                return(DescriptionFieldAttribute.GetDescription((CObjetDonnee)valeur));
            }
            if (valeur != null)
            {
                string strVal = valeur.ToString();
                if (valeur is double || valeur is int)
                {
                    strVal = AppliqueSeparateurMilliers(strVal);
                }
                if (ChampCustom != null && ChampCustom.IsChoixParmis())
                {
                    strVal = ChampCustom.GetDisplayValue(valeur);
                }
                return(strVal);
            }

            return("");
        }
Beispiel #11
0
        internal void CreateVariable(CObjetDonnee objet)
        {
            CVariableDynamiqueSelectionObjetDonnee variable = new CVariableDynamiqueSelectionObjetDonnee(Macro);

            if (objet != null)
            {
                variable.Nom = objet.DescriptionElement.Trim().Replace("[", "-").Replace("]", "-");
            }
            else
            {
                variable.Nom = "V" + variable.IdVariable;
            }
            CFiltreDynamique filtre = new CFiltreDynamique(Macro, Macro.ContexteDonnee);

            filtre.TypeElements          = TypeObjet;
            variable.FiltreSelection     = filtre;
            variable.ExpressionRetournee = new C2iExpressionThis(TypeObjet);
            string strField = DescriptionFieldAttribute.GetDescriptionField(TypeObjet, "DescriptionElement");

            if (strField != "")
            {
                CDefinitionProprieteDynamiqueDotNet def = new CDefinitionProprieteDynamiqueDotNet(
                    strField,
                    strField,
                    new CTypeResultatExpression(typeof(string), false),
                    false,
                    true,
                    "");
                variable.ExpressionAffichee = new C2iExpressionChamp(def);
            }
            Macro.AddVariable(variable);
            Macro.SetInitialValue(variable, objet as CObjetDonneeAIdNumerique);
            m_strIdVariableAssociee = variable.IdVariable;
            CDefinitionProprieteDynamiqueVariableDynamique defSource = new CDefinitionProprieteDynamiqueVariableDynamique(variable);

            FormuleSelectionObjet = new C2iExpressionChamp(defSource);
        }
        //-------------------------------------------------------------------------------
        private void FillListeEntites()
        {
            ListViewItem item = m_wndListeResumée.SelectedItems.Count == 1 ?
                                m_wndListeResumée.SelectedItems[0] : null;

            m_wndListeItems.BeginUpdate();
            m_wndListeItems.Items.Clear();
            if (item != null && item.Tag is DataTable)
            {
                DataTable table = item.Tag as DataTable;
                m_lblTypeEntite.Text = item.Text;
                foreach (DataRow row in table.Rows)
                {
                    CObjetDonnee objet    = Activator.CreateInstance(CContexteDonnee.GetTypeForTable(table.TableName), new object[] { row }) as CObjetDonnee;
                    ListViewItem listItem = new ListViewItem(DescriptionFieldAttribute.GetDescription(objet));
                    listItem.Tag        = objet;
                    listItem.ImageIndex =
                        row.RowState == DataRowState.Added ? 0 :
                        (row.RowState == DataRowState.Modified ? 1 : 2);
                    m_wndListeItems.Items.Add(listItem);
                }
            }
            m_wndListeItems.EndUpdate();
        }
Beispiel #13
0
 private void m_lnkTester_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (m_panelEditionConsultation.Folder != null)
     {
         m_panelEditionConsultation.MajChamps();
         CFolderConsultationRacineFromElement racine = m_panelEditionConsultation.Folder as CFolderConsultationRacineFromElement;
         if (racine != null)
         {
             CObjetDonnee objet = CFormSelectUnObjetDonnee.SelectionRechercheRapide(
                 I.T("Select an element for test|20735"),
                 racine.TypeRacine,
                 null,
                 "",
                 DescriptionFieldAttribute.GetDescriptionField(racine.TypeRacine, "Description"),
                 "FORTESTCONSULT");
             if (objet == null)
             {
                 return;
             }
             racine.InitConsultation(objet);
         }
         CFormTestConsultationHierarchique.TestFolder(m_panelEditionConsultation.Folder);
     }
 }
        //-----------------------------------------------------------
        public void AlloueCombo()
        {
            if (m_variable == null)
            {
                return;
            }
            Type typeElement = m_variable.TypeDonnee.TypeDotNetNatif;

            if (m_variable is CVariableDynamiqueSelectionObjetDonnee)
            {
                typeElement = ((CVariableDynamiqueSelectionObjetDonnee)m_variable).FiltreSelection.TypeElements;
            }
            //Combos hiérarchiques
            if (typeof(IObjetDonneeAutoReference).IsAssignableFrom(typeElement) &&
                typeof(IObjetHierarchiqueACodeHierarchique).IsAssignableFrom(typeElement))
            {
                try
                {
                    if (!(m_combo is CComboBoxArbreObjetDonneesHierarchique) && m_combo != null)
                    {
                        m_combo.Visible = false;
                        m_combo.Parent.Controls.Remove(m_combo);
                        m_combo.Dispose();
                        m_combo = null;
                    }

                    CComboBoxArbreObjetDonneesHierarchique arbre;
                    if (m_combo is CComboBoxArbreObjetDonneesHierarchique)
                    {
                        arbre = (CComboBoxArbreObjetDonneesHierarchique)m_combo;
                    }
                    else
                    {
                        arbre = new CComboBoxArbreObjetDonneesHierarchique();
                        arbre.ElementSelectionneChanged += new EventHandler(arbre_ElementSelectionneChanged);
                    }
                    CFiltreData filtre      = null;
                    Type        tp          = m_variable.TypeDonnee.TypeDotNetNatif;
                    string      strChamp    = DescriptionFieldAttribute.GetDescriptionField(tp, "DescriptionElement", true);
                    string      strTextNull = "";
                    if (m_variable is CVariableDynamiqueSelectionObjetDonnee)
                    {
                        CVariableDynamiqueSelectionObjetDonnee varSel = (CVariableDynamiqueSelectionObjetDonnee)m_variable;
                        tp = ((CVariableDynamiqueSelectionObjetDonnee)m_variable).FiltreSelection.TypeElements;
                        CFiltreDynamique filtreDyn = varSel.FiltreSelection;
                        filtre      = GetFiltre(filtreDyn);
                        strChamp    = DescriptionFieldAttribute.GetDescriptionField(tp, "DescriptionElement", true);
                        strTextNull = varSel.TextNull;
                    }
                    if (m_variable is CChampCustom)
                    {
                        CFiltreDynamique filtreDyn = ((CChampCustom)m_variable).FiltreObjetDonnee;
                        filtre = GetFiltre(filtreDyn);
                    }

                    using (CContexteDonnee contexte = new CContexteDonnee(1, true, false))
                    {
                        CObjetDonnee objet = (CObjetDonnee)Activator.CreateInstance(tp, new object[] { contexte });
                        arbre.Init(tp,
                                   ((IObjetDonneeAutoReference)objet).ProprieteListeFils,
                                   ((IObjetDonneeAutoReference)objet).ChampParent,
                                   strChamp,
                                   filtre,
                                   null
                                   );
                        if (strTextNull != "")
                        {
                            arbre.TextNull = strTextNull;
                        }
                    }
                    m_combo = arbre;
                    return;
                }
                catch { }
            }
            IList lst = null;

            lst = m_variable.Valeurs;
            if (m_variable is CChampCustom && ((CChampCustom)m_variable).TypeDonneeChamp.TypeDonnee == TypeDonnee.tObjetDonneeAIdNumeriqueAuto &&
                lst is CListeObjetsDonnees)
            {
                CFiltreData      filtre    = ((CListeObjetsDonnees)lst).Filtre;
                CFiltreDynamique filtreDyn = ((CChampCustom)m_variable).FiltreObjetDonnee;
                if (filtreDyn != null)
                {
                    filtre = GetFiltre(filtreDyn);
                }

                ((CListeObjetsDonnees)lst).Filtre = filtre;
            }
            else
            {
                lst = m_variable.Valeurs;
            }
            C2iComboBox combo = null;

            if (lst is CListeObjetsDonnees && ((CListeObjetsDonnees)lst).TypeObjets != typeof(CValeurChampCustom))
            {
                CComboBoxListeObjetsDonnees cmbListe = null;
                if (m_combo is CComboBoxListeObjetsDonnees)
                {
                    cmbListe = (CComboBoxListeObjetsDonnees)m_combo;
                }
                else
                {
                    if (m_combo != null)
                    {
                        m_combo.Visible = false;
                        m_combo.Parent.Controls.Remove(m_combo);
                        m_combo.Dispose();
                        m_combo = null;
                    }
                    cmbListe = new CComboBoxListeObjetsDonnees();
                    cmbListe.SelectedValueChanged += new EventHandler(cmbListe_SelectedValueChanged);
                }
                cmbListe.NullAutorise = true;
                cmbListe.Init((CListeObjetsDonnees)lst,
                              DescriptionFieldAttribute.GetDescriptionField(m_variable.TypeDonnee.TypeDotNetNatif, "DescriptionElement"),
                              true);
                combo = cmbListe;
            }
            else
            {
                if (m_combo != null && m_combo.GetType() == typeof(C2iComboBox))
                {
                    combo = (C2iComboBox)m_combo;
                }
                else
                {
                    if (m_combo != null)
                    {
                        m_combo.Visible = false;
                        m_combo.Parent.Controls.Remove(m_combo);
                        m_combo.Dispose();
                        m_combo = null;
                    }
                    combo = new C2iComboBox();
                    combo.SelectionChangeCommitted += new EventHandler(combo_SelectionChangeCommitted);
                }
                combo.DisplayMember = "Display";
                combo.ValueMember   = "Value";
                combo.DataSource    = lst;
            }
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.Sorted        = false;
            combo.IsLink        = false;
            if (m_combo == null)
            {
                combo.CreateControl();
            }
            m_combo = combo;
        }
 protected override void OnChangeElementEdite(object element)
 {
     if (element != null &&
         WndFiltreRapide != null)
     {
         CFiltreData filtreData;
         if (WndFiltreRapide.Filter != null)
         {
             CElementAVariablesDynamiques eltAVar = new CElementAVariablesDynamiques();
             CVariableDynamiqueStatique   var     = new CVariableDynamiqueStatique(eltAVar);
             var.Nom        = "EditedElement";
             var.IdVariable = "0";
             var.SetTypeDonnee(new CTypeResultatExpression(element.GetType(), false));
             eltAVar.AddVariable(var);
             eltAVar.SetValeurChamp(var, element);
             CFiltreDynamique filtreDyn = WndFiltreRapide.Filter;
             filtreDyn.ElementAVariablesExterne = eltAVar;
             filtreData = (CFiltreData)filtreDyn.GetFiltreData().Data;
         }
         else
         {
             filtreData = null;
         }
         Type typePropriete = null;
         if (WndFiltreRapide.Property != null)
         {
             typePropriete = WndFiltreRapide.Property.TypeDonnee.TypeDotNetNatif;
         }
         else if (WndFiltreRapide.Filter != null)
         {
             typePropriete = WndFiltreRapide.Filter.TypeElements;
         }
         if (typePropriete != null)
         {
             string strDesc = DescriptionFieldAttribute.GetDescriptionField(typePropriete, "DescriptionElement");
             C2iTextBoxFiltreRapide txtRapide = m_selectionneur as C2iTextBoxFiltreRapide;
             if (txtRapide != null)
             {
                 txtRapide.InitAvecFiltreDeBase(typePropriete, strDesc, filtreData, true);
             }
             else
             {
                 CComboBoxListeObjetsDonnees cmb = m_selectionneur as CComboBoxListeObjetsDonnees;
                 cmb.NullAutorise = true;
                 cmb.TextNull     = I.T("None|19");
                 if (cmb != null)
                 {
                     cmb.Init(
                         typePropriete,
                         filtreData,
                         strDesc,
                         true);
                 }
             }
             if (WndFiltreRapide.Property != null)
             {
                 CObjetDonnee valeur = CInterpreteurProprieteDynamique.GetValue(EditedElement, WndFiltreRapide.Property).Data as CObjetDonnee;
                 m_selectionneur.ElementSelectionne = valeur;
             }
         }
     }
 }