Public Class C에너지분석OD

    Dim T As String = "에너지분석"


    Public ZZone As String
    Public Mon As String
    Private ErrMsg As String = "월에너지분석이 계산되지 않았습니다"
    Public Sub New(ByVal mIdx As Integer, Optional ByVal pZone As String = "00")
        Me.ZZone = pZone
        Mon = "M" & Format(mIdx, "00")
    End Sub
    ReadOnly Property 에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "에너지요구량")
                Return 0
            Else
                Return 난방에너지요구량열(CStr(IIf(Zone <> "00", Zone, ZZone))) + _
                난방에너지요구량공조환기(CStr(IIf(Zone <> "00", Zone, ZZone))) + _
                냉방에너지요구량열(CStr(IIf(Zone <> "00", Zone, ZZone))) + _
                냉방에너지요구량공조환기(CStr(IIf(Zone <> "00", Zone, ZZone))) + _
                조명에너지요구량(CStr(IIf(Zone <> "00", Zone, ZZone))) + _
                급탕에너지요구량(CStr(IIf(Zone <> "00", Zone, ZZone)))
            End If
        End Get
    End Property
    ReadOnly Property 면적당에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Return Me.난방단위면적당요구량 + Me.냉방단위면적당요구량 + Me.조명단위면적당요구량 + Me.급탕단위면적당요구량
        End Get
    End Property
    ReadOnly Property 난방에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Return Me.난방에너지요구량열(IIf(Zone <> "00", Zone, ZZone).ToString) + Me.난방에너지요구량공조환기(IIf(Zone <> "00", Zone, ZZone).ToString)
        End Get
    End Property

    ReadOnly Property 난방단위면적당요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            If Result1o.사용면적.H = 0 Then
                Return 0
            Else
                Return Me.난방에너지요구량 / Result1o.사용면적.H
            End If
            ' Return Me.난방에너지요구량열(Zone) + Me.난방에너지요구량공조환기(Zone)
        End Get
    End Property


    Property 난방에너지요구량열(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "난방에너지요구량열")
                Return 0
            Else
                Return TOSG(T, DR(0)("난방요구량열"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "난방에너지요구량열")
            Else
                DR(0)("난방요구량열") = value
            End If
        End Set
    End Property
    Property 난방에너지요구량공조환기(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "난방에너지요구량공조환기")
                Return 0
            Else
                Return TOSG(T, DR(0)("난방요구량공조"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "난방에너지요구량공조환기")
            Else
                DR(0)("난방요구량공조") = value
            End If
        End Set
    End Property

    ReadOnly Property 냉방에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Return Me.냉방에너지요구량열(CStr(IIf(Zone <> "00", Zone, ZZone))) + Me.냉방에너지요구량공조환기(CStr(IIf(Zone <> "00", Zone, ZZone)))
        End Get
    End Property

    ReadOnly Property 냉방단위면적당요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            If Result1o.사용면적.H = 0 Then
                Return 0
            Else
                Return Me.냉방에너지요구량 / Result1o.사용면적.C
            End If
            ' Return Me.난방에너지요구량열(Zone) + Me.난방에너지요구량공조환기(Zone)
        End Get
    End Property


    Property 냉방에너지요구량열(Optional ByVal Zone As String = "00") As Decimal
        Get



            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "냉방에너지요구량열")
                Return 0
            Else
                Return TOSG(T, DR(0)("냉방요구량열"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "냉방에너지요구량열")
            Else
                DR(0)("냉방요구량열") = value
            End If
        End Set
    End Property
    Property 냉방에너지요구량공조환기(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "냉방에너지요구량공조환기")
                Return 0
            Else
                Return TOSG(T, DR(0)("냉방요구량공조"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "냉방에너지요구량공조환기")
            Else
                DR(0)("냉방요구량공조") = value
            End If
        End Set
    End Property

    Property 조명에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "조명에너지요구량")
                Return 0
            Else
                Return TOSG(T, DR(0)("조명요구량"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "조명에너지요구량")
            Else
                DR(0)("조명요구량") = value
            End If
        End Set
    End Property
    ReadOnly Property 조명단위면적당요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            If Result1o.사용면적.L = 0 Then
                Return 0
            Else
                Return Me.조명에너지요구량 / Result1o.사용면적.L
            End If
            ' Return Me.난방에너지요구량열(Zone) + Me.난방에너지요구량공조환기(Zone)
        End Get
    End Property

    Property 급탕에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "급탕요구량")
                Return 0
            Else
                Return TOSG(T, DR(0)("급탕요구량"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "급탕요구량")
            Else
                DR(0)("급탕요구량") = value
            End If
        End Set
    End Property
    ReadOnly Property 급탕단위면적당요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            If Result1o.사용면적.W = 0 Then
                Return 0
            Else
                Return Me.급탕에너지요구량 / Result1o.사용면적.W
            End If
            ' Return Me.난방에너지요구량열(Zone) + Me.난방에너지요구량공조환기(Zone)
        End Get
    End Property
    Property 공조풍량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "공조풍량")
                Return 0
            Else
                Return TOSG(T, DR(0)("공조풍량"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "공조풍량")
            Else
                DR(0)("공조풍량") = value
            End If
        End Set
    End Property
    Property 공조에너지요구량난방(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "공조에너지요구량난방")
                Return 0
            Else
                Return TOSG(T, DR(0)("공조요구량난방"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "공조에너지요구량난방")
            Else
                DR(0)("공조요구량난방") = value
            End If
        End Set
    End Property
    Property 공조에너지요구량냉방(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
                Return 0
            Else
                Return TOSG(T, DR(0)("공조요구량냉방"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
            Else
                DR(0)("공조요구량냉방") = value
            End If
        End Set
    End Property
    Property 공조에너지요구량가습(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
                Return 0
            Else
                Return TOSG(T, DR(0)("공조요구량가습"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
            Else
                DR(0)("공조요구량가습") = value
            End If
        End Set
    End Property
    Property 환기에너지요구량(Optional ByVal Zone As String = "00") As Decimal
        Get
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone = "00", ZZone, Zone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
                Return 0
            Else
                Return TOSG(T, DR(0)("환기요구량"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.월별에너지분석Row = CType(DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='" & IIf(Zone <> "00", Zone, ZZone).ToString & "'"), DSR.월별에너지분석Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg)
            Else
                DR(0)("환기요구량") = value
            End If
        End Set
    End Property
    Public Sub Calc()
        '//Zone 이 00일떄만 계산된다

        '//여기데이터는 12개가 미리존재한다 그러므로 현재 속한 월말 계산하면된다
        '//현재 월 존에해당하는 데이터가없다면 생성해준다.
        Dim Drow As DSR.월별에너지분석Row
        If DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존='00'").GetUpperBound(0) = -1 Then
            Drow = DSETR1.월별에너지분석.New월별에너지분석Row
            Drow.존 = "00"
            Drow.월 = Mon
            DSETR1.월별에너지분석.Add월별에너지분석Row(Drow) '//기본줄을 추가함
            DSETR1.AcceptChanges()
        End If

        Dim a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 As Decimal
        a2 = 0 : a3 = 0 : a4 = 0 : a5 = 0 : a6 = 0
        a7 = 0 : a8 = 0 : a9 = 0 : a10 = 0 : a11 = 0 : a12 = 0
        For Each Dr As DSR.월별에너지분석Row In DSETR1.월별에너지분석.Select("월='" & Mon & "' and 존 <> '00'", "존")
            '//존별로  에너지요구량 최상단 합데이터를 갱신한다.
            'Dr.에너지요구량 = Dr.난방요구량열 + Dr.난방요구량공조 + Dr.냉방요구량열 + Dr.냉방요구량공조 + Dr.조명요구량 + Dr.급탕요구량
            'a1 = a1 + Dr.에너지요구량
            a2 = a2 + Dr.난방요구량열
            a3 = a3 + Dr.난방요구량공조
            a4 = a4 + Dr.냉방요구량열
            a5 = a5 + Dr.냉방요구량공조
            a6 = a6 + Dr.조명요구량
            a7 = a7 + Dr.급탕요구량
            a8 = a8 + Dr.공조풍량
            a9 = a9 + Dr.공조요구량난방
            a10 = a10 + Dr.공조요구량냉방
            a11 = a11 + Dr.공조요구량가습
            a12 = a12 + Dr.환기요구량
            ' 'Console.WriteLine(String.Format(">>>>>>>>> a2={0},a3={1},a4={2},a5={3},a6={4},a7={5},a8={6},a9={7},a10={8},a11={9},a12={10}", a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12))
        Next

        'Me.에너지요구량 = a2 + a3 + a4 + a5 + a6 + a7 ㅇ건 Readonlye 로 계산한다.

        Me.난방에너지요구량열 = a2
        Me.난방에너지요구량공조환기 = a3
        Me.냉방에너지요구량열 = a4
        Me.냉방에너지요구량공조환기 = a5
        Me.조명에너지요구량 = a6
        Me.급탕에너지요구량 = a7
        Me.공조풍량 = a8
        Me.공조에너지요구량난방 = a9
        Me.공조에너지요구량냉방 = a10
        Me.공조에너지요구량가습 = a11
        Me.환기에너지요구량 = a12
        ' Next

    End Sub
End Class
