MyDataTableClass内存表管理

一、类名Class

类名:PublicFunctions.MyDataTableClass

 

二、属性Properties

 

三、方法Methods

1、获得DATATABLE中指定列的唯一值

函数:public static List<T> GetCellColumnsDistrictDataList<T>(string ColumnName, ref DataTable MyDataTable)

返回: List<T>

 

2、获得DATATABLE中指定列的唯一值(重载)

函数:public static List<T> GetCellColumnsDistrictDataList<T>(string ColumnName, ref DataTable MyDataTable, string StrWhere)

返回: List<T>

 

3、合并两张表

函数:public static void CombinDataTable(ref DataTable SourceDataTable, ref DataTable BaseDataTable, ref DataTable ResultDataTable)

SourceDataTable: 新数据源

BaseDataTable: 原数据表

ResultDataTable: 合并后的新数据表

返回: 无

 

4、将指定列的数据格式转换为string型

函数:public static void ConvertColumnType(string ColumnNameList, ref DataTable MyDataTable)

ColumnNameList: 要转换的列,如:"name,gender"

返回: 无

 

5、指定列的数据格式转换为任意类型

函数:public static void ConvertColumnType<T>(string ColumnNameList, ref DataTable MyDataTable)

ColumnNameList: 要转换的列,如:"name,gender"

返回: 无

 

6、转换指定列的名称

函数:public static void ConvertColumnName(string OldColumnName, string NewColumnName, ref DataTable MyDataTable, bool ConvertCaption = true)

返回: 无

 

7、指定列的顺序

函数:public static void SetColumnOrder(string ColumnName, int x, ref DataTable MyDataTable)

返回: 无

 

8、指定列的顺序(重载)

函数: public static void SetColumnOrder(string ColumnName, ref int x, ref DataTable MyDataTable)

返回: 无

 

9、添加字符型列

函数:public static void AddColumnList(string ColumnNameList, ref DataTable MyDataTable)

返回: 无

 

10、添加字符型列(重载)

函数:public static void AddColumnList(List<string> ColumnNameList, ref DataTable MyDataTable, int StartColumnIndex = -1)

StartColumnIndex: 起始序号

返回: 无

 

11、添加指定列,可指定字段类型

函数:public static void AddColumnList<T>(string ColumnNameList, ref DataTable MyDataTable)

返回: 无

 

12、删除指定列

函数:public static void RemoveColumnList(string ColumnNameList, ref DataTable MyDataTable)

返回: string;无

 

13、删除数据为空的字段

函数:public static void RemoveEmptyColumn(ref DataTable MaterialCodeDataTable)

返回: 无

 

14、为数据表绑定序号字段

函数:public static void BlindShowOrderColumn(int ColumnIndex, ref DataTable BasicDataResultDataTable)

ColumnIndex: “序号”字段排第几列,一般传0

返回: 无

 

15、为数据表绑定序号字段(重载),标明当前内存是第几页的数据表

函数:public static void BlindShowOrderColumn(int ColumnIndex, ref DataTable BasicDataResultDataTable, int pagesize, int pageno)

返回: 无

 

16、转换指定字段为有效的日期

函数:public static void ConvertColumnDataToValidDateTime(string ColumnNameList, ref DataTable MyDataTable)

返回: 无

 

17、转换指定字段为短日期格式

函数:public static void ConvertColumnDataToSmallDateTime(string ColumnNameList, ref DataTable MyDataTable)

返回: 无

 

18、将decimal字段转换为千分位显示字符串

函数:public static void FormatQFZNumber(ref DataTable MyDataTable)

返回: 无

 

19、只保留数据表中指定的字段,删除其它字段

函数:public static void RemoveAllUnnecessaryColumns(string ShowColumnList, ref DataTable ConsultResultDataTable)

返回: 无

 

20、只保留数据表中指定的字段,删除其它字段(重载)

函数:public static void RemoveAllUnnecessaryColumns(IEnumerable<string> ShowColumnList, ref DataTable ConsultResultDataTable)

返回: 无

 

21、还原数据库中的所有字符串数据

函数:public static void RestoreDataTableStringData(ref DataTable MyDataTable)

返回: 无

 

22、还原数据库中的所有HTML字符串数据

函数:public static void RestoreDataTableHtmlData(ref DataTable MyDataTable, string ColumnName)

返回: 无

 

23、克隆列

函数:public static void CloneColumn(string SourceColumnName, string TargetColumnName, ref DataTable MyDataTable)

返回: 无

 

24、删除数据表中的链接绑定

函数:public static void RemoveBlind(ref DataTable ExportExcelDataTable, bool RestoreDataTableStringData = true)

返回: 无

 

25、查询数据表

函数:public static DataTable SearchDataTable(DataTable AllDataTable, string StrWhere, string OrderBy = "")

返回: DataTable

 

26、合计运算

函数:public static decimal Sum(DataTable ReportTable, string SumColumnName, string StrWhere)

返回: decimal

 

27、count计算

函数:public static int Count(DataTable ReportTable, string ColumnName, string StrWhere)

返回: int

 

28、获得单条记录的数据字典

函数:public static Dictionary<string, T> GetCellRowDictionary<T>(int RowIndex, DataTable DataSource, string ColumnNameList = null)

返回: Dictionary<string, T>

 

29、获得单条记录的数据字典(重载)

函数:public static Dictionary<string, T> GetCellRowDictionary<T>(DataRow datarow, DataTable DataSource, string ColumnNameList = null)

返回: Dictionary<string, T>

 

30、获得两列的数据字典

函数:public static Dictionary<string, string> GetDictionary(string KeyColumnName, string ValueColumnName, DataTable DataSource)

KeyColumnName:&主键列

ValueColumnName:&值列

返回: Dictionary<string, string>

 

31、获得两列的数据字典(重载)

函数:public static Dictionary<string, string> GetDictionary(string KeyColumnName, string ValueColumnName, DataTable DataSource, string StrWhere)

KeyColumnName:&主键列

ValueColumnName:&值列

返回: Dictionary<string, string>

 

32、获得两列的数据字典(重载)

函数:public static Dictionary<T, V> GetDictionary<T, V>(string KeyColumnName, string ValueColumnName, DataTable DataSource)

KeyColumnName:&主键列

ValueColumnName:&值列

返回: Dictionary<T, V>

 

33、获得两列的数据字典(重载)

函数:public static Dictionary<T, V> GetDictionary<T, V>(string KeyColumnName, string ValueColumnName, DataTable DataSource, string StrWhere)

KeyColumnName:&主键列

ValueColumnName:&值列

返回: Dictionary<T, V>

 

34、获得单个字段的值

函数:public static string GetCellFieldValue(ref DataTable ResultDataTable, string FieldName, string StrWhere, string OrderBy = "")

返回: string

 

35、获得单个字段的值(重载),泛型

函数:public static T GetCellFieldValue<T>(ref DataTable ResultDataTable, string FieldName, string StrWhere)

返回: T

 

36、填充数据表的空值单元格

函数:public static void FillNullDisplayValue(ref DataTable datatable, List<string> RestrictColumnList = null, string NullDisplayValue = "<font class='GreyText'>-</font>")

返回: 无