biao_mod.aspx
来自「ASP.NET开发实战详解」· ASPX 代码 · 共 151 行
ASPX
151 行
<%@ 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
dim typestr as string
dim unitstr 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 cw_biao_info where id=" & theid
cmd=new sqlcommand(sql,cnn)
datar=cmd.executereader()
if datar.read() then
code.text=Iif(IsDbNull(datar("code")),"",datar("code"))
lc.text=Iif(IsDbNull(datar("lc")),"",datar("lc"))
bl.text=Iif(IsDbNull(datar("bl")),"",datar("bl"))
price.text=Iif(IsDbNull(datar("price")),"",datar("price"))
memo.text=iif(isdbnull(datar("memo")),"",datar("memo"))
typestr=datar("type")
unitstr=datar("unit")
select case trim(typestr)
case "电表"
ttype.selectedindex=0
case "水表"
ttype.selectedindex=1
case "气表"
ttype.selectedindex=2
end select
select case trim(unitstr)
case "度"
unit.selectedindex=0
case "吨"
unit.selectedindex=1
case "立方米"
unit.selectedindex=2
end select
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 codestr as string=code.text
dim lcstr as string=lc.text
dim blstr as string=bl.text
dim typestr as string=ttype.selecteditem.value
dim unitstr as string=unit.selecteditem.value
dim pricestr as string=price.text
dim memostr as string=memo.text
dim sql as string
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="update cw_biao_info set code='" & codestr & "',lc=" & lcstr & ",bl=" & blstr & ",price=" & pricestr & ",type='" & typestr & "',unit='" & unitstr & "',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="80%" align="center" border="0">
<tbody>
<tr>
<td height="50" width="34%">
编 号
<asp:TextBox class="input_text" id="code" runat="server" width="110"></asp:TextBox>
</td>
<td width="33%">
类 型
<asp:DropDownList class="input_text" id="ttype" runat="server" width="110">
<asp:ListItem Value="电表" selected="true">电表</asp:ListItem>
<asp:ListItem Value="水表">水表</asp:ListItem>
<asp:ListItem Value="气表">气表</asp:ListItem>
</asp:DropDownList>
</td>
<td>
单 位
<asp:DropDownList class="input_text" id="unit" runat="server" width="110">
<asp:ListItem Value="度" selected="true">度</asp:ListItem>
<asp:ListItem Value="吨">吨</asp:ListItem>
<asp:ListItem Value="立方米">立方米</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td height="50">
量 程
<asp:TextBox class="input_text" id="lc" runat="server" width="110"></asp:TextBox>
</td>
<td>
倍 率
<asp:TextBox class="input_text" id="bl" runat="server" width="110"></asp:TextBox>
</td>
<td>
单 价
<asp:TextBox class="input_text" id="price" runat="server" width="110"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=3 height="50">
备 注
<asp:TextBox class="input_text" id="memo" runat="server" width="500"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td valign="bottom" align="middle" colspan="3" height="100">
<asp:button class="input_button" id="SaveBtn" onclick="Save_Click" runat="server" text="保 存"></asp:button>
<br />
<asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="*" ControlToValidate="code">表编号不可为空</asp:RequiredFieldValidator><br>
<asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="*" ControlToValidate="price">单价不可为空</asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?