?? frmbuy.frm
字號:
VERSION 5.00
Begin VB.Form frmBuy
BorderStyle = 1 'Fixed Single
Caption = "進貨管理"
ClientHeight = 3600
ClientLeft = 5040
ClientTop = 4350
ClientWidth = 6705
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 3600
ScaleWidth = 6705
Begin VB.Frame FrameBG
Height = 3720
Left = 0
TabIndex = 8
Top = -120
Width = 6705
Begin VB.ComboBox cbo
Height = 300
Left = 1365
Style = 2 'Dropdown List
TabIndex = 0
Top = 735
Width = 4860
End
Begin VB.TextBox txt
Height = 990
Index = 4
Left = 1365
MaxLength = 500
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 1890
Width = 4830
End
Begin VB.TextBox txt
Height = 270
Index = 3
Left = 3630
MaxLength = 5
TabIndex = 4
Top = 1500
Width = 1080
End
Begin VB.TextBox txt
Height = 270
Index = 2
Left = 1365
MaxLength = 5
TabIndex = 3
Top = 1515
Width = 1080
End
Begin VB.PictureBox picTitle
Appearance = 0 'Flat
BackColor = &H00808080&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 360
Left = 30
ScaleHeight = 360
ScaleWidth = 6660
TabIndex = 9
TabStop = 0 'False
Top = 120
Width = 6660
Begin VB.Label lblTitle
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "登記進貨信息"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 210
Left = 255
TabIndex = 10
Top = 90
Width = 1350
End
End
Begin VB.TextBox txt
Height = 270
IMEMode = 3 'DISABLE
Index = 0
Left = 1365
TabIndex = 1
Top = 1140
Width = 1080
End
Begin VB.TextBox txt
Height = 270
IMEMode = 3 'DISABLE
Index = 1
Left = 3630
TabIndex = 2
Top = 1125
Width = 1080
End
Begin VB.CommandButton cmdBuy
Caption = "確定(&O)"
Height = 375
Left = 3615
TabIndex = 6
Top = 3045
Width = 1080
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消(&C)"
Height = 375
Left = 4950
TabIndex = 7
Top = 3045
Width = 1080
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "元"
Height = 180
Left = 2490
TabIndex = 17
Top = 1185
Width = 180
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "辦理員"
Height = 180
Left = 2895
TabIndex = 16
Top = 1560
Width = 540
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "送貨員"
Height = 180
Left = 405
TabIndex = 15
Top = 1560
Width = 540
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "進貨備注"
Height = 180
Left = 405
TabIndex = 14
Top = 1965
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "商品名稱"
Height = 180
Left = 405
TabIndex = 13
Top = 780
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "進貨單價"
Height = 180
Left = 405
TabIndex = 12
Top = 1185
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "數量"
Height = 180
Left = 3075
TabIndex = 11
Top = 1185
Width = 360
End
End
End
Attribute VB_Name = "frmBuy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Buy As clsBuy '進貨對象
'驗證用戶輸入的有效性
Private Function IsOK() As Boolean
Dim i As Long
'必須選擇進貨商品
If cbo.Text = "" Then
MsgBox "請選擇進貨商品!", vbInformation
Exit Function
End If
'除備注外的項目必須全部填寫
For i = 0 To 3
If txt(i) = "" Then
MsgBox "除備注外,請把所有項目填寫完整!", vbInformation
Exit Function
End If
Next i
'進價和數量必須為數字
If Not IsNumeric(txt(0)) Then
MsgBox "進價不是數字,請重新填寫!", vbInformation
txt(0).SetFocus
Exit Function
End If
If Not IsNumeric(txt(1)) Then
MsgBox "數量不是數字,請重新填寫!", vbInformation
txt(1).SetFocus
Exit Function
End If
'返回函數值
IsOK = True
End Function
Private Sub cmdBuy_Click()
'用戶輸入無效則退出該過程的執行
If Not IsOK Then Exit Sub
'初始化進貨對象
Set Buy = New clsBuy
With Buy
'為進貨對象的屬性賦值
.GoodsID = cbo.ItemData(cbo.ListIndex)
.UnitPrice = Val(txt(0))
.Amount = Val(txt(1))
.Deliverer = Trim(txt(2))
.Transactor = Trim(txt(3))
.RegistrarID = UserID
.Remark = IIf(Trim(txt(4)) = "", "無", RTrim(txt(4)))
'根據cmdBuy的Caption屬性修改或添加進貨對象
Select Case cmdBuy.Caption
Case "修改(&M)": UpdateBuy '修改進貨對象
Case Else: AddNewBuy '添加進貨對象
End Select
End With
cbo.SetFocus
End Sub
'更新進貨對象
Private Sub UpdateBuy()
Dim UpdateResult As gxcUpdate '更新結果
'指定進貨對象的ID屬性
Buy.ID = Me.Tag
'更新進貨對象并返回更新結果
UpdateResult = Buy.Update
Dim Buys As New clsBuys '進貨對象集
'按照編號查詢更新后的進貨對象
Buys.Query Buy.ID
'同步更新列表視圖并彈出提示消息框
ProcUpdateResult UpdateResult, Buys.Item(1)
End Sub
'添加進貨對象
Private Sub AddNewBuy()
Dim AddNewResult As gxcAddNew '添加結果
'添加進貨對象并返回添加結果
AddNewResult = Buy.AddNew
'添加成功之后的操作
If AddNewResult = AddNewOK Then
txt(0) = "": txt(1) = "": txt(2) = "": txt(3) = "": txt(4) = ""
'
Dim Buys As New clsBuys '進貨對象集
'按照編號查詢剛添加的進貨對象
Buys.Query Buy.ID
'當前操作處于瀏覽進貨信息狀態,則在列表視圖上添加進貨信息
If CurrentOperation = BrowseBuy Then ShowObjInLvw Buys.Item(1)
MsgBox "登記成功!", vbInformation
Exit Sub
End If
'添加失敗后的操作(消息框提示用戶)
ProcAddNewResult AddNewResult
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim Goodses As clsGoodses '商品對象集
Dim i As Long
'初始化商品對象集
Set Goodses = New clsGoodses
'檢索所有商品
Goodses.Query
'將商品名稱和編號添加到組合框
For i = 1 To Goodses.Count
cbo.AddItem Goodses.Item(i).GoodsName
cbo.ItemData(i - 1) = Goodses.Item(i).ID
Next i
End Sub
'文本框獲得焦點時選中所有文字
Private Sub txt_GotFocus(Index As Integer)
txt(Index).SelStart = 0 '選中文字的起始位置
txt(Index).SelLength = Len(txt(Index)) '選中文字的長度
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -