📄 frmdriverlr.frm
字号:
TabIndex = 28
Top = 1680
Width = 1260
End
Begin VB.Label Label6
Caption = "领证日期:"
Height = 300
Left = 2850
TabIndex = 27
Top = 285
Width = 1260
End
Begin VB.Label Label7
Caption = "证件有效期:"
Height = 300
Left = 2850
TabIndex = 26
Top = 630
Width = 1260
End
Begin VB.Label Label8
Caption = "驾龄:"
Height = 300
Left = 2850
TabIndex = 25
Top = 975
Width = 1260
End
Begin VB.Label Label9
Caption = "准驾车型:"
Height = 300
Left = 2850
TabIndex = 24
Top = 1335
Width = 1260
End
Begin VB.Label Label10
Caption = "何时参加工作:"
Height = 300
Left = 2850
TabIndex = 23
Top = 1680
Width = 1260
End
Begin VB.Label Label11
Caption = "联系电话:"
Height = 300
Left = 5640
TabIndex = 22
Top = 285
Width = 1260
End
Begin VB.Label Label12
Caption = "年检记录:"
Height = 300
Left = 5640
TabIndex = 21
Top = 630
Width = 1260
End
Begin VB.Label Label13
Caption = "备注:"
Height = 300
Left = 5640
TabIndex = 20
Top = 1335
Width = 1260
End
End
Begin VB.CommandButton cmdExit
Caption = "退 出(&E)"
Height = 330
Left = 7245
TabIndex = 0
Top = 2250
Width = 975
End
Begin VB.CommandButton cmdDelete
Caption = "删 除(&D)"
Height = 330
Left = 1995
TabIndex = 3
Top = 2250
Width = 975
End
Begin VB.CommandButton cmdCancel
Caption = "取 消(&Q)"
Enabled = 0 'False
Height = 330
Left = 5235
TabIndex = 1
Top = 2250
Width = 975
End
Begin VB.CommandButton cmdUpdate
Caption = "修 改(&U)"
Height = 330
Left = 1035
TabIndex = 4
Top = 2250
Width = 975
End
Begin VB.CommandButton cmdAdd
Caption = "添 加(&A)"
Height = 330
Left = 75
TabIndex = 5
Top = 2250
Width = 975
End
Begin VB.CommandButton cmdOk
Caption = "确 定(&O)"
Enabled = 0 'False
Height = 330
Left = 4275
TabIndex = 2
Top = 2250
Width = 975
End
End
Attribute VB_Name = "frmDriverlr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Sub cmdAdd_Click()
Unlockctl
Dim temp1
temp1 = CStr(Year(Now))
Adodc1.RecordSource = "select * from 驾驶员档案 order by 驾驶员编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
Text1.Text = Year(Now) & Format(Val(Right(Adodc1.Recordset.Fields(0), 4) + 1), "0000")
Else
Text1.Text = Year(Now) & "0001"
End If
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Text2.SetFocus
cmdOk.Enabled = True
cmdCancel.Enabled = True
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
DTPicker1.Visible = True
Adodc1.Enabled = False
i = 1
End Sub
Private Sub cmdCancel_Click()
On Error Resume Next '当没有添加数据的时候 处理异常
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
Lockctl
Text1.Text = ""
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
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
End If
End Sub
Private Sub cmdExit_Click()
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
Text1.Text = Adodc1.Recordset.Fields(0)
Text2.Text = Adodc1.Recordset.Fields(1)
Text3.Text = Adodc1.Recordset.Fields(2)
DTPicker1.Value = Adodc1.Recordset.Fields(3)
Text4.Text = Adodc1.Recordset.Fields(4)
DTPicker2.Value = Adodc1.Recordset.Fields(5)
Text5.Text = Adodc1.Recordset.Fields(6)
Text6.Text = Adodc1.Recordset.Fields(7)
Combo1.Text = Adodc1.Recordset.Fields(8)
DTPicker3.Value = Adodc1.Recordset.Fields(9)
Text7.Text = Adodc1.Recordset.Fields(10)
Text8.Text = Adodc1.Recordset.Fields(11)
Text9.Text = Adodc1.Recordset.Fields(12)
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.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Combo1.Text = "" Then
MsgBox "每一项不能为空!", , "系统提示"
Exit Sub
End If
adoCon.Execute ("insert into 驾驶员档案 values ('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & DTPicker1.Value & "','" & Text4 & "','" & DTPicker2.Value & "','" & Text5 & "','" & Text6.Text & "','" & Combo1.Text & "','" & DTPicker3.Value & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "')")
MsgBox "记录添加成功!", , "系统提示"
Adodc1.Refresh
Case 2
adoCon.Execute ("update 驾驶员档案 set 驾驶员编号='" & Text1.Text & "',姓名='" & Text2.Text & "',性别='" & Text3.Text & "',出生年月='" & DTPicker1.Value & "',驾驶证号='" & Text4.Text & "',领证日期='" & DTPicker1.Value & "',证件有效期='" & Text5.Text & "',驾龄='" & Text6.Text & "',准驾车型='" & Combo1.Text & "',何时参加工作='" & DTPicker1.Value & "',联系电话='" & Text7.Text & "',年检记录='" & Text8.Text & "',备注='" & Text9.Text & "' where 驾驶员编号='" & Text1.Text & "'")
MsgBox "记录修改成功!", , "系统提示"
Adodc1.Refresh
End Select
Lockctl
cmdOk.Enabled = False
cmdCancel.Enabled = False
cmdAdd.Visible = True
cmdUpdate.Visible = True
cmdDelete.Visible = True
Adodc1.Enabled = True
End Sub
Private Sub cmdUpdate_Click()
Unlockctl
i = 2
cmdOk.Enabled = True
cmdCancel.Enabled = True
cmdAdd.Enabled = False
cmdDelete.Enabled = False
DTPicker1.Visible = True
Adodc1.Enabled = False
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = valiText(KeyAscii, Chr(13), True)
If KeyAscii = 13 Then DTPicker3.SetFocus
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text4.SetFocus
End Sub
Private Sub DTPicker2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text5.SetFocus
End Sub
Private Sub DTPicker3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text7.SetFocus
End Sub
Private Sub Form_Load()
frmDriverlr.Width = 8460
frmDriverlr.Height = 3120
Adodc2.RecordSource = "select * from 车辆类型表"
Adodc2.Refresh
For i = 0 To Adodc2.Recordset.RecordCount - 1
Combo1.AddItem Adodc2.Recordset.Fields(0).Value
Adodc2.Recordset.MoveNext
Next
End Sub
Private Sub Lockctl()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
DTPicker1.Enabled = False
DTPicker2.Enabled = False
DTPicker3.Enabled = False
Text9.Enabled = False
Text8.Enabled = False
Combo1.Enabled = False
End Sub
Private Sub Unlockctl()
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
DTPicker1.Enabled = True
DTPicker2.Enabled = True
DTPicker3.Enabled = True
Text9.Enabled = True
Text8.Enabled = True
Combo1.Enabled = True
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text1.Text = "" Then
MsgBox "驾驶编号不能为空!", , "系统提示"
Text1.SetFocus
End If
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text2.Text = "" Then
MsgBox "姓名不能为空!!", , "系统提示"
Text2.SetFocus
End If
Text3.SetFocus
End If
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text3.Text = "" Then
MsgBox "性别不能为空!", , "系统提示"
Text3.SetFocus
End If
DTPicker1.SetFocus
End If
End Sub
Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text4.Text = "" Then
MsgBox "驾驶证号不能为空!!", , "系统提示"
Text4.SetFocus
End If
DTPicker2.SetFocus
End If
End Sub
Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Text5.Text = "" Then
MsgBox "证件有效期不能为空!", , "系统提示"
Text5.SetFocus
End If
Text6.SetFocus
End If
End Sub
Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Combo1.SetFocus
End Sub
Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text8.SetFocus
End Sub
Private Sub Text8_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text9.SetFocus
End Sub
Private Sub Text9_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then cmdOk.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -