Csharp 两个DataTable或DataView互换,可以用来加密解密
/// <summary> /// 涂聚文 geovindu.blog.163.com /// www.dusystem.com www.dupcit.com /// 2011-05-28 /// </summary> /// <param name="table"></param> /// <returns></returns> static DataTable GetDecTable(DataTable table) { if (!object.Equals(table, null))// { DataTable tableDec = new DataTable(); tableDec.Columns.Add("序号", typeof(string)); tableDec.Columns.Add("员工编号", typeof(string)); tableDec.Columns.Add("姓名", typeof(string)); tableDec.Columns.Add("身份证号", typeof(string)); tableDec.Columns.Add("入职时间", typeof(DateTime)); foreach (DataRow row in table.Rows) // Loop over the rows. { tableDec.Rows.Add(row["序号"].ToString(), row["员工编号"].ToString(), row["姓名"].ToString(), row["身份证号"].ToString(), row["入职时间"].ToString()); } return tableDec; } else { return null; } } /// <summary> /// 涂聚文 締友計算機信息技術有限公司,捷為工作室,geovindu.blog.163.com /// www.dusystem.com www.dupcit.com /// 2011-05-28 /// </summary> /// <param name="view"></param> /// <returns></returns> static DataView getDecView(DataView view) { if (!object.Equals(view, null)) { DataTable tableDec = new DataTable(); tableDec.Columns.Add("序号", typeof(string)); tableDec.Columns.Add("员工编号", typeof(string)); tableDec.Columns.Add("姓名", typeof(string)); tableDec.Columns.Add("身份证号", typeof(string)); tableDec.Columns.Add("入职时间", typeof(DateTime)); DataView dv = new DataView(tableDec); //DataSet dset = new DataSet(); //dset = hr.HrestDataSet(); dv.AllowNew = true; //rowView["ProductName"] = "New Product Name"; //dv.AddNew(); //foreach (DataRow theRow in thisDataSet.Tables["Employee"].Rows) //{ // Console.WriteLine(theRow["ID"] + "\t" + theRow["FirstName"]); //} //DataView view = new DataView(ds.Tables[0]); foreach (DataRowView drv in view) { DataRowView rowView = dv.AddNew(); rowView["序号"] = drv["序号"].ToString(); rowView["员工编号"] =drv["员工编号"].ToString(); rowView["姓名"] = drv["姓名"].ToString; rowView["身份证号"] = drv["身份证号"].ToString(); rowView["入职时间"] = drv["入职时间"].ToString(); } //// find the record for Rick //view.RowFilter = "Name = 'Evy'"; //foreach (DataRowView drv in view) //{ // Console.WriteLine(drv["Name"].ToString()); //} return dv; } else { return null; } }
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)