📄 frmcardalr.frm
字号:
End
Begin VB.Label Label12
Caption = "年 检 否:"
Height = 255
Left = 3120
TabIndex = 23
Top = 969
Width = 975
End
Begin VB.Label Label13
Caption = "保 险 否:"
Height = 255
Left = 3120
TabIndex = 22
Top = 1311
Width = 975
End
Begin VB.Label Label14
Caption = "异 动 否:"
Height = 255
Left = 3120
TabIndex = 21
Top = 1653
Width = 975
End
Begin VB.Label Label15
Caption = "报 废 否:"
Height = 255
Left = 3120
TabIndex = 20
Top = 1995
Width = 975
End
Begin VB.Label Label16
Caption = "备 注:"
Height = 255
Left = 120
TabIndex = 19
Top = 1995
Width = 975
End
Begin VB.Label Label1
Caption = "车牌号码:"
Height = 255
Left = 120
TabIndex = 18
Top = 285
Width = 975
End
Begin VB.Label Label7
Caption = "厂牌型号:"
Height = 255
Left = 3120
TabIndex = 17
Top = 285
Width = 975
End
End
Begin VB.CommandButton cmdExit
Caption = " 退 出(&E)"
Height = 330
Left = 6030
TabIndex = 5
Top = 2265
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "删 除(&D)"
Height = 330
Left = 6030
TabIndex = 3
Top = 795
Width = 1095
End
Begin VB.CommandButton cmdUpdate
Caption = "修 改(&U)"
Height = 330
Left = 6030
TabIndex = 2
Top = 480
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "添 加(&A)"
Height = 330
Left = 6030
TabIndex = 0
Top = 165
Width = 1095
End
Begin MSAdodcLib.Adodc Adodc2
Height = 330
Left = 1680
Top = 2190
Visible = 0 'False
Width = 1830
_ExtentX = 3228
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 车辆类型表"
Caption = "Adodc2"
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 = "frmcardalr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Sub cmbf_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
End Sub
Private Sub cmdCancel_Click()
On Error Resume Next '当没有添加数据的时候 处理异常
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
Lockctl
cmdok.Enabled = False: cmdCancel.Enabled = False
cmdAdd.Enabled = True: cmdUpdate.Enabled = True
cmdDelete.Enabled = True: Adodc1.Enabled = True
End Sub
Private Sub cmdDelete_Click()
If MsgBox("您确实要删除记录吗?", vbOKCancel, "系统提示") = vbOK Then
adoCon.Execute ("delete from 车辆档案 where 车牌号码='" & Text1 & "'")
MsgBox " 记录已删除!", , "系统提示"
Adodc1.Refresh
End If
End Sub
Private Sub cmdExit_Click()
MDIForm1.StatusBar1.Panels(1).Text = ""
Unload Me
End Sub
Private Sub cmdFind_Click()
Dim str As String
str = InputBox$("输入你要查询的车牌号码:", "系统提示")
If str = "" Then Exit Sub
Adodc1.RecordSource = "select * from 车辆档案 where 车牌号码='" + str + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
On Error Resume Next
Text1.Text = Adodc1.Recordset.Fields(0)
Combo1.Text = Adodc1.Recordset.Fields(1)
Combo2.Text = Adodc1.Recordset.Fields(2)
DTPicker1.Value = Adodc1.Recordset.Fields(3)
Text7.Text = Adodc1.Recordset.Fields(4)
Text4.Text = Adodc1.Recordset.Fields(5)
Text5.Text = Adodc1.Recordset.Fields(6)
cmnj.Text = Adodc1.Recordset.Fields(7)
cmbx.Text = Adodc1.Recordset.Fields(8)
cmyd.Text = Adodc1.Recordset.Fields(9)
cmbf.Text = Adodc1.Recordset.Fields(10)
Text6.Text = Adodc1.Recordset.Fields(11)
cmdUpdate.Enabled = True
cmdDelete.Enabled = True
Else
MsgBox "没有你需要的信息!", , "系统提示"
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
End If
End Sub
Private Sub cmdOk_Click()
Select Case i
Case 1
If Text1 = "" Then
MsgBox "车牌号码不能为空", , "系统提示"
Text1.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "车辆类型不能为空", , "系统提示"
Combo1.SetFocus
Exit Sub
End If
If DTPicker1.Value = "" Then
MsgBox "购置日期不能为空", , "系统提示"
DTPicker1.SetFocus
Exit Sub
End If
adoCon.Execute ("insert into 车辆档案 values ('" & Text1 & "','" & Combo1 & "','" & Combo2 & "','" & DTPicker1.Value & "','" & Text7 & "','" & Text4 & "','" & Text5 & "','" & cmnj & "','" & cmbx & "','" & cmyd & "','" & cmbf & "','" & Text6 & "')")
MsgBox "记录添加成功!", , "系统提示"
Adodc1.Refresh
Case 2
adoCon.Execute ("update 车辆档案 set 车辆类型='" & Combo1 & "',驾驶员编号='" & Combo2 & "',使用人或单位='" & Text4 & "',车辆所在单位='" & Text5 & "',备注='" & Text6 & "', 厂牌型号='" & Text7 & "',购置日期='" & DTPicker1.Value & "',年检审='" & cmnj.Text & "',保险否='" & cmbx.Text & "',异动否='" & cmyd.Text & "',报废否='" & cmbf.Text & "' where 车牌号码='" & Text1 & "'")
MsgBox "记录修改成功!", , "系统提示"
Adodc1.Refresh
End Select
Lockctl
cmdok.Enabled = False: cmdCancel.Enabled = False
cmdAdd.Enabled = True: cmdUpdate.Enabled = True
cmdDelete.Enabled = True: Adodc1.Enabled = True
End Sub
Private Sub cmdAdd_Click()
Unlockctl
DTPicker1.Value = Format(Now, "yyyy-mm-dd")
Text1 = "": Text2 = "": Combo2 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = ""
Combo1.Text = ""
cmnj.Text = "是"
cmbx.Text = "是"
cmyd.Text = "是"
cmbf.Text = "是"
Text1.SetFocus
cmdok.Enabled = True: cmdCancel.Enabled = True
cmdDelete.Enabled = False: Combo1.Visible = True
Adodc1.Enabled = False: cmdUpdate.Enabled = False
i = 1
End Sub
Private Sub cmdUpdate_Click()
Unlockctl
i = 2
cmdok.Enabled = True: cmdCancel.Enabled = True
cmdAdd.Enabled = False: cmdDelete.Enabled = False
Adodc1.Enabled = False: Text1.Enabled = False
End Sub
Private Sub cmnj_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then cmbx.SetFocus
End Sub
Private Sub cmbx_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then cmyd.SetFocus
End Sub
Private Sub cmyd_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then cmbf.SetFocus
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyAscii = vbKeyReturn Then cmnj.SetFocus
End Sub
Private Sub Form_Load()
frmcardalr.Height = 3075: frmcardalr.Width = 7410
Adodc1.RecordSource = "select * from 车辆档案"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then DTPicker1.Value = Adodc1.Recordset.Fields("购置日期")
Adodc2.RecordSource = "select * from 车辆类型表"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount = 0 Then Exit Sub
For i = 0 To Adodc2.Recordset.RecordCount - 1
Combo1.AddItem Adodc2.Recordset.Fields(0).Value
Adodc2.Recordset.MoveNext
Next
Adodc3.RecordSource = "select * from 驾驶员档案"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount = 0 Then Exit Sub
For i = 0 To Adodc3.Recordset.RecordCount - 1
Combo2.AddItem Adodc3.Recordset.Fields(0).Value
Adodc3.Recordset.MoveNext
Next
On Error Resume Next
Combo1.Text = Adodc1.Recordset.Fields(1)
Combo2.Text = Adodc1.Recordset.Fields(2)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
cmdExit_Click
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Combo1.SetFocus
End Sub
Private Sub Text1_LostFocus()
Dim rs As New ADODB.Recordset
Set rs = adoCon.Execute("select * from 车辆档案 where 车牌号码='" & Text1.Text & "'")
If rs.EOF = False Then
MsgBox "此车牌号码已经存在!", , "系统提示"
Text1 = ""
Text1.SetFocus
End If
rs.Close
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then Combo2.SetFocus
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then Text4.SetFocus
End Sub
'Private Sub Text3_LostFocus()
' Adodc1.RecordSource = "select * from 驾驶员档案 where 驾驶员编号='" + Text3.Text + "'"
' Adodc1.Refresh
' If Text3.Text = "" Then Exit Sub
' If Adodc1.Recordset.RecordCount > 0 Then
' Else
' MsgBox "本公司没有驾驶员!", , "系统提示"
' Text3.SetFocus
' End If
'End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text6.SetFocus
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text7.SetFocus
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text5.SetFocus
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then DTPicker1.SetFocus
End Sub
Private Sub Lockctl()
Text1.Enabled = False: Combo1.Enabled = False: Combo2.Enabled = False
Text4.Enabled = False: Text5.Enabled = False: Text6.Enabled = False
Text7.Enabled = False
DTPicker1.Enabled = False
cmnj.Enabled = False: cmbx.Enabled = False: cmyd.Enabled = False: cmbf.Enabled = False
End Sub
Private Sub Unlockctl()
Text1.Enabled = True: Combo1.Enabled = True: Combo2.Enabled = True
Text4.Enabled = True: Text5.Enabled = True: Text6.Enabled = True
Text7.Enabled = True
DTPicker1.Enabled = True
cmnj.Enabled = True: cmbx.Enabled = True: cmyd.Enabled = True: cmbf.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -