frmdriverlr.frm
来自「用VB开发的车辆数据库管理系统」· FRM 代码 · 共 773 行 · 第 1/2 页
FRM
773 行
Caption = "准驾车型:"
Height = 300
Left = 2850
TabIndex = 17
Top = 1335
Width = 1260
End
Begin VB.Label Label10
Caption = "何时参加工作:"
Height = 300
Left = 2850
TabIndex = 16
Top = 1680
Width = 1260
End
Begin VB.Label Label11
Caption = "联系电话:"
Height = 300
Left = 5640
TabIndex = 15
Top = 285
Width = 1260
End
Begin VB.Label Label12
Caption = "年检记录:"
Height = 300
Left = 5640
TabIndex = 14
Top = 630
Width = 1260
End
Begin VB.Label Label13
Caption = "备注:"
Height = 300
Left = 5640
TabIndex = 13
Top = 1335
Width = 1260
End
End
Begin VB.Image Imgexit
Height = 345
Left = 7245
Picture = "frmDriverlr.frx":1C7E
Stretch = -1 'True
Top = 2280
Width = 945
End
Begin VB.Image Imgcancel
Height = 345
Left = 5235
Picture = "frmDriverlr.frx":5C50
Stretch = -1 'True
Top = 2280
Width = 945
End
Begin VB.Image Imgok
Height = 350
Left = 4290
Picture = "frmDriverlr.frx":9C62
Stretch = -1 'True
Top = 2280
Width = 950
End
Begin VB.Image Imgfind
Height = 345
Left = 3345
Picture = "frmDriverlr.frx":DC6F
Stretch = -1 'True
Top = 2280
Width = 945
End
Begin VB.Image Imgdelete
Height = 345
Left = 1950
Picture = "frmDriverlr.frx":11C77
Stretch = -1 'True
Top = 2280
Width = 945
End
Begin VB.Image Imgupdate
Height = 350
Left = 1020
Picture = "frmDriverlr.frx":15C86
Stretch = -1 'True
Top = 2280
Width = 950
End
Begin VB.Image Imgadd
Height = 345
Left = 75
Picture = "frmDriverlr.frx":19CA1
Stretch = -1 'True
Top = 2280
Width = 945
End
End
Attribute VB_Name = "frmDriverlr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*************************************************************************
'**模 块 名:frmDriverlr
'**版权说明:吉林省明日科技有限公司享有本软件的所有版权,如果本软件用于商
'** 业用途,必须经过吉林省明日科技有限公司授权。如果提供网上免费
'** 下载,必须经过吉林省明日科技有限公司授权,并保证程序的完整,
'** 不得修改代码、注释和相关内容,否则,我公司将追究其法律责任
'**网 址:www.mingrisoft.com 价值无限,服务无限
'**电 话:(0431)84978981,84978982
'**创 建 人:明日科技
'**日 期:2007-10-31
'**修 改 人:mraj
'**日 期:2007-10-31
'**描 述:
'*************************************************************************
Dim i As Integer
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 '按回车键Text4获得焦点
End Sub
Private Sub DTPicker2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTPicker4.SetFocus '按回车键DTPicker4获得焦点
End Sub
Private Sub DTPicker3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text7.SetFocus '按回车键Text6获得焦点
End Sub
Private Sub DTPicker4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text6.SetFocus '按回车键Text7获得焦点
End Sub
Private Sub Form_Load()
frmDriverlr.Width = 8430
frmDriverlr.Height = 3150
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
DTPicker4.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
DTPicker4.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 Imgadd_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 = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Text2.SetFocus
'设置控件状态
Imgok.Enabled = True
Imgcancel.Enabled = True
Imgupdate.Enabled = False
Imgdelete.Enabled = False
DTPicker1.Visible = True
Adodc1.Enabled = False
i = 1
End Sub
Private Sub Imgcancel_Click() '取消
On Error Resume Next '当没有添加数据的时候 处理异常
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
Lockctl
Text1.Text = ""
Imgok.Enabled = False
Imgcancel.Enabled = False
Imgadd.Enabled = True
Imgupdate.Enabled = True
Imgdelete.Enabled = True
Adodc1.Enabled = True
End Sub
Private Sub Imgdelete_Click() '删除
If MsgBox("您确实要删除记录吗?", vbOKCancel, "车辆管理系统") = vbOK Then
cnn.Execute ("delete from 驾驶员档案 where 驾驶员编号='" & Text1 & "'")
MsgBox " 记录已删除!", , "车辆管理系统"
Adodc1.Refresh
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
DTPicker4.Value = Data
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
End If
End Sub
Private Sub Imgexit_Click() '退出
Unload Me
End Sub
Private Sub Imgfind_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)
DTPicker4.Value = 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)
Imgupdate.Enabled = True
Imgdelete.Enabled = True
Else
MsgBox "没有你需要的信息!", , "车辆管理系统"
Imgupdate.Enabled = False
Imgdelete.Enabled = False
End If
End Sub
Private Sub Imgok_Click() '确定
Select Case i
Case 1
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Combo1.Text = "" Then
MsgBox "每一项不能为空!", , "车辆管理系统"
Exit Sub
End If
Call main1
Dim rs As New ADODB.Recordset
' Set rs = adoCon.Execute("insert into 驾驶员档案 values ('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & DTPicker1.Value & "','" & Text4 & "','" & DTPicker2.Value & "','" & DTPicker4.value & "','" & Text6.Text & "','" & Combo1.Text & "','" & DTPicker3.Value & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "')")
rs.Open "select * from 驾驶员档案 ", adoCon, adOpenKeyset, adLockOptimistic
rs.AddNew
rs.Fields(0) = Text1.Text
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = DTPicker1.Value
rs.Fields(4) = Text4.Text
rs.Fields(5) = DTPicker2.Value
rs.Fields(6) = DTPicker4.Value
rs.Fields(7) = Text6.Text
rs.Fields(8) = Combo1.Text
rs.Fields(9) = DTPicker3.Value
rs.Fields(10) = Text7.Text
rs.Fields(11) = Text8.Text
rs.Fields(12) = Text9.Text
rs.Update
MsgBox "记录添加成功!", , "车辆管理系统"
rs.Close
Adodc1.Refresh
adoCon.Close
Case 2
cnn.Execute ("update 驾驶员档案 set 驾驶员编号='" & Text1.Text & "',姓名='" & Text2.Text & "',性别='" & Text3.Text & "',出生年月='" & DTPicker1.Value & "',驾驶证号='" & Text4.Text & "',领证日期='" & DTPicker1.Value & "',证件有效期='" & DTPicker4.Value & "',驾龄='" & Text6.Text & "',准驾车型='" & Combo1.Text & "',何时参加工作='" & DTPicker1.Value & "',联系电话='" & Text7.Text & "',年检记录='" & Text8.Text & "',备注='" & Text9.Text & "' where 驾驶员编号='" & Text1.Text & "'")
MsgBox "记录修改成功!", , "车辆管理系统"
Adodc1.Refresh
End Select
Lockctl
Imgok.Enabled = False
Imgcancel.Enabled = False
Imgadd.Visible = True
Imgupdate.Visible = True
Imgdelete.Visible = True
Adodc1.Enabled = True
End Sub
Private Sub Imgupdate_Click() '修改
Unlockctl
i = 2
Imgok.Enabled = True
Imgcancel.Enabled = True
Imgadd.Enabled = False
Imgdelete.Enabled = False
DTPicker1.Visible = True
Adodc1.Enabled = False
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 Text6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Combo1.SetFocus '按回车键Combo1获得焦点
End Sub
Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text8.SetFocus '按回车键Combo1获得焦点
End Sub
Private Sub Text8_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text9.SetFocus '按回车键Combo1获得焦点
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?