📄 outstoreadd.aspx
字号:
<%@ 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("subnum",system.type.gettype("System.Int32"))
dtable.columns.add("hadout",system.type.gettype("System.Int32"))
dtable.columns.add("outnum",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("<script language=javascript>alert('数据保存成功!');</script>"))
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="addtoout" 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 subnum as integer
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(subnum),0) as nums from receivesubsheet where bookcode='" & trim(codestr) & "' and buyercode='" & trim(selbuyer.selecteditem.value) & "'"
cmd=new sqlcommand(sql,cnn)
datar=cmd.executereader()
if datar.read() then
subnum=cint(datar("nums"))
else
subnum=0
end if
datar.close()
'获取总的出库数
sql="select isnull(sum(outstorenum),0) as nums 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"))
else
outnum=0
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(subnum))
drow(6)=trim(cint(outnum))
drow(8)="1.00"
dtable.rows.add(drow)
bindgrid1()
end if
end if
end Sub
sub CKJh_Click(Sender As Object,E As EventArgs)
dim datar as sqldatareader
dim sql as string
dim DRow as datarow
dtable.rows.clear()
cnn=new sqlconnection(configurationsettings.appsettings("connection"))
cnn.open()
sql="select bookcode,sum(subnum) as recnum,0 as hadout into #mid1 from receivesubsheet where buyercode='" & selbuyer.selecteditem.value & "' group by bookcode"
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
sql="select outstoresheetz.bookcode as bookcode1,sum(outstorenum) as outnum into #mid2 from outstoresheetz,#mid1 where outstoresheetz.bookcode=#mid1.bookcode and buyercode='" & selbuyer.selecteditem.value & "' group by outstoresheetz.bookcode"
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
sql="update #mid1 set hadout=outnum from #mid2 where bookcode=bookcode1"
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
sql="select bookcode,abbrname,author,price,name,recnum,hadout from #mid1 a,bookinfosheet b,pressinfosheet c where a.bookcode=b.code and presscode=c.code and (recnum-hadout)>0 order by bookcode"
cmd=new sqlcommand(sql,cnn)
datar=cmd.executereader
do while datar.read()
drow=dtable.newrow()
drow(0)=trim(datar("bookcode"))
drow(1)=trim(datar("name"))
drow(2)=trim(datar("abbrname"))
drow(3)=trim(datar("author"))
drow(4)=trim(csng(datar("price")))
drow(5)=trim(cint(datar("recnum")))
drow(6)=trim(cint(datar("hadout")))
drow(8)="1.00"
dtable.rows.add(drow)
loop
datar.close()
sql="drop table #mid1"
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
sql="drop table #mid2"
cmd=new sqlcommand(sql,cnn)
cmd.executenonquery
bindgrid1()
End Sub
Sub Save_Click(Sender As Object, E As EventArgs)
' Response.write (Server.HtmlDecode("<script language=javascript>alert('数据保存成功!');</script>"))
dim myDataRowCollection as datarowcollection
dim theRow as datarow
dim theTag as Integer
dim theBookCode as String
dim theoutNum 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -