📄 addorderdialog.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form AddOrderDialog
BorderStyle = 3 'Fixed Dialog
Caption = "添加订单"
ClientHeight = 3960
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3960
ScaleWidth = 6000
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Caption = "订单信息"
Height = 3255
Left = 120
TabIndex = 2
Top = 120
Width = 5775
Begin VB.TextBox Text2
Height = 270
Left = 960
TabIndex = 24
Top = 2400
Width = 1815
End
Begin VB.TextBox Text1
Height = 270
Left = 960
TabIndex = 23
Top = 360
Width = 1815
End
Begin MSComCtl2.DTPicker DTPicker2
Height = 300
Left = 3840
TabIndex = 18
Top = 2880
Width = 1815
_ExtentX = 3201
_ExtentY = 529
_Version = 393216
Format = 149880833
CurrentDate = 39083
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 300
Left = 960
TabIndex = 17
Top = 2880
Width = 1815
_ExtentX = 3201
_ExtentY = 529
_Version = 393216
Format = 149880833
CurrentDate = 39083
End
Begin VB.ComboBox Combo3
Height = 315
Left = 960
Style = 2 'Dropdown List
TabIndex = 11
Top = 1920
Width = 1815
End
Begin VB.ComboBox Combo2
Height = 315
Left = 960
Style = 2 'Dropdown List
TabIndex = 7
Top = 1440
Width = 1815
End
Begin VB.ComboBox Combo1
Height = 315
Left = 960
Style = 2 'Dropdown List
TabIndex = 5
Top = 960
Width = 1815
End
Begin VB.Label Label16
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3840
TabIndex = 22
Top = 1920
Width = 1815
End
Begin VB.Label Label15
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3840
TabIndex = 21
Top = 1440
Width = 1815
End
Begin VB.Label Label14
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3840
TabIndex = 20
Top = 960
Width = 1815
End
Begin VB.Label Label13
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3840
TabIndex = 19
Top = 360
Width = 1815
End
Begin VB.Label Label12
Caption = "交货日期"
Height = 255
Left = 3000
TabIndex = 16
Top = 2880
Width = 855
End
Begin VB.Label Label11
Caption = "订购日期"
Height = 255
Left = 120
TabIndex = 15
Top = 2880
Width = 735
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "产品库存"
Height = 195
Left = 3000
TabIndex = 14
Top = 360
Width = 720
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "产品名称"
Height = 195
Left = 3000
TabIndex = 13
Top = 1920
Width = 720
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "订购数量"
Height = 195
Left = 120
TabIndex = 12
Top = 2400
Width = 720
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "产品编号"
Height = 195
Left = 120
TabIndex = 10
Top = 1920
Width = 720
End
Begin VB.Label Label6
Caption = "雇员姓名"
Height = 255
Left = 3000
TabIndex = 9
Top = 1440
Width = 735
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "雇员编号"
Height = 195
Left = 120
TabIndex = 8
Top = 1440
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "客户单位"
Height = 195
Left = 3000
TabIndex = 6
Top = 960
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "客户编号"
Height = 195
Left = 120
TabIndex = 4
Top = 960
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "订单编号"
Height = 195
Left = 120
TabIndex = 3
Top = 360
Width = 720
End
End
Begin VB.CommandButton CancelButton
Caption = "取消"
Height = 375
Left = 3720
TabIndex = 1
Top = 3480
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "确定"
Height = 375
Left = 1200
TabIndex = 0
Top = 3480
Width = 1215
End
End
Attribute VB_Name = "AddOrderDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MyDB As Database
Dim MyRecord As Recordset
Dim TempStr As String
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub Combo1_Click()
Set MyRecord = MyDB.OpenRecordset("客户表")
MyRecord.Index = "PrimaryKey"
MyRecord.Seek "=", Combo1.Text
If MyRecord.NoMatch Then
MsgBox "没有编号为" + Combo1.Text + "的客户!"
Else
Label14.Caption = MyRecord.Fields("CompanyTitle")
End If
End Sub
Private Sub Combo2_Click()
Set MyRecord = MyDB.OpenRecordset("雇员表")
MyRecord.Index = "PrimaryKey"
MyRecord.Seek "=", Combo2.Text
If MyRecord.NoMatch Then
MsgBox "没有编号为" + Combo2.Text + "的雇员!"
Else
Label15.Caption = MyRecord.Fields("Name")
End If
End Sub
Private Sub Combo3_Click()
Set MyRecord = MyDB.OpenRecordset("产品表")
MyRecord.Index = "PrimaryKey"
MyRecord.Seek "=", Combo3.Text
If MyRecord.NoMatch Then
MsgBox "没有编号为" + Combo3.Text + "的产品!"
Else
Label16.Caption = MyRecord.Fields("Product")
Label13.Caption = MyRecord.Fields("Quantity")
Text2.Text = Val(MyRecord.Fields("Quantity"))
End If
End Sub
Private Sub Form_Load()
Set MyDB = OpenDatabase(VB.App.Path + "\MySampleDB.mdb", False, False)
Set MyRecord = MyDB.OpenRecordset("订单表")
MyRecord.Index = "PrimaryKey"
MyRecord.MoveLast
TempStr = MyRecord.Fields("OrderID")
TempStr = "DD" & Format((Val(Right(TempStr, 5)) + 1), "0000#")
Text1.Text = TempStr
Set MyRecord = MyDB.OpenRecordset("客户表")
MyRecord.Index = "PrimaryKey"
Do While Not MyRecord.EOF
Combo1.AddItem MyRecord.Fields("CustomerID")
MyRecord.MoveNext
Loop
Set MyRecord = MyDB.OpenRecordset("雇员表")
MyRecord.Index = "PrimaryKey"
Do While Not MyRecord.EOF
Combo2.AddItem MyRecord.Fields("EmployeeID")
MyRecord.MoveNext
Loop
Set MyRecord = MyDB.OpenRecordset("产品表")
MyRecord.Index = "PrimaryKey"
Do While Not MyRecord.EOF
Combo3.AddItem MyRecord.Fields("ProductID")
MyRecord.MoveNext
Loop
'End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyRecord.Close
MyDB.Close
End Sub
Private Sub OKButton_Click()
If Combo1.Text = "" Or Combo2.Text = "" Or Combo3.Text = "" Then
MsgBox "请填写完整信息!"
Else
TempStr = "INSERT INTO 订单表 VALUES ('" & Text1.Text & "','" & Combo1.Text & _
"','" & Combo2.Text & "','" & DTPicker1.Value & "','" & Combo3.Text & _
"','" & Text2.Text & "','" & DTPicker2.Value & "')"
MyDB.Execute TempStr
TempStr = "UPDATE 产品表 SET Quantity=" & (Val(Label13.Caption) - Val(Text2.Text)) & _
" WHERE ProductID='" & Combo3.Text & "'"
MyDB.Execute TempStr
MsgBox "成功添加订单" & Text1.Text & "!"
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -