⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recretadd.aspx

📁 本系统主要内容是围绕图书销售管理系统而展开讨论的
💻 ASPX
📖 第 1 页 / 共 2 页
字号:
<%@ 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 DTable as new datatable("Subtable")
    'Public DTable as datatable
    Sub Page_Load(Sender As Object, E As EventArgs)
    '    SaveBtn.Attributes.Add("onclick","return confirm('skdfjsdfk');")

        if dtable.columns.count=0 then
            dtable.columns.add("code",System.Type.GetType("System.String"))
            dtable.columns.add("name",system.type.gettype("System.String"))
            dtable.columns.add("cbs",system.type.gettype("System.String"))
            dtable.columns.add("author",system.type.gettype("System.String"))
            dtable.columns.add("price",system.type.gettype("System.Single"))
            dtable.columns.add("hadout",system.type.gettype("System.Int32"))
            dtable.columns.add("retnum",system.type.gettype("System.Int32"))
            dtable.columns.add("discount",system.type.gettype("System.Single"))
            dim thekey() as datacolumn={dtable.columns("code")}
            dtable.primarykey=thekey
            bindgrid1()
        end if
        If Not IsPostBack Then
            SelBuyer.DataSource = CreateDataSource()
            SelBuyer.DataTextField = "name"
            SelBuyer.DataValueField = "code"
            SelBuyer.DataBind()
            ddate.text=year(now) & "-" & format(month(now),"00") & "-" & format(day(now),"00")


            BindGrid()
            BindGrid1()
        End If
    End Sub

    Sub Clear_Click(Sender As Object, E As EventArgs)
    '    Response.write (Server.HtmlDecode("&lt;script language=javascript&gt;alert('数据保存成功!');&lt;/script&gt;"))
        dtable.rows.clear()
        bindgrid1()

    End Sub


    Function CreateDataSource() As ICollection
        dim dtcmd as sqldataadapter
        dim dset as dataset
        cnn=new sqlconnection(configurationsettings.appsettings("connection"))
        dtcmd=new sqldataadapter("select * from buyerinfosheet order by code",cnn)
        dset=new dataset
        dtcmd.fill(dset)
        Dim dv As New DataView(dset.tables(0))
        Return dv
        cnn.close()
    End Function

    Sub Query_Click(sender As Object, e As EventArgs)
        Bindgrid()
    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
        cnn=new sqlconnection(configurationsettings.appsettings("connection"))
        if query_content.text<>"" then
            str1=" and " & query_tj.SelectedItem.value & " like '%" & query_content.text & "%'"
        end if
        str1="select a.*,abbrname,storeamounta,storeamountz from bookinfosheet a,pressinfosheet b,bookstoresheeta c,bookstoresheetz d where a.presscode=b.code and a.code=c.bookcode and a.code=d.bookcode " & str1 & " order by a.code"
        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 BindGrid1()
        dim MaxPage as integer  '计算最大页数
        dim str2 as string
        dim Str1 as string
        if (dtable.defaultview.count mod datagrid2.pagesize)>0 then
            maxpage=dtable.defaultview.count \datagrid2.pagesize+1
        else
            maxpage=dtable.defaultview.count \datagrid2.pagesize
        end if
        do while datagrid2.currentpageindex>0
            if maxpage<datagrid2.currentpageindex+1 then
                datagrid2.currentpageindex=datagrid2.currentpageindex-1
            else
                exit do
            end if
        loop
        datagrid2.datasource=dtable
        datagrid2.databind()
    End Sub


    Sub AddToSub_Click(Sender As Object, E As DataGridCommandEventArgs)
        dim dataR as sqldatareader
        if CType(e.CommandSource,LinkButton).CommandName="addtorecret" then
            dim CodeStr as string=E.Item.Cells(0).text
            dim NameStr as string=E.Item.Cells(1).text
            dim CbsStr as string=E.Item.Cells(2).text
            dim AuthorStr as string=E.Item.Cells(4).text
            dim PriceStr as single=Csng(E.Item.Cells(3).text.tostring())
            dim myDataRowCollection as datarowcollection
            dim retdis as single
            dim outnum as integer
            dim Sql as string
            dim DRow as datarow=dtable.newrow()

            mydatarowcollection=dtable.rows
            if mydatarowcollection.Contains(codestr) then
                Page.RegisterStartupScript("",getalertinfo("该图书已在收退单中,无法再次添加!"))
            else
                cnn=new sqlconnection(configurationsettings.appsettings("connection"))
                cnn.open
                '获取总的出库数
                sql="select isnull(sum(outstorenum),0) as nums,isnull(avg(outdiscountz),1) as retdis from outstoresheetz where bookcode='" & trim(codestr) & "' and buyercode='" & trim(selbuyer.selecteditem.value) & "'"
                cmd=new sqlcommand(sql,cnn)
                datar=cmd.executereader
                if datar.read() then
                    outnum=cint(datar("nums"))
                    retdis=csng(datar("retdis"))
                else
                    outnum=0
                    retdis="1.00"
                end if
                datar.close()
                cnn.close()

                drow(0)=trim(codestr)
                drow(1)=trim(namestr)
                drow(2)=trim(cbsstr)
                drow(3)=trim(authorstr)
                drow(4)=trim(pricestr)
                drow(5)=trim(cint(outnum))
                drow(7)=retdis
                dtable.rows.add(drow)

                bindgrid1()
            end if
        end if
    end Sub

    Sub Save_Click(Sender As Object, E As EventArgs)
    '    Response.write (Server.HtmlDecode("&lt;script language=javascript&gt;alert('数据保存成功!');&lt;/script&gt;"))
        dim myDataRowCollection as datarowcollection
        dim theRow as datarow
        dim theTag as Integer
        dim theBookCode as String
        dim theretNum as Integer
        dim UnitCode as String
        dim theDiscount as single
        dim DataR as SqlDataReader
        dim theDate as date
        dim BuyerCode as String=selbuyer.selecteditem.value
        dim strmemo as string=trim(memo.text)
        dim Sql as String
        if not isdate(ddate.text) then
            page.registerstartupscript("",getalertinfo("错误的日期!"))
            exit sub
        end if
        thedate=cdate(ddate.text.tostring())
        mydatarowcollection=dtable.rows
        if mydatarowcollection.count=0 then
            Page.RegisterStartupScript("",getalertinfo("没有添加数据,无法保存!"))
        else
            thetag=0
            cnn=new sqlconnection(configurationsettings.appsettings("connection"))
            cnn.open
            unitcode=trim(right(year(now),2)) & trim(format(month(now),"00")) & trim(format(day(now),"00"))
            sql="select * from recretbooksheet where left(code,6)='" & trim(unitcode) & "' order by code desc"
            cmd=new sqlcommand(sql,cnn)
            datar=cmd.executereader()
            if datar.read() then
                unitcode=trim(unitcode) & trim(format(cint(right(datar("code").tostring,3))+1,"000"))
            else
                unitcode=trim(unitcode) & "001"
            end if
            datar.close()
            for each theRow In mydatarowcollection
                if not isdbnull(therow(6)) then
                    if cint(therow(6))<>0 then
                        if isdbnull(therow(7)) then
                            thediscount=1
                        else
                            if isnumeric(therow(7)) then
                                thediscount=csng(therow(7))
                            else

⌨️ 快捷键说明

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