/// <summary> /// 执行保存. /// </summary> public void Save() { FrmRpt rpt = new FrmRpt(this.EnsName); DataTable dtCol = BP.DA.DBAccess.RunSQLReturnTable(rpt.SQLOfColumn); DataTable dtRow = BP.DA.DBAccess.RunSQLReturnTable(rpt.SQLOfRow); BP.DA.DBAccess.RunSQL("DELETE " + rpt.PTable + " WHERE RefOID=" + this.RefPKVal); Paras ps = new Paras(); ps.SQL = "INSERT INTO " + rpt.PTable + " ()VALUES()"; foreach (DataRow drCol in dtCol.Rows) { string col = drCol[0].ToString(); foreach (DataRow drRow in dtRow.Rows) { ps.Clear(); string row = drRow[0].ToString(); string val = this.Pub1.GetTextBoxByID("TB_" + col + "" + row).Text; ps.Add("Col", col); ps.Add("Row", col); ps.Add("Val", decimal.Parse(val)); ps.Add("MyPK", col + "_" + row + "_" + this.RefPKVal); BP.DA.DBAccess.RunSQL(ps); } } }
protected void Page_Load(object sender, EventArgs e) { this.Page.RegisterClientScriptBlock("s", "<link href='../Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />"); FrmRpt mdtl = new FrmRpt(this.EnsName); if (this.IsReadonly == 1) { mdtl._IsReadonly = 1; this.Button1.Enabled = false; } this.Bind(mdtl); }
public void Bind(FrmRpt rpt) { if (this.Request.QueryString["IsTest"] != null) { BP.DA.Cash.SetMap(this.EnsName, null); } this.FK_MapData = rpt.FK_MapData; #region 生成标题 DataTable dtCol = BP.DA.DBAccess.RunSQLReturnTable(rpt.SQLOfColumn); DataTable dtRow = BP.DA.DBAccess.RunSQLReturnTable(rpt.SQLOfRow); this.Pub1.AddTable(); this.Pub1.AddTR(); this.Pub1.AddTDTitle("序号"); this.Pub1.AddTDTitle("项目"); foreach (DataRow drCol in dtCol.Rows) { this.Pub1.AddTDTitle(drCol[1].ToString()); } this.Pub1.AddTREnd(); #endregion // 获得数据源数据. DataTable dt = null; try { string sql = "SELECT * FROM " + rpt.PTable + " WHERE RefOID=" + this.RefOID; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); } catch { BP.Sys.DataRpt rptTemplete = new DataRpt(); rpt.CheckPhysicsTable(); string sqlRename = ""; switch (BP.Sys.SystemConfig.AppCenterDBType) { case DBType.MSSQL: sqlRename = "EXEC SP_RENAME Sys_DataRpt, " + rpt.PTable; break; case DBType.Informix: sqlRename = "RENAME TABLE Sys_DataRpt TO " + rpt.PTable; break; case DBType.Oracle: sqlRename = "ALTER TABLE Sys_DataRpt rename to " + rpt.PTable; break; case DBType.MySQL: sqlRename = "ALTER TABLE Sys_DataRpt rename to " + rpt.PTable; break; default: throw new Exception("@未涉及到此类型."); } DBAccess.RunSQL(sqlRename); string sql = "SELECT * FROM " + rpt.PTable + " WHERE RefOID=" + this.RefOID; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); } #region 生成单元格 foreach (DataRow drCol in dtCol.Rows) { string noOfCol = drCol[0].ToString(); this.Pub1.AddTR(); foreach (DataRow drRow in dtRow.Rows) { string noOfRow = drRow[0].ToString(); TextBox tb = new TextBox(); tb.ID = "TB_" + noOfCol + "" + noOfRow; //求出此单元格数据. foreach (DataRow dr in dt.Rows) { if (dr[BP.Sys.DataRptAttr.ColCount].ToString() != noOfCol) { continue; } if (dr[BP.Sys.DataRptAttr.RowCount].ToString() != noOfRow) { continue; } tb.Text = dr["Val"].ToString(); break; } this.Pub1.AddTD(tb); } this.Pub1.AddTREnd(); } #endregion 生成单元格 this.Pub1.AddTableEnd(); }