?? frmaddexpendable.frm
字號:
VERSION 5.00
Begin VB.Form frmAddExpendable
BorderStyle = 1 'Fixed Single
Caption = "消耗品登記"
ClientHeight = 3855
ClientLeft = 45
ClientTop = 330
ClientWidth = 5655
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3855
ScaleWidth = 5655
Begin VB.Frame Frame1
Height = 2655
Left = 600
TabIndex = 5
Top = 120
Width = 4455
Begin VB.ComboBox cmbStoreID
Height = 315
Left = 1800
Style = 2 'Dropdown List
TabIndex = 14
Top = 1920
Width = 855
End
Begin VB.TextBox txtEName
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 10
TabIndex = 8
Top = 480
Width = 1575
End
Begin VB.TextBox txtPrice
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 9
TabIndex = 7
Top = 960
Width = 1575
End
Begin VB.TextBox txtECount
Appearance = 0 'Flat
Height = 375
Left = 1800
MaxLength = 5
TabIndex = 6
Top = 1440
Width = 1575
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 = 13
Top = 480
Width = 945
End
Begin VB.Label Label5
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 = 960
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 = 11
Top = 1440
Width = 945
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 = 10
Top = 1920
Width = 945
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "元"
Height = 195
Left = 3480
TabIndex = 9
Top = 1080
Width = 180
End
End
Begin VB.CommandButton cmdSearch
Caption = "查詢"
Height = 375
Left = 3480
TabIndex = 4
Top = 3120
Width = 975
End
Begin VB.CommandButton cmdModi
Caption = "修改"
Height = 375
Left = 1200
TabIndex = 3
Top = 3120
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 4560
TabIndex = 2
Top = 3120
Width = 975
End
Begin VB.CommandButton cmdDel
Caption = "刪除"
Height = 375
Left = 2280
TabIndex = 1
Top = 3120
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 120
TabIndex = 0
Top = 3120
Width = 975
End
End
Attribute VB_Name = "frmAddExpendable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'ENAME Not VarChar(30), --消耗品名稱
'price Not Money, --價格
'ECOUNT INT NULL, --數量
'STOREID CHAR(1) REFERENCES STORE(STOREID)) --存儲地點
Private objExpendable As New clsExpendable
Private Sub cmdAdd_Click()
'添加消耗品
If checkForm() Then
Call getFormValues
If objExpendable.AddNew() Then
MsgBox "數據添加成功!"
Else
MsgBox "數據添加失敗!"
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 Trim(Me.txtEName.Text) = "" Then
MsgBox "請填寫消耗品名稱!"
Me.txtEName.SetFocus
Exit Sub
End If
objExpendable.ENAME = Trim(Me.txtEName.Text)
If objExpendable.Delete() Then
MsgBox "數據刪除成功!"
Else
MsgBox "數據刪除失敗!"
End If
Call resetForm(Me)
End Sub
Private Sub cmdModi_Click()
'修改消耗品
If checkForm() Then
Call getFormValues
If objExpendable.Modi() Then
MsgBox "數據修改成功!"
Else
MsgBox "數據修改失敗!"
End If
Else
Exit Sub
End If
Call resetForm(Me)
End Sub
Private Sub cmdSearch_Click()
'查詢消耗品
Dim strCondition As String
Dim rsq As New ADODB.Recordset
Dim i As Integer
If Trim(Me.txtEName.Text) = "" Then
MsgBox "請填寫消耗品名稱!"
Me.txtEName.SetFocus
Exit Sub
End If
objExpendable.ENAME = Trim(Me.txtEName.Text)
strCondition = "EName='" & Trim(Me.txtEName.Text) & "'"
Set rsq = objDBOpt.getRecord("Expendable", "*", strCondition)
If rsq Is Nothing Then
MsgBox "查詢失敗!"
ElseIf rsq.EOF And rsq.BOF Then
MsgBox "沒有符合條件的記錄!"
Else
Me.txtECount.Text = setNotNull(rsq.Fields("ECount").value, 0)
Me.txtPrice.Text = setNotNull(rsq.Fields("Price").value, 0)
For i = 0 To Me.cmbStoreID.ListCount
If Me.cmbStoreID.Text = Trim(setNotNull(rsq.Fields("Storeid").value, 0)) Then
Me.cmbStoreID.ListIndex = i
Exit For
End If
Next
End If
End Sub
Private Sub Form_Load()
Call resetForm(Me)
'獲取倉庫列表
Dim rs1 As New ADODB.Recordset
'Set rs1 = objDBOpt.getRecords("select distinct STOREID from store where ltrim(storeid)<>'' and not(storeid is null)")
Set rs1 = objDBOpt.getRecords("select storeid from store")
' If rs.State = adStateClosed Then
' MsgBox "rs is nothing"
' Exit Sub
' End If
Me.cmbStoreID.Clear
Do While Not rs1.EOF
Me.cmbStoreID.AddItem rs1.Fields("storeid")
rs1.MoveNext
Loop
'While Not rs.EOF
'Me.cmbStoreID.AddItem rs.Fields("storeid").value
'rs.MoveNext
'Wend
If Me.cmbStoreID.ListCount > 0 Then
Me.cmbStoreID.ListIndex = 0
End If
End Sub
Private Sub getFormValues()
objExpendable.ENAME = setValue(Me.txtEName.Text)
objExpendable.ECOUNT = setValue(Me.txtECount.Text, 0)
objExpendable.Price = setValue(Me.txtPrice.Text, 0)
objExpendable.STOREID = setValue(Me.cmbStoreID.Text, 0)
End Sub
Private Function checkForm() As Boolean
If Trim(Me.txtEName.Text) = "" Then
MsgBox "消耗品名稱不能為空!"
Me.txtEName.SetFocus
checkForm = False
Exit Function
End If
If IsNumeric(Me.txtECount.Text) = False Or InStr(1, Me.txtECount.Text, ".", vbTextCompare) > 0 Or InStr(1, Me.txtECount.Text, "-", vbTextCompare) > 0 Then
MsgBox "消耗品數量應該為整數!"
Me.txtECount.SetFocus
checkForm = False
Exit Function
End If
If IsNumeric(Me.txtPrice.Text) = False Or InStr(1, Me.txtPrice.Text, "-", vbTextCompare) > 0 Then
MsgBox "消耗品價格應該為數字!"
Me.txtPrice.SetFocus
checkForm = False
Exit Function
End If
checkForm = True
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -