/// <Summary>
/// Tu juwen
/// 2012-04-14
/// </Summary>
/// <Param name = "table"> </param>
/// <Returns> </returns>
Static DataTable GetDecTable (DataTable table)
{
If (! Object. Equals (table, null ))//
{
// Foreach (DataRow myRow in thisTable. Rows ){
// Foreach (DataColumn myCol in thisTable. Columns ){
// Console. WriteLine (myRow [myCol]);
//}
// DataTable tablecopy = table. Copy ();
DataTable tableDec = new DataTable ();
// TableDec = table. Copy ();
// Obtain the column name and data type.
// Foreach (DataColumn column in table. Columns)
//{
// TableDec. Columns. Add (column. ColumnName, column. DataType );
//}
// Foreach (DataColumn myCol in table. Columns)
//{
// If (myCol. ColumnName = "EmployeeNo ")
//{
/// Row [myCol]
//}
// Foreach (DataRow row in table. Rows) // Loop over the rows.
//{
/// TableDec. Rows. Add (myRow [myCol])
//}
// String employeeNo = CryptographerUTF. GetDecryptString (row ["EmployeeNo"]. ToString ());
// String employeeName = CryptographerUTF. GetDecryptString (row ["EmployeeName"]. ToString ());
// TableDec. Rows. Add ();
//}
// Clone table structure, data record not filled
// TableDec = table. Clone ();
// Foreach (DataColumn gcol in datatable. Columns)
//{
// If (gcol. ColumnName = "EmployeeNo ")
//{
/// Modify the Data Type
// Gcol. DataType = typeof (String );
//}
//}
// Fill in data for the new table
// Foreach (DataRow row in tableDec. Rows)
//{
// DataRow nr = datatable. NewRow ();
// Nr ["EmployeeName"] = row ["EmployeeName"];
//// Modify the record
// Nr ["EmployeeNo"] = row ["EmployeeNo"]. toString ()";
// Nr ["sex"] = row ["sex"];
// Datatable. Rows. Add (nr );
//}
// Copy the table structure and data
TableDec = table. Copy ();
// Change the data of a specified Column
Foreach (DataRow row in tableDec. Rows)
{
// Modify the record value
Row ["EmployeeNo"] = CryptographerUTF. GetDecryptString (row ["EmployeeNo"]. ToString ());
// Modify the record value
Row ["EmployeeName"] = CryptographerUTF. GetDecryptString (row ["EmployeeName"]. ToString ());
}
Return tableDec;
}
Else
{
Return null;
}
}
From®Geovin Du Dream Park™