62,046
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(function () {
$("#delete").live("click",function () {
var $id = $(this).attr("deleteid");
$("#form1").attr("action", "ReaderBorrowHistory.aspx?cid=" + $id);
$("#form1").submit();
});
});
</script>
<body>
<form id="form1" method="post" action="ReaderBorrowHistory.aspx">
<div>
<table id="Table1" style="font-family:Tahoma; font-size:12px; border-collapse:collapse ;" align="center" bgcolor="#f1f0f4" border="0" width="398">
<tr>
<td align ="center" >
<h1><font face ="GB_2312">借阅记录</font></h1>
<hr width ="90%" />
</td>
</tr>
<tr>
<td align ="center">
<%=outputTable %> <!-- outputtable是在后台定义的公共变量 用于放置动态拼接出的一个table -->
</td>
</tr>
</table>
</div>
</form>
</body>
public string outputTable;
protected void Page_Load(object sender, EventArgs e)
{
//if (!this.IsPostBack)
//{
// GridViewDataBind();
//}
StringBuilder sText = new StringBuilder();
sText.Append("<table id='table2'><tr><td>");
sText.Append("选择</td><td>");
sText.Append("题名/作者</td><td>出版信息</td>");
sText.Append("<td>借阅时间</td><td>应还时间</td></tr>");
Borrow borrow = new Borrow();
DataSet ds = borrow.QueryCurrentBorrow(Session["userID"].ToString());
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
sText.Append("<tr><td> <INPUT name=‘chkSon’ id='hkSon1' type='checkbox' value=" + row["BookID"].ToString() + "/></td>");
sText.Append("<td>" + row["BookName"].ToString() + "/ "
+ row["BookAuthor"].ToString() + "</td>");
sText.Append("<td>" + row["BookPublish"].ToString() + ""
+ row["BookPublishDate"].ToString() + "</td>");
sText.Append("<td>" + DateTime.Parse(row["BorrowBeginDate"].ToString()).ToString("yyyy-MM-dd") + "</td><td>"
+ DateTime.Parse(row["BorrowEndDate"].ToString()).ToString("yyyy-MM-dd") + "</td>");
sText.Append("<td><span>编辑</span></td>");
sText.Append("<td><span id='delete' deleteid='" + row["BorrowID"].ToString() + "'>删除</span></td></tr>");
}
sText.Append("</table>");
outputTable = sText.ToString();
}
else
{
outputTable = "<h1>该用户目前没有借书</h1>";
}
if (Request["cid"] != null)
{
int cid = int.Parse(Request["cid"]);
bool result = borrow.DeleteByProc(cid);
if (result)
{
Page.ClientScript.RegisterStartupScript (this.GetType(),"","<script> alert('删除记录成功');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script> alert('删除记录失败');</script>");
}
}
}