⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 房屋信息.frm

📁 小区物业管理系统vb开发的,曾用于本科毕业设计
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Width           =   2175
      Begin VB.Frame Frame3 
         BackColor       =   &H00C0C0FF&
         Caption         =   "选择大楼"
         Height          =   615
         Left            =   120
         TabIndex        =   46
         Top             =   360
         Width           =   1935
         Begin VB.ComboBox Cmbtype 
            Height          =   300
            Left            =   120
            TabIndex        =   47
            Top             =   240
            Width           =   1695
         End
      End
      Begin MSComctlLib.TreeView TreeView1 
         Height          =   4935
         Left            =   120
         TabIndex        =   1
         Top             =   1080
         Width           =   1935
         _ExtentX        =   3413
         _ExtentY        =   8705
         _Version        =   393217
         Style           =   7
         Appearance      =   1
      End
   End
   Begin CSCommand.Command Cmddelete 
      Height          =   375
      Left            =   4560
      TabIndex        =   48
      ToolTipText     =   "删除记录"
      Top             =   5760
      Width           =   1095
      _ExtentX        =   1931
      _ExtentY        =   661
      Icon            =   "房屋信息.frx":49C3
      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
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 objlog As New Recordset


Private Sub Cmbtype_Click()
For i = 0 To 3
    cmdMove(i).Visible = True
Next i
txtNews.Visible = True
 '获取楼房区信息
 Set objhome = New Recordset
 With objhome
      Set .ActiveConnection = objcn
          .CursorLocation = adUseClient
          .CursorType = adOpenStatic
          .LockType = adLockOptimistic
          .Open "select * from " & Trim(Cmbtype.Text)

      Text1.Text = .Fields("房号")
      Text2.Text = .Fields("大楼名称")
      Text3.Text = .Fields("住户名称")
      Text4.Text = .Fields("住户人数")
      Text5.Text = .Fields("楼层号")
      Text6.Text = .Fields("房屋结构")
      Text7.Text = .Fields("房型")
      Text8.Text = .Fields("使用面积")
      Combo1.Text = .Fields("朝向")
      Text9.Text = .Fields("建筑面积")
      Combo2.Text = .Fields("使用类型")
      Text10.Text = .Fields("套用面积")
      Combo3.Text = .Fields("使用状态")
      Combo4.Text = .Fields("车位")
      Text11.Text = .Fields("维修情况")
      Text12.Text = .Fields("简要说明")
      Text13.Text = .Fields("备注")
  End With
  cmdMove(0).Value = True
End Sub

'添加记录
Private Sub Cmdadd_Click()
txtNews = "添加新记录"
 Text1.Text = ""
 Text2.Text = ""
 'Text3.Text = ""
 Text4.Text = ""
 Text5.Text = ""
 Text6.Text = ""
 Text7.Text = ""
 Text8.Text = ""
 Combo1.Text = ""
 Text9.Text = ""
 Combo2.Text = ""
 Text10.Text = ""
 Combo3.Text = ""
 Combo4.Text = ""
 Text11.Text = ""
 Text12.Text = ""
 Text13.Text = ""
 isadding = True
End Sub
'退出添加状态
Private Sub Cmdback_Click()
If isadding Then
   isadding = False
   cmdMove(0).Value = True
End If
End Sub

'删除记录
Private Sub Cmddelete_Click()
With objhome
'在当前表中无数据和不添加记录时,不执行删除操作
If Not isadding And .RecordCount < 1 Then Exit Sub

If isadding Then
   MsgBox "目前处在添加记录状态" & vbCrLf & "不能删除记录!", vbCritical, "温馨提示"
   txtNews = "当前记录:" & .AbsolutePosition & "/" & .RecordCount
   isadding = False
   If objhome.RecordCount < 1 Then
      txtNews = "记录:无"
      Text1.Text = ""
      Text2.Text = ""
      Text3.Text = ""
      Text4.Text = ""
      Text5.Text = ""
      Text6.Text = ""
      Text7.Text = ""
      Text8.Text = ""
      Combo1.Text = ""
      Text9.Text = ""
      Combo2.Text = ""
      Text10.Text = ""
      Combo3.Text = ""
      Combo4.Text = ""
      Text11.Text = ""
      Text12.Text = ""
      Text13.Text = ""
   Else
      Text1.Text = .Fields("房号")
      Text2.Text = .Fields("大楼名称")
      Text3.Text = .Fields("住户名称")
      Text4.Text = .Fields("住户人数")
      Text5.Text = .Fields("楼层号")
      Text6.Text = .Fields("房屋结构")
      Text7.Text = .Fields("房型")
      Text8.Text = .Fields("使用面积")
      Combo1.Text = .Fields("朝向")
      Text9.Text = .Fields("建筑面积")
      Combo2.Text = .Fields("使用类型")
      Text10.Text = .Fields("套用面积")
      Combo3.Text = .Fields("使用状态")
      Combo4.Text = .Fields("车位")
      Text11.Text = .Fields("维修情况")
      Text12.Text = .Fields("简要说明")
      Text13.Text = .Fields("备注")
   End If
