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

📄 费用数据录入.frm

📁 小区物业管理系统vb开发的,曾用于本科毕业设计
💻 FRM
📖 第 1 页 / 共 3 页
字号:
'数据库联接
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
         Cmbflor.AddItem .Fields("大楼名称")
         .MoveNext
   Wend
End If
End With

'获取维修信息数据
Set objrep = New Recordset
With objrep
Set .ActiveConnection = objcn
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockOptimistic
    .Open "select * from 维修信息"
    Set .ActiveConnection = Nothing
End With

End Sub

Private Sub Cmbflor_Click()
'获取费用结算表
Set objcount = New Recordset
With objcount
Set .ActiveConnection = objcn
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockOptimistic
    .Open "select * from 费用结算 where 大楼名称= '" & Trim(Cmbflor.Text) & "'"
End With
 '获取楼房区信息
 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

'获取水表信息数据
Set objwater = New Recordset
With objwater
Set .ActiveConnection = objcn
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockOptimistic
    .Open "select * from 水表信息 where 大楼名称='" & Trim(Cmbflor.Text) & "'"
    
End With

'获取电表信息数据
Set objlight = New Recordset
With objlight
Set .ActiveConnection = objcn
    .CursorLocation = adUseClient
    .CursorType = adOpenStatic
    .LockType = adLockOptimistic
    .Open "select * from 电表信息  where 大楼名称='" & Trim(Cmbflor.Text) & "'"
End With
End Sub

Private Sub Cmbroom_Click()

Text1.Text = 费用计算.Text1      '管理费
Text2.Text = 费用计算.Text2      '排污费
If "A栋" = Trim(Cmbflor.Text) Then     '租金
   Text3.Text = "0"
ElseIf "B栋" = Trim(Cmbflor.Text) Then
   Text3.Text = 费用计算.Text3
ElseIf "C栋" = Trim(Cmbflor.Text) Then
   Text3.Text = "1000"
End If
   

With objrep                          '维修金
g = Trim(Cmbflor.Text)
If g = Trim(.Fields("大楼名称")) And .RecordCount > 0 Then
   .MoveFirst
   .Find "大楼名称='" & g & "'"
   .MoveNext
   If Trim(Cmbroom.Text) = Trim(.Fields("房号")) Then
      If .Fields("需要费用") <> "" Then
         Text4.Text = .Fields("需要费用")
      Else
         Text4.Text = 0
      End If
    Else
        Text4.Text = 0
    End If
Else
   Text4.Text = 0
End If
End With

With objhome                    '停车费
If .RecordCount > 0 Then
   .MoveFirst
   .Find "房号='" & Trim(Cmbroom.Text) & "'"
   If Trim(objhome.Fields("房号")) = Trim(Cmbroom.Text) Then
      If Trim(.Fields("车位")) = "有" Then
         Text5.Text = 200
      Else
         Text5.Text = 0
      End If
   End If
End If
End With


Text6.Text = 费用计算.Text5      '其它1
Text7.Text = 费用计算.Text6      '其它2

