Public Class C1차소요량
    Public Mon As String
    Private ErrMsg As String = "1차에너지소요량 계산되지 않았습니다"
    Private MIdx As Integer

    '//M00 일떄의 합계식이 추가되지않았따
    '//해당부분은 주로 합계식에서 사용된다.

    Public Sub Calc_Summary()

        If MIdx <> 0 Then
            MsgBox("Calc 계산식은 0번만 가능합니다")
            Return
        End If

        Dim i1, i2, i3, i4, i5, i6 As Decimal

        i1 = 0 : i2 = 0 : i3 = 0 : i4 = 0 : i5 = 0
        For i As Integer = 1 To 12
            i1 += Result.일차E소요량(i).난방등유
            i2 += Result.일차E소요량(i).난방LNG
            i3 += Result.일차E소요량(i).난방LPG
            i4 += Result.일차E소요량(i).난방지역
            i5 += Result.일차E소요량(i).난방전력
        Next
        Me.난방등유 = i1
        Me.난방LNG = i2
        Me.난방LPG = i3
        Me.난방지역 = i4
        Me.난방전력 = i5

        i1 = 0 : i2 = 0 : i3 = 0 : i4 = 0 : i5 = 0 : i6 = 0
        For i As Integer = 1 To 12
            i1 += Result.일차E소요량(i).냉방등유
            i2 += Result.일차E소요량(i).냉방LNG
            i3 += Result.일차E소요량(i).냉방LPG
            i4 += Result.일차E소요량(i).냉방지역난방열
            i5 += Result.일차E소요량(i).냉방지역냉방열
            i6 += Result.일차E소요량(i).냉방전력
        Next
        Me.냉방등유 = i1
        Me.냉방LNG = i2
        Me.냉방LPG = i3
        Me.냉방지역난방열 = i4
        Me.냉방지역냉방열 = i5
        Me.냉방전력 = i6

        i1 = 0 : i2 = 0 : i3 = 0 : i4 = 0 : i5 = 0
        For i As Integer = 1 To 12
            i1 += Result.일차E소요량(i).급탕등유
            i2 += Result.일차E소요량(i).급탕LNG
            i3 += Result.일차E소요량(i).급탕LPG
            i4 += Result.일차E소요량(i).급탕지역
            i5 += Result.일차E소요량(i).급탕전력
        Next
        Me.급탕등유 = i1
        Me.급탕LNG = i2
        Me.급탕LPG = i3
        Me.급탕지역 = i4
        Me.급탕전력 = i5

    End Sub

    Private DSETR As DSR
    Private Result As CResult
    Public Sub New(ByRef pdsetr As DSR, ByRef presult As CResult, Optional ByVal pmIdx As Integer = 0)
        DSETR = pdsetr
        Result = presult
        MIdx = pmIdx
        Mon = "M" & Format(pmIdx, "00")
    End Sub

    ReadOnly Property 소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = 0
                For i As Integer = 1 To 12
                    R += Result.일차E소요량(i).소요량
                Next
                Return R
            Else
                Return Me.난방소요량 + Me.냉방소요량 + Me.급탕소요량 + Me.조명소요량 + Me.환기소요량 - (Result.생산E(MIdx).태양광전력생산량 * Result.E변환계수.전력) - (Result.생산E(MIdx).열병합전력생산량 * Result.E변환계수.전력)
            End If
        End Get
    End Property

    ReadOnly Property 단위면적() As Decimal
        Get
            If MIdx <> 0 Then
                Return 0
            Else
                Return Me.난방면적 + Me.냉방면적 + Me.급탕면적 + Me.조명면적 + Me.환기면적
            End If

        End Get
    End Property