Else
    If MsgBox("是否删除当前记录?", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
         objhome.Delete
         cmdMove(2).Value = True
    Else
      Text1.Text = .Fields("房号")
      Text2.Text = .Fields("大楼名称")
      Text3.Text = .Fields("住户名称")
      Text4.Text = .Fields("住户人数")
      Text5.Text = .Fields("楼层号")
      Text6.Text = .Fields("房屋结构")
      Text7.Text = .Fields("房型")
      Text8.Text = .Fields("使用面积")
      Combo1.Text = .Fields("朝向")
      Text9.Text = .Fields("建筑面积")
      Combo2.Text = .Fields("使用类型")
      Text10.Text = .Fields("套用面积")
      Combo3.Text = .Fields("使用状态")
      Combo4.Text = .Fields("车位")
      Text11.Text = .Fields("维修情况")
      Text12.Text = .Fields("简要说明")
      Text13.Text = .Fields("备注")
    End If
End If
End With
End Sub

Private Sub Cmdexit_Click()
物业管理系统.Show
Unload Me
End Sub

Private Sub cmdMove_Click(Index As Integer)
    With objhome
        Select Case Index           '切换当前记录
            Case 0                  '使第一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then .MoveFirst
            Case 1                  '使上一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then
                    .MovePrevious
                    If .BOF Then .MoveFirst
                End If
            Case 2                  '使下一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then
                    .MoveNext
                    If .EOF Then .MoveLast
                End If
            Case 3                  '使最后一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then .MoveLast
        End Select
        If .RecordCount < 1 Then
            txtNews = "记录:无"    '显示无记录提示
        Else
            '显示当前记录数据
           Text1.Text = .Fields("房号")
           Text2.Text = .Fields("大楼名称")
           If IsNull(.Fields("住户名称")) Then
              Text3.Text = ""
           Else
              Text3.Text = .Fields("住户名称")
           End If
           If IsNull(.Fields("住户人数")) Then
              Text4.Text = ""
           Else
              Text4.Text = .Fields("住户人数")
           End If
           If IsNull(.Fields("楼层号")) Then
              Text5.Text = ""
           Else
              Text5.Text = .Fields("楼层号")
           End If
           If IsNull(.Fields("房屋结构")) Then
              Text6.Text = ""
           Else
              Text6.Text = .Fields("房屋结构")
           End If
           If IsNull(.Fields("房型")) Then
              Text7.Text = ""
           Else
              Text7.Text = .Fields("房型")
           End If
           If IsNull(.Fields("使用面积")) Then
              Text8.Text = ""
           Else
              Text8.Text = .Fields("使用面积")
           End If
           If IsNull(.Fields("朝向")) Then
              Combo1.Text = ""
           Else
              Combo1.Text = .Fields("朝向")
           End If
           If IsNull(.Fields("建筑面积")) Then
              Text9.Text = ""
           Else
              Text9.Text = .Fields("建筑面积")
           End If
           If IsNull(.Fields("使用类型")) Then
              Combo2.Text = ""
           Else
              Combo2.Text = .Fields("使用类型")
           End If
           If IsNull(.Fields("套用面积")) Then
              Text10.Text = ""
           Else
              Text10.Text = .Fields("套用面积")
           End If
           If IsNull(.Fields("使用状态")) Then
              Combo3.Text = ""
           Else
              Combo3.Text = .Fields("使用状态")
           End If
           If IsNull(.Fields("车位")) Then
              Combo4.Text = ""
           Else
              Combo4.Text = .Fields("车位")
           End If
           If IsNull(.Fields("维修情况")) Then
              Text11.Text = ""
           Else
              Text11.Text = .Fields("维修情况")
           End If
           If IsNull(.Fields("简要说明")) Then
              Text12.Text = ""
           Else
               Text12.Text = .Fields("简要说明")
           End If
           If IsNull(.Fields("备注")) Then
              Text13.Text = ""
           Else
              Text13.Text = .Fields("备注")
           End If
            '显示当前记录编号和记录总数
            txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
        End If
    End With
    If isadding Then isadding = False
End Sub

Private Sub Cmdsave_Click()
If isadding = False Then
   MsgBox "此状态不允许添加记录!", vbCritical, "温馨提示"
   Exit Sub
End If
With objhome
If Text1.Text = "" Then          '选择房号
   MsgBox "请输入房号", vbInformation, "温馨提示"
   Text1.SetFocus
   Text1.Text = ""
   Exit Sub
End If
If Text2.Text = "" Then         '选择大楼名称
   MsgBox "请输入大楼名称!", vbInformation, "温馨提示"
   Text2.SetFocus
   Exit Sub
End If
'If Trim(Text12.Text) = "" Then
   'MsgBox "请输入日期", vbInformation, "温馨提示"
   'Text12.SetFocus
   'Exit Sub
'End If
'If Trim(Text13.Text) = "" Then
   'MsgBox "请输入日期", vbInformation, "温馨提示"
   'Text13.SetFocus
   'Exit Sub
'End If
'检查代码是否重复
Dim objcopy As New Recordset
Set objcopy = objhome.Clone
If objcopy.RecordCount > 0 Then
   objcopy.MoveFirst
   objcopy.Find "房号='" & Trim(Text1.Text) & "'"
   If (isadding And Not objcopy.EOF) Or (Not isadding And Not objcopy.EOF And objcopy.AbsolutePosition <> objhome.AbsolutePosition) Then
       MsgBox "此大楼房间已存在!", vbCritical, "温馨提示"
       Text1.SetFocus
       Text1.SelStart = 0
       Exit Sub
    Else
       If isadding Then objhome.AddNew
           .Fields("房号") = Trim(Text1.Text)
           .Fields("大楼名称") = Trim(Text2.Text)
           '.Fields("住户名称") = Trim(Text3.Text)
           .Fields("住户人数") = Trim(Text4.Text)
           .Fields("楼层号") = Trim(Text5.Text)
           .Fields("房屋结构") = Trim(Text6.Text)
           .Fields("房型") = Trim(Text7.Text)
           .Fields("使用面积") = Trim(Text8.Text)
           .Fields("朝向") = Trim(Combo1.Text)
           .Fields("建筑面积") = Trim(Text9.Text)
           .Fields("使用类型") = Trim(Combo2.Text)
           .Fields("套用面积") = Trim(Text10.Text)
           .Fields("使用状态") = Trim(Combo3.Text)
           .Fields("车位") = Trim(Combo4.Text)
           .Fields("维修情况") = Trim(Text11.Text)
           .Fields("简要说明") = Trim(Text12.Text)
           .Fields("备注") = Trim(Text13.Text)
           .Update
          MsgBox "数据保存成功!", vbInformation, "温馨提示"
          isadding = False
          txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
        'End If
    End If
 Else
   If adding Then
      .AddNew
           .Fields("房号") = Trim(Text1.Text)
           .Fields("大楼名称") = Trim(Text2.Text)
           '.Fields("住户名称") = Trim(Text3.Text)
           .Fields("住户人数") = Trim(Text4.Text)
           .Fields("楼层号") = Trim(Text5.Text)
           .Fields("房屋结构") = Trim(Text6.Text)
           .Fields("房型") = Trim(Text7.Text)
           .Fields("使用面积") = Trim(Text8.Text)
           .Fields("朝向") = Trim(Combo1.Text)
           .Fields("建筑面积") = Trim(Text9.Text)
           .Fields("使用类型") = Trim(Combo2.Text)
           .Fields("套用面积") = Trim(Text10.Text)
           .Fields("使用状态") = Trim(Combo3.Text)
           .Fields("车位") = Trim(Combo4.Text)
           .Fields("维修情况") = Trim(Text11.Text)
           .Fields("简要说明") = Trim(Text12.Text)
           .Fields("备注") = Trim(Text13.Text)
      .Update
       MsgBox "数据保存成功!", vbInformation, "温馨提示"
       isadding = False
       txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
    End If
End If
End With
End Sub


Private Sub Form_Load()

MsgBox "欢迎登录房屋信息查询" & vbCrLf & "请选择大楼!", vbInformation, "温馨提示"

 '建立数据库联接
    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
 With objflor
      If .RecordCount > 0 Then
         .MoveFirst
         While Not .EOF
               Cmbtype.AddItem .Fields("大楼名称")
               .MoveNext
         Wend
       End If
 End With
For i = 0 To 3
    cmdMove(i).Visible = False
Next i
txtNews.Visible = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -