qj_ap_mod.aspx

来自「ASP.NET开发实战详解」· ASPX 代码 · 共 132 行

ASPX
132
字号
<%@ 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 qj_item where code='" & theid & "'"
                     cmd=new sqlcommand(sql,cnn)
                     datar=cmd.executereader()
                     if datar.read() then
	                code.text=Iif(IsDbNull(datar("code")),"",datar("code"))
                        name.text=Iif(IsDbNull(datar("name")),"",datar("name"))
                        place.text=Iif(IsDbNull(datar("place")),"",datar("place"))
			content.text=iif(isdbnull(datar("content")),"",datar("content"))
                        fzr.text=Iif(IsDbNull(datar("fzr")),"",datar("fzr"))
                        ttime.text=Iif(IsDbNull(datar("ttime")),"",datar("ttime"))
                        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 CodeStr as string=code.text
                  dim NameStr as string=name.text
                  dim PlaceStr as string=place.text
                  dim contentstr as string=content.text
                  dim fzrstr as string=fzr.text
                  dim ttimestr as string=ttime.text
                  dim memostr as string=memo.text
                  dim sql as string
                  cnn=new sqlconnection(configurationsettings.appsettings("connection"))
                  cnn.open()
                  sql="update qj_item set name='" & namestr & "',place='" & placestr & "',content='" & contentstr & "',fzr='" & fzrstr & "',ttime='" & ttimestr & "',memo='" & memostr & "' where code='" & 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" width="34%">
                                项目编号
                                <asp:TextBox class="input_text" enabled="false" id="code" runat="server" width="120"></asp:TextBox>
                            </td>
                            <td>
                                项目名称
                                <asp:TextBox class="input_text" id="name" runat="server" width="300"></asp:TextBox>
                            </td>
                        </tr>
                        <tr class="tr4">
                            <td colspan="2" height="40">
                                清洁地段
                                <asp:TextBox class="input_text" id="place" runat="server" width="520"></asp:TextBox>
                            </td>
                        </tr>
                        <tr class="tr4">
                            <td height="40" width="34%">
                                负&nbsp;责&nbsp;人
                                <asp:TextBox class="input_text" id="fzr" runat="server" width="120"></asp:TextBox>
                            </td>
                            <td>
                                清洁时间
                                <asp:TextBox class="input_text" id="ttime" runat="server" width="300"></asp:TextBox>
                            </td>
                        </tr>
                        <tr class="tr4">
                            <td valign="top" colspan="2" height="90">
                                清洁内容<br />
                                <asp:TextBox id="content" runat="server" width="590" TextMode="MultiLine" Rows="4"></asp:TextBox>
                            </td>
                        </tr>
                        <tr class="tr4">
                            <td colspan="2" height="40">
                                备&nbsp;&nbsp;&nbsp;&nbsp;注
                                <asp:TextBox class="input_text" id="memo" runat="server" width="520"></asp:TextBox>
                            </td>
                        </tr>
                        <tr class="tr4">
                            <td valign="bottom" align="middle" colspan="2" height="90">
                                <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="name">项目名称不可为空</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </tbody>
                </table>

    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?