Utility.aspx.cs:(主页面)
try
{
DataTable dt = new DataTable();
//获取Utility_Pre.aspx多个ID Session
string[] strArrUtilizeID = Session["utilizeID"].ToString().Split(';');
//ID循环
for (int i = 0; i < strArrUtilizeID.Length-1; i++)
{
//获取数据库
SqlParameter[] sqlParam = new SqlParameter[1];
sqlParam[0] = new SqlParameter("@utilizeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "@utilizeID", DataRowVersion.Default,strArrUtilizeID[i].ToString());
ds = db.GetDataSet("procUtility", sqlParam);
//DataTable初始化
# region dt Column
if (i == 0)
{
for (int intColumn = 0; intColumn < ds.Tables[0].Columns.Count; intColumn++)
{
dt.Columns.Add(ds.Tables[0].Columns[intColumn].ColumnName);
}
}
# endregion
//DataRow 初始化
DataRow dr = dt.NewRow();
for (int intCol = 0; intCol < ds.Tables[0].Columns.Count; intCol++)
{
#region dr
if (ds.Tables[0].Columns[intCol].ColumnName == "M_Piece" || ds.Tables[0].Columns[intCol].ColumnName == "M_Utilize")
{
try
{
dr[intCol] = decimal.Parse(ds.Tables[0].Rows[0][intCol].ToString());
}
catch
{
dr[intCol] = 0;
}
}
else if (ds.Tables[0].Columns[intCol].ColumnName == "UpdateDate")
{
try
{
dr[intCol] = DateTime.Parse(ds.Tables[0].Rows[0][intCol].ToString());
}
catch
{
dr[intCol] = DateTime.Now;
}
}
else
{
dr[intCol] = ds.Tables[0].Rows[0][intCol].ToString();
}
# endregion
}
grdUtility.DataBind();
}
catch (Exception e)
{
string strEX = e.ToString();
}
{
DataTable dt = new DataTable();
//获取Utility_Pre.aspx多个ID Session
string[] strArrUtilizeID = Session["utilizeID"].ToString().Split(';');
//ID循环
for (int i = 0; i < strArrUtilizeID.Length-1; i++)
{
//获取数据库
SqlParameter[] sqlParam = new SqlParameter[1];
sqlParam[0] = new SqlParameter("@utilizeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "@utilizeID", DataRowVersion.Default,strArrUtilizeID[i].ToString());
ds = db.GetDataSet("procUtility", sqlParam);
//DataTable初始化
# region dt Column
if (i == 0)
{
for (int intColumn = 0; intColumn < ds.Tables[0].Columns.Count; intColumn++)
{
dt.Columns.Add(ds.Tables[0].Columns[intColumn].ColumnName);
}
}
# endregion
//DataRow 初始化
DataRow dr = dt.NewRow();
for (int intCol = 0; intCol < ds.Tables[0].Columns.Count; intCol++)
{
#region dr
if (ds.Tables[0].Columns[intCol].ColumnName == "M_Piece" || ds.Tables[0].Columns[intCol].ColumnName == "M_Utilize")
{
try
{
dr[intCol] = decimal.Parse(ds.Tables[0].Rows[0][intCol].ToString());
}
catch
{
dr[intCol] = 0;
}
}
else if (ds.Tables[0].Columns[intCol].ColumnName == "UpdateDate")
{
try
{
dr[intCol] = DateTime.Parse(ds.Tables[0].Rows[0][intCol].ToString());
}
catch
{
dr[intCol] = DateTime.Now;
}
}
else
{
dr[intCol] = ds.Tables[0].Rows[0][intCol].ToString();
}
# endregion
}
dt.Rows.Add(dr);
}
grdUtility.DataSource
= dt;grdUtility.DataBind();
}
catch (Exception e)
{
string strEX = e.ToString();
}
Utility_Pre.aspx.cs
protected void btnOK_Click(object sender, EventArgs e)
{
string strUID = "";
for (int i = 0; i < grdPre.Rows.Count; i++)
{
if (((CheckBox)grdPre.Rows[i].Cells[0].FindControl("item")).Checked == true)
{
string strD = ((Label)grdPre.Rows[0].Cells[10].FindControl("Label1")).Text;
string strM = ((Label)grdPre.Rows[0].Cells[11].FindControl("Label2")).Text;
string strSql = "select max(utilizeID) from t_bputilize";
DataSet ds = db.GetDataSet(strSql);
int intU = int.Parse(ds.Tables[0].Rows[0][0].ToString())+1;
db.ExecuteNonQuery(strSql);
}
}
Session["utilizeID"] = strUID;
Response.Write("<script>window.opener.refresh();window.close()</script>");
}
{
string strUID = "";
for (int i = 0; i < grdPre.Rows.Count; i++)
{
if (((CheckBox)grdPre.Rows[i].Cells[0].FindControl("item")).Checked == true)
{
string strD = ((Label)grdPre.Rows[0].Cells[10].FindControl("Label1")).Text;
string strM = ((Label)grdPre.Rows[0].Cells[11].FindControl("Label2")).Text;
string strSql = "select max(utilizeID) from t_bputilize";
DataSet ds = db.GetDataSet(strSql);
int intU = int.Parse(ds.Tables[0].Rows[0][0].ToString())+1;
strSql
= "insert into t_bputilize(utilizeID,MoelGroupID,DetailID) values('"+intU+"','" + strM + "','" + strD + "')";db.ExecuteNonQuery(strSql);
strUID
= strUID+intU.ToString()+";";}
}
Session["utilizeID"] = strUID;
Response.Write("<script>window.opener.refresh();window.close()</script>");
}
Utility_Pre.aspx:
<yyc:SmartGridView ID="grdPre" runat='server' AutoGenerateColumns="False">
<HeaderStyle CssClass="grid_head" />
<Columns>
<asp:TemplateField>
<headertemplate>
<asp:CheckBox ID="all" runat="server" />
</headertemplate>
<itemtemplate>
<asp:CheckBox ID="item" runat="server" />
</itemtemplate>
<itemstyle width="50px" />
</asp:TemplateField>
<asp:BoundField DataField="CMALPH" HeaderText="Customer" />
<asp:BoundField DataField="Size" HeaderText="Size" />
<asp:BoundField DataField="TACFilm" HeaderText="TACFilm" />
<asp:BoundField DataField="Treatment" HeaderText="Treatment" />
<asp:BoundField DataField="thickness" HeaderText="Thickness" />
<asp:BoundField DataField="Tablets" HeaderText="T/B" />
<asp:BoundField DataField="AbsorAngle" HeaderText="Absorption Angle" />
<asp:BoundField DataField="DimensionX" HeaderText="Dimension_X" />
<asp:BoundField DataField="DimensionY" HeaderText="Dimension_Y" />
<asp:TemplateField HeaderText="DetailID" visible="false">
<edititemtemplate>
<asp:TextBox runat="server" Text='<%# Bind("DetailID") %>' id="TextBox1"></asp:TextBox>
</edititemtemplate>
<itemtemplate>
<asp:Label runat="server" Text='<%# Bind("DetailID") %>' id="Label1"></asp:Label>
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ModelGroupID" visible="false">
<edititemtemplate>
<asp:TextBox runat="server" Text='<%# Bind("ModelGroupID") %>' id="TextBox2"></asp:TextBox>
</edititemtemplate>
<itemtemplate>
<asp:Label runat="server" Text='<%# Bind("ModelGroupID") %>' id="Label2"></asp:Label>
</itemtemplate>
</asp:TemplateField>
</Columns>
<CascadeCheckboxes >
<yyc:CascadeCheckbox ChildCheckboxID="item" ParentCheckboxID="all" />
</CascadeCheckboxes>
</yyc:SmartGridView>
<asp:Button ID="btnOK" runat="server" OnClick="btnOK_Click" Text="确定" /></div>
<HeaderStyle CssClass="grid_head" />
<Columns>
<asp:TemplateField>
<headertemplate>
<asp:CheckBox ID="all" runat="server" />
</headertemplate>
<itemtemplate>
<asp:CheckBox ID="item" runat="server" />
</itemtemplate>
<itemstyle width="50px" />
</asp:TemplateField>
<asp:BoundField DataField="CMALPH" HeaderText="Customer" />
<asp:BoundField DataField="Size" HeaderText="Size" />
<asp:BoundField DataField="TACFilm" HeaderText="TACFilm" />
<asp:BoundField DataField="Treatment" HeaderText="Treatment" />
<asp:BoundField DataField="thickness" HeaderText="Thickness" />
<asp:BoundField DataField="Tablets" HeaderText="T/B" />
<asp:BoundField DataField="AbsorAngle" HeaderText="Absorption Angle" />
<asp:BoundField DataField="DimensionX" HeaderText="Dimension_X" />
<asp:BoundField DataField="DimensionY" HeaderText="Dimension_Y" />
<asp:TemplateField HeaderText="DetailID" visible="false">
<edititemtemplate>
<asp:TextBox runat="server" Text='<%# Bind("DetailID") %>' id="TextBox1"></asp:TextBox>
</edititemtemplate>
<itemtemplate>
<asp:Label runat="server" Text='<%# Bind("DetailID") %>' id="Label1"></asp:Label>
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ModelGroupID" visible="false">
<edititemtemplate>
<asp:TextBox runat="server" Text='<%# Bind("ModelGroupID") %>' id="TextBox2"></asp:TextBox>
</edititemtemplate>
<itemtemplate>
<asp:Label runat="server" Text='<%# Bind("ModelGroupID") %>' id="Label2"></asp:Label>
</itemtemplate>
</asp:TemplateField>
</Columns>
<CascadeCheckboxes >
<yyc:CascadeCheckbox ChildCheckboxID="item" ParentCheckboxID="all" />
</CascadeCheckboxes>
</yyc:SmartGridView>
<asp:Button ID="btnOK" runat="server" OnClick="btnOK_Click" Text="确定" /></div>
相关文章
暂无评论...