Public Class Report_Graph

#Region "data Base 변경여부및 적용방법"

    '''변경된내용을적용한다.
    Public Overrides Function AcceptChanged() As Boolean

        Return True
    End Function

    '''변경된내용이있다면 취소한다.
    Public Overrides Function RejectChanged() As Boolean

        Return True
    End Function

    '''데이터에변형이있었는가?
    Public Overrides Function HasChanged() As Boolean
        Return False
    End Function

#End Region


    Private Sub Frm_v20091231_Result_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.DSR.TReqUse.Merge(DSETR1.TReqUse)
        MakeGraphTable()
        Me.ReportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth
        Me.ReportViewer1.ZoomPercent = 100
        Me.ReportViewer1.RefreshReport()
    End Sub
    Private Sub MakeGraphTable()
        If DSR.TReqUse.Rows.Count < 1 Then Return

        Dim Dr As DSR.Graph_ReqRow
        For Gubun As Short = 0 To 1
            For mon As Short = 1 To 12
                If Gubun = 0 Then   '//6번
                    Dr = Me.DSR.Graph_Req.NewGraph_ReqRow
                    Dr.Gubun = "난방에너지요구량"
                    Dr.Mon = Format(mon, "0") & "월"
                    Dr.Req = Result1.E요구량(mon).난방면적
                    Me.DSR.Graph_Req.Rows.Add(Dr)
                Else    '//11번
                    Dr = Me.DSR.Graph_Req.NewGraph_ReqRow
                    Dr.Gubun = "냉방에너지요구량"
                    Dr.Mon = Format(mon, "0") & "월"
                    Dr.Req = Result1.E요구량(mon).냉방면적
                    Me.DSR.Graph_Req.Rows.Add(Dr)
                End If
            Next
        Next

        '//연간에너지요구량및소요량
        '//Graph_requse gubun,type,
        '1차에너지소요량	에너지소요량	에너지요구량	
        '신재생에너지(-57)
        '난방에너지	106	91.87445415	56.14013248	
        '냉방에너지	155.3678094	119.8832527	40.83005443	
        '급탕에너지	42.6421498	14.21404993	14.6	
        '조명에너지	144.2220948	48.07403159	73.08380082	
        '환기에너지	61.68818331	20.56272777		

        Dim 신재생에너지 As Decimal
        Dim 난방에너지 As Decimal
        Dim 냉방에너지 As Decimal
        Dim 급탕에너지 As Decimal
        Dim 조명에너지 As Decimal
        Dim 환기에너지 As Decimal
        'Dim 합계 As Decimal


        Dim Dr2 As DSR.Graph_ReqUseRow
        For Gubun As Short = 0 To 3
            Select Case Gubun
                Case 0  '//1차에너지소요량

                    신재생에너지 = 0
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "신재생에너지"
                    Dr2.Req = 신재생에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    난방에너지 = Result1.일차E소요량(0).난방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "난방에너지"
                    Dr2.Req = 난방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    냉방에너지 = Result1.일차E소요량(0).냉방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "냉방에너지"
                    Dr2.Req = 냉방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    급탕에너지 = Result1.일차E소요량(0).급탕면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "급탕에너지"
                    Dr2.Req = 급탕에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    조명에너지 = Result1.일차E소요량(0).조명면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "조명에너지"
                    Dr2.Req = 조명에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    '계산결과!H92*3/계산결과!H27
                    환기에너지 = Result1.일차E소요량(0).환기면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "환기에너지"
                    Dr2.Req = 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "1차소요량"
                    Dr2.type = "합계"
                    Dr2.Req = 난방에너지 + 냉방에너지 + 급탕에너지 + 조명에너지 + 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)


                Case 1  '//에너지소요량

                    Dim Sum As Decimal = Result1.생산E(0).태양광전력생산량 / (Result1.일차E소요량(0).난방전력 + Result1.일차E소요량(0).냉방전력 + Result1.일차E소요량(0).급탕전력 + Result1.일차E소요량(0).조명전력 + Result1.일차E소요량(0).환기전력)
                    Dim 난방 As Decimal = Sum * Result1.일차E소요량(0).난방전력  '//아마게산이안도잇으니 여기값들이 0이잇을거에요.
                    Dim 냉방 As Decimal = Sum * Result1.일차E소요량(0).냉방전력
                    Dim 조명 As Decimal = Sum * Result1.일차E소요량(0).조명전력
                    Dim 급탕 As Decimal = Sum * Result1.일차E소요량(0).급탕전력
                    Dim 환기 As Decimal = Sum * Result1.일차E소요량(0).환기전력


                    Dim 난방면적 As Decimal = 0
                    Dim 냉방면적 As Decimal = 0
                    Dim 조명면적 As Decimal = 0
                    Dim 급탕면적 As Decimal = 0
                    Dim 환기면적 As Decimal = 0
                    If Result1.사용면적.H <> 0 Then
                        난방면적 = TOSG(IIf(난방 = 0, 0, 난방 / Result1.사용면적.H))
                    End If
                    If Result1.사용면적.C <> 0 Then
                        냉방면적 = TOSG(IIf(냉방 = 0, 0, 냉방 / Result1.사용면적.C))
                    End If
                    If Result1.사용면적.L <> 0 Then
                        조명면적 = TOSG(IIf(조명 = 0, 0, 조명 / Result1.사용면적.L))
                    End If
                    If Result1.사용면적.W <> 0 Then
                        급탕면적 = TOSG(IIf(급탕 = 0, 0, 급탕 / Result1.사용면적.W))
                    End If
                    If Result1.사용면적.V <> 0 Then
                        환기면적 = TOSG(IIf(환기 = 0, 0, 환기 / Result1.사용면적.V))
                    End If

                    Dim 면적 As Decimal = 난방면적 + 냉방면적 + 조명면적 + 급탕면적 + 환기면적

                    '=-SUM(계산결과!G108:G109)-계산결과!F42-계산결과!F48-계산결과!F51-계산결과!F56-계산결과!F59

                    'F42=IF($G$15=0,0,F38/$G$15)
                    'f38=(G104)/(SUM(H76:S76)+SUM(H85:S85)+SUM(H93:S93)+SUM(H97:S97)+SUM(H101:S101))*SUM(H76:S76)
                    'g15=난방면적

                    'f48=IF($G$20=0,0,F44/$G$20)
                    'f44=(G104)/(SUM(H76:S76)+SUM(H85:S85)+SUM(H93:S93)+SUM(H97:S97)+SUM(H101:S101))*SUM(H85:S85)
                    'g20=냉방면적


                    신재생에너지 = -1 * (Result1.생산E(0).면적당생산량태양열 + Result1.생산E(0).면적당생산량지열) - 면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "신재생에너지"
                    Dr2.Req = 신재생에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    난방에너지 = Result1.E소요량(0).난방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "난방에너지"
                    Dr2.Req = 난방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)


                    냉방에너지 = Result1.E소요량(0).냉방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "냉방에너지"
                    Dr2.Req = 냉방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)


                    급탕에너지 = Result1.E소요량(0).급탕면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "급탕에너지"
                    Dr2.Req = 급탕에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    조명에너지 = Result1.E소요량(0).조명면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "조명에너지"
                    Dr2.Req = 조명에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    환기에너지 = Result1.E소요량(0).환기면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "환기에너지"
                    Dr2.Req = 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "소요량"
                    Dr2.type = "합계"
                    Dr2.Req = 난방에너지 + 냉방에너지 + 급탕에너지 + 조명에너지 + 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)


                Case 2  '//에너지요구량


                    신재생에너지 = 0
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "신재생에너지"
                    Dr2.Req = 신재생에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    '계산결과!H14
                    난방에너지 = Result1.E요구량(0).난방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "난방에너지"
                    Dr2.Req = 난방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    냉방에너지 = Result1.E요구량(0).냉방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "냉방에너지"
                    Dr2.Req = 냉방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    '계산결과!H25
                    급탕에너지 = Result1.E요구량(0).급탕면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "급탕에너지"
                    Dr2.Req = 급탕에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    '계산결과!H22
                    조명에너지 = Result1.E요구량(0).조명면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "조명에너지"
                    Dr2.Req = 조명에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    환기에너지 = 0
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "환기에너지"
                    Dr2.Req = 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "요구량"
                    Dr2.type = "합계"
                    Dr2.Req = 난방에너지 + 냉방에너지 + 급탕에너지 + 조명에너지 + 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                Case 3  '//co2발생량

                    신재생에너지 = 0
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "신재생에너지"
                    Dr2.Req = 신재생에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    난방에너지 = Result1.Co2발생량(0).난방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "난방에너지"
                    Dr2.Req = 난방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    냉방에너지 = Result1.Co2발생량(0).냉방면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "냉방에너지"
                    Dr2.Req = 냉방에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    급탕에너지 = Result1.Co2발생량(0).급탕면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "급탕에너지"
                    Dr2.Req = 급탕에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    조명에너지 = Result1.Co2발생량(0).조명면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "조명에너지"
                    Dr2.Req = 조명에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    '계산결과!H92*3/계산결과!H27
                    환기에너지 = Result1.Co2발생량(0).환기면적
                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "환기에너지"
                    Dr2.Req = 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)

                    Dr2 = Me.DSR.Graph_ReqUse.NewGraph_ReqUseRow
                    Dr2.Gubun = "Co2발생량"
                    Dr2.type = "합계"
                    Dr2.Req = 난방에너지 + 냉방에너지 + 급탕에너지 + 조명에너지 + 환기에너지
                    Me.DSR.Graph_ReqUse.Rows.Add(Dr2)
            End Select
        Next

    End Sub


End Class