With objwater '水费
If .RecordCount > 0 Then
   .MoveFirst
   .Find "房号='" & Trim(Cmbroom.Text) & "'"
   If .EOF Then
       If MsgBox("此用户没有交水费,不能进行费用录入!" & vbCrLf _
               & "请先登录水费信息管理", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
          水费管理.Show
          Exit Sub
        End If
   Else
       If Trim(.Fields("房号")) = Trim(Cmbroom.Text) Then
             a = Trim(.Fields("实际用水量"))
          If .Fields("实际用水量") <> "" And a < 10 Then
             Text8.Text = a * 0.6
          Else
             Text8.Text = 10 * 0.6 + (a - 10) * 1.2
          End If
       End If
   End If
    
End If
End With

With objlight                  '电费
If .RecordCount > 0 Then
   .MoveFirst
   .Find "房号='" & Trim(Cmbroom.Text) & "'"
   If .EOF Then
      If MsgBox("此用户没有交电费,不能进行费用录入!" & vbCrLf _
               & "请先登录电费信息管理", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
         电费管理.Show
         Exit Sub
      End If
   Else
      If Trim(Cmbroom.Text) = Trim(.Fields("房号")) Then
          a = Trim(.Fields("实际用电量"))
         If .Fields("实际用电量") <> "" And a < 60 Then
            Text9.Text = a * 0.8
         Else
            Text9.Text = 60 * 0.8 + (a - 10) * 1.6
         End If
      End If
    End If
End If
End With

End Sub

Private Sub Cmdcount_Click()
If isadding = False Then
   Exit Sub
Else
   If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Then
      Exit Sub
   Else
      Text10.Text = CInt(CInt(Text1.Text) + CInt(Text2.Text) + CInt(Text3.Text) + CInt(Text4.Text) + CInt(Text5.Text) + CInt(Text6.Text) + CInt(Text7.Text) + CInt(Text8.Text) + CInt(Text9.Text))
   End If
End If
End Sub
Private Sub Cmdadd_Click()
Cmdsave.Enabled = True
Cmdback.Enabled = True
Cmbflor.Enabled = True
Cmbroom.Enabled = True
isadding = True

Cmbroom.Clear         '清除原有数据
Cmbflor.Text = ""
Cmbroom.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
Private Sub Cmdsave_Click()
If isadding = False Then
   MsgBox "此状态不允许保存记录!", vbCritical, "温馨提示"
   Exit Sub
End If

'检查费用总结
If Text10.Text = "" Then
   MsgBox "请结算数据," & vbCrLf & "并进行保存!", vbCritical, "温馨提示"
   Exit Sub
End If
With objcount
If .RecordCount > 0 Then
   
   .MoveFirst
   .Find "房号='" & Trim(Cmbroom.Text) & "'"
   '判断是否出现重复记录
   'And Trim(.Fields("房号")) = Trim(Cmbroom.Text)
      If Not .EOF Then
         MsgBox "此用户数据已记录!", vbInformation, "温馨提示"
         Cmbflor.Text = ""
         Cmbroom.Text = ""
         Text1.Text = ""
         Text2.Text = ""
         Text3.Text = ""
         Text4.Text = ""
         Text5.Text = ""
         Text6.Text = ""
         Text7.Text = ""
         Text8.Text = ""
         Text9.Text = ""
         Text10.Text = ""
         Cmbflor.Enabled = False
         Cmbroom.Enabled = False
         Exit Sub
      Else
          If isadding Then .AddNew             '添加已有大楼记录
             .Fields("大楼名称") = Cmbflor.Text
             .Fields("房号") = Cmbroom.Text
             .Fields("管理费") = Text1.Text
             .Fields("排污费") = Text2.Text
             .Fields("租金") = Text3.Text
             .Fields("维修金") = Text4.Text
             .Fields("停车费") = Text5.Text
             .Fields("其它1") = Text6.Text
             .Fields("其它2") = Text7.Text
             .Fields("水费") = Text8.Text
             .Fields("电费") = Text9.Text
             .Fields("总费用结算") = Text10.Text
             .Update
             MsgBox "数据保存成功!", vbInformation, "温馨提示"
             isadding = False
      End If
 Else
      If isadding Then .AddNew              '此前没有添加大楼
          .Fields("大楼名称") = Cmbflor.Text
          .Fields("房号") = Cmbroom.Text
          .Fields("管理费") = Text1.Text
          .Fields("排污费") = Text2.Text
          .Fields("租金") = Text3.Text
          .Fields("维修金") = Text4.Text
          .Fields("停车费") = Text5.Text
          .Fields("其它1") = Text6.Text
          .Fields("其它2") = Text7.Text
          .Fields("水费") = Text8.Text
          .Fields("电费") = Text9.Text
          .Fields("总费用结算") = Text10.Text
          .Update
           MsgBox "数据保存成功!", vbInformation, "温馨提示"
           isadding = False
  End If
   

End With
End Sub
Private Sub Cmdback_Click()
If isadding = True Then
   isadding = False
   MsgBox "要放弃数据的保存?", vbInformation, "温馨提示"
   Cmbflor.Text = ""
   Cmbroom.Text = ""
   Text1.Text = ""
   Text2.Text = ""
   Text3.Text = ""
   Text4.Text = ""
   Text5.Text = ""
   Text6.Text = ""
   Text7.Text = ""
   Text8.Text = ""
   Text9.Text = ""
   Text10.Text = ""
  ' Cmdsave.Enabled = False
  'Cmdback.Enabled = False
   Cmbflor.Enabled = False
   Cmbroom.Enabled = False
End If
End Sub

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

⌨️ 快捷键说明

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