Esempio n. 1
0
        /// //////////////////////////////////////////////////////////
        private void ItemFiltreClick(object sender, EventArgs e)
        {
            if (!(sender is CMenuItemFiltre))
            {
                return;
            }
            CFiltreDynamiqueInDb filtreInDb = ((CMenuItemFiltre)sender).Filtre;
            CFiltreDynamique     filtreDyn  = filtreInDb.Filtre;
            CFiltreData          filtreData = CFormFiltreDynamic.GetFiltreData(filtreDyn);

            if (filtreData == null)
            {
                return;
            }
            CListeObjetsDonnees listeSel = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, m_typeLien.TypeElements);

            filtreData      = CFiltreData.GetAndFiltre(filtreData, m_typeLien.FiltreDataAssocie);
            listeSel.Filtre = filtreData;

            try
            {
                if (listeSel.CountNoLoad == 0)
                {
                    CFormAlerte.Afficher(I.T("No @1 matches the filter|30089", DynamicClassAttribute.GetNomConvivial(m_typeLien.TypeElements)), EFormAlerteType.Exclamation);
                    return;
                }
                if (CFormAlerte.Afficher(I.T("You will add @1 element(s) to the selection. Continue ?|30088", listeSel.CountNoLoad.ToString()), EFormAlerteType.Question) == DialogResult.Yes)
                {
                    CListeObjetsDonnees listeExiste = m_entreeAgenda.RelationsElementsAgenda;
                    listeExiste.Filtre = new CFiltreData(CRelationTypeEntreeAgenda_TypeElementAAgenda.c_champId + "=@1",
                                                         m_typeLien.Id);
                    listeExiste.Filtre = CFiltreData.GetAndFiltre(listeExiste.Filtre, new CFiltreData(CRelationTypeEntreeAgenda_TypeElementAAgenda.c_champId + "=@1",
                                                                                                      m_typeLien.Id));
                    using (CWaitCursor waiter = new CWaitCursor())
                    {
                        foreach (CObjetDonneeAIdNumerique objet in listeSel)
                        {
                            listeExiste.Filtre = new CFiltreData(CRelationEntreeAgenda_ElementAAgenda.c_champIdElementAAgenda + "=@1",
                                                                 objet.Id);
                            if (listeExiste.Count == 0)
                            {
                                CRelationEntreeAgenda_ElementAAgenda rel = new CRelationEntreeAgenda_ElementAAgenda(m_entreeAgenda.ContexteDonnee);
                                rel.CreateNewInCurrentContexte();
                                rel.EntreeAgenda = m_entreeAgenda;
                                rel.RelationTypeEntree_TypeElement = m_typeLien;
                                rel.ElementLie = objet;
                            }
                        }
                        UpdateListe();
                    }
                }
            }
            catch
            {
            }
        }
        /// //////////////////////////////////////////////////////////
        private void ItemFiltreClick(object sender, EventArgs e)
        {
            if (!(sender is CMenuItemFiltre))
            {
                return;
            }
            CFiltreDynamiqueInDb filtreInDb = ((CMenuItemFiltre)sender).Filtre;
            CFiltreDynamique     filtreDyn  = filtreInDb.Filtre;
            CFiltreData          filtreData = CFormFiltreDynamic.GetFiltreData(filtreDyn);

            if (filtreData == null)
            {
                return;
            }
            CListeObjetsDonnees listeSel = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, m_typElements);

            filtreData      = CFiltreData.GetAndFiltre(filtreData, m_filtreInitial);
            listeSel.Filtre = filtreData;

            try
            {
                if (listeSel.CountNoLoad == 0)
                {
                    CFormAlerte.Afficher("Aucun " + DynamicClassAttribute.GetNomConvivial(m_typElements) + " ne correspond au filtre", EFormAlerteType.Exclamation);
                    return;
                }
                if (CFormAlerte.Afficher(I.T("You will add @1 element(s) to the selection. Continue ?|30088", listeSel.CountNoLoad.ToString()), EFormAlerteType.Question) == DialogResult.Yes)
                {
                    using (CWaitCursor waiter = new CWaitCursor())
                    {
                        bool bModif = false;
                        foreach (CObjetDonneeAIdNumerique objet in listeSel)
                        {
                            bModif |= AddElement(objet);
                        }
                        if (bModif && OnChangeSelection != null)
                        {
                            OnChangeSelection(this, new EventArgs( ));
                        }
                        UpdateListe();
                    }
                }
            }
            catch
            {
            }
        }