?? frmaddfittings.frm
字號(hào):
VERSION 5.00
Begin VB.Form frmAddFittings
BorderStyle = 1 'Fixed Single
Caption = "配件登記"
ClientHeight = 4950
ClientLeft = 45
ClientTop = 330
ClientWidth = 5940
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4950
ScaleWidth = 5940
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 240
TabIndex = 18
Top = 4200
Width = 975
End
Begin VB.CommandButton cmdDel
Caption = "刪除"
Height = 375
Left = 2400
TabIndex = 17
Top = 4200
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 4680
TabIndex = 16
Top = 4200
Width = 975
End
Begin VB.CommandButton cmdModi
Caption = "修改"
Height = 375
Left = 1320
TabIndex = 15
Top = 4200
Width = 975
End
Begin VB.CommandButton cmdSearch
Caption = "查詢"
Height = 375
Left = 3600
TabIndex = 14
Top = 4200
Width = 975
End
Begin VB.Frame Frame1
Height = 3735
Left = 600
TabIndex = 0
Top = 120
Width = 4455
Begin VB.TextBox txtStoreID
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 15
TabIndex = 12
Top = 2880
Width = 1575
End
Begin VB.TextBox txtFCount
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 9
TabIndex = 11
Top = 2400
Width = 1575
End
Begin VB.TextBox txtPrice
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 9
TabIndex = 10
Top = 1920
Width = 1575
End
Begin VB.TextBox txtFType
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 15
TabIndex = 9
Top = 1440
Width = 1575
End
Begin VB.TextBox txtBrand
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 20
TabIndex = 8
Top = 960
Width = 1575
End
Begin VB.TextBox txtFName
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 10
TabIndex = 7
Top = 480
Width = 1575
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "元"
Height = 195
Left = 3480
TabIndex = 13
Top = 2040
Width = 180
End
Begin VB.Label Label7
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 = 6
Top = 2880
Width = 945
End
Begin VB.Label Label6
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "數(shù)量:"
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 = 5
Top = 2400
Width = 945
End
Begin VB.Label Label5
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "價(jià)格:"
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 = 4
Top = 1920
Width = 945
End
Begin VB.Label Label4
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "型號(hào):"
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 = 3
Top = 1440
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 = 2
Top = 960
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 = 1
Top = 480
Width = 945
End
End
End
Attribute VB_Name = "frmAddFittings"
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), --型號(hào)
' PRICE Not Money, --價(jià)格
' FCOUNT INT NOT NULL, --數(shù)量
' STOREID VARCHAR(30)) --存儲(chǔ)地點(diǎn),但個(gè)字符表示倉庫,其他表示地點(diǎn)
Private objFittings As New fittings
Private Sub cmdAdd_Click()
If checkForm() = True Then
Call getFormValues
'添加內(nèi)容到數(shù)據(jù)庫
If objFittings.AddNew() Then
MsgBox "數(shù)據(jù)添加成功!"
Call resetForm(Me)
Else
MsgBox "數(shù)據(jù)添加失敗!"
End If
Else
Exit Sub
End If
Call resetForm(Me)
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdDel_Click()
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 "配件型號(hào)不能為空!"
Me.txtFType.SetFocus
Exit Sub
End If
Call getFormValues
If MsgBox("確認(rèn)要?jiǎng)h除該記錄嗎?", vbOKCancel) Then
If objFittings.Delete() = True Then
MsgBox "數(shù)據(jù)刪除成功!"
Else
MsgBox "數(shù)據(jù)刪除失敗!"
End If
End If
Call resetForm(Me)
End Sub
Private Sub cmdModi_Click()
If checkForm() = True Then
Call getFormValues
If objFittings.Modify() Then
MsgBox "數(shù)據(jù)修改成功!"
Call resetForm(Me)
Else
MsgBox "數(shù)據(jù)修改失敗!"
End If
Else
Exit Sub
End If
Call resetForm(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 "配件型號(hào)不能為空!"
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 "數(shù)據(jù)查詢失敗!"
Exit Sub
End If
If rsS.EOF And rsS.BOF Then
MsgBox "沒有符合條件的數(shù)據(jù)!"
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.txtPrice.Text = setNotNull(rsS.Fields("price").Value)
Me.txtFCount.Text = setNotNull(rsS.Fields("fcount").Value)
Me.txtStoreID.Text = setNotNull(rsS.Fields("storeid").Value)
rsS.Close
End Sub
Private Sub Form_Load()
Call resetForm(Me)
End Sub
Private Sub getFormValues()
'將頁面輸入框中的值讀入到類屬性中
objFittings.fname = setValue(Trim(Me.txtFName.Text))
objFittings.brand = setValue(Trim(Me.txtBrand.Text))
objFittings.ftype = setValue(Trim(Me.txtFType.Text))
objFittings.Price = setValue(Trim(Me.txtPrice.Text), 0)
objFittings.fcount = setValue(Trim(Me.txtFCount.Text), 0)
objFittings.STOREID = setValue(Trim(Me.txtStoreID.Text), 0)
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 "配件型號(hào)不能為空!"
Me.txtFType.SetFocus
checkForm = False
Exit Function
End If
If Me.txtPrice.Text = "" Then
MsgBox "配件價(jià)格不能為空!"
Me.txtPrice.SetFocus
checkForm = False
Exit Function
End If
If Not (IsNumeric(Me.txtPrice.Text) And InStr(1, Me.txtPrice.Text, "-", vbTextCompare) < 1) Then
MsgBox "配件價(jià)格應(yīng)該為數(shù)字!"
Me.txtPrice.SetFocus
checkForm = False
Exit Function
End If
If Me.txtFCount.Text = "" Then
MsgBox "配件數(shù)量不能為空!"
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 "配件數(shù)量應(yīng)該為數(shù)字!"
Me.txtFCount.SetFocus
checkForm = False
Exit Function
End If
checkForm = True
End Function
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -