?? frmusefittings.frm
字號:
VERSION 5.00
Begin VB.Form frmUseFittings
BorderStyle = 1 'Fixed Single
Caption = "領用&歸還"
ClientHeight = 4410
ClientLeft = 45
ClientTop = 330
ClientWidth = 5280
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4410
ScaleWidth = 5280
Begin VB.Frame Frame1
Height = 3495
Left = 480
TabIndex = 3
Top = 120
Width = 4335
Begin VB.OptionButton optType
Caption = "歸還"
Height = 375
Index = 1
Left = 2760
TabIndex = 14
Top = 360
Width = 735
End
Begin VB.OptionButton optType
Caption = "領用"
Height = 375
Index = 0
Left = 1800
TabIndex = 13
Top = 360
Value = -1 'True
Width = 855
End
Begin VB.TextBox txtFName
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 10
TabIndex = 7
Top = 840
Width = 1575
End
Begin VB.TextBox txtBrand
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 20
TabIndex = 6
Top = 1320
Width = 1575
End
Begin VB.TextBox txtFType
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 15
TabIndex = 5
Top = 1800
Width = 1575
End
Begin VB.TextBox txtFCount
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 9
TabIndex = 4
Top = 2280
Width = 1575
End
Begin VB.Label Label2
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "操作:"
BeginProperty Font
Name = "楷體_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 840
TabIndex = 12
Top = 360
Width = 945
End
Begin VB.Label Label1
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "名稱:"
BeginProperty Font
Name = "楷體_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 840
TabIndex = 11
Top = 840
Width = 945
End
Begin VB.Label Label3
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "品牌:"
BeginProperty Font
Name = "楷體_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 840
TabIndex = 10
Top = 1320
Width = 945
End
Begin VB.Label Label4
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "型號:"
BeginProperty Font
Name = "楷體_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 840
TabIndex = 9
Top = 1800
Width = 945
End
Begin VB.Label Label6
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "數量:"
BeginProperty Font
Name = "楷體_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 285
Left = 840
TabIndex = 8
Top = 2280
Width = 945
End
End
Begin VB.CommandButton cmdSearch
Caption = "查詢"
Height = 375
Left = 2160
TabIndex = 2
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 3840
TabIndex = 1
Top = 3840
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "確定"
Height = 375
Left = 480
TabIndex = 0
Top = 3840
Width = 975
End
End
Attribute VB_Name = "frmUseFittings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' FNAME Not VarChar(20), --配件名稱
' BRAND VarChar(40), --品牌
' FTYPE Not VarChar(30), --型號
' PRICE Not Money, --價格
' FCOUNT INT NOT NULL, --數量
' STOREID VARCHAR(30)) --存儲地點,但個字符表示倉庫,其他表示地點
Private objFittings As New fittings
Private Sub cmdAdd_Click()
If checkForm() = True Then
Call getFormValues
'添加內容到數據庫
If Me.optType.Item(0).Value = True Then
'領用
If objFittings.Use() Then
MsgBox "成功領用!"
Call resetForm(Me)
Exit Sub
Else
MsgBox "領用失敗!"
Call resetForm(Me)
Exit Sub
End If
Else
'歸還
If objFittings.ReturnBack() Then
MsgBox "成功歸還!"
Call resetForm(Me)
Exit Sub
Else
MsgBox "歸還失敗!"
Call resetForm(Me)
Exit Sub
End If
End If
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdSearch_Click()
Dim rsS As ADODB.Recordset
Dim strCondition As String
If Me.txtFName.Text = "" Then
MsgBox "配件名稱不能為空!"
Me.txtFName.SetFocus
Exit Sub
End If
If Me.txtBrand.Text = "" Then
MsgBox "配件品牌不能為空!"
Me.txtBrand.SetFocus
Exit Sub
End If
If Me.txtFType.Text = "" Then
MsgBox "配件型號不能為空!"
Me.txtFType.SetFocus
Exit Sub
End If
objFittings.fname = Me.txtFName.Text
objFittings.brand = Me.txtBrand.Text
objFittings.ftype = Me.txtFType.Text
strCondition = "fname='" & objFittings.fname & "' and FTYPE = '" & objFittings.ftype & "' and brand='" & objFittings.brand & "'"
Set rsS = objDBOpt.getRecord("fittings", "*", strCondition)
If rsS Is Nothing Then
MsgBox "數據查詢失敗!"
Exit Sub
End If
If rsS.EOF And rsS.BOF Then
MsgBox "沒有符合條件的數據!"
rsS.Close
Exit Sub
End If
Me.txtFName.Text = setNotNull(rsS.Fields("fname").Value)
Me.txtBrand.Text = setNotNull(rsS.Fields("brand").Value)
Me.txtFType.Text = setNotNull(rsS.Fields("ftype").Value)
Me.txtFCount.Text = setNotNull(rsS.Fields("fcount").Value)
rsS.Close
End Sub
Private Sub Form_Load()
Call resetForm(Me)
End Sub
Private Sub getFormValues()
'將頁面輸入框中的值讀入到類屬性中
objFittings.fname = Trim(Me.txtFName.Text)
objFittings.brand = Trim(Me.txtBrand.Text)
objFittings.ftype = Trim(Me.txtFType.Text)
objFittings.fcount = Trim(Me.txtFCount.Text)
End Sub
Private Function checkForm() As Boolean
If Me.txtFName.Text = "" Then
MsgBox "配件名稱不能為空!"
Me.txtFName.SetFocus
checkForm = False
Exit Function
End If
If Me.txtBrand.Text = "" Then
MsgBox "配件品牌不能為空!"
Me.txtBrand.SetFocus
checkForm = False
Exit Function
End If
If Me.txtFType.Text = "" Then
MsgBox "配件型號不能為空!"
Me.txtFType.SetFocus
checkForm = False
Exit Function
End If
If Me.txtFCount.Text = "" Then
MsgBox "配件數量不能為空!"
Me.txtFCount.SetFocus
checkForm = False
Exit Function
End If
If Not (IsNumeric(Me.txtFCount.Text) And (InStr(1, CStr(Me.txtFCount.Text), ".", vbTextCompare) < 1) And (InStr(1, CStr(Me.txtFCount.Text), "-", vbTextCompare) < 1)) Then
MsgBox "配件數量應該為數字!"
Me.txtFCount.SetFocus
checkForm = False
Exit Function
End If
checkForm = True
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -