📄 form4.frm
字号:
VERSION 5.00
Begin VB.Form Form4
Caption = "药品出库"
ClientHeight = 5760
ClientLeft = 3945
ClientTop = 2205
ClientWidth = 7680
LinkTopic = "Form4"
Picture = "Form4.frx":0000
ScaleHeight = 5760
ScaleWidth = 7680
Begin VB.CommandButton Command2
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 4800
TabIndex = 7
Top = 4920
Width = 1095
End
Begin VB.ComboBox Combo2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "Form4.frx":20FE
Left = 4920
List = "Form4.frx":2100
TabIndex = 6
Top = 2280
Width = 2295
End
Begin VB.TextBox Text4
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4920
TabIndex = 5
Top = 3480
Width = 2295
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "Form4.frx":2102
Left = 4920
List = "Form4.frx":2118
TabIndex = 2
Top = 1080
Width = 2295
End
Begin VB.CommandButton Command1
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 0
Top = 4920
Width = 1095
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "输入出库数量:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 1080
TabIndex = 4
Top = 3600
Width = 1680
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "选择药品入库批号:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 600
TabIndex = 3
Top = 2280
Width = 2160
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "选择出库药品名称:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 600
TabIndex = 1
Top = 1080
Width = 2160
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_LostFocus()
Combo2.SetFocus
End Sub
Private Sub Combo2_GotFocus()
Dim rs As New ADODB.Recordset
Dim sql As String
If Combo1.Text = "" Then
MsgBox "请输入出库的药品名!", vbOKOnly + vbExclamation, "警告!"
Combo1.SetFocus
Else
sql = "select * from 药品库存表 where 药品名称='" & Combo1.Text & "'"
rs.Open sql, con, adOpenKeyset, adLockPessimistic
If (rs.RecordCount <= 0) Then
MsgBox "暂时没有该药品!", vbOKOnly + vbExclamation, "警告!"
Combo1.SetFocus
Else
Do While Not rs.EOF
Combo2.AddItem rs.Fields(0)
rs.MoveNext
Loop
rs.Close
End If
End If
End Sub
Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
Dim sql As String
Dim rs2 As New ADODB.Recordset
Dim sql2 As String
If Combo1.Text = "" Then
MsgBox "请输入出库药品名!", vbOKOnly + vbExclamation, "警告!"
Combo1.SetFocus
Else
If Combo2.Text = "" Then
MsgBox "请输入进库编号!", vbOKOnly + vbExclamation, "警告!"
Combo1.SetFocus
Else
If Text4.Text = "" Or (Not IsNumeric(Text4.Text)) Then
MsgBox "出库数量必须非空且为数字型!", vbOKOnly + vbExclamation, "警告!"
Text4.SetFocus
Else
sql = "select * from 药品库存表 where 进库编号='" & (Combo2.Text) & "'"
rs.CursorLocation = adUseClient
rs.Open sql, con, adOpenKeyset, adLockPessimistic
Do While (Text4.Text = "" Or rs.Fields(4).Value < Val(Text4.Text))
Text4.Text = InputBox("库存数量不够,重新选择出库量", "重新选择!")
Loop
rs.Fields(4) = rs.Fields(4) - Text4.Text
rs.Update
sql2 = "select * from 出库记录表"
rs2.Open sql2, con, adOpenKeyset, adLockPessimistic
rs2.AddNew
rs2.Fields(1) = Combo1.Text
rs2.Fields(2) = Text4.Text
rs2.Fields(3) = Date
rs2.Fields(4) = rs.Fields(3)
rs2.Update
End If
End If
End If
MsgBox "药品出库操作已完成!", vbOKOnly + vbExclamation, "恭喜!"
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -