📄 form1.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "房产信息管理系统"
ClientHeight = 7245
ClientLeft = 60
ClientTop = 750
ClientWidth = 12480
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 7245
ScaleWidth = 12480
StartUpPosition = 2 '屏幕中心
WindowState = 2 'Maximized
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 2
Top = 6990
Width = 12480
_ExtentX = 22013
_ExtentY = 450
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 5
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Object.Width = 4304
MinWidth = 4304
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 1
Enabled = 0 'False
TextSave = "CAPS"
EndProperty
BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 2
TextSave = "NUM"
EndProperty
BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 6
TextSave = "2008-10-22"
EndProperty
BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 5
TextSave = "14:35"
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList ImageList2
Left = 11640
Top = 6240
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 1
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0E42
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList ImageList1
Left = 10800
Top = 6240
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 6
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":1C94
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":256E
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":2E48
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":3722
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":3FFC
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":4596
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 600
Left = 0
TabIndex = 0
Top = 0
Width = 12480
_ExtentX = 22013
_ExtentY = 1058
ButtonWidth = 3043
ButtonHeight = 1005
Appearance = 1
Style = 1
TextAlignment = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 5
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "添加房产信息"
Key = "AddHouse"
Description = "添加房产信息"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修改房产信息"
Key = "EditHouse"
Description = "修改房产信息"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删除房产信息"
Key = "DeleteHouse"
Description = "删除房产信息"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "查找房产信息"
Key = "FindHouse"
Description = "查找房产信息"
ImageIndex = 4
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "显示全部信息"
Key = "ShowAll"
ImageIndex = 5
EndProperty
EndProperty
End
Begin MSComctlLib.ListView ListView1
Height = 5415
Left = 0
TabIndex = 1
Top = 720
Width = 11535
_ExtentX = 20346
_ExtentY = 9551
View = 3
LabelEdit = 1
Sorted = -1 'True
MultiSelect = -1 'True
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
_Version = 393217
Icons = "ImageList1"
SmallIcons = "ImageList2"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Key = "ID"
Text = "房产编号(*)"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Key = "Kind"
Text = "房产户型"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Key = "Address"
Text = "房产地址"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Key = "Price"
Text = "销售价格"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Key = "Area"
Text = "房面积"
Object.Width = 2540
EndProperty
End
Begin VB.Menu House
Caption = "房产信息管理(&M)"
Begin VB.Menu AddHouse
Caption = "添加房产信息(&A)"
Shortcut = ^A
End
Begin VB.Menu EditHouse
Caption = "修改房产信息(&E)"
Shortcut = ^E
End
Begin VB.Menu DeleteHouse
Caption = "删除房产信息(&D)"
Shortcut = ^D
End
Begin VB.Menu FindHouse
Caption = "查询房产信息(&F)"
Shortcut = ^F
End
Begin VB.Menu ShowAll
Caption = "显示全部信息(&S)"
Shortcut = ^S
End
Begin VB.Menu Sep
Caption = "-"
End
Begin VB.Menu Quit
Caption = "退出(&Q)"
Shortcut = ^Q
End
End
Begin VB.Menu View
Caption = "查看(&V)"
Begin VB.Menu Icons
Caption = "图标(&I)"
Checked = -1 'True
End
Begin VB.Menu Details
Caption = "详细信息(&D)"
Checked = -1 'True
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub AddHouse_Click()
Form2.Show
End Sub
Public Sub DeleteHouse_Click()
Dim sql As String
Dim i As Long
Dim rtn As Integer
'检查数据库是否为空
If ListView1.ListItems.Count = 0 Then
MsgBox "数据库中已经没有信息!", vbExclamation
Exit Sub
End If
'检查是否选中删除信息
If ListView1.SelectedItem = "" Then
MsgBox "没有选中删除信息!", vbExclamation
Exit Sub
End If
'确认删除
rtn = MsgBox("你确实想要删除选中的信息吗?", vbOKCancel)
If rtn = 2 Then
Exit Sub
End If
'删除操作
For i = ListView1.ListItems.Count To 1 Step -1
If ListView1.ListItems.Item(i).Selected = True Then
sql = "DELETE * FROM House WHERE ID =" & ListView1.ListItems.Item(i) & ""
conn.Execute sql
End If
Next
'重新显示
House_Show
'提示
MsgBox "删除成功!", vbInformation
End Sub
Private Sub Details_Click()
Icons.Checked = False
Details.Checked = True
ListView1.View = lvwReport
End Sub
Public Sub EditHouse_Click()
'检查数据库是否为空
If ListView1.ListItems.Count = 0 Then
MsgBox "数据库中已经没有信息!", vbExclamation
Exit Sub
End If
'检查是否选中修改信息
If ListView1.SelectedItem = "" Then
MsgBox "没有选中修改信息!", vbExclamation
Exit Sub
End If
'显示修改信息窗体
Form3.Show
End Sub
Public Sub FindHouse_Click()
If ListView1.ListItems.Count = 0 Then
MsgBox "数据库中已经没有信息!", vbExclamation
Exit Sub
End If
Form4.Show
End Sub
Private Sub Form_Load()
On Error GoTo error
Icons.Checked = False
House_Show
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Form_Resize()
On Error GoTo error
ListView1.Width = Me.ScaleWidth
ListView1.Height = Me.ScaleHeight
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error GoTo error
'关闭全局数据库连接对象
conn.Close
'检查卸载子窗体
If Form(2) = True Then
Unload Form2
End If
If Form(3) = True Then
Unload Form3
End If
If Form(4) = True Then
Unload Form4
End If
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Icons_Click()
On Error GoTo error
Icons.Checked = True
Details.Checked = False
ListView1.View = lvwIcon
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
On Error GoTo error
Select Case ColumnHeader
Case "房产编号": ListView1.SortKey = 0
Case "房产户型": ListView1.SortKey = 1
Case "房产地址": ListView1.SortKey = 2
Case "销售价格": ListView1.SortKey = 3
Case "房面积": ListView1.SortKey = 4
End Select
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub ListView1_DblClick()
On Error GoTo error
EditHouse_Click
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo error
If Button = 2 Then
PopupMenu House
End If
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Quit_Click()
On Error GoTo error
Unload Me
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Public Sub House_Show()
On Error GoTo error
Dim rs As New ADODB.Recordset
Dim sql As String
Dim li As ListItem
'打开记录集
sql = "SELECT * FROM House"
rs.Open sql, conn, adOpenStatic, adLockReadOnly
'状态条信息
StatusBar1.Panels(1) = "全部信息数目:" & rs.RecordCount
'显示记录集信息
ListView1.ListItems.Clear
Do Until rs.EOF = True
Set li = ListView1.ListItems.Add(, , rs.Fields("ID"), 6, 1)
li.SubItems(1) = rs.Fields("Kind")
li.SubItems(2) = rs.Fields("Address")
li.SubItems(3) = rs.Fields("Price")
li.SubItems(4) = rs.Fields("Area")
rs.MoveNext
Loop
'关闭记录集
rs.Close
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Public Sub ShowAll_Click()
On Error GoTo error
House_Show
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo error
Select Case Button.Key
Case "AddHouse"
Form2.Show
Case "EditHouse"
EditHouse_Click
Case "DeleteHouse"
DeleteHouse_Click
Case "FindHouse"
FindHouse_Click
Case "ShowAll"
ShowAll_Click
End Select
Exit Sub
error:
MsgBox Err.Description, vbExclamation
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -