欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

frms.vb

需要在.net环境下运行需要安装框架
VB
字号:
Imports System.Data.OleDb
Public Class FRMS
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents labToday As System.Windows.Forms.Label
    Friend WithEvents labSum As System.Windows.Forms.Label
    Friend WithEvents btnSum As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.labToday = New System.Windows.Forms.Label()
        Me.labSum = New System.Windows.Forms.Label()
        Me.btnSum = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'labToday
        '
        Me.labToday.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.labToday.Location = New System.Drawing.Point(13, 16)
        Me.labToday.Name = "labToday"
        Me.labToday.Size = New System.Drawing.Size(264, 16)
        Me.labToday.TabIndex = 0
        Me.labToday.Text = "Label1"
        '
        'labSum
        '
        Me.labSum.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.labSum.Location = New System.Drawing.Point(15, 40)
        Me.labSum.Name = "labSum"
        Me.labSum.Size = New System.Drawing.Size(264, 16)
        Me.labSum.TabIndex = 1
        Me.labSum.Text = "Label1"
        '
        'btnSum
        '
        Me.btnSum.Location = New System.Drawing.Point(104, 96)
        Me.btnSum.Name = "btnSum"
        Me.btnSum.TabIndex = 2
        Me.btnSum.Text = "结算"
        '
        'FRMS
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(292, 133)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSum, Me.labSum, Me.labToday})
        Me.Name = "FRMS"
        Me.Text = "月末结算"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private thisMonth As Integer
    Private Sub FRMS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sqlStr As String = "select iMonth from information"
        Dim dbopera1 As DbOpera = New DbOpera(sqlStr)
        thisMonth = dbopera1.getSum()
        labSum.Text = "上次结算的月份为:" & dbopera1.getSum().ToString()
        labToday.Text = "今天是:" & Date.Now.ToString()
    End Sub

    Private Sub btnSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSum.Click
        If thisMonth = Date.Today.Month Then
            MsgBox("本月已经结算过了!", MsgBoxStyle.Exclamation, "OK")
            Exit Sub
        End If
        Dim sqlStr3 As String = "select iDate from information"
        Dim dbopera3 As DbOpera = New DbOpera(sqlStr3)
        If dbopera3.getSum() > Date.Today.Day Then
            MsgBox("未到结算的日期,结算只能是在月末!", MsgBoxStyle.Exclamation, "OK")
            Exit Sub
        End If
        Dim sqlStr1 As String
        sqlStr1 = "select hID from houseOwner"
        Dim connStr2 As String
        connStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\xqglxt.mdb"
        Dim conn2 As OleDbConnection = New OleDbConnection(connStr)
        Dim comm As OleDbCommand = New OleDbCommand(sqlStr1, conn2)
        Try
            If (conn2.State = System.Data.ConnectionState.Closed) Then
                conn2.Open()
            End If
            Dim reader As OleDbDataReader
            Dim hoMoney As Integer
            Dim dbopera1 As DbOpera
            Dim hID As Integer
            reader = comm.ExecuteReader()
            While reader.Read()
                hID = reader.GetInt32(0)
                sqlStr1 = "select hoMoney from houseOwner where hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = dbopera1.getSum() '欠款
                sqlStr1 = "select mSumFee from mend where hID=" & hID.ToString() & " and mUse='否'"
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = hoMoney + dbopera1.getSum() '加上报修费用
                sqlStr1 = "select eCost from eletrityCost where hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = hoMoney + dbopera1.getSum() '加上电费
                sqlStr1 = "select wCost from waterCost where hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = hoMoney + dbopera1.getSum() '加上水费
                sqlStr1 = "select gPrice from garage where hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = hoMoney + dbopera1.getSum() '加上停车费
                sqlStr1 = "select iManageCost from information"
                dbopera1 = New DbOpera(sqlStr1)
                hoMoney = hoMoney + dbopera1.getSum() '加上管理费
                sqlStr1 = "update houseOwner set hoMoney=" & hoMoney.ToString() & " where hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                dbopera1.opera() '更新用户欠款
                sqlStr1 = "update mend set mUse='是' where mUse='否' and mDo='是' and hID=" & hID.ToString()
                dbopera1 = New DbOpera(sqlStr1)
                dbopera1.opera() '更新报修记录
                'MsgBox("Cost:" & hID.ToString() & ":" & hoMoney.ToString(), MsgBoxStyle.Exclamation, "OK")
            End While
            conn2.Close()
        Catch e1 As System.Exception
            MsgBox("Error!", MsgBoxStyle.Exclamation, "OK")
            Exit Sub
        End Try
        Dim sqlStr2 As String
        thisMonth = (thisMonth + 1) Mod 12
        If thisMonth = 0 Then
            thisMonth = 12
        End If
        sqlStr2 = "update information set iMonth=" & thisMonth.ToString()
        Dim dbopera2 As DbOpera = New DbOpera(sqlStr2)
        dbopera2.opera()
        MsgBox("结算成功!", MsgBoxStyle.Exclamation, "OK")
    End Sub
End Class

⌨️ 快捷键说明

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