我看代码应该没错误啊
以下内容为程序代码:
1 If e.DataCol.Name = "出库日期" Then
2
3 If e.NewValue Is Nothing Then
4 e.DataRow("出库月份") = Nothing
5
6 Else
7 Dim d As Date = e.NewValue '日期,新值
8 Dim m As Integer = d.Month '月份
9
10 e.DataRow("出库月份") = m
11
12
13 Dim s As String = format(e.DataRow("出库日期"),"yyMM")
14 Dim i As String = DataTables("库房明细").SQLCompute("Max(出库单号)" , "出货仓库 ='"& Vars("二批名称") & "' and [出库单号] Like '%" & s & "%' " ) '不加载数据使
15 Dim n As Integer
16 If i IsNot Nothing Then
17
18
19 n = CInt(i.Substring(9,3)) + 1
20 e.DataRow("出库单号") = Vars("单位代码") & "-" & s & "-" & Format(n,"000")
21 Else
22 n =1
23 e.DataRow("出库单号")= Vars("单位代码") & "-" & s & "-" & Format(n,"000")
24 End If
25
26 End If
27 End If
28
29 Dim jee As DataRow = e.DataRow '定义je为当前行
30 Select Case e.DataCol.Name '如果列名称
31 Case "数量","包装系数" '变化的是这些列
32 If jee.IsNull("数量") Then '如果派车瓶数列为空
33 'jee("金额") = Nothing
34 jee("件数") = Nothing
35
36 Else
37 'jee("金额") = jee("数量") * jee("单价")
38 jee("件数") = jee("数量") / jee("包装系数")
39 End If
40 End Select
41 If e.DataCol.Name = "签收" Then
42 If e.NewValue = True Then
43 If Forms("调拨入库").Controls("DateTimePicker1").Value Is Nothing '如果入库窗口的入库日期框为空值
44 Messagebox.Show("请先填写入库日期!","提示") '弹出提示框
45
46
47 Else '如果入库日期已选
48
49 Tables("库房明细.库房入库").AddNew()
50 Tables("库房明细.库房入库").Current("入库日期") =Forms("调拨入库").controls("DateTimePicker1").Value
51 Tables("库房明细.库房入库").Current("车号") = Tables("库房明细").Current("车号")
52 Tables("库房明细.库房入库").Current("规格") = Tables("库房明细").Current("规格")
53 Tables("库房明细.库房入库").Current("收货仓库") = Tables("库房明细").Current("收货仓库")
54 Tables("库房明细.库房入库").Current("出货仓库") = Tables("库房明细").Current("出货仓库")
55 Tables("库房明细.库房入库").Current("包装系数") = Tables("库房明细").Current("包装系数")
56 Tables("库房明细.库房入库").Current("单价") = Tables("库房明细").Current("单价")
57 Tables("库房明细.库房入库").Current("件数") = Tables("库房明细").Current("件数")
58 Tables("库房明细.库房入库").Current("数量") = Tables("库房明细").Current("数量")
59 Tables("库房明细.库房入库").Current("类型") ="内部调拨"
60
61
62 End If
63 End If
64 End If
65
66 If e.DataCol.Name = "数量" Then
67 If Tables("库房明细").Current("类型")="订单出库"
68 Dim sum As Integer = 0
69 For Each drr As DataRow In DataTables("库房明细").Select("订单ID = '"& e.DataRow("订单ID") &"' And 产品名称 = '"& e.DataRow("产品名称") &"' and 类型 = '订单出库'")
70 sum = sum + drr("数量")
71 Next
72 If sum > Tables("一级订单明细表").Current("数量")
73 Messagebox.Show("出库数量错误,请重新输入!","提示") '弹出提示框
74 e.DataRow("数量")=0
75 e.Cancel = True
76 End If
77 End If
78 If Tables("库房明细").Current("类型")="结案出库"
79 Dim sum1 As Integer = 0
80 For Each drr As DataRow In DataTables("库房明细").Select("订单ID = '"& e.DataRow("订单ID") &"' And 产品名称 = '"& e.DataRow("产品名称") &"' and 类型 = '结案出库'")
81 sum1 = sum1 + drr("数量")
82 Next
83 If sum1 > Tables("结案明细表").Current("数量")
84 Messagebox.Show("出库数量错误,请重新输入!","提示") '弹出提示框
85 e.DataRow("数量")=0
86 e.Cancel = True
87 End If
88 End If
89 End If
90 Select Case e.DataCol.Name
91 Case "数量"
92 Dim dr As DataRow = e.DataRow
93 Dim pr1 As DataRow
94 Dim filter1 As String
95 filter1 = "产品名称 = '" & dr("产品名称") & "' And 出货仓库 = '" & dr("出货仓库") & "'"
96 pr1 = DataTables("库存表").Find(filter1)
97 If pr1 IsNot Nothing Then
98 pr1("出库") = pr1("出库")- e.OldValue + dr("数量")
99 pr1("可用瓶数")= pr1("期初瓶数") + pr1("入库") - pr1("出库")
100 pr1("可用库存")= pr1("可用瓶数") / pr1("包装系数")
101 pr1("库房出库") = pr1("库房出库")- e.OldValue+ dr("数量")
102 pr1("实际瓶数")= pr1("期初瓶数") + pr1("库房入库") - pr1("库房出库")
103 pr1("实际瓶数")= pr1("实际瓶数") / pr1("包装系数")
104 End If
105 DataTables("库存表").Save
106 End Select