‘程序9-4
Private Sub 商品出库_Click()
Dim sql As String
Dim rst As ADODB.Recordset
Dim number As Integer
If IsNull(Me![仓库编号]) Then
MsgBox "请选择仓库"
DoCmd.GoToControl "仓库编号"
ElseIf IsNull(Me![商品编号]) Then
MsgBox "请输入商品编号"
DoCmd.GoToControl "商品编号"
ElseIf IsNull(Me![出库数量]) Then
MsgBox "请输入数量"
DoCmd.GoToControl "出库数量"
ElseIf IsNull(Me![员工编号]) Then
MsgBox "请输入员工编号"
DoCmd.GoToControl "员工编号"
ElseIf IsNull(Me![出库日期]) Then
MsgBox "请输入日期"
DoCmd.GoToControl "出库日期"
ElseIf IsNull(Me![订单编号]) Then
MsgBox "请输入订单编号"
DoCmd.GoToControl "订单编号"
ElseIf IsNull(Me![送货方式]) Then
MsgBox "请输入送货方式"
DoCmd.GoToControl "送货方式"
Else
sql = "select * from 商品 where"
sql = sql & " [商品编号]=" & Me![商品编号]
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
If Not (rst.EOF) Then
'修改库存信息
sql = "select * from 库存信息 where [仓库编号]=" & Me![仓库编号]
sql = sql & " and [商品编号]=" & Me![商品编号]
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
If Not (rst.EOF) Then
number = rst!当前库存数量
number = number - Me![出库数量]
rst!当前库存数量 = number
rst.Close
Set rst = Nothing
sql = "当前库存数量为:" & number
MsgBox sql
Exit Sub
Else
rst.Close
Set rst = Nothing
MsgBox "没有该商品的库存信息,不能出库"
Exit Sub
End If
'添加出库记录
sql = "select * from 出库记录"
rst.Close
Set rst = Nothing
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open sql
With rst
.AddNew
!订单编号 = Me![订单编号]
!仓库编号 = Me![仓库编号]
!出库日期 = Me![出库日期]
!商品编号 = Me![商品编号]
!经办员工编号 = Me![员工编号]
!数量 = Me![出库数量]
!送货方式 = Me![送货方式]
End With
rst.Close
Set rst = Nothing
Else
rst.Close
Set rst = Nothing
MsgBox "系统中没有该商品的信息,请先添加商品详细信息"
Exit Sub
Me.Visible = False
End If
End If
End Sub
评论0