//------------------------------------------------------------- private int?GetIdChampOptimFromFormule(C2iExpression formule) { C2iExpressionChamp exp = formule as C2iExpressionChamp; if (exp != null) { //TESTDBKEYOK CDefinitionProprieteDynamiqueChampCustom prop = exp.DefinitionPropriete as CDefinitionProprieteDynamiqueChampCustom; if (prop != null) { return(CChampCustom.GetIdFromDbKey(prop.DbKeyChamp)); } } return(null); }
//----------------------------------------------------------- private C2iRequeteAvancee GetRequeteChampCustom(CParametreInspirationProprieteDeType parametre) { CDefinitionProprieteDynamiqueChampCustom defChampCustom = parametre.Champ as CDefinitionProprieteDynamiqueChampCustom; if (defChampCustom == null || parametre.Type == null || defChampCustom.DbKeyChamp == null) { return(null); } DataTable table = new DataTable(); DataRow row = table.NewRow(); IObjetDonneeAChamps objet = Activator.CreateInstance(parametre.Type, new object[] { row }) as IObjetDonneeAChamps; if (objet != null) { string strTableValeurs = objet.GetNomTableRelationToChamps(); C2iRequeteAvancee requete = new C2iRequeteAvancee(); requete.TableInterrogee = strTableValeurs; requete.ListeChamps.Add(new C2iChampDeRequete("LABEL", new CSourceDeChampDeRequete(CRelationElementAChamp_ChampCustom.c_champValeurString), typeof(string), OperationsAgregation.None, true)); int nIdChamp = -1; //TESTDBKEYOK SC 31/03/2014 if (defChampCustom.DbKeyChamp.IsNumericalId()) { nIdChamp = (int)defChampCustom.DbKeyChamp.GetValeurInDb(); } else { nIdChamp = CChampCustom.GetIdFromDbKey(defChampCustom.DbKeyChamp); } requete.FiltreAAppliquer = new CFiltreData(CChampCustom.c_champId + "=@1", nIdChamp); return(requete); } return(null); }