HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>EIP資訊系統-會議室申請單管理</title>
<script language="javascript" type="text/javascript">
function btn_delete()
{
if(confirm('确定要刪除嗎?')==true)
{
var select=document.getElementById("GridView1").getElementsByTagName("input");
var no="";
for(var i=1;i<select.length;i++)
{
if(select[i].checked==true)
{
no=document.getElementById("GridView1").rows[i].cells[1].firstChild.innerText;
//調用后台方法
PageMethods.Hello(no,funReady,funError);
}
}
}
}
// result 就是后台方法返回的数据
function funReady(result){
alert("刪除成功!");
}
// err 就是后台方法返回的错误信息
function funError(err){
alert("Error:" + err._message);
}
</script>
</head>
<body>
<form id="form1" runat="server" method="post">
<table cellspacing="0" cellpadding="0" width="100%" border="0" bgcolor="#00bfff" style="font-family: 細明體; font-size: 10pt;">
<tr>
<td>
<table id="Table2" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td width="100%">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<font color= "#ff4500">會議室申請單</font> <img src="../IMG/xpLens.gif" alt=""/> 搜索关键字:
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem Value="0" Selected="True">--所有记录--</asp:ListItem>
<asp:ListItem Value="1">單據類別</asp:ListItem>
<asp:ListItem Value="doc_no">單據代號</asp:ListItem>
<asp:ListItem Value="fact_no">申請廠別</asp:ListItem>
<asp:ListItem Value="dept_no">申請單位</asp:ListItem>
<asp:ListItem Value="employee_no">申請人</asp:ListItem>
<asp:ListItem Value="3">審核狀態</asp:ListItem>
</asp:DropDownList>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="txt_date" runat="server" CssClass="Wdate" οnfοcus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})" Width="80"></asp:TextBox>
<asp:Button ID="btn_Search" runat="server" Text="查詢" />
<asp:Button ID="btn_Add" runat="server" Text="新增" PostBackUrl="~/UI/DOC/Add_MeetingInfo.aspx"/>
<input type="button" id="btn_del" value="刪除" οnclick="btn_delete();" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table cellpadding="1" cellspacing="2" border="0" width="100%" style="font-family: 細明體; font-size: 12pt;">
<tr>
<td width="100%" >
<asp:GridView ID="GridView1" runat="server" CellPadding="0" Width="100%"
AutoGenerateColumns="False" AllowPaging="True"
PageSize="15" HeaderStyle-Font-Size="10.5">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" ToolTip='<%#Eval("doc_no") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="申請單號" SortExpression="doc_no">
<ItemTemplate>
<asp:Label ID="lab_no" runat="server" Text='<%#Eval("doc_no") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="申請單位" DataField="dept_no" />
<asp:BoundField HeaderText="會議主題" DataField="subject" />
<asp:BoundField HeaderText="申請日期" DataField="app_date" />
<asp:BoundField HeaderText="申請人" DataField="employee_no" />
<asp:BoundField HeaderText="會議日期" DataField="minfo_date" />
<asp:TemplateField HeaderText="狀態" SortExpression="state">
<ItemTemplate>
<asp:DropDownList ID="drop_state" runat="server" Width="60px" Enabled="False" AutoPostBack="True" SelectedValue='<%# bind("state") %>'>
<asp:ListItem Text="未審核" Value="0"></asp:ListItem>
<asp:ListItem Text="送審中" Value="1"></asp:ListItem>
<asp:ListItem Text="已審核" Value="2"></asp:ListItem>
<asp:ListItem Text="已取消" Value="3"></asp:ListItem>
<asp:ListItem Text="已確認" Value="4"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="10.5pt" />
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
Asp.Net .cs文件
//后台方法功实现刪除功能,傳申請單號
[System.Web.Services.WebMethod]
public static string Hello(string no)
{
string sql = "delete from doc_meeting where doc_no='" + no + "'";
OracleDataAccess orcl = new OracleDataAccess();
orcl.ExeSql(sql);
return "刪除成功!";
}