当多用户几乎同时点下单时,在服务端几乎同时执行了以下代码,好多的变量,是不是我整个思路错了,还一直停留在之前电脑客户端上开发的状态,如果真错了,请老师告诉我应该如何处理,谢谢!
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
Dim nms() As String
If e.PostValues("合同类型") = "常规" Then
nms = {"公司","工程名称","工程地点","浇注部位","开盘时间","混凝土标号","塌落度","浇注方法","计划方量","需方联系人","需方电话","业务员","业务员电话"} '不能为空的列名数组,去除运输里程
Else
nms = {"公司","工程名称","工程地点","浇注部位","开盘时间","混凝土标号","塌落度","浇注方法","计划方量","运输里程","需方联系人","需方电话","业务员","业务员电话"} '不能为空的列名数组
End If
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
Dim dr As DataRow = _dt生产任务通知.AddNew()
Dim dr1 As DataRow
dr1 = _dt销售合同.SQLFind("审核 = 1 And 合同 = '" & e.PostValues("合同") & "'")
If dr1 IsNot Nothing Then '如果找到的话
dr("代码") = dr1("代码")
Else
With wb.AddMsgPage("","msgpage","下单失败", "意外错误,在销售合同中未找到需方代码,请与管理员联系")
.icon = "Warn" '改变图标
.AddButton("btn1","返回").Attribute = ""
End With
e.WriteString(wb.Build)
Return "" '必须返回
End If
dr("录入时间") = Date.Now
dr("录入人") = DecryptText(e.Cookies("username"),"123","123")
dr("发货单位") = "投资有限公司"
dr("接收站") = "投资有限公司"
Dim msg As String = Format(Date.today, "yyyyMMdd")
If scxdbh.ContainsKey(msg) Then '如果存在这个类别的编号,scxdbh是字典,在全局代码中设置
scxdbh(msg) = scxdbh(msg) + 1 '将该类别最大编号加1
Else
scxdbh.Add(msg,1) '如果是这个列表的首次编号,则编号等于1
End If
dr("单号") = "SCXD-" & Format(Date.today, "yyyyMMdd") & "-" & Format(scxdbh(msg),"000")
nms = New String() {"合同类型","合同","公司","工程名称","工程地点","浇注部位","开盘时间","混凝土标号","塌落度","浇注方法","计划方量","运输里程","车辆及频率","需方联系人","需方电话","其它技术要求","备注","业务员","业务员电话"} '重新定义了nms数组,用于增加或减少列
For Each nm As String In nms
If e.PostValues.ContainsKey(nm) Then
dr(nm) = e.PostValues(nm)
End If
Next
If e.PostValues("运输里程") >0 Then
If e.PostValues("运输里程") >20 Then
dr("里程单价") = 40 + (e.PostValues("运输里程") - 20) * 2
ElseIf e.PostValues("运输里程") >10 Then
dr("里程单价") = 40
Else
dr("里程单价") = 30
End If
End If
'保存并生成增加成功提示页面
dr.save()
With wb.AddMsgPage("","msgpage","下单成功", "单号:" & dr("单号")) '生成成功提示页
Dim htm As String
If DecryptText(e.Cookies("username"),"123","123") = e.PostValues("业务员") Then
htm = "Xd_jbxx.htm"
Else
htm = "Xd_jbxxplus.htm"
End If
.AddButton("btn1","继续下单",htm)
.AddButton("btn2","返回首页","default.htm")
End With
e.WriteString(wb.Build)