dyxx.aspx
来自「ASP.NET开发实战详解」· ASPX 代码 · 共 481 行 · 第 1/2 页
ASPX
481 行
<%@ 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")
Sub Page_Load(Sender As Object, E As EventArgs)
if dtable.columns.count=0 then
dtable.columns.add("id",System.Type.GetType("System.Int32"))
dtable.columns.add("gg",System.Type.GetType("System.String"))
dtable.columns.add("ggname",System.Type.GetType("System.String"))
dtable.columns.add("cx",System.Type.GetType("System.String"))
dtable.columns.add("cxname",System.Type.GetType("System.String"))
dtable.columns.add("gn",System.Type.GetType("System.String"))
dtable.columns.add("gnname",System.Type.GetType("System.String"))
dtable.columns.add("zx",System.Type.GetType("System.String"))
dtable.columns.add("zxname",System.Type.GetType("System.String"))
dtable.columns.add("symj",system.type.gettype("System.Single"))
dtable.columns.add("jzmj",system.type.gettype("System.Single"))
dtable.columns.add("sfmj",system.type.gettype("System.Single"))
dtable.columns.add("fjmj",system.type.gettype("System.Single"))
dtable.columns.add("czmj",system.type.gettype("System.Single"))
dtable.columns.add("shiymj",system.type.gettype("System.Single"))
dtable.columns.add("ptmj",system.type.gettype("System.Single"))
dtable.columns.add("snmj",system.type.gettype("System.Single"))
dtable.columns.add("kzmj",system.type.gettype("System.Single"))
dim thekey() as datacolumn={dtable.columns("id")}
dtable.primarykey=thekey
bindgrid()
end if
If Not IsPostBack Then
BindGrid()
Sellp.DataSource = CreateDataSource("lp")
Sellp.DataTextField = "name"
Sellp.DataValueField = "code"
Sellp.DataBind()
Sellg.DataSource = CreateDataSource("lg")
Sellg.DataTextField = "name"
Sellg.DataValueField = "code"
Sellg.DataBind()
Sellt.DataSource = CreateDataSource("lt")
Sellt.DataTextField = "name"
Sellt.DataValueField = "code"
Sellt.DataBind()
Selgn.DataSource = CreateDataSource("gn")
Selgn.DataTextField = "name"
Selgn.DataValueField = "code"
Selgn.DataBind()
Selzx.DataSource = CreateDataSource("zx")
Selzx.DataTextField = "name"
Selzx.DataValueField = "code"
Selzx.DataBind()
Selcx.DataSource = CreateDataSource("cx")
Selcx.DataTextField = "name"
Selcx.DataValueField = "code"
Selcx.DataBind()
Selgg.DataSource = CreateDataSource("gg")
Selgg.DataTextField = "name"
Selgg.DataValueField = "code"
Selgg.DataBind()
End If
End Sub
Sub Clear_Click(Sender As Object, E As EventArgs)
dtable.rows.clear()
bindgrid()
End Sub
Sub BindGrid()
datagrid1.datasource=dtable
datagrid1.databind()
End Sub
Sub Create_Click(Sender As Object, E As EventArgs)
dim theRownum as string=mcdy.text
dim i as integer
if trim(therownum)<>"" then
if isnumeric(trim(therownum)) and cint(therownum)>0 then
dtable.rows.clear()
for i=1 to cint(therownum)
dim DRow as datarow=dtable.newrow()
drow(0)=i
drow(1)=selgg.selecteditem.value
drow(2)=selgg.selecteditem.text
drow(3)=selcx.selecteditem.value
drow(4)=selcx.selecteditem.text
drow(5)=selgn.selecteditem.value
drow(6)=selgn.selecteditem.text
drow(7)=selzx.selecteditem.value
drow(8)=selzx.selecteditem.text
dtable.rows.add(drow)
next
bindgrid()
end if
end if
end Sub
Sub Update_Click(Sender As Object, E As EventArgs)
dim gxhstr as string=updateh.text
dim myDataRowCollection as datarowcollection
dim theRow as datarow
dim i as integer
myDataRowCollection=dtable.rows
if myDataRowCollection.count=0 then
page.registerstartupscript("",getalertinfo("请先创建单元!"))
exit sub
end if
if trim(gxhstr)="" then
page.registerstartupscript("",getalertinfo("请先输入更新行!"))
exit sub
end if
if not isnumeric(gxhstr) then
page.registerstartupscript("",getalertinfo("错误的更新行!"))
exit sub
end if
if CInt(gxhstr)>myDataRowCollection.count then
page.registerstartupscript("",getalertinfo("过大的更新行!"))
exit sub
end if
if trim(gxhstr)<>0 then
if mydatarowcollection.Contains(cint(gxhstr)) then
therow=mydatarowcollection.Find(cint(gxhstr))
therow(1)=selgg.selecteditem.value
therow(2)=selgg.selecteditem.text
therow(3)=selcx.selecteditem.value
therow(4)=selcx.selecteditem.text
therow(5)=selgn.selecteditem.value
therow(6)=selgn.selecteditem.text
therow(7)=selzx.selecteditem.value
therow(8)=selzx.selecteditem.text
if trim(symj.text)<>"" and isnumeric(symj.text) then
therow(9)=symj.text
end if
if trim(jzmj.text)<>"" and isnumeric(jzmj.text) then
therow(10)=jzmj.text
end if
if trim(sfmj.text)<>"" and isnumeric(sfmj.text) then
therow(11)=sfmj.text
end if
if trim(fjmj.text)<>"" and isnumeric(fjmj.text) then
therow(12)=fjmj.text
end if
if trim(czmj.text)<>"" and isnumeric(czmj.text) then
therow(13)=czmj.text
end if
if trim(shiymj.text)<>"" and isnumeric(shiymj.text) then
therow(14)=shiymj.text
end if
if trim(ptmj.text)<>"" and isnumeric(ptmj.text) then
therow(15)=ptmj.text
end if
if trim(snmj.text)<>"" and isnumeric(snmj.text) then
therow(16)=snmj.text
end if
if trim(kzmj.text)<>"" and isnumeric(kzmj.text) then
therow(17)=kzmj.text
end if
if therow.haserrors then
dtable.RejectChanges
else
dtable.AcceptChanges
end if
end if
else
for i=1 to myDataRowCollection.count
if mydatarowcollection.Contains(i) then
therow=mydatarowcollection.Find(i)
therow(1)=selgg.selecteditem.value
therow(2)=selgg.selecteditem.text
therow(3)=selcx.selecteditem.value
therow(4)=selcx.selecteditem.text
therow(5)=selgn.selecteditem.value
therow(6)=selgn.selecteditem.text
therow(7)=selzx.selecteditem.value
therow(8)=selzx.selecteditem.text
if trim(symj.text)<>"" and isnumeric(symj.text) then
therow(9)=symj.text
end if
if trim(jzmj.text)<>"" and isnumeric(jzmj.text) then
therow(10)=jzmj.text
end if
if trim(sfmj.text)<>"" and isnumeric(sfmj.text) then
therow(11)=sfmj.text
end if
if trim(fjmj.text)<>"" and isnumeric(fjmj.text) then
therow(12)=fjmj.text
end if
if trim(czmj.text)<>"" and isnumeric(czmj.text) then
therow(13)=czmj.text
end if
if trim(shiymj.text)<>"" and isnumeric(shiymj.text) then
therow(14)=shiymj.text
end if
if trim(ptmj.text)<>"" and isnumeric(ptmj.text) then
therow(15)=ptmj.text
end if
if trim(snmj.text)<>"" and isnumeric(snmj.text) then
therow(16)=snmj.text
end if
if trim(kzmj.text)<>"" and isnumeric(kzmj.text) then
therow(17)=kzmj.text
end if
if therow.haserrors then
dtable.RejectChanges
else
dtable.AcceptChanges
end if
end if
next
end if
bindgrid()
end Sub
Sub Save_Click(Sender As Object, E As EventArgs)
dim lpcode as string=sellp.selecteditem.value
dim lgcode as string=sellg.selecteditem.value
dim ltcode as string=sellt.selecteditem.value
dim lc1 as string=lcfw1.text
dim lc2 as string=lcfw2.text
dim qzstr as string=qz.text
dim myDataRowCollection as datarowcollection
dim datar as sqldatareader
dim theRow as datarow
dim i as integer
dim dycode as string
dim sql as string
dim CodeStr as string
dim NameStr as string
dim ggstr,cxstr as string
dim gnstr as string
dim zxstr as string
dim symjstr as string
dim sfmjstr as string
dim jzmjstr as string
dim fjmjstr as string
dim czmjstr as string
dim ptmjstr as string
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?