//--------------------------------------------------- public virtual DataTable GetTable(string strNomTable, CListeQuerySource sources) { foreach (I2iObjetGraphique objet in Childs) { IObjetDeEasyQuery ob = objet as IObjetDeEasyQuery; if (ob != null && ob.NomFinal == strNomTable) { CResultAErreur result = ob.GetDatas(sources); if (result) { return(result.Data as DataTable); } } } return(null); }
//----------------------------------------------------------------- private void m_menuBrowse_Click(object sender, EventArgs e) { if (Selection.Count == 1) { IObjetDeEasyQuery obj = Selection[0] as IObjetDeEasyQuery; CResultAErreur result = CResultAErreur.True; ((CEasyQuery)ObjetEdite).ClearCache(); if (obj != null) { result = obj.GetDatas(((CEasyQuery)ObjetEdite).ListeSources); } if (!result || !(result.Data is DataTable)) { CFormAfficheErreur.Show(result.Erreur); } else { CFormVisuTable.ShowTable(result.Data as DataTable); } } }
//-------------------------------------------------------------------------------------- public CResultAErreurType <DataTable> FiltreData(DataTable tableSource, CEasyQuery query, CListeQuerySource sources) { CResultAErreurType <DataTable> resTable = new CResultAErreurType <DataTable>(); //Trouve la table source IObjetDeEasyQuery objet = query.GetObjet(m_strTableId); if (objet == null) { resTable.EmpileErreur(I.T("Can not find table @1|20017", m_strTableId)); return(resTable); } //Récupére les données de la table source CResultAErreur result = objet.GetDatas(sources); if (!result) { resTable.EmpileErreur(result.Erreur); return(resTable); } DataTable tableResult = tableSource.Clone(); List <DataRow> lstRows1 = new List <DataRow>(); foreach (DataRow row in tableSource.Rows) { lstRows1.Add(row); } List <DataRow> lstRows2 = new List <DataRow>(); DataTable table = result.Data as DataTable; if (table != null) { foreach (DataRow row in table.Rows) { lstRows2.Add(row); } } Dictionary <object, List <DataRow> > keys1 = null; CParametreJointure.GetDicValeurs(lstRows1, ParametreJointure.FormuleTable1, ref keys1); Dictionary <object, List <DataRow> > keys2 = null; CParametreJointure.GetDicValeurs(lstRows2, ParametreJointure.FormuleTable2, ref keys2); HashSet <DataRow> rowsToKeep = new HashSet <DataRow>(); foreach (KeyValuePair <object, List <DataRow> > kv in keys1) { if (ParametreJointure.Operateur == EOperateurJointure.Egal) { List <DataRow> rows2 = null; if (keys2.TryGetValue(kv.Key, out rows2)) { if (rows2.Count() > 0) { foreach (DataRow row in kv.Value) { rowsToKeep.Add(row); } } } } else { foreach (KeyValuePair <object, List <DataRow> > kv2 in keys2) { if (CParametreJointure.Compare(kv.Key, kv2.Key, ParametreJointure.Operateur)) { foreach (DataRow row in kv.Value) { rowsToKeep.Add(row); } } } } } tableResult.BeginLoadData(); foreach (DataRow row in tableSource.Rows) { if (rowsToKeep.Contains(row)) { tableResult.ImportRow(row); } } tableResult.EndLoadData(); resTable.DataType = tableResult; return(resTable); }
//------------------------------------------------ public CResultAErreur GetDonnees(IElementAVariablesDynamiquesAvecContexteDonnee elementAVariables, CListeObjetsDonnees listeDonnees, sc2i.common.IIndicateurProgression indicateur) { CResultAErreur result = CResultAErreur.True; if (indicateur != null) { indicateur.SetBornesSegment(0, IdTablesARetourner.Count()); } DataSet ds = new DataSet(); int nNbTables = 0; if (m_query != null) { m_query.ClearCache(); } foreach (string strIdTable in IdTablesARetourner) { foreach (object obj in m_query.Childs) { IObjetDeEasyQuery q = obj as IObjetDeEasyQuery; if (q.Id == strIdTable) { if (indicateur != null) { indicateur.SetInfo(q.NomFinal); } result = q.GetDatas(m_query.ListeSources); if (result) { DataTable table = result.Data as DataTable; if (table.DataSet != null) { DataTable newTable = table.Clone(); newTable.BeginLoadData(); foreach (DataRow row in table.Rows) { newTable.ImportRow(row); } newTable.EndLoadData(); table = newTable; } ds.Tables.Add(table); } else { return(result); } } } if (indicateur != null) { indicateur.SetValue(nNbTables++); } } if (indicateur != null) { indicateur.SetValue(IdTablesARetourner.Count()); } result.Data = ds; return(result); }