[VB]不能全部冲减Store表中mount库存数据,只能结算到表List中的五行数据。
请各位大侠急救表List
Id DId OId mount
363 81 70 5000
364 81 80 1600
365 81 78 1800
367 81 800 1800
370 81 74 1200
371 81 71 1200
372 81 60 13000
373 81 68 13000
374 81 62 3300
表Draw
Id CreateDate DepId Flag
81 2018-9-29 17 0
表Store
OId Name mount
70 c1 8000
80 c2 3000
78 c3 5000
800 c4 6000
74 c5 7000
71 c6 3000
60 c7 20000
68 c8 20000
62 c9 4000
List类模块代码
程序代码:
'按照领用单号读取所有明细,并更改库存数量 Public Sub UpdateStore(ByVal TmpId As Long) Dim rs As New ADODB.Recordset '定义结果集对象 Dim lAmount As Integer '领用数量 Dim TmpOId As Long '生产辅料编号 '设置SELECT语句,读取编号为TmpId的记录 SqlStmt = "SELECT * FROM DrawList WHERE DId=" + Trim(TmpId) '将结果集读取到rs中 Set rs = QueryExt(SqlStmt) Do While Not rs.EOF MyStore.OAmount = 0 - rs.Fields(3) '领用数量 MyStore.UpdateAmount (rs.Fields(2)) '生产辅料编号 rs.MoveNext Loop End Sub
Store类模块代码
程序代码:
'更新库存数量 Public Sub UpdateAmount(ByVal OriOId As Long) SqlStmt = "UPDATE Store Set mount=mount+" + Trim(mount) _ + " WHERE OId=" + Trim(Str(OriOId)) SQLExt (SqlStmt) End Sub '审核结算 Private Sub Cmd_Check_Click() If Adodc1.Recordset.EOF Then MsgBox "请选择记录" Exit Sub End If On Error Resume Next If Adodc1.Recordset.Fields(4) = 0 Then '确认后更改领用单标志Flag值为1 MyDraw.UpdateFlag (Adodc1.Recordset.Fields(0)) '按照领用单明细更改当前库存数量 MyList.UpdateStore (Adodc1.Recordset.Fields(0)) DataRefresh Else MsgBox "已经领用" End If End Sub
不能全部冲减Store表中mount库存数据,只能结算到表List中的五行数据。