[Quantproject-developers] QuantProject/b1_ADT ExtendedDataTable.cs,1.2,1.3
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-07-25 12:09:01
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4857/b1_ADT Modified Files: ExtendedDataTable.cs Log Message: New methods to: - ExtendedDataTable class; - Quotes and Tickers_tickerGroups in DataAccess layer; - Quotes and TickerDataTable in Data layer Index: ExtendedDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/ExtendedDataTable.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExtendedDataTable.cs 27 Jun 2004 19:15:02 -0000 1.2 --- ExtendedDataTable.cs 25 Jul 2004 12:08:52 -0000 1.3 *************** *** 19,49 **** /// Sort the given DataTable by the specified field, in a DESC mode /// </summary> ! ! public static void Sort(DataTable tableToSort, string sortingFieldName) { DataTable copyOfTableToSort = tableToSort.Copy(); ! DataRow[] orderedRows = copyOfTableToSort.Select("", sortingFieldName + " DESC"); ! int numRows = tableToSort.Rows.Count; ! int numColumns = tableToSort.Columns.Count; ! object[] valuesToAdd = new object[numColumns]; tableToSort.Rows.Clear(); ! for(int i = 0;i<numRows;i++) { ! for(int j = 0;j<numColumns;j++) ! { ! valuesToAdd[j]=orderedRows[i][j]; ! } ! tableToSort.Rows.Add(valuesToAdd); } - tableToSort.AcceptChanges(); - } ! public static void DeleteRows(DataTable tableWithRowsToDelete, long indexOfRowFromWhichDeletionHasToBeDone) { ! for(long i = indexOfRowFromWhichDeletionHasToBeDone;i<tableWithRowsToDelete.Rows.Count;i++) { ! tableWithRowsToDelete.Rows.RemoveAt((int)i); } - tableWithRowsToDelete.AcceptChanges(); } --- 19,59 ---- /// Sort the given DataTable by the specified field, in a DESC mode /// </summary> ! public static void Sort(DataTable tableToSort, string sortingFieldName, bool sortByASC) { DataTable copyOfTableToSort = tableToSort.Copy(); ! string sortDirection = " DESC"; ! if(sortByASC) ! sortDirection = " ASC"; ! DataRow[] orderedRows = copyOfTableToSort.Select("", sortingFieldName + sortDirection); tableToSort.Rows.Clear(); ! for(int i = 0;i<orderedRows.Length;i++) { ! tableToSort.ImportRow(orderedRows[i]); } } ! ! /// <summary> ! /// Copy the given DataTable into another DataTable, sorting by the specified field, in a DESC mode ! /// </summary> ! public static DataTable CopyAndSort(DataTable tableToCopyAndSort, string sortingFieldName, bool sortByASC) { ! DataTable copyOfTableToCopyAndSort = tableToCopyAndSort.Clone(); ! string sortDirection = " DESC"; ! if(sortByASC) ! sortDirection = " ASC"; ! DataRow[] orderedRows = tableToCopyAndSort.Select("", sortingFieldName + sortDirection); ! for(int i = 0;i<orderedRows.Length;i++) { ! copyOfTableToCopyAndSort.ImportRow(orderedRows[i]); ! } ! return copyOfTableToCopyAndSort; ! } ! ! public static void DeleteRows(DataTable table, long fromIndex) ! { ! for(long i = table.Rows.Count - 1;i>=fromIndex; i=table.Rows.Count-1) ! { ! table.Rows.RemoveAt((int)i); } } |