📄 楼房信息.frm
字号:
Begin MSComDlg.CommonDialog CDlg
Left = 960
Top = 1200
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
End
Begin VB.Frame Frame1
BackColor = &H00C0C0FF&
Caption = "查询"
Height = 735
Left = 0
TabIndex = 0
Top = 0
Width = 5295
Begin VB.ComboBox Combo1
Height = 300
ItemData = "楼房信息.frx":64C7
Left = 1440
List = "楼房信息.frx":64C9
TabIndex = 2
Top = 240
Width = 1455
End
Begin CSCommand.Command Cmdchange
Height = 375
Left = 3720
TabIndex = 1
Top = 240
Width = 1095
_ExtentX = 1931
_ExtentY = 661
Icon = "楼房信息.frx":64CB
Caption = " 选择"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Caption = " 大楼名称:"
Height = 255
Left = 240
TabIndex = 3
Top = 240
Width = 1095
End
End
Begin VB.Label Label17
BorderStyle = 1 'Fixed Single
Caption = " 备 注:"
Height = 255
Left = 120
TabIndex = 20
Top = 4320
Width = 1215
End
Begin VB.Label Label16
BorderStyle = 1 'Fixed Single
Caption = " 已租套数:"
Height = 255
Left = 5400
TabIndex = 19
Top = 3840
Width = 1215
End
Begin VB.Label Label15
BorderStyle = 1 'Fixed Single
Caption = " 已售套数:"
Height = 255
Left = 2760
TabIndex = 18
Top = 3840
Width = 1215
End
Begin VB.Label Label14
BorderStyle = 1 'Fixed Single
Caption = " 占地面积:"
Height = 255
Left = 2760
TabIndex = 17
Top = 1440
Width = 1215
End
Begin VB.Label Label13
BorderStyle = 1 'Fixed Single
Caption = " 大楼用途:"
Height = 255
Left = 2760
TabIndex = 16
Top = 2400
Width = 1215
End
Begin VB.Label Label12
BorderStyle = 1 'Fixed Single
Caption = " 交楼日期:"
Height = 255
Left = 5400
TabIndex = 15
Top = 3360
Width = 1215
End
Begin VB.Label Label11
BorderStyle = 1 'Fixed Single
Caption = " 竣工日期:"
Height = 255
Left = 2760
TabIndex = 14
Top = 3360
Width = 1215
End
Begin VB.Label Label10
BorderStyle = 1 'Fixed Single
Caption = " 开发日期:"
Height = 255
Left = 120
TabIndex = 13
Top = 3360
Width = 1215
End
Begin VB.Label Label9
BorderStyle = 1 'Fixed Single
Caption = " 总房间数:"
Height = 255
Left = 120
TabIndex = 12
Top = 3840
Width = 1215
End
Begin VB.Label Label8
BorderStyle = 1 'Fixed Single
Caption = " 大数类型:"
Height = 255
Left = 120
TabIndex = 11
Top = 2400
Width = 1215
End
Begin VB.Label Label7
BorderStyle = 1 'Fixed Single
Caption = " 建筑面积:"
Height = 255
Left = 120
TabIndex = 10
Top = 2880
Width = 1215
End
Begin VB.Label Label6
BorderStyle = 1 'Fixed Single
Caption = " 施工单位:"
Height = 255
Left = 120
TabIndex = 9
Top = 1920
Width = 1215
End
Begin VB.Label Label5
BorderStyle = 1 'Fixed Single
Caption = " 开 发 商:"
Height = 255
Left = 2760
TabIndex = 8
Top = 1920
Width = 1215
End
Begin VB.Label Label4
BorderStyle = 1 'Fixed Single
Caption = " 地理位置:"
Height = 255
Left = 120
TabIndex = 7
Top = 1440
Width = 1215
End
Begin VB.Label Label3
BorderStyle = 1 'Fixed Single
Caption = " 大楼名称:"
Height = 255
Left = 2760
TabIndex = 6
Top = 960
Width = 1215
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Caption = " 大楼代码:"
Height = 255
Left = 120
TabIndex = 5
Top = 960
Width = 1215
End
End
Attribute VB_Name = "楼房信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objcn As Connection
Dim isadding As Boolean
Dim objflor As Recordset
Dim FileName As String
'添加记录
Private Sub Cmdadd_Click()
'
If isadding = False Then
isadding = True
Adodc1.Recordset.AddNew
Adodc1.Caption = "添加新记录!"
Else
MsgBox "目前处于添加状态!" & vbCrLf & "请添加记录", vbInformation, "温馨提示"
End If
End Sub
'查询信息
Private Sub Cmdchange_Click()
If Combo1.Text = "" Then
MsgBox "请选择大楼名称", vbExclamation, "温馨提示"
Combo1.SetFocus
Exit Sub
End If
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find ("大楼名称='" & Trim(Combo1.Text) & "'")
If Adodc1.Recordset.EOF Then
MsgBox "未找到指定大楼", vbExclamation, "温馨提示"
Combo1.SetFocus
Adodc1.Refresh
End If
End Sub
Private Sub Cmdexit_Click()
If MsgBox("是否要退出楼房信息查看?", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
物业管理系统.Show
Unload Me
End If
End Sub
'保存信息
Private Sub Cmdsave_Click()
If isadding = False Then
MsgBox "此状态不允许添加记录!", vbCritical, "温馨提示"
Exit Sub
End If
Dim flors As New ADODB.Stream '以二进制方式
If isadding Then
If Text1.Text = "" Then
MsgBox "大楼代码!", , "温馨提示"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "大楼名称!", , "温馨提示"
Exit Sub
End If
If FileName = "" Then
MsgBox "照片不允许为空! ", , "温馨提示"
Exit Sub
End If
flors.Type = adTypeBinary '以二进制的方式写入
flors.Open
flors.LoadFromFile (FileName)
Adodc1.Recordset.Fields("图片").Value = flors.Read
Adodc1.Recordset.Update
FileName = ""
MsgBox "保存记录成功!", vbQuestion, "温馨提示"
Else
flors.Type = adTypeBinary
flors.Open
If FileName = "" Then
Adodc1.Recordset.Update
MsgBox "修改记录成功!", , "温馨提示"
Else
flors.LoadFromFile (FileName)
Adodc1.Recordset.Fields("图片").Value = flors.Read
Adodc1.Recordset.Update
FileName = ""
MsgBox "保存记录成功!", vbQuestion, "温馨提示"
End If
End If
isadding = False
Adodc1.Refresh
Adodc1.Caption = "当前记录:" & Adodc1.Recordset.AbsolutePosition & "/" & Adodc1.Recordset.RecordCount
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 Cmdtake_Click()
CDlg.Filter = "JPEG(*.jpg)|*.jpg" '显示打开文件的公用对话框,选择需要加入数据库的图片
CDlg.ShowOpen
FileName = CDlg.FileName
Picture1.Picture = LoadPicture(FileName) '预览图片
End Sub
Private Sub Cmdback_Click()
If isadding = True Then
MsgBox "是否放弃添加记录?", vbQuestion, "温馨提示"
Adodc1.Recordset.CancelBatch
Adodc1.Refresh
Adodc1.Caption = "当前记录:" & Adodc1.Recordset.AbsolutePosition & "/" & Adodc1.Recordset.RecordCount
isadding = False
End If
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 objflor = New Recordset
With objflor
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 大楼信息"
End With
'大楼名称查询
'Combo1.AddItem ""
With objflor
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Combo1.AddItem .Fields("大楼名称")
.MoveNext
Wend
End If
End With
Adodc1.Caption = "当前记录:" & Adodc1.Recordset.AbsolutePosition & "/" & Adodc1.Recordset.RecordCount
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -