📄 frmvehicle.frm
字号:
VERSION 5.00
Begin VB.Form Frmvehicle
BorderStyle = 1 'Fixed Single
Caption = "车辆基本信息"
ClientHeight = 4410
ClientLeft = 3270
ClientTop = 1650
ClientWidth = 8610
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4410
ScaleWidth = 8610
Begin VB.CommandButton Cmdcancel
Caption = "取 消"
Height = 375
Left = 5880
TabIndex = 26
Top = 3840
Width = 1335
End
Begin VB.CommandButton Cmdsave
Caption = "确 定"
Height = 375
Left = 4200
TabIndex = 25
Top = 3840
Width = 1335
End
Begin VB.Frame Frame1
Caption = "车辆信息管理"
Height = 3255
Left = 120
TabIndex = 0
Top = 360
Width = 8295
Begin VB.TextBox txtitem
Height = 375
Index = 11
Left = 5400
TabIndex = 24
Top = 2640
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 10
Left = 5400
TabIndex = 23
Top = 2160
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 9
Left = 5400
TabIndex = 22
Top = 1680
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 8
Left = 5400
TabIndex = 21
Top = 1200
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 7
Left = 5400
TabIndex = 20
Top = 720
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 6
Left = 5400
TabIndex = 19
Top = 240
Width = 2655
End
Begin VB.TextBox txtitem
Height = 375
Index = 5
Left = 1200
TabIndex = 18
Top = 2640
Width = 2535
End
Begin VB.TextBox txtitem
Height = 375
Index = 4
Left = 1200
TabIndex = 17
Top = 2160
Width = 2535
End
Begin VB.TextBox txtitem
Height = 375
Index = 3
Left = 1200
TabIndex = 16
Top = 1680
Width = 2535
End
Begin VB.TextBox txtitem
Height = 390
Index = 2
Left = 1200
TabIndex = 15
Top = 1200
Width = 2535
End
Begin VB.TextBox txtitem
Height = 375
Index = 1
Left = 1200
TabIndex = 14
Top = 720
Width = 2535
End
Begin VB.TextBox txtitem
Height = 375
Index = 0
Left = 1200
TabIndex = 13
Top = 240
Width = 2535
End
Begin VB.Label Label12
Caption = "主要司机:"
Height = 255
Left = 4200
TabIndex = 12
Top = 2760
Width = 975
End
Begin VB.Label Label11
Alignment = 2 'Center
Caption = "颜 色:"
Height = 255
Left = 4200
TabIndex = 11
Top = 2280
Width = 735
End
Begin VB.Label Label10
Alignment = 2 'Center
Caption = "发证时间:"
Height = 255
Left = 4200
TabIndex = 10
Top = 1800
Width = 975
End
Begin VB.Label Label9
Alignment = 2 'Center
Caption = "登记时间:"
Height = 255
Left = 4200
TabIndex = 9
Top = 1320
Width = 975
End
Begin VB.Label Label8
Alignment = 2 'Center
Caption = "核定载客:"
Height = 255
Left = 4200
TabIndex = 8
Top = 840
Width = 975
End
Begin VB.Label Label7
Alignment = 2 'Center
Caption = "车 重:"
Height = 255
Left = 4200
TabIndex = 7
Top = 360
Width = 735
End
Begin VB.Label Label6
Caption = "厂牌型号:"
Height = 375
Left = 120
TabIndex = 6
Top = 2760
Width = 975
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Caption = "车架号:"
Height = 255
Left = 120
TabIndex = 5
Top = 2280
Width = 855
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "发动机号:"
Height = 375
Left = 120
TabIndex = 4
Top = 1800
Width = 975
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "车 主:"
Height = 255
Left = 120
TabIndex = 3
Top = 1320
Width = 735
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "车 型:"
Height = 255
Left = 120
TabIndex = 2
Top = 840
Width = 735
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "牌 照:"
Height = 255
Left = 120
TabIndex = 1
Top = 360
Width = 855
End
End
End
Attribute VB_Name = "Frmvehicle"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim txtchange As Boolean
Dim mrc As ADODB.Recordset
Public txtsql As String
Private Sub cmdcancel_Click()
If txtchange 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 txtcount As Integer
Dim tmsg As String
Dim msgtext As String
For txtcount = 0 To 3
If Trim(Txtitem(txtcount) & "") = "" Then
Select Case txtcount
Case 0
tmsg = "车牌"
Case 1
tmsg = "车型"
Case 2
tmsg = "车主"
Case 3
tmsg = "发动机号"
End Select
tmsg = tmsg & "不能为空!"
MsgBox tmsg, vbOKOnly + vbExclamation, "警告"
Txtitem(txtcount).SetFocus
Exit Sub
End If
Next txtcount
If Not IsNumeric(Txtitem(6)) Then
MsgBox "输入错误,请输入数字", vbOKOnly + vbExclamation, "警告"
Txtitem(6).SetFocus
Exit Sub
End If
If Not IsNumeric(Txtitem(7)) Then
MsgBox "输入错误,请输入数字", vbOKOnly + vbExclamation, "警告"
' Exit Sub
Txtitem(7).SetFocus
Exit Sub
End If
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
If gintvMode = 1 Then
txtsql = "select * from vehicle where cl_id='" & Trim(Txtitem(0)) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = False Then
MsgBox "此车辆信息已经存在", vbOKOnly + vbExclamation, "警告"
Txtitem(0).SetFocus
Exit Sub
Else
mrc.AddNew
For txtcount = 0 To 11
mrc.Fields(txtcount) = Trim(Txtitem(txtcount))
Next txtcount
mrc.Update
End If
mrc.Close
MsgBox "添加信息成功", vbOKOnly + vbExclamation, "添加信息"
End If
If gintvMode = 2 Then
txtsql = "delete from vehicle where cl_id='" & Trim(Txtitem(0)) & "'"
ExecuteSQL txtsql, msgtext
txtsql = "select * from vehicle"
Set mrc = ExecuteSQL(txtsql, msgtext)
mrc.AddNew
For txtcount = 0 To 11
mrc.Fields(txtcount) = Trim(Txtitem(txtcount))
Next txtcount
mrc.Update
mrc.Close
flagvEdit = True
MsgBox "信息修改成功", vbOKOnly + vbExclamation, "修改信息"
End If
If gintvMode = 1 Then
For txtcount = 0 To 11
Txtitem(txtcount) = ""
Next txtcount
txtchange = False
End If
If gintvMode = 2 Then
Unload Me
If flagvEdit = True Then
Unload frmvehiclelist
End If
frmvehiclelist.txtsql = "select * from vehicle"
frmvehiclelist.Show
End If
End Sub
Private Sub Form_Load()
Dim txtcount As Integer
Dim msgtext As String
Me.Left = 3225
Me.Top = 1320
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 txtcount = 0 To 11
If (.Fields(txtcount) & "") <> "" Then
Txtitem(txtcount) = .Fields(txtcount)
End If
Next txtcount
End With
Txtitem(0).Enabled = False
End If
mrc.Close
Me.Caption = Me.Caption & "修改"
End If
txtchange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintvMode = 0
End Sub
Private Sub txtitem_Change(Index As Integer)
txtchange = 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 + -