gsinfo.aspx
来自「ASP.NET开发实战详解」· ASPX 代码 · 共 156 行
ASPX
156 行
<%@ 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
Sub Page_Load(Sender As Object, E As EventArgs)
dim Sql as string
dim dataR as sqldatareader
If Not IsPostBack Then
If Session("curruser") = "" Then
Response.Redirect("../index.aspx")
End If
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
sql="select * from pub_gs"
cmd=new sqlcommand(sql,cnn)
cnn.open()
datar=cmd.executereader()
if datar.read() then
name.text=Iif(IsDbNull(datar("name")),"",datar("name"))
frdb.text=Iif(IsDbNull(datar("lxr")),"",datar("lxr"))
sf.text=Iif(IsDbNull(datar("xf")),"",datar("xf"))
sxq.text=Iif(IsDbNull(datar("sq")),"",datar("sq"))
addr.text=Iif(IsDbNull(datar("addr")),"",datar("addr"))
yb.text=Iif(IsDbNull(datar("zip")),"",datar("zip"))
tel.text=Iif(IsDbNull(datar("tel")),"",datar("tel"))
fax.text=Iif(IsDbNull(datar("fax")),"",datar("fax"))
account.text=Iif(IsDbNull(datar("bankno")),"",datar("bankno"))
khh.text=Iif(IsDbNull(datar("khh")),"",datar("khh"))
memo.text=Iif(IsDbNull(datar("memo")),"",datar("memo"))
else
name.text=""
frdb.text=""
sf.text=""
sxq.text=""
addr.text=""
yb.text=""
tel.text=""
fax.text=""
account.text=""
khh.text=""
memo.text=""
End If
datar.close()
cnn.close()
end if
End Sub
Sub save_click(Sender As Object, E As EventArgs)
dim sql as string
dim datar as sqldatareader
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
sql="select * from pub_gs"
cmd=new sqlcommand(sql,cnn)
cnn.open
datar=cmd.executereader()
if datar.read() then
sql="update pub_gs set name='" & trim(name.text) & "',lxr='" & trim(frdb.text) & "',xf='" & trim(sf.text) & "',sq='" & trim(sxq.text) & "',addr='" & trim(addr.text) & "',zip='" & trim(yb.text) & "',tel='" & trim(tel.text) & "',fax='" & trim(fax.text) & "',bankno='" & trim(account.text) & "',khh='" & trim(khh.text) & "',memo='" & trim(memo.text) & "'"
else
sql="insert into pub_gs(name,lxr,xf,sq,addr,zip,tel,fax,bankno,khh,memo) values('" & trim(name.text) & "','" & trim(frdb.text) & "','" & trim(sf.text) & "','" & trim(sxq.text) & "','" & trim(addr.text) & "','" & trim(yb.text) & "','" & trim(tel.text) & "','" & trim(fax.text) & "','" & trim(account.text) & "','" & trim(khh.text) & "','" & trim(memo.text) & "')"
end if
datar.close()
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
page.registerstartupscript("",getalertinfo("数据保存成功!"))
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>
<link href="../Main.css" type="text/css" rel="stylesheet" />
</head>
<body background="../images/1.jpg">
<form runat="server">
<br />
<table id="search" cellspacing="1" cellpadding="0" width="80%" align="center" border="0">
<tbody>
<tr class="tr4">
<td colspan="2" height="40">
公司名称
<asp:TextBox class="input_text" id="name" runat="server" width="350"></asp:TextBox>
</td>
<td width="33%">
法人代表
<asp:TextBox class="input_text" id="frdb" runat="server" width="140"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td width="34%" height="40">
所在省份
<asp:TextBox class="input_text" id="sf" runat="server" width="140"></asp:TextBox>
</td>
<td colspan="2">
所在市(县、区)
<asp:TextBox class="input_text" id="sxq" runat="server" width="330"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td colspan="3" height="40">
公司地址
<asp:TextBox class="input_text" id="addr" runat="server" width="600"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td width="34%" height="40">
公司邮编
<asp:TextBox class="input_text" id="yb" runat="server" width="140"></asp:TextBox>
</td>
<td width="33%">
联系电话
<asp:TextBox class="input_text" id="tel" runat="server" width="140"></asp:TextBox>
</td>
<td width="33%">
传真号码
<asp:TextBox class="input_text" id="fax" runat="server" width="140"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td height="40">
银行账号
<asp:TextBox class="input_text" id="account" runat="server" width="140"></asp:TextBox>
</td>
<td colspan="2">
开 户 行
<asp:TextBox class="input_text" id="khh" runat="server" width="370"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td valign="top" colspan="3" height="120">
备注信息<br />
<asp:TextBox id="memo" runat="server" width="660" TextMode="MultiLine" Rows="4"></asp:TextBox>
</td>
</tr>
<tr class="tr4">
<td valign="botton" align="middle" colspan="3" height="50">
<asp:button class="input_button" id="SaveBtn" onclick="Save_Click" runat="server" text="保 存"></asp:button>
<br />
<br />
<asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="*" ControlToValidate="name">公司名称不可为空</asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?