?? frmedit.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmEdit
BorderStyle = 3 'Fixed Dialog
Caption = "入庫修改"
ClientHeight = 7740
ClientLeft = 45
ClientTop = 330
ClientWidth = 9660
LinkTopic = "Form5"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 7740
ScaleWidth = 9660
ShowInTaskbar = 0 'False
Begin VB.Frame Frame4
Caption = "產品查詢"
Height = 855
Left = 240
TabIndex = 16
Top = 120
Width = 9015
Begin VB.CommandButton cmdClear
Caption = "清空"
Height = 495
Left = 6120
TabIndex = 24
Top = 240
Width = 1695
End
Begin VB.TextBox txtName
Height = 495
Left = 2160
TabIndex = 18
Top = 240
Width = 1695
End
Begin VB.CommandButton cmdQuery
Caption = "查詢"
Default = -1 'True
Height = 495
Left = 4200
TabIndex = 17
Top = 240
Width = 1575
End
Begin VB.Label Label5
Caption = "名稱"
Height = 375
Left = 600
TabIndex = 19
Top = 360
Width = 1215
End
End
Begin VB.Frame Frame3
Caption = "查詢結果"
Height = 2415
Left = 240
TabIndex = 14
Top = 1080
Width = 9015
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2055
Left = 240
TabIndex = 15
Top = 240
Width = 8415
_ExtentX = 14843
_ExtentY = 3625
_Version = 393216
AllowUpdate = 0 'False
Enabled = -1 'True
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin VB.Frame Frame2
Height = 855
Left = 240
TabIndex = 9
Top = 6120
Width = 9015
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 495
Left = 4800
TabIndex = 13
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdUpdate
Caption = "保存"
Height = 495
Left = 2805
TabIndex = 12
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdEdit
Caption = "修改"
Height = 495
Left = 840
TabIndex = 11
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdClose
Caption = "關閉"
Height = 495
Left = 6720
TabIndex = 10
Top = 240
Width = 1575
End
End
Begin VB.Frame Frame1
Caption = "產品修改"
Height = 1815
Left = 240
TabIndex = 0
Top = 3600
Width = 9015
Begin VB.TextBox txtFields
Height = 495
Index = 5
Left = 7080
TabIndex = 22
Top = 960
Width = 1695
End
Begin VB.TextBox txtFields
Height = 495
Index = 4
Left = 4200
TabIndex = 21
Top = 960
Width = 1815
End
Begin VB.TextBox txtFields
Height = 495
Index = 3
Left = 1080
TabIndex = 4
Top = 960
Width = 1815
End
Begin VB.TextBox txtFields
Height = 495
Index = 2
Left = 7080
TabIndex = 3
Top = 240
Width = 1695
End
Begin VB.TextBox txtFields
Height = 495
Index = 1
Left = 4200
TabIndex = 2
Top = 240
Width = 1815
End
Begin VB.TextBox txtFields
Height = 495
Index = 0
Left = 1080
TabIndex = 1
Top = 240
Width = 1815
End
Begin VB.Label Label7
Caption = "經手人"
Height = 375
Left = 6120
TabIndex = 23
Top = 960
Width = 855
End
Begin VB.Label Label6
Caption = "入庫數量"
Height = 495
Left = 6120
TabIndex = 20
Top = 360
Width = 735
End
Begin VB.Label Label1
Caption = "產品名稱"
Height = 375
Left = 240
TabIndex = 8
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "產品價格"
Height = 495
Left = 3240
TabIndex = 7
Top = 360
Width = 975
End
Begin VB.Label Label3
Caption = "產品描述"
Height = 495
Left = 240
TabIndex = 6
Top = 1080
Width = 975
End
Begin VB.Label Label4
Caption = "其它"
Height = 375
Left = 3240
TabIndex = 5
Top = 1080
Width = 735
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 240
Top = 5520
Width = 9015
_ExtentX = 15901
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "frmEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdEdit_Click()
'如果有錯則轉入出錯處理部分
On Error GoTo EditErr
'設置按鈕狀態,添加按鈕為禁用
SetButtons False
Exit Sub
EditErr:
'顯示出錯信息
MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click()
On Error GoTo CancelErr
Adodc1.Recordset.CancelBatch adAffectAll
'設置按鈕狀態,添加按鈕為真
SetButtons True
'顯示操作信息
MsgBox "取消成功!", vbExclamation + vbOKOnly, "產品修改"
Exit Sub
CancelErr:
'顯示出錯信息
MsgBox Err.Description
End Sub
Private Sub cmdClear_Click()
'清空查詢條件
txtName.Text = ""
'設置鼠標焦點
txtName.SetFocus
End Sub
Private Sub cmdClose_Click()
'釋放窗體本身
Unload Me
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
'條件判斷保證輸入的合理性
'如果名稱文本框為空,則顯示提示信息并返回
If Trim(txtFields(0).Text) = "" Then
MsgBox "名稱不能為空", vbExclamation + vbOKOnly, "警告"
'設置鼠標焦點
txtFields(0).SetFocus
Exit Sub
End If
'判斷價格文本框不能為空
If Trim(txtFields(1).Text) = "" Then
MsgBox "價格不能為空", vbExclamation + vbOKOnly, "警告"
'設置鼠標焦點
txtFields(1).SetFocus
Exit Sub
End If
'判斷價格文本框必須為數字
If Not IsNumeric(Trim(txtFields(1).Text)) Then
MsgBox "價格必須為數字", vbExclamation + vbOKOnly, "警告"
'設置鼠標焦點
txtFields(1).SetFocus
'使文本變為選中狀態
'設置選擇的起始位置和選擇的長度
txtFields(1).SelStart = 0
txtFields(1).SelLength = Len(txtFields(1).Text)
Exit Sub
End If
'判斷入庫數量文本框輸入必須為數字
If Not IsNumeric(Trim(txtFields(2).Text)) Then
MsgBox "入庫數量必須為數字", vbExclamation + vbOKOnly, "警告"
'設置鼠標焦點
txtFields(2).SetFocus
'使文本變為選中狀態
'設置選擇的起始位置和選擇的長度
txtFields(2).SelStart = 0
txtFields(2).SelLength = Len(txtFields(2).Text)
Exit Sub
End If
'保存adodc1的記錄集的修改
Adodc1.Recordset.UpdateBatch adAffectAll
'保存后,設置按鈕狀態
SetButtons True
'顯示操作信息
MsgBox "保存成功!", vbExclamation + vbOKOnly, "產品修改"
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub cmdQuery_Click()
Dim strSQL As String
'判斷名稱文本框不能為空
If Trim(txtName.Text) = "" Then
MsgBox "查詢名稱不能為空!", vbOKOnly + vbExclamation, "警告!"
'設置鼠標焦點
txtName.SetFocus
Exit Sub
End If
strSQL = "Select * From product Where 名稱 like " + "'" + _
Replace(Trim(txtName.Text), "'", "''", 1) + "%'"
'設置Adodc1的命令類型和記錄源
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
'刷新Adodc1
Adodc1.Refresh
End Sub
Private Sub Form_Load()
'設置Adodc1的連接字符串和記錄源
Adodc1.ConnectionString = ConnectString
Adodc1.RecordSource = "Select * From product "
'將文本框和Adodc1綁定
Dim i As Integer
For i = 1 To 6
'設置文本框的數據源
Set txtFields(i - 1).DataSource = Adodc1
'設置文本框的數據綁定字段
txtFields(i - 1).DataField = Adodc1.Recordset.Fields(i).Name
Next i
'設置DataGrid1的數據源
Set DataGrid1.DataSource = Adodc1
'設置按鈕狀態
SetButtons True
End Sub
'設置按鈕和文本的使用狀態
'添加按鈕可用時,保存取消兩個按鈕禁用
'點擊添加按鈕后,添加按鈕禁用,保存取消兩個按鈕可用
'點擊保存取消兩個按鈕之一后,添加按鈕又可用,保存取消兩個按鈕禁用
'對于文本框,點擊添加按鈕后可以使用,否則則禁用
Private Sub SetButtons(bVal As Boolean)
cmdEdit.Enabled = bVal
cmdUpdate.Enabled = Not bVal
cmdCancel.Enabled = Not bVal
cmdClose.Enabled = bVal
Dim i As Integer
For i = 0 To 5
txtFields(i).Enabled = Not bVal
Next i
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -