DataTable table1 = new DataTable();
DbDataAdapter adapter1 = this.CreatAdapter();
adapter1.SelectCommand = this.CreatCommand(commandText, paraValue); try {
adapter1.Fill(table1); } finally {
adapter1.Dispose(); }
return table1; }
public void ExecuteNonQuery(string commandText) {
string[] textArray1 = new string[0];
this.ExecuteNonQuery(commandText, textArray1); }
public void ExecuteNonQuery(string commandText, object[] paraValue) {
this.CreatCommand(commandText, paraValue).ExecuteNonQuery(); }
public void ExecuteNonQuery(string commandText, string[] paraValue) {
this.CreatCommand(commandText, paraValue).ExecuteNonQuery(); }
public object ExecuteScalar(string commandText) {
string[] textArray1 = new string[0];
return this.CreatCommand(commandText, textArray1).ExecuteScalar(); }
public object ExecuteScalar(string commandText,object[] paraValue) {
return this.CreatCommand(commandText,paraValue).ExecuteScalar(); }
public object ExecuteScalar(string commandText,string[] paraValue) {
return this.CreatCommand(commandText,paraValue).ExecuteScalar(); } } }
(2)、根据XML文件生成表格类(MakeTable.cs):
using System;
using System.Data;
using System.Configuration; using System.Web;
using System.Web.Security; using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml; namespace Zhigu.Common {
///
/// 根据XML文件生成Table对象 /// public class MakeTable {
public MakeTable() { //
// TODO: 在此处添加构造函数逻辑 // }
#region 根据XML文件生成Table ///
/// 根据XML文件生成Table ///
/// ///
public Table MakeTableByXml(string _XmlFileName) {
int iSpan = Zhigu.Common.StaticVariable.CellsForOneRow; Table Table1 = new Table(); Table1.Width = Unit.Parse(\); Table1.CellPadding = 0; Table1.CellSpacing = 1;
Table1.BackColor = System.Drawing.Color.White; XmlDataSource XmlDataSource1 = new XmlDataSource(); XmlDataSource1.DataFile = _XmlFileName;
XmlDocument doc = XmlDataSource1.GetXmlDocument(); XmlElement xRoot = doc.DocumentElement; TableRow trTitle = new TableRow(); TableCell tcTitle = new TableCell(); Label LblUserName = new Label(); Label LblInfo = new Label();
LblInfo.Text = \的体检结果:\;
LblUserName.Text = xRoot.Name;//整编文档的根节点 此处为“未命名” LblUserName.Font.Bold = true;
LblUserName.ForeColor = System.Drawing.Color.Red; tcTitle.Controls.Add(LblUserName); tcTitle.Controls.Add(LblInfo); tcTitle.ColumnSpan = iSpan;
tcTitle.HorizontalAlign = HorizontalAlign.Left; tcTitle.Height = Unit.Parse(\); trTitle.Controls.Add(tcTitle); Table1.Rows.Add(trTitle); if (xRoot.HasChildNodes) {
for (int i = 0; i < xRoot.ChildNodes.Count; i++) {
TableRow tr = new TableRow(); TableCell td = new TableCell(); XmlNode xN = xRoot.ChildNodes[i]; Label LblkeshiName = new Label();
LblkeshiName.Text = \ + xN.Name + \体检详细情况:\;
Image img = new Image(); img.ID = \ + i.ToString(); img.ImageUrl = \; img.AlternateText = \展开详细内容\; td.Controls.Add(img);
td.Controls.Add(LblkeshiName);
tr.Attributes.Add(\, \); tr.Attributes.Add(\, \);
td.Attributes.Add(\, \ + i.ToString() + \);
td.ToolTip = \展开详细内容\;
tr.HorizontalAlign = HorizontalAlign.Left; tr.Font.Bold = true; tr.Cells.Add(td); Table1.Rows.Add(tr); if (xN.HasChildNodes) {
TableRow trInfo = new TableRow(); TableCell tcInfo = new TableCell(); Panel pan = new Panel(); pan.ID = \ + i.ToString();
pan.Attributes.Add(\,\);
Table tableInfo = new Table(); tableInfo.Width = Unit.Parse(\); tableInfo.CellPadding = 5; tableInfo.CellSpacing = 1; tableInfo.BorderWidth = 1;
tableInfo.BorderWidth = Unit.Parse(\);
for (int j = 0; j < xN.ChildNodes.Count; ) {
TableRow tr1 = new TableRow(); if (j - (iSpan * (j / iSpan)) == 0) {
tr1.Attributes.Add(\, \); } else {
tr1.Attributes.Add(\, \); }
for (int jj = 1; jj < iSpan / 2; jj++) {
if (xN.ChildNodes[j] != null) {
TableCell tc1 = new TableCell();
tc1.HorizontalAlign = HorizontalAlign.Right; tc1.Width = Unit.Parse(\);
tc1.Text = xN.ChildNodes[j].Name + \:\; tr1.Cells.Add(tc1);
TableCell tc2 = new TableCell();
tc2.HorizontalAlign = HorizontalAlign.Left; tc2.Width = Unit.Parse(\); tc2.Text = xN.ChildNodes[j].InnerText; tr1.Cells.Add(tc2); j++; }
if (xN.ChildNodes[j] != null) {
TableCell tc3 = new TableCell();
tc3.HorizontalAlign = HorizontalAlign.Right; tc3.Width = Unit.Parse(\);
tc3.Text = xN.ChildNodes[j].Name + \:\; tr1.Cells.Add(tc3);
TableCell tc4 = new TableCell();
tc4.HorizontalAlign = HorizontalAlign.Left;
tc4.Width = Unit.Parse(\); tc4.Text =
xN.ChildNodes[j].InnerText;//.Replace(xN.ChildNodes[j].Name, \ tr1.Cells.Add(tc4); j++; } }
tableInfo.Rows.Add(tr1); }
pan.Controls.Add(tableInfo); tcInfo.Controls.Add(pan); trInfo.Cells.Add(tcInfo); Table1.Rows.Add(trInfo); } } }
XmlDataSource1.Dispose(); return Table1; }
#endregion }
}
(3)、通用函数类(StaticFunction.cs):
using System; using System.Data;
using System.Configuration; using System.Web;
using System.Web.Security; using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text.RegularExpressions; using System.IO; namespace Zhigu.Common {
///
public class StaticFunction {
#region 根据提示信息、出错返回方式及返回地址生成Javascript代码 ///