📄 frmauthors.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmAuthors
Caption = "Authors"
ClientHeight = 6390
ClientLeft = 60
ClientTop = 345
ClientWidth = 7725
LinkTopic = "Form1"
ScaleHeight = 6390
ScaleWidth = 7725
StartUpPosition = 3 'Windows Default
Begin VB.CheckBox chkExecute
Caption = "Use Execute"
Height = 375
Left = 6360
TabIndex = 13
Top = 4440
Width = 1215
End
Begin VB.TextBox txtId
Height = 375
Left = 120
TabIndex = 1
Top = 3000
Width = 2535
End
Begin VB.CommandButton cmdDelete
Caption = "Delete"
Height = 375
Left = 6360
TabIndex = 12
Top = 3840
Width = 1215
End
Begin VB.CommandButton cmdNew
Caption = "New"
Height = 375
Left = 6360
TabIndex = 10
Top = 2880
Width = 1215
End
Begin VB.CommandButton cmdUpdate
Caption = "Update"
Enabled = 0 'False
Height = 375
Left = 6360
TabIndex = 11
Top = 3360
Width = 1215
End
Begin VB.TextBox txtFirstName
Height = 375
Left = 120
TabIndex = 2
Top = 3720
Width = 2535
End
Begin VB.TextBox txtLastName
Height = 375
Left = 2760
TabIndex = 3
Top = 3720
Width = 2535
End
Begin VB.TextBox txtAddress
Height = 375
Left = 120
TabIndex = 4
Top = 4440
Width = 5175
End
Begin VB.TextBox txtCity
Height = 375
Left = 120
TabIndex = 5
Top = 5160
Width = 2535
End
Begin VB.TextBox txtState
Height = 375
Left = 2760
TabIndex = 6
Top = 5160
Width = 855
End
Begin VB.TextBox txtZip
Height = 375
Left = 3720
TabIndex = 7
Top = 5160
Width = 1575
End
Begin VB.TextBox txtPhone
Height = 375
Left = 120
TabIndex = 8
Top = 5880
Width = 2535
End
Begin VB.CheckBox chkContract
Caption = "Contract"
Height = 375
Left = 2760
TabIndex = 9
Top = 5880
Width = 1935
End
Begin ComctlLib.ListView listAuthors
Height = 2535
Left = 120
TabIndex = 0
Top = 120
Width = 7455
_ExtentX = 13150
_ExtentY = 4471
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Name"
Object.Width = 3528
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "Address"
Object.Width = 3528
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "City"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "State"
Object.Width = 882
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "Zip"
Object.Width = 1235
EndProperty
_Items = "frmAuthors.frx":0000
End
Begin VB.Label lblId
Caption = "Id"
Height = 375
Left = 120
TabIndex = 21
Top = 2760
Width = 1935
End
Begin VB.Label lblFirstName
Caption = "First"
Height = 375
Left = 120
TabIndex = 20
Top = 3480
Width = 1935
End
Begin VB.Label lblLastName
Caption = "Last"
Height = 375
Left = 2760
TabIndex = 19
Top = 3480
Width = 1335
End
Begin VB.Label lblAddress
Caption = "Address"
Height = 255
Left = 120
TabIndex = 18
Top = 4200
Width = 2175
End
Begin VB.Label lblCity
Caption = "City"
Height = 375
Left = 120
TabIndex = 17
Top = 4920
Width = 1695
End
Begin VB.Label lblState
Caption = "State"
Height = 255
Left = 2760
TabIndex = 16
Top = 4920
Width = 855
End
Begin VB.Label lblZip
Caption = "Zip Code"
Height = 375
Left = 3720
TabIndex = 15
Top = 4920
Width = 1575
End
Begin VB.Label lblPhone
Caption = "Phone"
Height = 375
Left = 120
TabIndex = 14
Top = 5640
Width = 1095
End
End
Attribute VB_Name = "frmAuthors"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private mConn As Connection
'has something changed
Private mbNeedSave As Boolean
'are we working with a new record
Private mbNewRecord As Boolean
'keep track of the current record
Private msCurrentRecord As String
Private Function UpdateRecord() As Boolean
Dim sCmd As String
Dim rs As Recordset
If mbNewRecord Then
'try to insert
If chkExecute.Value = vbChecked Then
'use the execute method of the connection
sCmd = "insert into authors (au_id,au_fname,au_lname,address" _
+ ",city,state,zip,phone,contract)"
sCmd = sCmd + " values ("
sCmd = sCmd + "'" + txtId.Text + "'"
sCmd = sCmd + ",'" + txtFirstName.Text + "'"
sCmd = sCmd + ",'" + txtLastName.Text + "'"
sCmd = sCmd + ",'" + txtAddress.Text + "'"
sCmd = sCmd + ",'" + txtCity.Text + "'"
sCmd = sCmd + ",'" + txtState.Text + "'"
sCmd = sCmd + ",'" + txtZip.Text + "'"
sCmd = sCmd + ",'" + txtPhone.Text + "'"
sCmd = sCmd + "," & IIf(chkContract.Value = vbChecked, 1, 0)
sCmd = sCmd + ")"
On Error GoTo UpdateFailed:
mConn.Execute sCmd
On Error GoTo 0
Else
'use a Recordset Object to add it
Set rs = New Recordset
On Error GoTo UpdateFailed
rs.Open "select * from authors where au_id = '" _
+ txtId.Text + "'", mConn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!au_id = txtId.Text
rs!au_fname = txtFirstName.Text
rs!au_lname = txtLastName.Text
rs!address = txtAddress.Text
rs!city = txtCity.Text
rs!State = txtState.Text
rs!zip = txtZip.Text
rs!phone = txtPhone.Text
rs!contract = (chkContract.Value = vbChecked)
rs.Update
On Error GoTo 0
rs.Close
Set rs = Nothing
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -