📄 frmvehicle1.frm
字号:
VERSION 5.00
Begin VB.Form frmVehicle1
BorderStyle = 3 'Fixed Dialog
Caption = "车辆信息"
ClientHeight = 3444
ClientLeft = 48
ClientTop = 336
ClientWidth = 7932
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3444
ScaleWidth = 7932
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.Frame Frame2
Caption = "车辆相关信息"
Height = 2655
Left = 4080
TabIndex = 20
Top = 240
Width = 3615
Begin VB.TextBox txtItem
Height = 270
Index = 11
Left = 1200
MaxLength = 10
TabIndex = 11
Top = 2160
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 10
Left = 1200
MaxLength = 4
TabIndex = 10
Top = 1800
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 9
Left = 1200
MaxLength = 20
TabIndex = 9
Top = 1440
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 8
Left = 1200
MaxLength = 20
TabIndex = 8
Top = 1080
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 7
Left = 1200
MaxLength = 2
TabIndex = 7
Top = 720
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 6
Left = 1200
MaxLength = 8
TabIndex = 6
Top = 360
Width = 2175
End
Begin VB.Label Label2
Caption = "主要司机:"
Height = 255
Index = 10
Left = 240
TabIndex = 27
Top = 2160
Width = 975
End
Begin VB.Label Label2
Caption = "颜 色:"
Height = 255
Index = 9
Left = 240
TabIndex = 26
Top = 1800
Width = 975
End
Begin VB.Label Label2
Caption = "发证时间:"
Height = 255
Index = 8
Left = 240
TabIndex = 25
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "登记时间:"
Height = 255
Index = 7
Left = 240
TabIndex = 24
Top = 1080
Width = 975
End
Begin VB.Label Label2
Caption = "核定载客:"
Height = 255
Index = 5
Left = 240
TabIndex = 22
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "总 质 量:"
Height = 255
Index = 4
Left = 240
TabIndex = 21
Top = 360
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "车辆基本信息"
Height = 2655
Left = 240
TabIndex = 14
Top = 240
Width = 3735
Begin VB.TextBox txtItem
Height = 270
Index = 5
Left = 1320
MaxLength = 20
TabIndex = 5
Top = 2160
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 4
Left = 1320
MaxLength = 10
TabIndex = 4
Top = 1800
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1320
MaxLength = 10
TabIndex = 0
Top = 360
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1320
MaxLength = 10
TabIndex = 1
Top = 720
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 2
Left = 1320
MaxLength = 20
TabIndex = 2
Top = 1080
Width = 2175
End
Begin VB.TextBox txtItem
Height = 270
Index = 3
Left = 1320
MaxLength = 10
TabIndex = 3
Top = 1440
Width = 2175
End
Begin VB.Label Label2
Caption = "车 主:"
Height = 255
Index = 6
Left = 240
TabIndex = 23
Top = 1080
Width = 975
End
Begin VB.Label Label2
Caption = "车 架 号:"
Height = 255
Index = 3
Left = 240
TabIndex = 19
Top = 1800
Width = 975
End
Begin VB.Label Label2
Caption = "车 号:"
Height = 255
Index = 0
Left = 240
TabIndex = 18
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "类 型:"
Height = 255
Index = 1
Left = 240
TabIndex = 17
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "厂牌型号:"
Height = 255
Index = 2
Left = 240
TabIndex = 16
Top = 2160
Width = 975
End
Begin VB.Label Label2
Caption = "发动机号:"
Height = 255
Index = 16
Left = 240
TabIndex = 15
Top = 1440
Width = 975
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 6240
TabIndex = 13
Top = 3000
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 4800
TabIndex = 12
Top = 3000
Width = 1215
End
End
Attribute VB_Name = "frmVehicle1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
For intCount = 0 To 3
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "车号"
Case 1
sMeg = "类型"
Case 2
sMeg = "车主"
Case 3
sMeg = "发动机号"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
For intCount = 6 To 7
If Not IsNumeric(txtItem(intCount)) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
Next intCount
If Trim(txtItem(8) & "") <> "" Then
If Not IsDate(txtItem(8)) Then
MsgBox "登记时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(8).SetFocus
Exit Sub
Else
txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(9) & "") <> "" Then
If Not IsDate(txtItem(9)) Then
MsgBox "发证时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(9).SetFocus
Exit Sub
Else
txtItem(9) = Format(txtItem(9), "yyyy-mm-dd")
End If
End If
'添加判断是否有相同的ID记录
If gintvMode = 1 Then
txtSQL = "select * from vehicle where clid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在此车号的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
mrc.Close
End If
'先删除已有记录
txtSQL = "delete from vehicle where clid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "select * from vehicle"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Trim(txtItem(0))
For intCount = 1 To 11
mrc.Fields(intCount) = Trim(txtItem(intCount))
Next intCount
mrc.Update
mrc.Close
If gintvMode = 1 Then
For intCount = 0 To 11
txtItem(intCount) = ""
Next intCount
mblChange = False
ElseIf gintvMode = 2 Then
Unload Me
If flagvEdit Then
Unload frmVehicle
End If
txtSQL = "select * from vehicle"
frmVehicle.Show
End If
End Sub
Private Sub Form_Load()
Dim MsgText As String
Dim intCount As Integer
If gintvMode = 1 Then
Me.Caption = Me.Caption & "添加"
ElseIf gintvMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 11
If Trim(.Fields(intCount) & " ") <> "" Then
txtItem(intCount) = .Fields(intCount)
End If
Next intCount
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
mrc.Close
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintvMode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -