📄 frm_cldj.frm
字号:
Begin VB.Label Label9
Caption = "购置日期"
Height = 360
Left = 195
TabIndex = 30
Top = 3150
Width = 840
End
Begin VB.Label Label11
Caption = "发动机号"
Height = 270
Left = 195
TabIndex = 29
Top = 3900
Width = 975
End
Begin VB.Line Line1
BorderColor = &H00008000&
Index = 1
X1 = 225
X2 = 8205
Y1 = 4215
Y2 = 4215
End
Begin VB.Line Line2
BorderColor = &H00008000&
Index = 1
X1 = 225
X2 = 8205
Y1 = 4245
Y2 = 4245
End
Begin VB.Label Label17
Caption = "备注信息"
Height = 255
Left = 195
TabIndex = 21
Top = 4935
Width = 810
End
Begin VB.Label Label16
Caption = "里程数"
Height = 255
Left = 6645
TabIndex = 19
Top = 4425
Width = 615
End
Begin VB.Label Label15
Caption = "驾驶员"
Height = 240
Left = 5070
TabIndex = 18
Top = 4425
Width = 585
End
Begin VB.Label Label14
Caption = "座位数"
Height = 195
Left = 3510
TabIndex = 16
Top = 4425
Width = 555
End
Begin VB.Label Label13
Caption = "载重"
Height = 240
Left = 2115
TabIndex = 14
Top = 4410
Width = 660
End
Begin VB.Label Label12
Caption = "车辆颜色"
Height = 285
Left = 195
TabIndex = 12
Top = 4395
Width = 975
End
Begin VB.Label Label10
Caption = "购置价格"
Height = 225
Left = 195
TabIndex = 9
Top = 3540
Width = 735
End
Begin VB.Label Label8
Caption = "出厂日期"
Height = 285
Left = 195
TabIndex = 8
Top = 2775
Width = 780
End
Begin VB.Label Label7
Caption = "厂牌型号"
Height = 270
Left = 195
TabIndex = 7
Top = 2385
Width = 840
End
Begin VB.Line Line2
BorderColor = &H00008000&
Index = 0
X1 = 240
X2 = 8190
Y1 = 4755
Y2 = 4755
End
Begin VB.Label Label6
Caption = "车辆类型"
Height = 270
Left = 195
TabIndex = 5
Top = 2010
Width = 885
End
Begin VB.Label Label3
Caption = "编号"
Height = 210
Left = 195
TabIndex = 4
Top = 960
Width = 585
End
Begin VB.Label Label2
Caption = "记录修改人"
Height = 255
Left = 6165
TabIndex = 2
Top = 4935
Width = 960
End
Begin VB.Label Label1
Caption = "记录修改日期"
Height = 225
Left = 3495
TabIndex = 0
Top = 4950
Width = 1140
End
Begin VB.Line Line1
BorderColor = &H00008000&
Index = 0
X1 = 240
X2 = 8175
Y1 = 4725
Y2 = 4725
End
End
Attribute VB_Name = "frm_cldj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim c
Private Sub Cbx_lx_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(3).SetFocus
End If
End Sub
Private Sub Cbx_ys_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(6).SetFocus
End If
End Sub
Private Sub Dgr_Sjll_Click()
On Error Resume Next
If Adodc1.Recordset.RecordCount > 0 Then
Text1(0).Text = Adodc1.Recordset.Fields(0)
Text1(1).Text = Adodc1.Recordset.Fields(1)
Text1(2).Text = Adodc1.Recordset.Fields(2)
Cbx_lx.Text = Adodc1.Recordset.Fields(3)
Text1(3).Text = Adodc1.Recordset.Fields(4)
DT1.Value = Adodc1.Recordset.Fields(5)
DT2.Value = Adodc1.Recordset.Fields(6)
Text1(4).Text = Adodc1.Recordset.Fields(7)
Text1(5).Text = Adodc1.Recordset.Fields(8)
Cbx_ys.Text = Adodc1.Recordset.Fields(9)
Text1(6).Text = Adodc1.Recordset.Fields(10)
Text1(7).Text = Adodc1.Recordset.Fields(11)
Text1(8).Text = Adodc1.Recordset.Fields(12)
Text1(9).Text = Adodc1.Recordset.Fields(13)
Text1(10).Text = Adodc1.Recordset.Fields(14)
Txt_Date.Text = Adodc1.Recordset.Fields(15)
Txt_lxr.Text = Adodc1.Recordset.Fields(16)
End If
End Sub
Private Sub DT1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
DT2.SetFocus
End If
End Sub
Private Sub DT2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text1(4).SetFocus
End If
End Sub
Private Sub Form_Load()
DT1.Value = Date
DT2.Value = Date
Call LoadFile
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from 车辆登记 order by 编号"
Adodc1.Refresh
Call Tbr_cortrol(Tbr_xxcz, True)
End Sub
Private Sub Tbr_xxcz_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "Add"
Call Tbr_cortrol(Tbr_xxcz, False)
AdoRs.Open "select * from 车辆登记 order by 编号", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
AdoRs.MoveLast
StrNum = Mid(AdoRs.Fields("编号"), 2, Len(AdoRs.Fields("编号")))
Call Con_PublicNum '调用位数转换函数
Text1(0).Text = "C" & StrIn
Else
Text1(0).Text = "C0001"
End If
AdoRs.Close
For i = 1 To 10
Text1(i).Text = ""
Text1(i).Locked = False
Next i
Cbx_lx.Text = ""
Cbx_ys.Text = ""
Text1(1).SetFocus
DT1.Value = Date
DT2.Value = Date
Case "Del" '删除信息
Call Deletes
Case "Edit" '修改信息
Call Edits
Case "Save" '保存信息
Call Saves
Case "Cancel"
Call Tbr_cortrol(Tbr_xxcz, True)
For i = 1 To 10
Text1(i).Text = ""
Text1(1).SetFocus
Text1(i).Locked = True
Next i
Adodc1.RecordSource = "select * from 车辆登记 order by 编号"
Adodc1.Refresh
Case "Exit"
Unload Me
End Select
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
If Index = 0 Then
AdoRs.Open "select * from 车辆登记 where 编号='" + Text1(0) + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Text1(0).Text = AdoRs.Fields(0)
Text1(1).Text = AdoRs.Fields(1)
Text1(2).Text = AdoRs.Fields(2)
Cbx_lx.Text = AdoRs.Fields(3)
Text1(3).Text = AdoRs.Fields(4)
DT1.Value = AdoRs.Fields(5)
DT2.Value = AdoRs.Fields(6)
Text1(4).Text = AdoRs.Fields(7)
Text1(5).Text = AdoRs.Fields(8)
Cbx_ys.Text = AdoRs.Fields(9)
Text1(6).Text = AdoRs.Fields(10)
Text1(7).Text = AdoRs.Fields(11)
Text1(8).Text = AdoRs.Fields(12)
Text1(9).Text = AdoRs.Fields(13)
Text1(10).Text = AdoRs.Fields(14)
Txt_Date.Text = AdoRs.Fields(15)
Txt_lxr.Text = AdoRs.Fields(16)
End If
AdoRs.Close
ElseIf Index = 2 Then
Cbx_lx.SetFocus
Exit Sub
ElseIf Index = 3 Then
DT1.SetFocus
Exit Sub
ElseIf Index = 5 Then
Cbx_ys.SetFocus
Exit Sub
End If
End If
If KeyCode = 38 Then
If Index = 6 Then
Cbx_ys.SetFocus
Exit Sub
ElseIf Index = 4 Then
DT2.SetFocus
Exit Sub
ElseIf Index = 3 Then
Cbx_lx.SetFocus
Exit Sub
End If
End If
If Index < 11 And KeyCode = 38 Then Text1(Index - 1).SetFocus
If Index >= 0 And KeyCode = 13 Then Text1(Index + 1).SetFocus
If Index = 10 And KeyCode = 13 Then
Call Saves
End If
End Sub
Private Sub Saves() '保存信息的事件过程
If Text1(0).Text = "" Or Text1(1).Text = "" Or Text1(8).Text = "" Then
MsgBox "重要信息不能为空值", 48, "提示信息"
Else
If IsNumeric(Text1(6)) Then
AdoRs.Open "select * from 车辆登记 where 车牌号码='" + Text1(2).Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
MsgBox "该信息已经存在", 48, "提示信息"
AdoRs.Close
Else
AdoRs.Close
c = MsgBox("确认保存信息吗?", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("insert into 车辆登记 values('" & Text1(0) _
& "','" & Text1(1) & "','" & Text1(2) & "','" & Cbx_lx & "','" & Text1(3) & "','" & STR(DT1.Value) & "','" & STR(DT2.Value) & "','" _
& Text1(4) & "','" & Text1(5) & "','" & Cbx_ys & "','" & Text1(6) & "','" & Text1(7) & "','" & Text1(8) & "','" & Text1(9) & "','" & Text1(10) & "',' ',' ')")
MsgBox "数据保存成功", 64, "提示信息"
Adodc1.RecordSource = "select * from 车辆登记 order by 编号"
Adodc1.Refresh
Else
End If
End If
Call Tbr_cortrol(Tbr_xxcz, True)
Else
MsgBox "输入的载重数值非法", 48, "提示信息"
Text1(6).Text = ""
Text1(6).SetFocus
End If
End If
End Sub
Private Sub Edits() '修改信息的事件过程
c = MsgBox("确认修改信息吗?", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("UPDATE 车辆登记 SET 编号='" + Text1(0) + "',车属单位='" + Text1(1) + "',车牌号码='" + Text1(2) + "',车辆类型='" _
+ Cbx_lx + "',厂牌型号='" + Text1(3) + "',出厂日期='" + STR(DT1.Value) + "',购置日期='" + STR(DT2.Value) + "',购买价格='" + Text1(4) + "',发动机号='" + Text1(5) + "',车辆颜色='" + Cbx_ys + "',载重='" + Text1(6) _
+ "',座位='" + Text1(7) + "',驾驶员='" + Text1(8) + "',里程数='" + Text1(9) + "',备注信息='" + Text1(10) + "',记录修改日期='" + STR(Date) + "',记录修改人='" + Name1 + "' where 编号='" + Text1(0).Text + "'")
MsgBox "数据修改成功", 64, "提示信息"
Adodc1.RecordSource = "select * from 车辆登记 order by 编号"
Adodc1.Refresh
StrId = Text1(0).Text
StrTitle = Text1(1).Text
Call joinRZ
Else
End If
End Sub
Private Sub LoadFile()
On Error Resume Next
AdoRs.Open "select * from 车辆登记", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
Text1(0).Text = AdoRs.Fields(0)
Text1(1).Text = AdoRs.Fields(1)
Text1(2).Text = AdoRs.Fields(2)
Cbx_lx.Text = AdoRs.Fields(3)
Text1(3).Text = AdoRs.Fields(4)
DT1.Value = AdoRs.Fields(5)
DT2.Value = AdoRs.Fields(6)
Text1(4).Text = AdoRs.Fields(7)
Text1(5).Text = AdoRs.Fields(8)
Cbx_ys.Text = AdoRs.Fields(9)
Text1(6).Text = AdoRs.Fields(10)
Text1(7).Text = AdoRs.Fields(11)
Text1(8).Text = AdoRs.Fields(12)
Text1(9).Text = AdoRs.Fields(13)
Text1(10).Text = AdoRs.Fields(14)
Txt_Date.Text = AdoRs.Fields(15)
Txt_lxr.Text = AdoRs.Fields(16)
End If
AdoRs.Close
End Sub
Private Sub Deletes() '删除信息
c = MsgBox("确认删除该信息吗?", 17, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("Delete 车辆登记 from 车辆登记 where 编号='" + Text1(0).Text + "'")
Adodc1.RecordSource = "select * from 车辆登记 order by 编号"
Adodc1.Refresh
End If
For i = 0 To 10
Text1(i).Text = ""
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -