ajax Detail.aspx页面
protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(500);
string Keyid = Request.QueryString["Id"].ToString();
//string wsn = Request.QueryString["wsn"].ToString();
DataTable dt = Hst.Paging.Paging.GetList(" ExecSN ='" + Keyid + "' and (Status='已检验' or status='部分入库')", "V_ExecPro_Bom1").Tables[0];
StringBuilder sb = new StringBuilder();
sb.Append("<table style='width:83%' style='margin:2px;border:Double 3px #5D7B9D;'><tr><th>选择</th>");
sb.Append("<th>产品编码</th><th>产品名称</th><th>产品规格</th><th>产品型号</th><th>产品材质</th>");
sb.Append("<th>产品图纸号</th><th>产品单位</th><th>计划数量</th><th>合格数量</th><th>未入库数量</th><th>本次入库数量</th></tr>");
string a = "";
bool isFirst = false;
if (dt.Rows.Count != 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string onleyone = dt.Rows[i]["R_BOMSN"].ToString() + dt.Rows[i]["PlanSN"].ToString();
if (a != onleyone || isFirst = false)
{
a = onleyone; isFirst = true;
sb.Append("<tr><td class='detail'><input type='checkbox' name='checkbox' value='" + dt.Rows[i]["ExecProID"].ToString() + "'/>");
sb.Append("<td class='detail'>" + dt.Rows[i]["BOMSN"].ToString() + " </td><td class='detail'>" + dt.Rows[i]["BomName"].ToString() + " </td><td class='detail'>" + dt.Rows[i]["Size"].ToString() + "</td><td class='detail'>" + dt.Rows[i]["Model"].ToString() + " </td> ");
sb.Append("<td class='detail'>" + dt.Rows[i]["Qulity"].ToString() + "</td><td class='detail'>" + dt.Rows[i]["ImageNo"].ToString() + "</td><td class='detail'>" + dt.Rows[i]["Unit"].ToString() + "</td><td class='detail'>" + dt.Rows[i]["PlanNumber"].ToString() + "</td><td class='detail'>" + dt.Rows[i]["OkNumber"].ToString() + "</td> ");
sb.Append("<td class='detail'><input id='TextNotIn_" + dt.Rows[i]["ExecProID"].ToString() + "' type='text' value='" + dt.Rows[i]["NotInNumber"].ToString() + "' style='background-color: transparent; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none; width: 50px;' readonly='readonly' /></td><td class='detail'><input id='TextRK_" + dt.Rows[i]["ExecProID"].ToString() + "' type='text' value='" + dt.Rows[i]["NotInNumber"].ToString() + "' style=' width:50px' /></td> </tr>");
}
}
sb.Append(" </table>");
Response.Write(sb.ToString());
}
else
{
return;
}
主页面
<script language="javascript" type="text/javascript" >
// <!CDATA[
function Show(id)
{
if(document.getElementById("Details"+id).style.display=="none")
{
document.getElementById("Details"+id).style.display="block";
document.getElementById("Content_"+id).innerHTML="<div style='font-weight:300; color:red; width:100%; text-align:center;'><img src='../../../images/ajax-loader.gif' /> 正在加载...</div>";
sendRequest("Detail.aspx?Id="+id,"GetOrdersDetails");
document.getElementById("ExpSpan"+id).src="../../../images/-.png";
}
else
{
document.getElementById("Details"+id).style.display="none";
document.getElementById("ExpSpan"+id).src="../../../images/+.png";
}
}
function ReEnter(a)
{
openWindow("../OutStorage/SelectWarehouse.aspx",700,600)
a.style.border="#cdcdcd 1px solid";
}
// ]]>
</script>
<ItemTemplate>
<tr>
<%--<td class="ItemTemplate">
<a href="javascript:openWindow('ProcMscinAdd.aspx?Id=<%#Eval("ExecSN") %>',900,700)">
选择</a>
</td>--%>
<td class="ItemTemplate " οnclick="Show('<%#Eval("ExecSN") %>')" style="cursor: hand">
<img src="../../../images/+.png" alt="点击展开" id="ExpSpan<%#Eval("ExecSN") %>" />
<%#Eval("CheckSN")%>
</td>
<td class="ItemTemplate " οnclick="Show('<%#Eval("ExecSN") %>')" style="cursor: hand">
<%#Eval("EmployeeName")%>
</td>
<td class="ItemTemplate " οnclick="Show('<%#Eval("ExecSN") %>')" style="cursor: hand">
<%#Eval("DepartMentName")%>
</td>
<td class="ItemTemplate " οnclick="Show('<%#Eval("ExecSN") %>')" style="cursor: hand">
<%#Eval("IsIn").ToString() == "0" ? "未出库" : "已出库"%>
</td>
<td class="ItemTemplate " οnclick="Show('<%#Eval("ExecSN") %>')" style="cursor: hand">
<%#((DateTime)Eval("CheckDate")).ToString("yyyy-MM-dd")%>
</td>
</tr>
<tr style="display: none" id="Details<%#Eval("ExecSN") %>">
<td colspan="6" style="text-align: left; padding-left: 25px; background-image: url(../images_index/L.gif);
background-repeat: no-repeat; background-position: 6px top;" id="Content_<%#Eval("ExecSN") %>">
</td>
</tr>
</ItemTemplate>
DataTable去除重复
public static DataTable GetInfoS( string WhereStr)
{
DataTable dt = Hst.DBUtility.DbHelperSQL.Query("select * from V_ExecPro_Bom_y where " + WhereStr).Tables[0];
DataTable dtNew = new DataTable();
dtNew = dt.Clone();
//Hst.DBUtility.DbHelperSQL.Query("select * from V_ExecPro_Bom_y where " + WhereStr).Tables[0];
bool isFrist = true;
string a = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
string one = dt.Rows[i]["BOMSN"].ToString() + dt.Rows[i]["PlanSN"].ToString();
if (a != one || isFrist == true)
{
a = one; isFrist = false;
dtNew.Rows.Add(dt.Rows[i].ItemArray);
}
}
return dtNew;
}
注:for (int i = 10; j < dt.Rows.Count; i++) { row = dtn.NewRow(); row = dt.Rows[j]; dtn.ImportRow(row); }
DataTable dtn =dt.Copy();
复制表结构和数据
dt.Clone,光复制表结构