
''' <summary>
''' 각존의 데이터를 참조한다
''' </summary>
Public Class CZones
    Dim ErrMsg As String = "최대냉난방부하가 계산되지 않았습니다"
    Public Items() As Citem

    Private DSET As DS
    Private DSETR As DSR
    Private Result As CResult
    Public Sub New(ByRef pds As DS, ByRef pdsetr As DSR, ByRef presult As CResult)   '//존은초기화값을 가지고 생성한다.
        DSET = pds
        DSETR = pdsetr
        Result = presult
        ReDim Items(Me.CountR)  '//결과내의 존을 초기화한다.
        Dim idx As Integer = 0
        For Each It As DSR.최대냉난방부하Row In DSETR.최대냉난방부하.Select("zone<>'00'")
            Items(idx) = New Citem(DSET, DSETR, Result, idx, It.Zone)
            idx += 1
        Next
        '//해당존의 코드값을 가지고 결과가 게산되어있따.
    End Sub
    Public Function Count() As Integer
        Return DSET.tbl_zone.Rows.Count '//현재 시스템의 존 카운터를 반환
    End Function
    Public Function CountR() As Integer
        Return DSETR.최대냉난방부하.Select("zone<>'00'").GetUpperBound(0) + 1 '//계산결과내의 존의 갯수를 반환
    End Function

    Public Class Citem
        Public Index As Integer
        Public Code As String
        Public 최대냉난방부하 As C최대냉난방부하.Citem
        Public 월에너지분석(11) As C에너지분석    '//이존의 12달의 내역을 참조한다.
        Private DSETR As DSR
        Private DSET As DS
        Private Result As CResult
        Public Sub New(ByRef pds As DS, ByRef pdsetr As DSR, ByRef presult As CResult, ByVal pidx As Integer, ByVal pcode As String)
            DSET = pds
            DSETR = pdsetr
            Result = presult
            Me.Index = pidx
            Me.Code = pcode
            최대냉난방부하 = New C최대냉난방부하.Citem(DSETR, pcode)

            Dim Idx As Integer = 0
            For Each DR As C에너지분석 In Me.월에너지분석
                DR = New C에너지분석(DSETR, Result, Idx, pcode)
                Idx += 1
            Next
        End Sub
        Public Function Name() As String
            Dim dR() As DataRow = DSET.tbl_zone.Select("code='" & Me.Code & "'")
            If dR.GetUpperBound(0) = -1 Then
                Return "존재하지않는 Zone 입니다"
            Else
                Return dR(0)("설명").ToString
            End If
        End Function
        Public Function Row() As DS.tbl_zoneRow
            Dim dR() As DS.tbl_zoneRow = CType(DSET.tbl_zone.Select("code='" & Me.Code & "'"), DS.tbl_zoneRow())
            If dR.GetUpperBound(0) = -1 Then
                Return Nothing
            Else
                Return dR(0)
            End If
        End Function
    End Class
End Class

