1、除非这个网页只有一个人使用,否则请不要使用全局变量传递数据。因为全局变量是服务端共用的,假设有10个人打开网页,那么全局变量的值是这个10个人共用的,谁最后打开网页,这个变量就是最后打开网页的这个人的值,其它人使用这个全局变量也是这个值,这肯定是有问题的
2、不要在httprequest里定义统一的变量,比如【Dim cmd As new SQLCommand】,因为所有访问服务端资源的请求(包括图片,js.....等等等)都会进入httprequest,每次都会初始化一个SQLCommand,即用不到也浪费内存和效率,哪个case里用到,再到那个case里定义变量好了
If e.Path.StartsWith("Reports\")
e.ResponseEncoding = "gb2312"
Select Case e.Path
Case "Reports\bg"
Dim cmd As new SQLCommand
cmd.ConnectionName="pk"
cmd.CommandText= "select t1.编号,t1.单据状态,t1.报告类型,t2.产品名称,t2.规格,t1.生产日期_开始 as 生产日期,t1.批次,t1.结论,t1.质检员,t1.制单,t1.审核,t1.批准 from 质检报告主表 t1 ,成品有出厂检验 t2 where t1.编号= t2.编号 and t1.生产日期_开始='"& e.PostValues("scrq") &"' And t2.产品名称='"& e.PostValues("cpmc") &"' And t2.规格='"& e.PostValues("gg") &"'"
Dim dtt As DataTable= cmd.ExecuteReader
If dtt.DataRows.count>=1 Then
Dim r As DataRow= dtt.DataRows(0)
e.AsyncExecute = True
Functions.AsyncExecute("baogao",e,r,e.PostValues("cpmc"),e.PostValues("gg") ,e.PostValues("scrq") )
End If
Case Else
e.AsReportServer("Reports/")
End Select
Else
Select Case e.Path
Case "test.htm"
If e.PostValues.Count = 0 Then
Dim wb As New weui
wb.AddPageTitle("","ph1","","中粮菏泽包装油质检报告查询")
wb.AddForm("","form1","Reports/bg")
With wb.AddInputGroup("form1","ipg1","查询条件")
With .AddInput("scrq","生产日期","date")
.Attribute = "onchange=""setAjaxOptions('cpmc','getProducts.htm','scrq',false)"""
End With
With .AddSelect("cpmc","产品名称","")
.Attribute = "onchange=""setAjaxOptions('gg','getProducts.htm','scrq','cpmc',false)"""
End With
With .AddSelect("gg","规格","")
' .Attribute = "onchange=""setAjaxOptions('gg1','getProducts.htm','scrq','cpmc','gg'false)"""
End With
End With
With wb.AddButtonGroup("form1","btg1",False) '垂直排列
.Add("btn1", "查询", "submit") '
End With
e.WriteString(wb.Build) '生成网页
Case "getProducts.htm"
Dim vals As String
Dim cmd As new SQLCommand
cmd.ConnectionName="pk"
cmd.CommandText="select t1.产品名称,t2.生产日期_开始,t1.规格 from 质检报告主表 t2 inner join 成品有出厂检验 t1 on t1.编号=t2.编号 where t2.生产日期_开始= '" & e.PostValues("scrq") & "'"
Dim dt As DataTable= cmd.ExecuteReader
If e.PostValues.Count = 1 Then
vals = "|" & dt.GetComboListString("产品名称","生产日期_开始='" & e.PostValues("scrq") & "'")
Vars("scrq") = e.PostValues("scrq")
ElseIf e.PostValues.Count = 2 Then
Dim Filter As String = "生产日期_开始='" & e.PostValues("scrq") & "' And 产品名称='" & e.PostValues("cpmc") & "'"
Vars("cpmc") = e.PostValues("cpmc")
vals = "|" & Dt.GetComboListString("规格", Filter)
End If
e.WriteString(vals)
End Select
End If