1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 |
Dim
e As
RequestEventArgs =
args(0)
'保存订单
Dim
dr As
DataRow =
DataTables("订单").SQLFind("订单编号='"
& e.PostValues("订单编号")
& "'")
Dim
nms() As
String =
{"客户","日期"}
'""
If
dr IsNot
Nothing Then
For
Each nm
As String
In nms
If
e.PostValues.ContainsKey(nm)
Then
dr(nm)=
e.PostValues(nm)
End
If
Next
End
If
dr.Save()
'保存明细
Dim
valid As
Boolean
'用于判断用户是否
输入了订单明细数据
nms
= New
String() {"产品","数量","单价"
}
For
Each nm
As String
In nms
If
e.PostValues.ContainsKey(nm)
Then
valid =
True
'如果
输入了订单明细数据,将valid变量设置为True
End
If
Next
If
valid Then
'如果提交了订单明细数据
Dim sr
As DataRow
If
e.PostValues.ContainsKey("DetailID")
Then
'如果传递了订单明细主键
sr =
DataTables("订单明细").SQLFind("[_Identify]="
& e.PostValues("DetailID"))
If
sr Is
Nothing Then
'多用户环境,必须考虑其他用户删除此明细的可能,避免程序报错
Return
""
End
If
Else
sr =
DataTables("订单明细").SQLAddNew()
'增加一个订单明细
sr("订单编号")
= dr("订单编号")
End If
For
Each nm
As String
In nms
sr(nm)
= e.PostValues(nm)
Next
sr.Save()
'必须保存,而且必须在最后保存,因为用SQLAddNew增加的行,一旦保存,就不能再引用此行
End If |