baoa_lf_mod.aspx
来自「ASP.NET开发实战详解」· ASPX 代码 · 共 152 行
ASPX
152 行
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.sqlclient" %>
<script runat="server">
dim Cnn as sqlconnection
dim cmd as sqlcommand
shared str3 as string
Sub Page_Load(Sender As Object, E As EventArgs)
dim sql as string
str3="<script language='javascript'>window.close()<"
str3+="/"
str3+="script>"
if Not IsPostBack then
dim theid as string=trim(request.querystring("id"))
dim datar as sqldatareader
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="select * from ba_visit where id=" & theid
cmd=new sqlcommand(sql,cnn)
datar=cmd.executereader()
if datar.read() then
stime.text=Iif(IsDbNull(datar("stime")),"",datar("stime"))
etime.text=Iif(IsDbNull(datar("etime")),"",datar("etime"))
lfr.text=Iif(IsDbNull(datar("lfr")),"",datar("lfr"))
zj.text=iif(isdbnull(datar("zj")),"",datar("zj"))
lfraddr.text=Iif(IsDbNull(datar("lfraddr")),"",datar("lfraddr"))
reason.text=Iif(IsDbNull(datar("reason")),"",datar("reason"))
bfr.text=Iif(IsDbNull(datar("bfr")),"",datar("bfr"))
bfraddr.text=Iif(IsDbNull(datar("bfraddr")),"",datar("bfraddr"))
zbr.text=Iif(IsDbNull(datar("zbr")),"",datar("zbr"))
memo.text=Iif(IsDbNull(datar("memo")),"",datar("memo"))
Else
page.registerstartupscript("",getalertinfo("该来访记录不存在,可能已被删除!"))
Page.RegisterStartupScript("StartUp",str3)
End if
datar.close()
End if
End Sub
Sub Save_Click(Sender As Object, E As EventArgs)
dim theid as string=trim(request.querystring("id"))
dim stimeStr as string=stime.text
dim etimeStr as string=etime.text
dim lfrStr as string=lfr.text
dim zjstr as string=zj.text
dim lfraddrstr as string=lfraddr.text
dim reasonstr as string=reason.text
dim bfrstr as string=bfr.text
dim bfraddrstr as string=bfraddr.text
dim zbrstr as string=zbr.text
dim memostr as string=memo.text
dim sql as string
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="update ba_visit set stime='" & stimestr & "',etime='" & etimestr & "',lfr='" & lfrstr & "',zj='" & zjstr & "',lfraddr='" & lfraddrstr & "',reason='" & reasonstr & "',bfr='" & bfrstr & "',bfraddr='" & bfraddrstr & "',zbr='" & zbrstr & "',memo='" & memostr & "' where id=" & theid
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
cnn.close
Page.RegisterStartupScript("",str3)
End Sub
Function GetAlertInfo(byval str1 as string) as String
dim Str2 as String
str2="<script language='javascript'>alert('" & str1 & "')<"
str2+="/"
str2+="script>"
return trim(str2)
End Function
</script>
<html>
<head>
<title>来访修改</title>
<base target="_self" />
</head>
<body background="../images/2.jpg">
<form runat="server">
<br><p align="center"><font style="color:blue" face="隶书" size="6"><strong>保安来访记录修改</strong></font></p>
<font style="color:blue">当前来访ID:</font><font style="color:red"><%=request.querystring("id")%></font>
<hr>
<table id="search" cellspacing="1" cellpadding="0" width="90%" align="center" border="0">
<tbody>
<tr class="tr4">
<td height="40">
来 访 人
<asp:TextBox class="input_text" id="lfr" runat="server" width="120"></asp:TextBox>
</td>
<td>
来访时间
<asp:TextBox class="input_text" id="stime" runat="server" width="120"></asp:TextBox>
</td>
<td>
离开时间
<asp:TextBox class="input_text" id="etime" runat="server" width="120"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td width="34%" height="40">
身份证号
<asp:TextBox class="input_text" id="zj" runat="server" width="120"></asp:TextBox>
</td>
<td colspan=2>
来访人地址
<asp:TextBox class="input_text" id="lfraddr" runat="server" width="300"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td colspan=3 height="10"><br></td>
</tr>
<tr class="tr4">
<td height="40">
被 访 人
<asp:TextBox class="input_text" id="bfr" runat="server" width="120"></asp:TextBox>
</td>
<td>
所属单元
<asp:TextBox class="input_text" id="bfraddr" runat="server" width="120"></asp:TextBox>
</td>
<td>
值 班 人
<asp:TextBox class="input_text" id="zbr" runat="server" width="120"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td colspan="3" height="40">
来访事由
<asp:TextBox class="input_text" id="reason" runat="server" width="560"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td colspan="3" height="40">
备 注
<asp:TextBox class="input_text" id="memo" runat="server" width="560"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td valign="bottom" align="middle" colspan="3" height="130">
<asp:button class="input_button" id="SaveBtn" onclick="Save_Click" runat="server" text="保 存"></asp:button>
<br />
<asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="*" ControlToValidate="stime">来访时间不可为空</asp:RequiredFieldValidator><br />
<asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="*" ControlToValidate="lfr">来访人不可为空</asp:RequiredFieldValidator><br>
<asp:RequiredFieldValidator id="Requiredfieldvalidator3" runat="server" ErrorMessage="*" ControlToValidate="bfr">被访人不可为空</asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?