📄 form7.frm
字号:
VERSION 5.00
Object = "{CFA7AFF4-3242-4269-9172-7389D695AE01}#1.0#0"; "StoneXP.ocx"
Object = "{DAAC6951-59A4-4C08-9D6E-FE3919B64861}#1.0#0"; "FlexCell.ocx"
Begin VB.Form Form7
BorderStyle = 1 'Fixed Single
Caption = "车辆管理"
ClientHeight = 5190
ClientLeft = 45
ClientTop = 375
ClientWidth = 6780
LinkTopic = "Form7"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5190
ScaleWidth = 6780
Begin FlexCell.Grid Grid1
Height = 3975
Left = 0
TabIndex = 0
Top = 360
Width = 6735
_ExtentX = 11880
_ExtentY = 7011
Cols = 5
Rows = 30
End
Begin StoneXP.XPButton XPButton5
Height = 375
Left = 4800
TabIndex = 1
Top = 4680
Width = 975
_ExtentX = 1720
_ExtentY = 661
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "退 出"
MouseIcon = "Form7.frx":0000
MousePointer = 99
End
Begin StoneXP.XPButton XPButton4
Height = 375
Left = 3840
TabIndex = 2
Top = 4680
Width = 975
_ExtentX = 1720
_ExtentY = 661
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "删 除"
MouseIcon = "Form7.frx":031A
MousePointer = 99
End
Begin StoneXP.XPButton XPButton3
Height = 375
Left = 2880
TabIndex = 3
Top = 4680
Width = 975
_ExtentX = 1720
_ExtentY = 661
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "修 改"
MouseIcon = "Form7.frx":0634
MousePointer = 99
End
Begin StoneXP.XPButton XPButton2
Height = 375
Left = 1920
TabIndex = 4
Top = 4680
Width = 975
_ExtentX = 1720
_ExtentY = 661
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "保 存"
MouseIcon = "Form7.frx":094E
MousePointer = 99
End
Begin StoneXP.XPButton XPButton1
Height = 375
Left = 960
TabIndex = 5
Top = 4680
Width = 975
_ExtentX = 1720
_ExtentY = 661
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "添 加"
MouseIcon = "Form7.frx":0C68
MousePointer = 99
End
End
Attribute VB_Name = "Form7"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gridsave As Boolean
Dim gridedit As Boolean
Dim griddelete As Boolean
Private Sub Form_Load()
mdi = False
'On Error GoTo finish
Set mdbrs1 = mdbconn.Execute("select * from 车辆表")
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '进行注册
With Grid1
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.Cols = 5
.DefaultFont.Name = "Tahoma"
.DefaultFont.Size = 8
.BackColorFixed = RGB(90, 158, 214)
.BackColorFixedSel = RGB(110, 180, 230)
.BackColorBkg = RGB(90, 158, 214)
.BackColorScrollBar = RGB(231, 235, 247)
.BackColor1 = RGB(231, 235, 247)
.BackColor2 = RGB(239, 243, 255)
.GridColor = RGB(148, 190, 231)
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.GridColor = RGB(148, 190, 231)
.DefaultFont.Name = "Tahoma"
.DefaultFont.Size = 8
.Column(0).Width = 0
.Column(1).Width = 20
.Column(2).Width = 100
.Column(3).Width = 100
.Column(4).Width = 100
.Column(2).CellType = cellComboBox
.ComboBox(2).Clear
Set mdbrs2 = mdbconn.Execute("select 单位名称 from 客户信息")
Do While Not mdbrs2.EOF
.ComboBox(2).AddItem mdbrs2.Fields(0).Value
mdbrs2.MoveNext
Loop
.Column(4).CellType = cellComboBox
.ComboBox(4).Clear
Set mdbrs2 = mdbconn.Execute("select * from 油价表")
Do While Not mdbrs2.EOF
.ComboBox(4).AddItem mdbrs2.Fields(1).Value & mdbrs2.Fields(2).Value & "~" & mdbrs2.Fields(3).Value
mdbrs2.MoveNext
Loop
End With
Call callmain
Grid1.Column(1).Locked = True
gridsave = False
gridedit = True
griddelete = True
mdi = False
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
mdi = True
End Sub
Private Sub callmain()
'On Error GoTo finish
gridsave = False
gridedit = True
griddelete = True
Set mdbrs = mdbconn.Execute("select * from 车辆表")
Grid1.Rows = 1
i = 4
Grid1.Cols = i + 1
For i = 0 To 3
Grid1.Cell(0, i + 1).Text = mdbrs.Fields(i).Name
Next
i = 1
Do While Not mdbrs.EOF
Grid1.Rows = Grid1.Rows + 1
For j = 1 To 4 '设定读取列
If mdbrs.Fields(j - 1) = Null Then '空值的处理
Grid1.Cell(i, j).Text = ""
Else
Grid1.Cell(i, j).Text = mdbrs.Fields(j - 1)
End If
Next
i = i + 1
mdbrs.MoveNext '读取下一记录
Loop
Grid1.Column(1).Locked = True
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton1_Click()
On Error GoTo finish
gridsave = True
gridedit = False
griddelete = False
Set mdbrs = mdbconn.Execute("select * from 车辆表")
Grid1.Rows = 1
Grid1.Rows = 2
Grid1.Column(1).Locked = True
Grid1.Cell(1, 2).SetFocus
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton2_Click()
On Error GoTo finish
If gridsave = False Then
MsgBox "不支持保存操作!", vbInformation, "当前不支持"
Exit Sub
End If
If Grid1.Cell(1, 2).Text <> "" And Grid1.Cell(1, 3).Text <> "" And Grid1.Cell(1, 4).Text <> "" Then
Set mdbrs = mdbconn.Execute("insert into 车辆表(单位名称,车牌号,加油型号) values('" & Grid1.Cell(1, 2).Text & "','" & Grid1.Cell(1, 3).Text & "','" & Grid1.Cell(1, 4).Text & "')")
MsgBox "提交成功!", vbInformation, ""
Call callmain
Else
MsgBox "单位名称,车牌号,加油型号,预存款都不可以是空格!", vbInformation, "错误提示"
End If
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton3_Click()
On Error GoTo finish
If gridedit = False Then
MsgBox "当前修改操作不被允许!", vbInformation, "非使用对象"
Exit Sub
End If
For i = 1 To Grid1.Rows - 1
Set mdbrs = mdbconn.Execute("update 车辆表 set 单位名称='" & Grid1.Cell(i, 2).Text & "',车牌号='" & Grid1.Cell(i, 3).Text & "',加油型号='" & Grid1.Cell(i, 4).Text & "' where 编号=val('" & Grid1.Cell(i, 1).Text & "')")
Next
MsgBox "修改的数据己经完成", vbInformation, "完成操作"
Call callmain
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton4_Click()
On Error GoTo finish
If griddelete = False Then
MsgBox "当前删除操作不被允许!", vbInformation, "非使用对象"
Exit Sub
End If
If hang = 0 Then
MsgBox "没有选择用户或者没有用户可以删除!", vbInformation, "非使用对象"
Exit Sub
End If
Set mdbrs = mdbconn.Execute("delete from 车辆表 where 编号=val('" & Grid1.Cell(hang, 1).Text & "')")
MsgBox "目标己删除,请刷新数据!", vbInformation, "删除成功"
Call callmain
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton5_Click()
Unload Me
End Sub
Private Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)
hang = Row
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -