📄 depreadd.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("deprenum",system.type.gettype("System.Int32"))
dim thekey() as datacolumn={dtable.columns("code")}
dtable.primarykey=thekey
bindgrid1()
end if
If Not IsPostBack Then
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)
dtable.rows.clear()
bindgrid1()
End Sub
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)
if CType(e.CommandSource,LinkButton).CommandName="addtodepre" 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 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
drow(0)=trim(codestr)
drow(1)=trim(namestr)
drow(2)=trim(cbsstr)
drow(3)=trim(authorstr)
drow(4)=trim(pricestr)
dtable.rows.add(drow)
bindgrid1()
end if
end if
end Sub
Sub Save_Click(Sender As Object, E As EventArgs)
dim myDataRowCollection as datarowcollection
dim theRow as datarow
dim theTag as Integer
dim theBookCode as String
dim theNum as Integer
dim UnitCode as String
dim theDiscount as single
dim DataR as SqlDataReader
dim theDate as date
dim EventStr as String=trim(EventTxt.text)
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 depresheet 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(5)) then
if cint(therow(5))<>0 then
thebookcode=therow(0).tostring
thenum=therow(5)
sql="insert into depresheet(code,ddate,event,bookcode,depreamount,memo) values('" & trim(unitcode) & "','" & thedate & "','" & eventstr & "','" & thebookcode & "'," & thenum & ",'" & strmemo & "')"
cmd=new sqlcommand(sql,cnn)
cmd.executeNonQuery
theTag=1
end if
end if
next
if thetag<>1 then
page.registerstartupscript("",getalertinfo("没有添加折损数,无法保存!"))
else
mydatarowcollection.clear()
page.registerstartupscript("",getalertinfo("数据保存成功!"))
bindgrid1()
bindgrid()
memo.text=""
end if
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -