Dim wb As New weui
Dim gsid As Integer
Dim ywid As Integer
Select Case e.Path
Case "addnew.htm"
If e.PostValues.Count = 0 Then
'Dim sb As New StringBuilder
'sb.AppendLine("接收到的数据有:<br/><br/>")
For Each key As String In e.Values.Keys
Select Case key
Case "gs"
gsid= e.Values(key)
Vars("gsid")=gsid
Case "yw"
ywid= e.Values(key)
Vars("ywid")=ywid
End Select
'sb.AppendLine(key & "=" & e.Values(key) & "<br/>")
Next
'e.WriteString("公司ID="& gsid &" And 员工ID= "& ywid &"")
Dim r As DataRow= DataTables("员工表").Find("公司ID="& gsid &" And 员工ID= "& ywid &"")
Dim fname As String= r("员工姓名")
wb.AddForm("","form1","addnew.htm") '.Attribute = "style='background-color: red;'"
With wb.AddInputGroup("form1","ipg1","客户资料")
.AddInput("姓名","姓名","Text") '.Attribute = "style='background-color: red;'"
'前一个"姓名"是ID,后一个"姓名"是标题
.AddInput("联系电话","联系电话","text")
.AddInput("交货日期","交货日期","date")
.AddInput("配送地址","配送地址","text")
End With
With wb.AddInputGroup("form1","ipg11","订货信息")
With .AddSelect("品牌","品牌","|" & DataTables("表A").GetComboListString("品牌"))
.Attribute = """
End With
.AddInput("数量","数量","number") '前一个"姓名"是ID,后一个"姓名"是标题
With .AddInput("yw","业务员","text")
.Value = fname
.Readonly= True
End With
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "确定", "submit")
End With
e.WriteString(wb.Build)
Else
Dim nms() As String = {"姓名","联系电话","交货日期","配送地址","品牌","数量"} '不能为空的列名数组
For Each nm As String In nms
If e.PostValues.ContainsKey(nm) = False Then '生成错误提示页
With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!")
.icon = "Warn" '改变图标
.AddButton("btn1","返回").Attribute = ""
End With
e.WriteString(wb.Build)
Return '必须返回
End If
Next
nms = New String() {"姓名","联系电话","交货日期","配送地址","数量","品牌"} '重新定义了nms数组,增加了两列.
Dim dr As DataRow = DataTables("订货单").AddNew()
For Each nm As String In nms
If e.PostValues.ContainsKey(nm) Then
dr(nm) = e.PostValues(nm)
End If
Next
'以下代码处理品牌复选列表项
'Dim pp As String
'nms = New String() {"5L香谷坊花生油","5L香谷坊非转一级大豆油","5L福之泉一级大豆油","10L福临门非转一级大豆油"} '将nms重新定义为品牌数组
'For Each nm As String In nms
'If e.PostValues.ContainsKey(nm) AndAlso e.PostValues(nm).Trim() = "on" Then '不能省略Trim
'pp = pp & nm & ","
'End If
'Next
'If pp > "" Then
'dr("品牌") = pp.Trim(",")
'End If
''保存并生成增加成功提示页面
dr.save()
'e.WriteString("addnew.htm?GS="& GSID &" & YW="& YWID &"")
With wb.AddMsgPage("","msgpage","提交成功", "祝你愉快每一天") '生成成功提示页
.AddButton("btn1","继续增加","addnew.htm?gs="& Vars("gsid") &"&yw="& vars("ywid") &"")
End With
e.WriteString(wb.Build)
End If
End Select
我在测试的过程中有时很正常,多人访问时 软件报错Object reference not set to an instance of an object. 此时页面就不动了,我关掉报错可以继续
是代码中哪里有问题吗
过程图片
此主题相关图片如下:1.jpg
此主题相关图片如下:2.jpg
此主题相关图片如下:3.jpg
[此贴子已经被作者于2020/3/2 19:12:59编辑过]