📄 form5.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Form5
Caption = "添加"
ClientHeight = 8295
ClientLeft = 2775
ClientTop = 2115
ClientWidth = 10905
LinkTopic = "Form5"
MDIChild = -1 'True
Picture = "Form5.frx":0000
ScaleHeight = 8295
ScaleWidth = 10905
Begin VB.ListBox List1
Height = 1320
ItemData = "Form5.frx":1BA4C
Left = 1320
List = "Form5.frx":1BA4E
TabIndex = 16
Top = 1200
Width = 3855
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 375
Left = 1320
TabIndex = 15
Top = 4680
Width = 3855
_ExtentX = 6800
_ExtentY = 661
_Version = 393216
Format = 22872065
CurrentDate = 39686
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 8160
TabIndex = 14
Top = 5880
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 6000
TabIndex = 13
Top = 5880
Width = 1815
End
Begin VB.TextBox Text6
Height = 375
Left = 6240
TabIndex = 12
Text = " "
Top = 3720
Width = 3615
End
Begin VB.TextBox Text5
Height = 375
Left = 6240
TabIndex = 11
Text = " "
Top = 2280
Width = 3615
End
Begin VB.TextBox Text4
Height = 375
Left = 6240
TabIndex = 10
Text = " "
Top = 840
Width = 3615
End
Begin VB.TextBox Text3
Height = 375
Left = 1320
TabIndex = 9
Text = " "
Top = 3720
Width = 3855
End
Begin VB.TextBox Text2
Height = 375
Left = 1320
TabIndex = 8
Text = " "
Top = 2280
Width = 3855
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 7
Text = " "
Top = 840
Width = 3855
End
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "日期:"
Height = 180
Left = 720
TabIndex = 6
Top = 4800
Width = 540
End
Begin VB.Label Label6
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "结存:"
Height = 180
Left = 5760
TabIndex = 5
Top = 3840
Width = 540
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "单价:"
Height = 180
Left = 5760
TabIndex = 4
Top = 2400
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "数量:"
Height = 180
Left = 5760
TabIndex = 3
Top = 960
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "货名:"
Height = 180
Left = 720
TabIndex = 2
Top = 3840
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "货号:"
Height = 180
Left = 720
TabIndex = 1
Top = 2400
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "型号:"
Height = 180
Left = 720
TabIndex = 0
Top = 960
Width = 540
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a As Integer
Dim b As String
Private Sub Command1_Click()
Set rs = New Recordset
Dim str As String
str = "select * from " & Trim(b) & ""
lian str, cn, rs
If Text1.Text = "" Then
MsgBox "请输入您的型号!", vbCritical, "提示"
Text1.SetFocus
ElseIf Text2.Text = "" Then
MsgBox "请输入您的货号!", vbCritical, "提示"
Text2.SetFocus
ElseIf Text3.Text = "" Then
MsgBox "请输入您的货名!", vbCritical, "提示"
Text3.SetFocus
ElseIf Text4.Text = "" Then
MsgBox "请输入您的购入数量!", vbCritical, "提示"
Text4.SetFocus
ElseIf Text5.Text = "" Then
MsgBox "请输入货物的单价!", vbCritical, "提示"
Text5.SetFocus
Else
rs.AddNew
rs!xh = Text1.Text
rs!hh = Text2.Text
rs!hm = Text3.Text
rs!sl = Val(Text4.Text)
rs!dj = Val(Text5.Text)
rs!je = Val(Text6.Text)
rs!rq = DTPicker1.Value
rs.Update
MsgBox "添加成功!", vbOKOnly, "成功"
Call k
End If
End Sub
Private Sub Command2_Click()
Call sh
End Sub
Private Sub Form_Load()
List1.Visible = False
Select Case h
Case 1
b = "qc"
Case 2
b = "gr"
Case 3
b = "xs"
Case Else
b = "jc"
End Select
End Sub
Private Sub List1_Click()
If List1.Top = Text1.Top + Text1.Height Then
Text1.Text = List1.Text
ElseIf List1.Top = Text2.Top + Text2.Height Then
Text2.Text = List1.Text
Else
Text3.Text = List1.Text
End If
End Sub
Private Sub Text1_Change()
List1.Clear
List1.Top = Text1.Top + Text1.Height
List1.Left = Text1.Left
If Text1.Text = "" Then
List1.Visible = False
Else
List1.Visible = True
Set rs = New Recordset
Dim str As String
str = "select * from " & Trim(b) & " where xh like '%" & Trim(Text1.Text) & "%'"
Call lian(str, cn, rs)
If rs.RecordCount < 1 Then
List1.Visible = False
Else
Dim i As Integer
For i = 1 To rs.RecordCount
If Trim(rs!xh) = Trim(Text1.Text) Then List1.Visible = False
List1.AddItem (rs!xh)
rs.MoveNext
Next i
cn.Close
End If
End If
If Text1.Text = List1.Text Then List1.Visible = False
End Sub
Private Sub Text2_Change()
List1.Clear
List1.Top = Text2.Top + Text2.Height
List1.Left = Text2.Left
If Text2.Text = "" Then
List1.Visible = False
Else
List1.Visible = True
Set rs = New Recordset
Dim str As String
str = "select * from " & Trim(b) & " where hh like '%" & Trim(Text2.Text) & "%'"
Call lian(str, cn, rs)
If rs.RecordCount < 1 Then
List1.Visible = False
Else
Dim i As Integer
For i = 1 To rs.RecordCount
If Trim(rs!hh) = Trim(Text2.Text) Then List1.Visible = False
List1.AddItem (rs!hh)
rs.MoveNext
Next i
cn.Close
End If
End If
If Text2.Text = List1.Text Then List1.Visible = False
End Sub
Private Sub Text3_Change()
List1.Clear
List1.Top = Text3.Top + Text3.Height
List1.Left = Text3.Left
If Text3.Text = "" Then
List1.Visible = False
Else
List1.Visible = True
Set rs = New Recordset
Dim str As String
str = "select * from " & Trim(b) & " where hm like '%" & Trim(Text3.Text) & "%'"
Call lian(str, cn, rs)
If rs.RecordCount < 1 Then
List1.Visible = False
Else
Dim i As Integer
For i = 1 To rs.RecordCount
If Trim(rs!hm) = Trim(Text3.Text) Then List1.Visible = False
List1.AddItem (rs!hm)
rs.MoveNext
Next i
cn.Close
End If
End If
If Text3.Text = List1.Text Then List1.Visible = False
str = "select * from " & Trim(b) & " where xh='" & Trim(Text1.Text) & "' and hh='" & Trim(Text2.Text) & "' and hm='" & Trim(Text3.Text) & "'"
lian str, cn, rs
If rs.RecordCount = 1 Then
Text4.Text = rs!sl
Text5.Text = rs!dj
End If
End Sub
Private Sub k()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub tr(aa As TextBox, a2 As String)
List1.Clear
List1.Top = aa.Top + aa.Height
List1.Left = aa.Left
If aa.Text = "" Then
List1.Visible = False
Else
aa.Visible = True
Set rs = New Recordset
str = "select * from " & Trim(b) & " where a2 like '%" & Trim(aa.Text) & "%'"
Call lian(str, cn, rs)
If rs.RecordCount < 1 Then
List1.Visible = False
Else
Dim i As Integer
For i = 1 To rs.RecordCount
If Trim(rs!a2) = Trim(aa.Text) Then List1.Visible = False
List1.AddItem (rs!a2)
rs.MoveNext
Next i
cn.Close
End If
End If
If aa.Text = List1.Text Then List1.Visible = False
End Sub
Private Sub bi(aa As TextBox)
aa.Text = List1.Text
End Sub
Private Sub Text6_Change()
Text6.Text = Val(Text4.Text) * Val(Text5.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -