📄 停车场管理.frm
字号:
End
End
Attribute VB_Name = "停车场管理"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isadding As Boolean
Dim objcn As Connection
Dim objflor As Recordset '大楼信息
Dim objhome As Recordset '房屋信息
Dim objcar As Recordset '汽车信息
Private Sub Cmbroom_Click()
With objhome
If .RecordCount > 0 Then
.MoveFirst
.Find "房号='" & Trim(Cmbroom.Text) & "'"
If .Fields("住户名称") <> Empty Then
If Not .EOF Then
Txtman.Text = .Fields("住户名称")
End If
Else
MsgBox "该房还没有业主入住!", vbInformation, "温馨提示"
Txtcarnumber.Text = ""
Cmbsit.Text = ""
Cmbmod.Text = ""
Cmbcolor.Text = ""
Cmbflor.Text = ""
Cmbroom.Text = ""
Txtman.Text = ""
Txtpho.Text = ""
Cmbway.Text = ""
Txtnotic.Text = ""
Txtwriteman.Text = ""
'获取文本框输入
Txtcarnumber.Enabled = False
Cmbsit.Enabled = False
Cmbmod.Enabled = False
Cmbcolor.Enabled = False
Cmbflor.Enabled = False
Cmbroom.Enabled = False
Txtman.Enabled = False
Txtpho.Enabled = False
Cmbway.Enabled = False
DTP1.Enabled = False
Txtnotic.Enabled = False
Txtwriteman.Enabled = False
Adodc1.Recordset.CancelBatch
Adodc1.Refresh
isadding = False
Exit Sub
End If
End If
End With
End Sub
Private Sub Form_Load()
'建立数据库联接
Set objcn = New Connection '实例化联接对象
With objcn '建立数据库联接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=sa;Data Source=(local);" & _
"Initial Catalog=物业管理系统"
.Open
End With
'获取客户投诉信息数据
Set objcar = New Recordset
With objcar
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 停车场信息"
End With
'获取大楼信息数据
Set objflor = New Recordset
With objflor
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 大楼信息"
End With
With objflor
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Cmbflor.AddItem .Fields("大楼名称")
.MoveNext
Wend
End If
End With
'树节点
Dim Root As Node
With TreeView1.Nodes
Set Root = .Add(, , , "A栋", 1, 2)
.Add Root.Index, tvwChild, , "粤A-1684", 3, 3
.Add Root.Index, tvwChild, , "粤X-4488", 3, 3
.Add Root.Index, tvwChild, , "粤C-6675", 3, 3
Set Root = .Add(, , , "B栋", 1, 2)
.Add Root.Index, tvwChild, , "桂A-4567", 3, 3
.Add Root.Index, tvwChild, , "湘G-3312", 3, 3
.Add Root.Index, tvwChild, , "港A-380", 3, 3
Set Root = .Add(, , , "C栋", 1, 2)
.Add Root.Index, tvwChild, , "空置", 3, 3
.Add Root.Index, tvwChild, , "空置", 3, 3
.Add Root.Index, tvwChild, , "空置", 3, 3
End With
End Sub
Private Sub Cmbflor_Click()
'获取楼房区信息
Set objhome = New Recordset
With objhome
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from " & Trim(Cmbflor.Text)
'Set .ActiveConnection = Nothing '断开数据库联接
End With
With objhome
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Cmbroom.AddItem .Fields("房号")
.MoveNext
Wend
End If
End With
End Sub
'添加记录
Private Sub Cmdadd_Click()
Cmbroom.Clear
If isadding = False Then
isadding = True '添加状态为真
Adodc1.Recordset.AddNew 'ADODB处在添加记录状态
Txtnumber.Text = "自动编号"
Txtcarnumber.Text = ""
Cmbsit.Text = ""
Cmbmod.Text = ""
Cmbcolor.Text = ""
Cmbflor.Text = ""
Cmbroom.Text = ""
Txtman.Text = ""
Txtpho.Text = ""
Cmbway.Text = ""
Txtnotic.Text = ""
Txtwriteman.Text = ""
'获取文本框输入
Txtcarnumber.Enabled = True
Cmbsit.Enabled = True
Cmbmod.Enabled = True
Cmbcolor.Enabled = True
Cmbflor.Enabled = True
Cmbroom.Enabled = True
Txtman.Enabled = True
Txtpho.Enabled = True
Cmbway.Enabled = True
DTP1.Enabled = True
Txtnotic.Enabled = True
Txtwriteman.Enabled = True
Else
MsgBox "已是添加状态", vbCritical, "温馨提示"
End If
End Sub
'退出添加状态
Private Sub Cmdback_Click()
If isadding Then
MsgBox "是否放弃添加记录?", vbQuestion, "温馨提示"
isadding = False
Txtcarnumber.Enabled = False
Cmbsit.Enabled = False
Cmbmod.Enabled = False
Cmbcolor.Enabled = False
Cmbflor.Enabled = False
Cmbroom.Enabled = False
Txtman.Enabled = False
Txtpho.Enabled = False
Cmbway.Enabled = False
DTP1.Enabled = False
Txtnotic.Enabled = False
Txtwriteman.Enabled = False
End If
Adodc1.Refresh
End Sub
'删除记录
Private Sub Cmddelete_Click()
If isadding = True Then
MsgBox "当前为状态为添加记录状态,不能删除记录"
Adodc1.Recordset.CancelBatch '显示当前记录
Else
If MsgBox("是否要删除当前记录?", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.Requery
End If
End If
End Sub
Private Sub Cmdexit_Click()
物业管理系统.Show
Unload Me
End Sub
Private Sub Cmdsave_Click()
If isadding = False Then
MsgBox "此记录已经存在!", vbCritical, "温馨提示"
Exit Sub
End If
With objcar
If Txtcarnumber.Text = "" Then
MsgBox "请输入车牌号!", vbInformation, "温馨提示"
Txtcarnumber.SetFocus
Txtcarnumber.Text = ""
Exit Sub
End If
If Cmbsit.Text = "" Then
MsgBox "请选择车位!", vbInformation, "温馨提示"
Cmbsit.SetFocus
Exit Sub
End If
If Trim(Txtpho.Text) = "" Then
MsgBox "请输入联系电话!", vbInformation, "温馨提示"
Txtpho.SetFocus
Exit Sub
End If
'保存信息
If isadding Then objcar.AddNew
.Fields("车牌号") = Trim(Txtcarnumber.Text)
.Fields("车位") = Trim(Cmbsit.Text)
.Fields("车型") = Trim(Cmbmod.Text)
.Fields("颜色") = Trim(Cmbcolor.Text)
.Fields("大楼名称") = Trim(Cmbflor.Text)
.Fields("房号") = Trim(Cmbroom.Text)
.Fields("车主") = Trim(Txtman.Text)
.Fields("联系电话") = Trim(Txtpho.Text)
.Fields("使用方式") = Trim(Cmbway.Text)
.Fields("开始使用日期") = Trim(DTP1.Value)
.Fields("备注") = Trim(Txtnotic.Text)
.Fields("录入员") = Trim(Txtwriteman.Text)
objcar.Update
MsgBox "数据保存成功!", vbInformation, "温馨提示"
isadding = False
End With
Adodc1.Refresh '刷新记录
End Sub
Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node) '展开节点时
If Node.Image = 1 Then
Node.Image = 1
End If
End Sub
Private Sub TreeView1_Collapse(ByVal Node As MSComctlLib.Node) '折叠节点时
If Node.Image = 2 Then
Node.Image = 2
End If
End Sub
'Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node) '单击节点
'cNodeIndex = Node.Index
'cnodekey = Node.Key
'open_close rescom
'rescom.Open "select * from communications"
'rescom.MoveFirst
'While Not rescom.EOF
' If Node.Key = "r" & rescom(0).Value Then
' display
' If Node.Children = 0 Then
' Command3.Enabled = True '修改
' Command4.Enabled = True '删除记录
' End If
' Exit Sub
'End If
'rescom.MoveNext
'Wend
'open_close resorg
'resorg.Open "select * from org order by id"
'Set Combo2.DataSource = resorg
'Combo2.Text = Node.Text
'resorg.MoveFirst
'Dim s As String
's = Right(cnodekey, Len(cnodekey) - 1)
'resorg.Find "id='" & s & "'"
'If resorg.EOF = False And Node.Children = 0 Then '记录中有该类别,且不包含子节点时,可以删除该类别
' deleteorg.Enabled = True
'End If
'Command3.Enabled = False '修改
'Command4.Enabled = False '删除记录
'rework.Enabled = True
'Delete.Enabled = True
'End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -