skcx.aspx

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

ASPX
170 行
字号
<%@ 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)
      If Not IsPostBack Then
         If Session("curruser") = "" Then
            Response.Redirect("../index.aspx")
         End If
         BindGrid()
      End If
    End Sub

 
    Sub BindGrid()
       dim dataR as sqldatareader
       dim dtcmd as sqldataadapter
       dim dt as new datatable
       dim MaxPage as integer  '计算最大页数
       dim str2 as string
       dim Str1 as string
       dim dystr as string=dyname.text
       dim yfstr as string=selyf.selecteditem.value
       cnn=new sqlconnection(configurationsettings.appsettings("connection"))
       if trim(dystr)<>"" then
          str2=" and c.name='" & trim(dystr) & "' "
       end if
       if selyf.selecteditem.text<>"--所有--" then
          str2=str2 & " and a.sfterm=" & yfstr
       end if
       str1="select count(*) as nums from cw_sf a,cw_sf_other_set b,fc_cell c where a.cellcode=c.code and a.itemcode=b.id " & str2
       cmd=new sqlcommand(str1,cnn)
       cnn.open()
       datar=cmd.executereader()
       if datar.read() then
         if datar("nums").tostring()="0" then
            msg.text=""
         else
            msg.text="合计:记录数 " & datar("nums").tostring()
         end if
       end if
       datar.close()
       str1="select a.id,c.name as cellname,a.sfterm,b.sfitem,shouldmoney,realmoney,a.ddate,sffs,jfr,agent,a.memo from cw_sf a,cw_sf_other_set b,fc_cell c where a.cellcode=c.code and a.itemcode=b.id " & str2 & " order by a.id desc"
       dtcmd=new sqldataadapter(str1,cnn)
       dtcmd.fill(dt)
       if (dt.defaultview.count mod datagrid1.pagesize)>0 then
         maxpage=dt.defaultview.count \datagrid1.pagesize+1
       else
         maxpage=dt.defaultview.count \datagrid1.pagesize
       end if
       do while datagrid1.currentpageindex>0
          if maxpage<datagrid1.currentpageindex+1 then
            datagrid1.currentpageindex=datagrid1.currentpageindex-1
          else
            exit do
          end if
       loop
       datagrid1.datasource=dt
       datagrid1.databind()
       cnn.close()
    End Sub
    
    Sub Query_Click(Sender As Object, E As EventArgs)
	bindgrid()
    end sub    
    
    Sub Grid1_Mod(Sender as object,E as DataGridCommandEventArgs)
        dim codestr as string=E.Item.Cells(0).Text
        dim sql as string
        dim url as string
        if CType(e.CommandSource,LinkButton).CommandName="Delete" then
           cnn=new sqlconnection(configurationsettings.appsettings("connection"))
           cnn.open()
           sql="delete from cw_sf where id=" & codestr
           cmd=new sqlcommand(sql,cnn)
           cmd.executeNonQuery
           cnn.close()
           bindgrid()
        end if
    End Sub
    
                   Sub Grid1_PageIndexChanged(Sender As Object, E As DataGridPageChangedEventArgs)
                       datagrid1.CurrentPageIndex = e.NewPageIndex
                       BindGrid()
                   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 leftmargin="0" topmargin="0" background="../images/1.jpg">
    <form runat="server">
                <table id="search" cellspacing="1" cellpadding="0" width="85%" align="center" border="0">
                        <tr class="tr4">
                            <td height="30" width="25%">
                                单元名称
                                <asp:TextBox class="input_text" id="dyname" runat="server" width="110"></asp:TextBox>
			    </td>
                            <td width="25%">
                                月&nbsp;&nbsp;&nbsp;&nbsp;份
                                <asp:DropDownList id="selyf" runat="server" width="110">
	                    <asp:ListItem Value="0" selected="true">--所有--</asp:ListItem> 
                            <asp:ListItem Value="1">一月</asp:ListItem>
			    <asp:ListItem Value="2">二月</asp:ListItem>
			    <asp:ListItem Value="3">三月</asp:ListItem>
			    <asp:ListItem Value="4">四月</asp:ListItem>
			    <asp:ListItem Value="5">五月</asp:ListItem>
			    <asp:ListItem Value="6">六月</asp:ListItem>
			    <asp:ListItem Value="7">七月</asp:ListItem>
			    <asp:ListItem Value="8">八月</asp:ListItem>
			    <asp:ListItem Value="9">九月</asp:ListItem>
			    <asp:ListItem Value="10">十月</asp:ListItem>
			    <asp:ListItem Value="11">十一月</asp:ListItem>
			    <asp:ListItem Value="12">十二月</asp:ListItem>
			</asp:DropDownList>
                            </td>
                            <td width="30%" align=center>
		                <asp:button id="QueryBtn" onclick="Query_Click" runat="server" text="查  询"></asp:button>
                            </td>
                            <td width="20%"></td>
                       </tr>
		</table>
                <table class="" id="search" cellspacing="1" cellpadding="0" width="88%" align="center" border="0">
                    <tbody>
                        <tr class="tr2">
                            <td style="PADDING-LEFT: 5px" height="25">
                                <asp:Label id="Msg" runat="server" forecolor="red"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="PADDING-LEFT: 5px" height="25">
                                <asp:DataGrid id="DataGrid1" runat="server" width="100%" OnPageIndexChanged="Grid1_PageIndexChanged" AllowSorting="True" AllowPaging="True" Font-Names="verdana" bordercolor="Black" cellpadding="2" font-name="verdana" font-size="8pt" headerstyle-backcolor="#F8FAFC" OnItemCommand="Grid1_Mod" AutoGenerateColumns="False" PageSize="10">
                                    <HeaderStyle font-bold="True" horizontalalign="Center" verticalalign="Middle" backcolor="#F8FAFC"></HeaderStyle>
                                    <PagerStyle nextpagetext="下一页" font-names="宋体" font-bold="True" prevpagetext="上一页" horizontalalign="Right" forecolor="Blue" mode="NumericPages"></PagerStyle>
                                    <EditItemStyle backcolor="#E9F0F8"></EditItemStyle>
                                    <Columns>
                                        <asp:BoundColumn DataField="id" visible="false" HeaderText="序号"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="cellname" HeaderText="单元名称"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="sfterm" HeaderText="收费月份"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="sfitem" HeaderText="收费项目"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="shouldmoney" HeaderText="应收金额"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="realmoney" HeaderText="实收金额"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="ddate" HeaderText="收费日期"  DataFormatString="{0:yyyy-MM-dd}"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="sffs" HeaderText="收费方式"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="jfr" HeaderText="缴费人"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="agent" HeaderText="经手人"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="memo" HeaderText="备注"></asp:BoundColumn>
                                        <asp:ButtonColumn Text="删除" HeaderText="删除" CommandName="Delete"></asp:ButtonColumn>
                                    </Columns>
                                </asp:DataGrid>
                            </td>
                        </tr>
                    </tbody>
                </table>
    </form>
</body>
</html>

⌨️ 快捷键说明

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