#Region "난방"
    ReadOnly Property 난방소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.난방등유 * Result.E변환계수.등유 + Me.난방LNG * Result.E변환계수.LNG + _
                Me.난방LPG * Result.E변환계수.LPG + Me.난방지역 * Result.E변환계수.지역난방 + _
                Me.난방전력 * Result.E변환계수.전력
                Try
                    Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                    (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.난방전력 * Result.E변환계수.전력
                Catch ex As Exception

                End Try
            Else
                Return Me.난방등유 * Result.E변환계수.등유 + Me.난방LNG * Result.E변환계수.LNG + _
                Me.난방LPG * Result.E변환계수.LPG + Me.난방지역 * Result.E변환계수.지역난방 + _
                Me.난방전력 * Result.E변환계수.전력
            End If
        End Get
    End Property

    ReadOnly Property 난방소요량2() As Decimal   '//140112(?)
        Get

            Dim 건물용도 As Integer = CInt(DSET1.tbl_Desc.Rows(0)("isjugo"))

            If MIdx = 0 Then

                If 건물용도 < 10 Then

                    Dim R As Decimal = Me.난방등유 * Result.E변환계수.지역난방 + Me.난방LNG * Result.E변환계수.지역난방 + _
                    Me.난방LPG * Result.E변환계수.지역난방 + Me.난방지역 * Result.E변환계수.지역난방 + _
                    Me.난방전력 * Result.E변환계수.전력
                    Try
                        Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                        (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.난방전력 * Result.E변환계수.전력
                    Catch ex As Exception

                    End Try

                Else
                    Dim R As Decimal = Me.난방등유 * Result.E변환계수.등유 + Me.난방LNG * Result.E변환계수.LNG + _
                    Me.난방LPG * Result.E변환계수.LPG + Me.난방지역 * Result.E변환계수.지역난방 + _
                    Me.난방전력 * Result.E변환계수.전력
                    Try
                        Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                        (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.난방전력 * Result.E변환계수.전력
                    Catch ex As Exception

                    End Try
                End If

                
            Else


                If 건물용도 < 10 Then
                    Return Me.난방등유 * Result.E변환계수.지역난방 + Me.난방LNG * Result.E변환계수.지역난방 + _
                    Me.난방LPG * Result.E변환계수.지역난방 + Me.난방지역 * Result.E변환계수.지역난방 + _
                    Me.난방전력 * Result.E변환계수.전력
                Else
                    Return Me.난방등유 * Result.E변환계수.등유 + Me.난방LNG * Result.E변환계수.LNG + _
                    Me.난방LPG * Result.E변환계수.LPG + Me.난방지역 * Result.E변환계수.지역난방 + _
                    Me.난방전력 * Result.E변환계수.전력
                End If



            End If
        End Get
    End Property

    Property 난방등유() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("난방등유"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("난방등유") = value
            End If
        End Set
    End Property
    Property 난방LNG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("난방LNG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("난방LNG") = value
            End If
        End Set
    End Property
    Property 난방LPG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("난방LPG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("난방LPG") = value
            End If
        End Set
    End Property
    'Property 난방펠렛() As Decimal
    '    Get
    '        Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
    '        If DR.GetUpperBound(0) = -1 Then
    '            MsgBox(ErrMsg,MsgBoxStyle.Information,"C1차소요량")
    '            Return 0
    '        Else
    '            Return TOSG(DR(0)("난방펠렛"))
    '        End If
    '    End Get
    '    Set(ByVal value As Decimal)
    '        Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
    '        If DR.GetUpperBound(0) = -1 Then
    '            MsgBox(ErrMsg,MsgBoxStyle.Information,"C1차소요량")
    '        Else
    '            DR(0)("난방펠렛") = value
    '        End If
    '    End Set
    'End Property
    Property 난방지역() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("난방지역"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("난방지역") = value
            End If
        End Set
    End Property
    Property 난방전력() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("난방전력"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("난방전력") = value
            End If
        End Set
    End Property

    ReadOnly Property 난방면적() As Decimal
        Get
            If Result.사용면적.H = 0 Then
                Return 0
            Else
                Return Me.난방소요량 / Result.사용면적.H
            End If
        End Get
    End Property

    ReadOnly Property 난방면적2() As Decimal
        Get
            If Result.사용면적.H = 0 Then
                Return 0
            Else
                Return Me.난방소요량2 / Result.사용면적.H
            End If
        End Get
    End Property

#End Region

#Region "냉방"
    ReadOnly Property 냉방소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.냉방등유 * Result.E변환계수.등유 + Me.냉방LNG * Result.E변환계수.LNG + _
                Me.냉방LPG * Result.E변환계수.LPG + Me.냉방지역난방열 * Result.E변환계수.지역난방 + _
                Me.냉방지역냉방열 * Result.E변환계수.지역냉방 + Me.냉방전력 * Result.E변환계수.전력
                Try
                    Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                    (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.냉방전력 * Result.E변환계수.전력
                Catch ex As Exception

                End Try
            Else
                Return Me.냉방등유 * Result.E변환계수.등유 + Me.냉방LNG * Result.E변환계수.LNG + _
                Me.냉방LPG * Result.E변환계수.LPG + Me.냉방지역난방열 * Result.E변환계수.지역난방 + _
                Me.냉방지역냉방열 * Result.E변환계수.지역냉방 + Me.냉방전력 * Result.E변환계수.전력
            End If
        End Get
    End Property
    Property 냉방등유() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방등유"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방등유") = value
            End If
        End Set
    End Property
    Property 냉방LNG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방LNG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방LNG") = value
            End If
        End Set
    End Property
    Property 냉방펠렛() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방펠렛"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방펠렛") = value
            End If
        End Set
    End Property
    Property 냉방LPG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방LPG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방LPG") = value
            End If
        End Set
    End Property
    Property 냉방지역난방열() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방지역"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방지역") = value
            End If
        End Set
    End Property
    Property 냉방지역냉방열() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방지역2"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방지역2") = value
            End If
        End Set
    End Property
    Property 냉방전력() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("냉방전력"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("냉방전력") = value
            End If
        End Set
    End Property
    ReadOnly Property 냉방면적() As Decimal
        Get
            If Result.사용면적.C = 0 Then
                Return 0
            Else
                Return Me.냉방소요량 / Result.사용면적.C
            End If
        End Get
    End Property
#End Region

#Region "급탕"
    ReadOnly Property 급탕소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = Me.급탕등유 * Result.E변환계수.등유 + Me.급탕LNG * Result.E변환계수.LNG + _
                Me.급탕LPG * Result.E변환계수.LPG + Me.급탕지역 * Result.E변환계수.지역난방 + _
                Me.급탕전력 * Result.E변환계수.전력

                '#If DEBUG Then
                '                Dim f As String = "c:\temp\1\급탕소요량1.txt"
                '                Dim b As New System.Text.StringBuilder
                '                If System.IO.File.Exists(f) = False Then
                '                    b.AppendLine("태양광전력생산량  열병합전력생산량    난방전력    냉방전력    급탕전력    조명전력    환기전력    전력변환계수")
                '                End If
                '                b.AppendLine(Result.생산E(0).태양광전력생산량.ToString() + vbTab + Result.생산E(0).열병합전력생산량.ToString() + vbTab + _
                '                난방전력.ToString() + vbTab + 냉방전력.ToString() + vbTab + 급탕전력.ToString() + vbTab + 조명전력.ToString() + vbTab + _
                '                환기전력.ToString() + vbTab + Result.E변환계수.전력.ToString())
                '                My.Computer.FileSystem.WriteAllText(f, b.ToString, True)
                '#End If
                Try
                    Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                    (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.급탕전력 * Result.E변환계수.전력
                Catch ex As Exception

                End Try
            Else

                '#If DEBUG Then
                '                Dim f As String = "c:\temp\1\급탕소요량2.txt"
                '                Dim b As New System.Text.StringBuilder
                '                If System.IO.File.Exists(f) = False Then
                '                    b.AppendLine("MIDX  급탕등유  급탕LNG   급탕LPG   급탕지역    급탕전력")
                '                End If
                '                b.AppendLine(MIdx.ToString() + vbTab + 급탕등유.ToString() + vbTab + 급탕LNG.ToString() + vbTab + 급탕LPG.ToString() + vbTab + 급탕지역.ToString() + vbTab + 급탕전력.ToString())
                '                My.Computer.FileSystem.WriteAllText(f, b.ToString, True)
                '#End If

                Return Me.급탕등유 * Result.E변환계수.등유 + Me.급탕LNG * Result.E변환계수.LNG + _
                Me.급탕LPG * Result.E변환계수.LPG + Me.급탕지역 * Result.E변환계수.지역난방 + _
                Me.급탕전력 * Result.E변환계수.전력
            End If
        End Get
    End Property

    ReadOnly Property 급탕소요량2() As Decimal
        Get
            Dim 건물용도 As Integer = CInt(DSET1.tbl_Desc.Rows(0)("isjugo"))

            If MIdx = 0 Then
                If 건물용도 < 10 Then
                    Dim R As Decimal = Me.급탕등유 * Result.E변환계수.지역난방 + Me.급탕LNG * Result.E변환계수.지역난방 + _
                      Me.급탕LPG * Result.E변환계수.지역난방 + Me.급탕지역 * Result.E변환계수.지역난방 + _
                      Me.급탕전력 * Result.E변환계수.전력
                    Try
                        Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                        (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.급탕전력 * Result.E변환계수.전력
                    Catch ex As Exception

                    End Try
                Else
                    Dim R As Decimal = Me.급탕등유 * Result.E변환계수.등유 + Me.급탕LNG * Result.E변환계수.LNG + _
                    Me.급탕LPG * Result.E변환계수.LPG + Me.급탕지역 * Result.E변환계수.지역난방 + _
                    Me.급탕전력 * Result.E변환계수.전력
                    Try
                        Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                        (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.급탕전력 * Result.E변환계수.전력
                    Catch ex As Exception

                    End Try
                End If
            
            Else

                If 건물용도 < 10 Then
                    Return Me.급탕등유 * Result.E변환계수.지역난방 + Me.급탕LNG * Result.E변환계수.지역난방 + _
                    Me.급탕LPG * Result.E변환계수.지역난방 + Me.급탕지역 * Result.E변환계수.지역난방 + _
                    Me.급탕전력 * Result.E변환계수.전력
                Else
                    Return Me.급탕등유 * Result.E변환계수.등유 + Me.급탕LNG * Result.E변환계수.LNG + _
                    Me.급탕LPG * Result.E변환계수.LPG + Me.급탕지역 * Result.E변환계수.지역난방 + _
                    Me.급탕전력 * Result.E변환계수.전력
                End If
                
            End If
        End Get
    End Property





    Property 급탕등유() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕등유"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕등유") = value
            End If
        End Set
    End Property
    Property 급탕LNG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕LNG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕LNG") = value
            End If
        End Set
    End Property
    Property 급탕펠렛() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕펠렛"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕펠렛") = value
            End If
        End Set
    End Property
    Property 급탕LPG() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕LPG"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕LPG") = value
            End If
        End Set
    End Property
    Property 급탕지역() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕지역"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕지역") = value
            End If
        End Set
    End Property
    Property 급탕전력() As Decimal
        Get
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
                Return 0
            Else
                Return TOSG(DR(0)("급탕전력"))
            End If
        End Get
        Set(ByVal value As Decimal)
            Dim DR() As DSR.에너지소요량1Row = CType(DSETR.에너지소요량1.Select("mon='" & Mon & "'"), DSR.에너지소요량1Row())
            If DR.GetUpperBound(0) = -1 Then
                MsgBox(ErrMsg, MsgBoxStyle.Information, "C1차소요량")
            Else
                DR(0)("급탕전력") = value
            End If
        End Set
    End Property
    ReadOnly Property 급탕면적() As Decimal
        Get
            If Result.사용면적.W = 0 Then
                Return 0
            Else
                Return Me.급탕소요량 / Result.사용면적.W
            End If
        End Get
    End Property
    ReadOnly Property 급탕면적2() As Decimal
        Get
            If Result.사용면적.W = 0 Then
                Return 0
            Else
                Return Me.급탕소요량2 / Result.사용면적.W
            End If
        End Get
    End Property
#End Region

#Region "조명부분(읽기전용)"
    ReadOnly Property 조명소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = 조명전력 * Result.E변환계수.전력

                Try
                    Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                    (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.조명전력 * Result.E변환계수.전력
                Catch ex As Exception

                End Try

            Else
                Return 조명전력 * Result.E변환계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 조명전력() As Decimal
        Get
            If MIdx = 0 Then   '//합계필드라면 12월의 합계를 반환한다.
                Dim i1 As Decimal = 0
                For i As Integer = 1 To 12
                    i1 += Result.일차E소요량(i).조명전력
                Next
                Return i1
            Else
                Return Result.E소요량(Me.MIdx).조명S
            End If
        End Get
    End Property
    ReadOnly Property 조명면적() As Decimal
        Get
            If Result.사용면적.L = 0 Then
                Return 0
            Else
                Return Me.조명소요량 / Result.사용면적.L
            End If
        End Get
    End Property

#End Region

#Region "환기부분(읽기전용)"
    ReadOnly Property 환기소요량() As Decimal
        Get
            If MIdx = 0 Then
                Dim R As Decimal = 환기전력 * Result.E변환계수.전력
                Try
                    Return R - (Result.생산E(0).태양광전력생산량 + Result.생산E(0).열병합전력생산량) / _
                    (Me.난방전력 + Me.냉방전력 + Me.급탕전력 + Me.조명전력 + Me.환기전력) * Me.환기전력 * Result.E변환계수.전력
                Catch ex As Exception

                End Try
            Else
                Return 환기전력 * Result.E변환계수.전력
            End If
        End Get
    End Property
    ReadOnly Property 환기전력() As Decimal
        Get
            If MIdx = 0 Then   '//합계필드라면 12월의 합계를 반환한다.
                Dim i1 As Decimal = 0
                For i As Integer = 1 To 12
                    i1 += Result.일차E소요량(i).환기전력
                Next
                Return i1
            Else
                Return Result.E소요량(Me.MIdx).환기S
            End If
        End Get
    End Property
    ReadOnly Property 환기면적() As Decimal
        Get
            If Result.사용면적.V = 0 Then
                Return 0
            Else
                Return Me.환기소요량 / Result.사용면적.V
            End If
        End Get
    End Property
#End Region


End Class
