0

how can i generate and download database report using itextsharp

Public Class GenerateCMR
    Public Function Generate(CMRGUID As String) As Panel
        Dim panel1 As New Panel

        Dim cmrb As New CMR
        cmrb = cmrb.GetCMR(CMRGUID.ToString)

        Dim dvtitle As New HtmlGenericControl("div")
        dvtitle.InnerHtml = "<h1>Compliance Monitoring Report (CMR)</h1><div style='text-align:center; font-size:20pt; font-weight:bold;'><u>" + cmrb.ProponentName.ToString.ToUpper + "</u><br/><span style='font-size:16pt;'>" + cmrb.ProponentAddress.ToString + "<br/>(Proponent)</span></div><br/><div style='font-size:16pt; text-align:left; font-weight:bold;'>MONITORING PERIOD COVERED: " + cmrb.MonPeriodDesc.ToString + " " + cmrb.MonYear.ToString + " (" + cmrb.MonPeriodSem.ToString + " " + cmrb.MonYear.ToString + ")</div>"
        dvtitle.Style.Add("padding", "5px")
        dvtitle.Style.Add("text-align", "center")

        dvtitle.InnerHtml += "<div style='text-align:left; font-size:16pt; font-weight:bold; padding-top:10px;'>I. Basic Project Information</div>"
        panel1.Controls.Add(dvtitle)

        Dim dvBasic As New HtmlGenericControl("div")
        dvBasic.Style.Add("padding", "20px")
        Dim tBasic As New Table
        tBasic.Style.Add("font-size", "12pt")
        tBasic.Width = Unit.Percentage(100)
        tBasic.CellPadding = 5

        For i As Integer = 0 To 11
            Dim r As New TableRow
            r.VerticalAlign = VerticalAlign.Top
            Dim c As New TableCell
            c.Font.Bold = True
            Dim c1 As New TableCell
            Select Case i
                Case 0
                    c.Text = "ECC Reference No."
                    c1.Text = cmrb.ECCNo.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 1
                    c.Text = "Project Title"
                    c1.Text = cmrb.ProjectTitle.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 2
                    c.Text = "Project Type"
                    c1.Text = cmrb.ProjectType.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 3
                    c.Text = "Location"
                    c1.Text = cmrb.Location.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 4
                    c.Text = "Project Stage/Phase"
                    c1.Text = cmrb.ProjectStage.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 5
                    c.Text = "Contact Person"
                    c1.Text = cmrb.ContactPerson.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")

                Case 6
                    c.Text = "Contact Numbers"
                    c1.Text = cmrb.ContactNo.ToString
                    c1.Style.Add("border-bottom", "Solid 1px Black")
                Case 7
                    c.Text = "EMP Approval"

                    Dim taprvl As New Table
                    Dim rapvl As New TableRow
                    Dim capvl As New TableCell

                    Dim chk As New HtmlInputCheckBox
                    chk.Checked = cmrb.EMPAprvlDuringECCApp
                    chk.Disabled = True
                    capvl.Controls.Add(chk)
                    rapvl.Cells.Add(capvl)

                    Dim capvll As New TableCell
                    capvll.Text = "During ECC Application Stage"
                    rapvl.Cells.Add(capvll)


                    taprvl.Rows.Add(rapvl)

                    Dim rapvl1 As New TableRow
                    Dim capvl1 As New TableCell

                    Dim chk1 As New HtmlInputCheckBox
                    chk1.Checked = cmrb.EMPAprvlAfterECCIssued
                    chk1.Disabled = True


                    capvl1.Controls.Add(chk1)
                    rapvl1.Cells.Add(capvl1)

                    Dim capvll1 As New TableCell
                    capvll1.Text = "Updated after ECC Issuance, approved on <u><span style='width:200px;'>" + cmrb.ApprovedOn.ToString + "</span></u>"
                    rapvl1.Cells.Add(capvll1)

                    taprvl.Rows.Add(rapvl1)


                    c1.Controls.Add(taprvl)
                Case 8
                    c.Text = "Project Description:"
                Case 9
                    c.Text = cmrb.ProjectDesc.ToString
                    c.Font.Bold = False
                    c.HorizontalAlign = HorizontalAlign.Justify
                    c.Font.Underline = True
                    c.ColumnSpan = 2

                Case 10
                    c.Text = "Changes in Project Desing (if any):"
                Case 11
                    c.Text = cmrb.ChangesInDesign.ToString
                    c.Font.Bold = False
                    c.HorizontalAlign = HorizontalAlign.Justify
                    c.Font.Underline = True
                    c.ColumnSpan = 2

                Case 10
            End Select

            r.Cells.Add(c)
            r.Cells.Add(c1)
            tBasic.Rows.Add(r)
        Next

        dvBasic.Controls.Add(tBasic)
        panel1.Controls.Add(dvBasic)


        'geographical coordinates
        Dim dvGeotitle As New HtmlGenericControl("div")
        dvGeotitle.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>a. Project Area Geo-Coordinates</div>"
        panel1.Controls.Add(dvGeotitle)

        Dim dvgeo As New HtmlGenericControl("div")
        dvgeo.Style.Add("padding", "20px")

        Dim np As New CMRPoint
        Dim ds As DataSet = np.GetCoor("Project Area", CMRGUID.ToString)

        Dim ta As New Table
        ta.CellSpacing = 0
        ta.Style.Add("font-size", "12pt")
        ta.Width = Unit.Percentage(100)
        ta.CellPadding = 5
        Dim rh As New TableRow
        For i As Integer = 0 To 2
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Area"
                Case 1
                    c.Text = "Latitude"
                    c.Width = Unit.Percentage(20)
                Case 2
                    c.Text = "Longitude"
                    c.Width = Unit.Percentage(20)

            End Select
            rh.Cells.Add(c)

        Next
        ta.Rows.Add(rh)
        Dim AreaDesc As String = String.Empty
        For Each dr As DataRow In ds.Tables(0).Rows
            Dim r As New TableRow
            If Not String.IsNullOrEmpty(dr("Latitude").ToString) Then
                For i As Integer = 0 To 2
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")
                    Select Case i
                        Case 0
                            If AreaDesc = dr("Area").ToString Then
                                c.Text = String.Empty
                            Else
                                c.Text = dr("Area").ToString

                            End If
                        Case 1
                            c.Text = dr("Latitude").ToString

                        Case 2
                            c.Text = dr("Longitude").ToString
                    End Select
                    r.Cells.Add(c)
                    AreaDesc = dr("Area").ToString
                Next
                ta.Rows.Add(r)

            End If
        Next
        dvgeo.Controls.Add(ta)
        panel1.Controls.Add(dvgeo)






        'buffer zzone
        Dim dvGeotitle1 As New HtmlGenericControl("div")
        dvGeotitle1.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>b. Project Buffer Zone</div>"
        panel1.Controls.Add(dvGeotitle1)

        Dim dvgeo1 As New HtmlGenericControl("div")
        dvgeo1.Style.Add("padding", "20px")

        ds = np.GetCoor("Buffer Zone", CMRGUID.ToString)

        Dim ta1 As New Table
        ta1.CellSpacing = 0
        ta1.Style.Add("font-size", "12pt")
        ta1.Width = Unit.Percentage(100)
        ta1.CellPadding = 5
        Dim rh1 As New TableRow
        For i As Integer = 0 To 2
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Area"
                Case 1
                    c.Text = "Latitude"
                    c.Width = Unit.Percentage(20)

                Case 2
                    c.Text = "Longitude"
                    c.Width = Unit.Percentage(20)
            End Select
            rh1.Cells.Add(c)

        Next
        ta1.Rows.Add(rh1)
        Dim AreaDesc1 As String = String.Empty
        For Each dr As DataRow In ds.Tables(0).Rows
            Dim r As New TableRow
            If Not String.IsNullOrEmpty(dr("Latitude").ToString) Then
                For i As Integer = 0 To 2
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")
                    Select Case i
                        Case 0
                            If AreaDesc = dr("Area").ToString Then
                                c.Text = String.Empty
                            Else
                                c.Text = dr("Area").ToString

                            End If
                        Case 1
                            c.Text = dr("Latitude").ToString
                        Case 2
                            c.Text = dr("Longitude").ToString
                    End Select
                    r.Cells.Add(c)
                    AreaDesc1 = dr("Area").ToString
                Next
                ta1.Rows.Add(r)

            End If
        Next
        dvgeo1.Controls.Add(ta1)
        panel1.Controls.Add(dvgeo1)




        'c. Carbon Sink/GHG Program Area Coordinates
        Dim dvGeotitle2 As New HtmlGenericControl("div")
        dvGeotitle2.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>c. Carbon Sink/GHG Program Area Coordinates</div>"
        panel1.Controls.Add(dvGeotitle2)

        Dim dvgeo2 As New HtmlGenericControl("div")
        dvgeo2.Style.Add("padding", "20px")

        ds = np.GetCoor("Program Area", CMRGUID.ToString)

        Dim ta2 As New Table
        ta2.CellSpacing = 0
        ta2.Style.Add("font-size", "12pt")
        ta2.Width = Unit.Percentage(100)
        ta2.CellPadding = 5
        Dim rh2 As New TableRow
        For i As Integer = 0 To 2
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Area"
                Case 1
                    c.Text = "Latitude"
                    c.Width = Unit.Percentage(20)

                Case 2
                    c.Text = "Longitude"
                    c.Width = Unit.Percentage(20)
            End Select
            rh2.Cells.Add(c)

        Next
        ta2.Rows.Add(rh2)
        Dim AreaDesc2 As String = String.Empty
        For Each dr As DataRow In ds.Tables(0).Rows
            Dim r As New TableRow
            If Not String.IsNullOrEmpty(dr("Latitude").ToString) Then
                For i As Integer = 0 To 2
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")
                    Select Case i
                        Case 0
                            If AreaDesc = dr("Area").ToString Then
                                c.Text = String.Empty
                            Else
                                c.Text = dr("Area").ToString

                            End If
                        Case 1
                            c.Text = dr("Latitude").ToString
                        Case 2
                            c.Text = dr("Longitude").ToString
                    End Select
                    r.Cells.Add(c)
                    AreaDesc2 = dr("Area").ToString
                Next
                ta2.Rows.Add(r)

            End If
        Next
        dvgeo2.Controls.Add(ta2)
        panel1.Controls.Add(dvgeo2)


        'ii executive summary
        Dim dvexeSum As New HtmlGenericControl("div")
        dvexeSum.Style.Add("padding", "5px")
        dvexeSum.InnerHtml = "<div style='text-align:left; font-size:16pt; font-weight:bold; padding-top:10px;'>II. EXECUTIVE SUMMARY</div>"

        dvexeSum.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>a. Summary of Major Findings for the Monitoring Period</div>"
        panel1.Controls.Add(dvexeSum)

        Dim dvSum As New HtmlGenericControl("div")
        dvSum.Style.Add("padding", "20px")


        Dim tanSum As New Table
        tanSum.CellSpacing = 0
        tanSum.Style.Add("font-size", "12pt")
        tanSum.Width = Unit.Percentage(100)
        tanSum.CellPadding = 5

        Dim rhnSum As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Condition / Requirement / Commitment"
                    c.Width = Unit.Percentage(25)

                Case 1
                    c.Text = "Compliance Status & Summary of Actions taken"
                    c.Width = Unit.Percentage(25)

                Case 2
                    c.Text = "Recommendation"
                    c.Width = Unit.Percentage(25)
                Case 3
                    c.Text = "Commitment for the Next Reporting Period"
                    c.Width = Unit.Percentage(25)
            End Select
            rhnSum.Cells.Add(c)

        Next
        tanSum.Rows.Add(rhnSum)

        Dim nSum As New CMRSummary
        Dim dsnSum As DataSet = nSum.getSummary(CMRGUID.ToString)
        Dim DescSum As String = String.Empty

        For Each dr As DataRow In dsnSum.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescSum = dr("Description").ToString Then
                                c.Text = String.Empty
                            Else
                                c.Text = dr("Description").ToString

                            End If
                        Case 1
                            c.Text = dr("CompStatus").ToString
                        Case 2
                            c.Text = dr("Recommendation").ToString
                        Case 3
                            c.Text = dr("Commitment").ToString
                    End Select
                    r.Cells.Add(c)
                    DescSum = dr("Description").ToString
                Next
                tanSum.Rows.Add(r)

            End If
        Next


        dvSum.Controls.Add(tanSum)
        panel1.Controls.Add(dvSum)


        'iii Results and Discussions

        Dim dvResDis As New HtmlGenericControl("div")
        dvResDis.Style.Add("padding", "5px")
        dvResDis.InnerHtml = "<div style='text-align:left; font-size:16pt; font-weight:bold; padding-top:10px;'>III. RESULTS AND DISCUSSIONS</div>"


        'a. compliance monitoring
        dvResDis.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>A. Compliance Monitoring</div>"

        'I. Project Description
        dvResDis.InnerHtml += "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>I. Status of Compliance to Project Description</div>"
        panel1.Controls.Add(dvResDis)


        Dim dvProjDesc As New HtmlGenericControl("div")
        dvProjDesc.Style.Add("padding", "20px")


        Dim tanProjDesc As New Table
        tanProjDesc.CellSpacing = 0
        tanProjDesc.Style.Add("font-size", "12pt")
        tanProjDesc.Width = Unit.Percentage(100)
        tanProjDesc.CellPadding = 5

        Dim rhnProjDesc As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Requirement"
                    c.Width = Unit.Percentage(20)

                Case 1
                    c.Text = "Description"
                    c.Width = Unit.Percentage(35)

                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(20)

                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(25)

            End Select
            rhnProjDesc.Cells.Add(c)

        Next
        tanProjDesc.Rows.Add(rhnProjDesc)

        Dim comp As New CMRCompliance
        Dim dsProjDesc As DataSet = comp.getCompliance(CMRGUID.ToString, "Project Description")
        Dim DescProjDesc As String = String.Empty

        For Each dr As DataRow In dsProjDesc.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescProjDesc = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else

                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescProjDesc = dr("Requirement").ToString
                Next
                tanProjDesc.Rows.Add(r)

            End If
        Next



        dvProjDesc.Controls.Add(tanProjDesc)
        panel1.Controls.Add(dvProjDesc)


        'II. ECC Condition
        Dim dvECCCon As New HtmlGenericControl("div")
        dvECCCon.Style.Add("padding", "5px")
        dvECCCon.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>II. Status of Compliance to ECC Conditions</div>"
        panel1.Controls.Add(dvECCCon)


        Dim dvnECCCon As New HtmlGenericControl("div")
        dvnECCCon.Style.Add("padding", "20px")


        Dim tanECCCon As New Table
        tanECCCon.CellSpacing = 0
        tanECCCon.Style.Add("font-size", "12pt")
        tanECCCon.Width = Unit.Percentage(100)
        tanECCCon.CellPadding = 5

        Dim rhnECCCon As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Requirement"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Description"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)

                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)

            End Select
            rhnECCCon.Cells.Add(c)

        Next
        tanECCCon.Rows.Add(rhnECCCon)


        Dim dsECCCon As DataSet = comp.getCompliance(CMRGUID.ToString, "ECC Condition")
        Dim DescECCCon As String = String.Empty

        For Each dr As DataRow In dsECCCon.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescECCCon = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")

                    End Select
                    r.Cells.Add(c)
                    DescECCCon = dr("Requirement").ToString
                Next
                tanECCCon.Rows.Add(r)

            End If
        Next



        dvnECCCon.Controls.Add(tanECCCon)
        panel1.Controls.Add(dvnECCCon)







        'III. EMP Condition
        Dim dvEMPCon As New HtmlGenericControl("div")
        dvEMPCon.Style.Add("padding", "5px")
        dvEMPCon.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>III. Status of Compliance to EMP Conditions</div>"
        panel1.Controls.Add(dvEMPCon)


        Dim dvnEMPCon As New HtmlGenericControl("div")
        dvnEMPCon.Style.Add("padding", "20px")


        Dim tanEMPCon As New Table
        tanEMPCon.CellSpacing = 0
        tanEMPCon.Style.Add("font-size", "12pt")
        tanEMPCon.Width = Unit.Percentage(100)
        tanEMPCon.CellPadding = 5

        Dim rhnEMPCon As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Impacts"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Mitigating Measures"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)
                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)
            End Select
            rhnEMPCon.Cells.Add(c)

        Next
        tanEMPCon.Rows.Add(rhnEMPCon)


        Dim dsEMPCon As DataSet = comp.getCompliance(CMRGUID.ToString, "EMP Condition")
        Dim DescEMPCon As String = String.Empty

        For Each dr As DataRow In dsEMPCon.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescEMPCon = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescEMPCon = dr("Requirement").ToString
                Next
                tanEMPCon.Rows.Add(r)

            End If
        Next



        dvnEMPCon.Controls.Add(tanEMPCon)
        panel1.Controls.Add(dvnEMPCon)




        'IV Annex B of ECC
        Dim dvAnnexB As New HtmlGenericControl("div")
        dvAnnexB.Style.Add("padding", "5px")
        dvAnnexB.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>IV. Status of Compliance to Annex B of ECC</div>"
        panel1.Controls.Add(dvAnnexB)


        Dim dvnAnnexB As New HtmlGenericControl("div")
        dvnAnnexB.Style.Add("padding", "20px")


        Dim tanAnnexB As New Table
        tanAnnexB.CellSpacing = 0
        tanAnnexB.Style.Add("font-size", "12pt")
        tanAnnexB.Width = Unit.Percentage(100)
        tanAnnexB.CellPadding = 5

        Dim rhnAnnexB As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Condition/Requirement"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Description"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)
                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)
            End Select
            rhnAnnexB.Cells.Add(c)

        Next
        tanAnnexB.Rows.Add(rhnAnnexB)


        Dim dsAnnexB As DataSet = comp.getCompliance(CMRGUID.ToString, "Annex B of ECC")
        Dim DescAnnexB As String = String.Empty

        For Each dr As DataRow In dsAnnexB.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescAnnexB = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescAnnexB = dr("Requirement").ToString
                Next
                tanAnnexB.Rows.Add(r)

            End If
        Next



        dvnAnnexB.Controls.Add(tanAnnexB)
        panel1.Controls.Add(dvnAnnexB)




        '6 SocPlan
        Dim dvSocPlan As New HtmlGenericControl("div")
        dvSocPlan.Style.Add("padding", "5px")
        dvSocPlan.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>V. Status of Compliance to Socia Development Plan (SDP)</div>"
        panel1.Controls.Add(dvSocPlan)


        Dim dvnSocPlan As New HtmlGenericControl("div")
        dvnSocPlan.Style.Add("padding", "20px")


        Dim tanSocPlan As New Table
        tanSocPlan.CellSpacing = 0
        tanSocPlan.Style.Add("font-size", "12pt")
        tanSocPlan.Width = Unit.Percentage(100)
        tanSocPlan.CellPadding = 5

        Dim rhnSocPlan As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Condition/Requirement"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Description"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)
                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)
            End Select
            rhnSocPlan.Cells.Add(c)

        Next
        tanSocPlan.Rows.Add(rhnSocPlan)


        Dim dsSocPlan As DataSet = comp.getCompliance(CMRGUID.ToString, "SDP")
        Dim DescSocPlan As String = String.Empty

        For Each dr As DataRow In dsSocPlan.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescSocPlan = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescSocPlan = dr("Requirement").ToString
                Next
                tanSocPlan.Rows.Add(r)

            End If
        Next



        dvnSocPlan.Controls.Add(tanSocPlan)
        panel1.Controls.Add(dvnSocPlan)



        'VII IEC
        Dim dvIEC As New HtmlGenericControl("div")
        dvIEC.Style.Add("padding", "5px")
        dvIEC.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>VI. Status of Compliance to Information Education Communication (IEC)</div>"
        panel1.Controls.Add(dvIEC)


        Dim dvnIEC As New HtmlGenericControl("div")
        dvnIEC.Style.Add("padding", "20px")


        Dim tanIEC As New Table
        tanIEC.CellSpacing = 0
        tanIEC.Style.Add("font-size", "12pt")
        tanIEC.Width = Unit.Percentage(100)
        tanIEC.CellPadding = 5

        Dim rhnIEC As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Condition/Requirement"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Description"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)
                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)
            End Select
            rhnIEC.Cells.Add(c)

        Next
        tanIEC.Rows.Add(rhnIEC)


        Dim dsIEC As DataSet = comp.getCompliance(CMRGUID.ToString, "IEC")
        Dim DescIEC As String = String.Empty

        For Each dr As DataRow In dsIEC.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescIEC = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                ' c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescIEC = dr("Requirement").ToString
                Next
                tanIEC.Rows.Add(r)

            End If
        Next



        dvnIEC.Controls.Add(tanIEC)
        panel1.Controls.Add(dvnIEC)



        'VII ERP
        Dim dvERP As New HtmlGenericControl("div")
        dvERP.Style.Add("padding", "5px")
        dvERP.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>VII. Status of Compliance to Contingency/Emergency Response Plan or Equivalent Risk Management Plan.</div>"
        panel1.Controls.Add(dvERP)


        Dim dvnERP As New HtmlGenericControl("div")
        dvnERP.Style.Add("padding", "20px")


        Dim tanERP As New Table
        tanERP.CellSpacing = 0
        tanERP.Style.Add("font-size", "12pt")
        tanERP.Width = Unit.Percentage(100)
        tanERP.CellPadding = 5

        Dim rhnERP As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Condition/Requirement"
                    c.Width = Unit.Percentage(15)

                Case 1
                    c.Text = "Description"
                Case 2
                    c.Text = "Status of Compliance"
                    c.Width = Unit.Percentage(10)
                Case 3
                    c.Text = "Remarks"
                    c.Width = Unit.Percentage(35)
            End Select
            rhnERP.Cells.Add(c)

        Next
        tanERP.Rows.Add(rhnERP)


        Dim dsERP As DataSet = comp.getCompliance(CMRGUID.ToString, "ERP")
        Dim DescERP As String = String.Empty

        For Each dr As DataRow In dsERP.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Description").ToString) Then
                For i As Integer = 0 To 3
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescERP = dr("Requirement").ToString Then
                                c.Text = String.Empty
                            Else
                                Dim hlink As New HyperLink
                                hlink.Target = "_blank"
                                hlink.NavigateUrl = dr("FilePath").ToString
                                hlink.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                                c.Controls.Add(hlink)
                                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Description").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            If dr("Compliant") = True Then
                                c.Text = "Complied"
                            Else
                                c.Text = "Not Complied"

                            End If
                            'Dim chk As New CheckBox
                            'chk.Checked = dr("Compliant")
                            'chk.Text = "Complied"
                            'chk.Enabled = False
                            'c.HorizontalAlign = HorizontalAlign.Center
                            'c.Controls.Add(chk)

                        Case 3
                            c.Text = dr("Remarks").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescERP = dr("Requirement").ToString
                Next
                tanERP.Rows.Add(r)

            End If
        Next



        dvnERP.Controls.Add(tanERP)
        panel1.Controls.Add(dvnERP)




        'b. Impact Monitoring
        Dim dvResDisImpPrev As New HtmlGenericControl("div")
        dvResDisImpPrev.Style.Add("padding", "5px")

        dvResDisImpPrev.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>B. Impact Monitoring</div>"

        'I. Summary of Previous Monitoring
        dvResDisImpPrev.InnerHtml += "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>I. Summary of Previous Monitoring</div>"
        panel1.Controls.Add(dvResDisImpPrev)



        Dim dvnPrevMon As New HtmlGenericControl("div")
        dvnPrevMon.Style.Add("padding", "20px")


        Dim tanPrevMon As New Table
        tanPrevMon.CellSpacing = 0
        tanPrevMon.Style.Add("font-size", "12pt")
        tanPrevMon.Width = Unit.Percentage(100)
        tanPrevMon.CellPadding = 5

        Dim rhnPrevMon As New TableRow
        For i As Integer = 0 To 2
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em Black;")
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Findings/Issues"
                    c.Width = Unit.Percentage(30)

                Case 1
                    c.Text = "Recommendations"
                    c.Width = Unit.Percentage(35)
                Case 2
                    c.Text = "  Action Plan"
                    c.Width = Unit.Percentage(35)

            End Select
            rhnPrevMon.Cells.Add(c)

        Next
        tanPrevMon.Rows.Add(rhnPrevMon)

        Dim impMon As New ImpactMonPrev
        Dim dsPrevMon As DataSet = impMon.getSummary(CMRGUID.ToString)
        Dim DescPrevMon As String = String.Empty

        For Each dr As DataRow In dsPrevMon.Tables(0).Rows
            Dim r As New TableRow
            r.Style.Add("vertical-align", "top")

            If Not String.IsNullOrEmpty(dr("Findings").ToString) Then
                For i As Integer = 0 To 2
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em Black;")

                    Select Case i
                        Case 0
                            If DescPrevMon = dr("Findings").ToString Then
                                c.Text = String.Empty
                            Else
                                c.Text = dr("Findings").ToString.Replace(Environment.NewLine, "<br />")

                            End If
                        Case 1
                            c.Text = dr("Recommendations").ToString.Replace(Environment.NewLine, "<br />")
                        Case 2
                            c.Text = dr("ActionPlan").ToString.Replace(Environment.NewLine, "<br />")
                    End Select
                    r.Cells.Add(c)
                    DescPrevMon = dr("Findings").ToString
                Next
                tanPrevMon.Rows.Add(r)

            End If
        Next



        dvnPrevMon.Controls.Add(tanPrevMon)
        panel1.Controls.Add(dvnPrevMon)


        'b. Impact Monitoring
        Dim dvResDisImpCur As New HtmlGenericControl("div")
        dvResDisImpCur.Style.Add("padding", "5px")

        'II. Summary of Current Monitoring
        dvResDisImpCur.InnerHtml += "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>II. Current Monitoring and Findings<br/><br/>Table 2. Summary Status of Environmental Impact Management and Monitoring Plan Implementation</div>"
        panel1.Controls.Add(dvResDisImpCur)


        Dim dvMon As New HtmlGenericControl("div")


        'A. water monitoring ambient
        Dim dvWater As New HtmlGenericControl("div")
        dvWater.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-left:40px;'>A. Ambient Water Quality Monitoring</div>"
        dvMon.Controls.Add(dvWater)

        Dim dvWaterRes As New HtmlGenericControl("div")
        dvWaterRes.Style.Add("padding", "20px")


        Dim stations As New Station
        Dim dsm As DataSet = stations.getStations(CMRGUID.ToString, "Water", True)


        Dim tstat As New Table
        tstat.Width = Unit.Percentage(100)
        tstat.CellSpacing = 0
        tstat.CellPadding = 5

        Dim monObj As String = String.Empty
        For Each r As DataRow In dsm.Tables(0).Rows
            'row for station information
            If Not String.IsNullOrEmpty(r("Location").ToString) Then

                If monObj.ToString <> r("MonObjective").ToString Then
                    Dim drs As New TableRow
                    For i As Integer = 0 To 2
                        Dim cs As New TableCell
                        cs.Style.Add("border", "Solid 0.1em Black;")

                        Select Case i
                            Case 0
                                cs.Text = "<b>Monitoring Objective:</b><br/>" + r("MonObjective").ToString
                            Case 1
                                cs.Text = "<b>Environmental Aspect:</b><br/>" + r("EnviAspect").ToString
                            Case 2
                                cs.Text = "<b>Environmental Impact:</b><br/>" + r("EnviImpact").ToString

                        End Select
                        drs.Cells.Add(cs)
                    Next
                    tstat.Rows.Add(drs)

                    monObj = r("MonObjective").ToString
                End If



                'row for the monitoring results
                Dim rf As New TableRow
                Dim cf As New TableCell
                cf.Style.Add("border", "Solid 0.1em Black;")
                cf.ColumnSpan = 6

                'Dim dvStat As New HtmlGenericControl("div")

                'dvStat.InnerHtml =
                Dim hlink As New HyperLink
                hlink.Target = "_blank"
                hlink.NavigateUrl = r("FilePath").ToString
                hlink.Text = "<b>Location:</b> " + r("Location").ToString + "   <b>Geo-Coordinate</b>- Lat:" + r("Latitude").ToString + ", Long:" + r("Longitude").ToString
                'c.Text = dr("Requirement").ToString.Replace(Environment.NewLine, "<br />")
                cf.Controls.Add(hlink)

                Dim tmr As New Table
                tmr.CellPadding = 5
                tmr.CellSpacing = 0
                tmr.Width = Unit.Percentage(100)
                Dim rhmr As New TableRow
                rhmr.HorizontalAlign = HorizontalAlign.Center
                For i As Integer = 0 To 7
                    Dim cmr As New TableCell
                    cmr.Style.Add("border", "Solid 0.1em Black;")
                    cmr.Font.Bold = True
                    Select Case i
                        Case 0
                            cmr.Text = "Parameter"
                            cmr.Width = Unit.Percentage(30)
                            cmr.HorizontalAlign = HorizontalAlign.Left
                        Case 1
                            cmr.Text = "Period"
                            cmr.Width = Unit.Percentage(8)
                        Case 2
                            cmr.Text = "Baseline"
                            cmr.Width = Unit.Percentage(8)
                        Case 3
                            cmr.Text = "Result"
                            cmr.Width = Unit.Percentage(8)
                        Case 4
                            cmr.Text = "Standard"
                            cmr.Width = Unit.Percentage(8)
                        Case 5
                            cmr.Text = "Within Standard"
                            cmr.Width = Unit.Percentage(12)
                        Case 6
                            cmr.Text = "EQPL"
                        Case 7
                            cmr.Text = "Remarks"
                            cmr.HorizontalAlign = HorizontalAlign.Left


                    End Select

                    rhmr.Cells.Add(cmr)
                Next

                tmr.Rows.Add(rhmr)

                Dim mRes As New MonResult
                Dim dsms = mRes.getMonResult(r("GUID").ToString)
                For Each drms As DataRow In dsms.Rows
                    Dim rmr As New TableRow
                    For i As Integer = 0 To 7
                        Dim cmr As New TableCell
                        cmr.Style.Add("border", "Solid 0.1em Black;")
                        cmr.HorizontalAlign = HorizontalAlign.Center

                        Select Case i
                            Case 0
                                cmr.Text = drms("Param").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left

                            Case 1
                                cmr.Text = drms("MonPeriod").ToString
                            Case 2
                                cmr.Text = drms("Baseline").ToString
                            Case 3
                                cmr.Text = drms("ResultCur").ToString
                            Case 4
                                cmr.Text = drms("Standard").ToString
                            Case 5
                                cmr.Text = drms("WithinStandard").ToString
                            Case 6
                                cmr.Text = drms("EQPL").ToString
                            Case 7
                                cmr.Text = drms("Remarks").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left


                        End Select

                        rmr.Cells.Add(cmr)
                    Next


                    tmr.Rows.Add(rmr)
                Next


                cf.Controls.Add(tmr)
                rf.Cells.Add(cf)

                tstat.Rows.Add(rf)

            End If
        Next
        dvWaterRes.Controls.Add(tstat)
        dvMon.Controls.Add(dvWaterRes)




        'B. Water monitoring effluent
        Dim dvWaterEff As New HtmlGenericControl("div")
        dvWaterEff.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-left:40px;'>B. Effluent Water Quality Monitoring</div>"
        dvMon.Controls.Add(dvWaterEff)

        Dim dvWaterResEff As New HtmlGenericControl("div")
        dvWaterResEff.Style.Add("padding", "20px")


        Dim dsmEff As DataSet = stations.getStations(CMRGUID.ToString, "Water", False)


        Dim tStatEff As New Table
        tStatEff.Width = Unit.Percentage(100)
        tStatEff.CellSpacing = 0
        tStatEff.CellPadding = 5

        Dim monObjEff As String = String.Empty
        For Each r As DataRow In dsmEff.Tables(0).Rows
            'row for StationEff information
            If Not String.IsNullOrEmpty(r("Location").ToString) Then

                If monObjEff.ToString <> r("MonObjective").ToString Then
                    Dim drs As New TableRow
                    For i As Integer = 0 To 2
                        Dim cs As New TableCell
                        cs.Style.Add("border", "Solid 0.1em Black;")

                        Select Case i
                            Case 0
                                cs.Text = "<b>Monitoring Objective:</b><br/>" + r("MonObjective").ToString
                            Case 1
                                cs.Text = "<b>Environmental Aspect:</b><br/>" + r("EnviAspect").ToString
                            Case 2
                                cs.Text = "<b>Environmental Impact:</b><br/>" + r("EnviImpact").ToString

                        End Select
                        drs.Cells.Add(cs)
                    Next
                    tStatEff.Rows.Add(drs)

                    monObjEff = r("MonObjective").ToString
                End If



                'row for the monitoring results
                Dim rf As New TableRow
                Dim cf As New TableCell
                cf.Style.Add("border", "Solid 0.1em Black;")
                cf.ColumnSpan = 6

                Dim hlink As New HyperLink
                hlink.Target = "_blank"
                hlink.NavigateUrl = r("FilePath").ToString
                hlink.Text = "<b>Location:</b> " + r("Location").ToString + "   <b>Geo-Coordinate</b>- Lat:" + r("Latitude").ToString + ", Long:" + r("Longitude").ToString
                 cf.Controls.Add(hlink)


                Dim tmr As New Table
                tmr.CellPadding = 5
                tmr.CellSpacing = 0
                tmr.Width = Unit.Percentage(100)
                Dim rhmr As New TableRow
                rhmr.HorizontalAlign = HorizontalAlign.Center
                For i As Integer = 0 To 7
                    Dim cmr As New TableCell
                    cmr.Style.Add("border", "Solid 0.1em Black;")
                    cmr.Font.Bold = True
                    Select Case i
                        Case 0
                            cmr.Text = "Parameter"
                            cmr.Width = Unit.Percentage(30)
                            cmr.HorizontalAlign = HorizontalAlign.Left
                        Case 1
                            cmr.Text = "Period"
                            cmr.Width = Unit.Percentage(8)
                        Case 2
                            cmr.Text = "Baseline"
                            cmr.Width = Unit.Percentage(8)
                        Case 3
                            cmr.Text = "Result"
                            cmr.Width = Unit.Percentage(8)
                        Case 4
                            cmr.Text = "Standard"
                            cmr.Width = Unit.Percentage(8)
                        Case 5
                            cmr.Text = "Within Standard"
                            cmr.Width = Unit.Percentage(12)
                        Case 6
                            cmr.Text = "EQPL"
                        Case 7
                            cmr.Text = "Remarks"
                            cmr.HorizontalAlign = HorizontalAlign.Left


                    End Select

                    rhmr.Cells.Add(cmr)
                Next

                tmr.Rows.Add(rhmr)

                Dim mRes As New MonResult
                Dim dsmEffs = mRes.getMonResult(r("GUID").ToString)
                For Each drms As DataRow In dsmEffs.Rows
                    Dim rmr As New TableRow
                    For i As Integer = 0 To 7
                        Dim cmr As New TableCell
                        cmr.Style.Add("border", "Solid 0.1em Black;")
                        cmr.HorizontalAlign = HorizontalAlign.Center

                        Select Case i
                            Case 0
                                cmr.Text = drms("Param").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left

                            Case 1
                                cmr.Text = drms("MonPeriod").ToString
                            Case 2
                                cmr.Text = drms("Baseline").ToString
                            Case 3
                                cmr.Text = drms("ResultCur").ToString
                            Case 4
                                cmr.Text = drms("Standard").ToString
                            Case 5
                                cmr.Text = drms("WithinStandard").ToString
                            Case 6
                                cmr.Text = drms("EQPL").ToString
                            Case 7
                                cmr.Text = drms("Remarks").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left


                        End Select

                        rmr.Cells.Add(cmr)
                    Next


                    tmr.Rows.Add(rmr)
                Next


                cf.Controls.Add(tmr)
                rf.Cells.Add(cf)

                tStatEff.Rows.Add(rf)

            End If
        Next
        dvWaterResEff.Controls.Add(tStatEff)

        'water quality remarks
        Dim dvWaterRemarks As New HtmlGenericControl("div")
        dvWaterRemarks.InnerHtml = "<div style='padding-top:20px; padding-bottom:10px; font-weight:bold; '>Overall Remarks on Water Quality Monitoring</div>" + cmrb.WaterRemarks.ToString
        dvWaterResEff.Controls.Add(dvWaterRemarks)

        dvMon.Controls.Add(dvWaterResEff)



        'Charting for water
        dvMon.Controls.Add(GenerateChart(CMRGUID.ToString, "Water", True))
        dvMon.Controls.Add(GenerateChart(CMRGUID.ToString, "Water", False))


        'C. Air monitoring ambient
        Dim dvAir As New HtmlGenericControl("div")
        dvAir.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-left:40px;'>C. Ambient Air Quality Monitoring</div>"
        dvMon.Controls.Add(dvAir)

        Dim dvAirRes As New HtmlGenericControl("div")
        dvAirRes.Style.Add("padding", "20px")

        Dim dsmAir As DataSet = stations.getStations(CMRGUID.ToString, "Air", True)


        Dim tstatAir As New Table
        tstatAir.Width = Unit.Percentage(100)
        tstatAir.CellSpacing = 0
        tstatAir.CellPadding = 5

        Dim monObjAir As String = String.Empty
        For Each r As DataRow In dsmAir.Tables(0).Rows
            'row for station information
            If Not String.IsNullOrEmpty(r("Location").ToString) Then

                If monObjAir.ToString <> r("MonObjective").ToString Then
                    Dim drs As New TableRow
                    For i As Integer = 0 To 2
                        Dim cs As New TableCell
                        cs.Style.Add("border", "Solid 0.1em Black;")

                        Select Case i
                            Case 0
                                cs.Text = "<b>Monitoring Objective:</b><br/>" + r("MonObjective").ToString
                            Case 1
                                cs.Text = "<b>Environmental Aspect:</b><br/>" + r("EnviAspect").ToString
                            Case 2
                                cs.Text = "<b>Environmental Impact:</b><br/>" + r("EnviImpact").ToString

                        End Select
                        drs.Cells.Add(cs)
                    Next
                    tstatAir.Rows.Add(drs)

                    monObjAir = r("MonObjective").ToString
                End If



                'row for the monitoring results
                Dim rf As New TableRow
                Dim cf As New TableCell
                cf.Style.Add("border", "Solid 0.1em Black;")
                cf.ColumnSpan = 6

                Dim hlink As New HyperLink
                hlink.Target = "_blank"
                hlink.NavigateUrl = r("FilePath").ToString
                hlink.Text = "<b>Location:</b> " + r("Location").ToString + "   <b>Geo-Coordinate</b>- Lat:" + r("Latitude").ToString + ", Long:" + r("Longitude").ToString
                cf.Controls.Add(hlink)


                Dim tmr As New Table
                tmr.CellPadding = 5
                tmr.CellSpacing = 0
                tmr.Width = Unit.Percentage(100)
                Dim rhmr As New TableRow
                rhmr.HorizontalAlign = HorizontalAlign.Center
                For i As Integer = 0 To 7
                    Dim cmr As New TableCell
                    cmr.Style.Add("border", "Solid 0.1em Black;")
                    cmr.Font.Bold = True
                    Select Case i
                        Case 0
                            cmr.Text = "Parameter"
                            cmr.Width = Unit.Percentage(30)
                            cmr.HorizontalAlign = HorizontalAlign.Left
                        Case 1
                            cmr.Text = "Period"
                            cmr.Width = Unit.Percentage(8)
                        Case 2
                            cmr.Text = "Baseline"
                            cmr.Width = Unit.Percentage(8)
                        Case 3
                            cmr.Text = "Result"
                            cmr.Width = Unit.Percentage(8)
                        Case 4
                            cmr.Text = "Standard"
                            cmr.Width = Unit.Percentage(8)
                        Case 5
                            cmr.Text = "Within Standard"
                            cmr.Width = Unit.Percentage(12)
                        Case 6
                            cmr.Text = "EQPL"
                        Case 7
                            cmr.Text = "Remarks"
                            cmr.HorizontalAlign = HorizontalAlign.Left

                    End Select

                    rhmr.Cells.Add(cmr)
                Next

                tmr.Rows.Add(rhmr)

                Dim mRes As New MonResult
                Dim dsmAirs = mRes.getMonResult(r("GUID").ToString)
                For Each drms As DataRow In dsmAirs.Rows
                    Dim rmr As New TableRow
                    For i As Integer = 0 To 7
                        Dim cmr As New TableCell
                        cmr.Style.Add("border", "Solid 0.1em Black;")
                        cmr.HorizontalAlign = HorizontalAlign.Center

                        Select Case i
                            Case 0
                                cmr.Text = drms("Param").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left

                            Case 1
                                cmr.Text = drms("MonPeriod").ToString
                            Case 2
                                cmr.Text = drms("Baseline").ToString
                            Case 3
                                cmr.Text = drms("ResultCur").ToString
                            Case 4
                                cmr.Text = drms("Standard").ToString
                            Case 5
                                cmr.Text = drms("WithinStandard").ToString
                            Case 6
                                cmr.Text = drms("EQPL").ToString


                            Case 7
                                cmr.Text = drms("Remarks").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left


                        End Select

                        rmr.Cells.Add(cmr)
                    Next


                    tmr.Rows.Add(rmr)
                Next


                cf.Controls.Add(tmr)
                rf.Cells.Add(cf)

                tstatAir.Rows.Add(rf)

            End If
        Next
        dvAirRes.Controls.Add(tstatAir)
        dvMon.Controls.Add(dvAirRes)











        'C. Air monitoring ambient
        Dim dvAirEff As New HtmlGenericControl("div")
        dvAirEff.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-left:40px;'>D. Effluent Air Quality Monitoring</div>"
        dvMon.Controls.Add(dvAirEff)

        Dim dvAirResEff As New HtmlGenericControl("div")
        dvAirResEff.Style.Add("padding", "20px")

        Dim dsmAirEff As DataSet = stations.getStations(CMRGUID.ToString, "Air", False)


        Dim tstatAirEff As New Table
        tstatAirEff.Width = Unit.Percentage(100)
        tstatAirEff.CellSpacing = 0
        tstatAirEff.CellPadding = 5

        Dim monObjAirEff As String = String.Empty
        For Each r As DataRow In dsmAirEff.Tables(0).Rows
            'row for station information
            If Not String.IsNullOrEmpty(r("Location").ToString) Then

                If monObjAirEff.ToString <> r("MonObjective").ToString Then
                    Dim drs As New TableRow
                    For i As Integer = 0 To 2
                        Dim cs As New TableCell
                        cs.Style.Add("border", "Solid 0.1em Black;")

                        Select Case i
                            Case 0
                                cs.Text = "<b>Monitoring Objective:</b><br/>" + r("MonObjective").ToString
                            Case 1
                                cs.Text = "<b>Environmental Aspect:</b><br/>" + r("EnviAspect").ToString
                            Case 2
                                cs.Text = "<b>Environmental Impact:</b><br/>" + r("EnviImpact").ToString

                        End Select
                        drs.Cells.Add(cs)
                    Next
                    tstatAirEff.Rows.Add(drs)

                    monObjAirEff = r("MonObjective").ToString
                End If



                'row for the monitoring results
                Dim rf As New TableRow
                Dim cf As New TableCell
                cf.Style.Add("border", "Solid 0.1em Black;")
                cf.ColumnSpan = 6

                Dim dvStat As New HtmlGenericControl("div")

                dvStat.InnerHtml = "<b>Location:</b> " + r("Location").ToString + "   <b>Geo-Coordinate</b>- Lat:" + r("Latitude").ToString + ", Long:" + r("Longitude").ToString
                cf.Controls.Add(dvStat)

                Dim tmr As New Table
                tmr.CellPadding = 5
                tmr.CellSpacing = 0
                tmr.Width = Unit.Percentage(100)
                Dim rhmr As New TableRow
                rhmr.HorizontalAlign = HorizontalAlign.Center
                For i As Integer = 0 To 7
                    Dim cmr As New TableCell
                    cmr.Style.Add("border", "Solid 0.1em Black;")
                    cmr.Font.Bold = True
                    Select Case i
                        Case 0
                            cmr.Text = "Parameter"
                            cmr.Width = Unit.Percentage(30)
                            cmr.HorizontalAlign = HorizontalAlign.Left
                        Case 1
                            cmr.Text = "Period"
                            cmr.Width = Unit.Percentage(8)
                        Case 2
                            cmr.Text = "Baseline"
                            cmr.Width = Unit.Percentage(8)
                        Case 3
                            cmr.Text = "Result"
                            cmr.Width = Unit.Percentage(8)
                        Case 4
                            cmr.Text = "Standard"
                            cmr.Width = Unit.Percentage(8)
                        Case 5
                            cmr.Text = "Within Standard"
                            cmr.Width = Unit.Percentage(12)
                        Case 6
                            cmr.Text = "EQPL"
                        Case 7
                            cmr.Text = "Remarks"
                            cmr.HorizontalAlign = HorizontalAlign.Left


                    End Select

                    rhmr.Cells.Add(cmr)
                Next

                tmr.Rows.Add(rhmr)

                Dim mRes As New MonResult
                Dim dsmAirEffs = mRes.getMonResult(r("GUID").ToString)
                For Each drms As DataRow In dsmAirEffs.Rows
                    Dim rmr As New TableRow
                    For i As Integer = 0 To 7
                        Dim cmr As New TableCell
                        cmr.Style.Add("border", "Solid 0.1em Black;")
                        cmr.HorizontalAlign = HorizontalAlign.Center

                        Select Case i
                            Case 0
                                cmr.Text = drms("Param").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left

                            Case 1
                                cmr.Text = drms("MonPeriod").ToString
                            Case 2
                                cmr.Text = drms("Baseline").ToString
                            Case 3
                                cmr.Text = drms("ResultCur").ToString
                            Case 4
                                cmr.Text = drms("Standard").ToString
                            Case 5
                                cmr.Text = drms("WithinStandard").ToString
                            Case 6
                                cmr.Text = drms("EQPL").ToString
                            Case 7
                                cmr.Text = drms("Remarks").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left


                        End Select

                        rmr.Cells.Add(cmr)
                    Next


                    tmr.Rows.Add(rmr)
                Next


                cf.Controls.Add(tmr)
                rf.Cells.Add(cf)

                tstatAirEff.Rows.Add(rf)

            End If
        Next
        dvAirResEff.Controls.Add(tstatAirEff)



        'Air quality remarks
        Dim dvAirRemarks As New HtmlGenericControl("div")
        dvAirRemarks.InnerHtml = "<div style='padding-top:20px; padding-bottom:10px; font-weight:bold; '>Overall Remarks on Air Quality Monitoring</div>" + cmrb.AirRemarks.ToString
        dvAirResEff.Controls.Add(dvAirRemarks)
        dvMon.Controls.Add(dvAirResEff)


        'Charting for Air
        dvMon.Controls.Add(GenerateChart(CMRGUID.ToString, "Air", True))
        dvMon.Controls.Add(GenerateChart(CMRGUID.ToString, "Air", False))


        panel1.Controls.Add(dvMon)











        'C. Noise monitoring ambient
        Dim dvNoiseEff As New HtmlGenericControl("div")
        dvNoiseEff.InnerHtml = "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-left:40px;'>E. Noise Level Monitoring</div>"
        dvMon.Controls.Add(dvNoiseEff)

        Dim dvNoiseResEff As New HtmlGenericControl("div")
        dvNoiseResEff.Style.Add("padding", "20px")

        Dim dsmNoiseEff As DataSet = stations.getStations(CMRGUID.ToString, "Noise", False)


        Dim tstatNoiseEff As New Table
        tstatNoiseEff.Width = Unit.Percentage(100)
        tstatNoiseEff.CellSpacing = 0
        tstatNoiseEff.CellPadding = 5

        Dim monObjNoiseEff As String = String.Empty
        For Each r As DataRow In dsmNoiseEff.Tables(0).Rows
            'row for station information
            If Not String.IsNullOrEmpty(r("Location").ToString) Then

                If monObjNoiseEff.ToString <> r("MonObjective").ToString Then
                    Dim drs As New TableRow
                    For i As Integer = 0 To 2
                        Dim cs As New TableCell
                        cs.Style.Add("border", "Solid 0.1em Black;")

                        Select Case i
                            Case 0
                                cs.Text = "<b>Monitoring Objective:</b><br/>" + r("MonObjective").ToString
                            Case 1
                                cs.Text = "<b>Environmental Aspect:</b><br/>" + r("EnviAspect").ToString
                            Case 2
                                cs.Text = "<b>Environmental Impact:</b><br/>" + r("EnviImpact").ToString

                        End Select
                        drs.Cells.Add(cs)
                    Next
                    tstatNoiseEff.Rows.Add(drs)

                    monObjNoiseEff = r("MonObjective").ToString
                End If



                'row for the monitoring results
                Dim rf As New TableRow
                Dim cf As New TableCell
                cf.Style.Add("border", "Solid 0.1em Black;")
                cf.ColumnSpan = 6

                Dim hlink As New HyperLink
                hlink.Target = "_blank"
                hlink.NavigateUrl = r("FilePath").ToString
                hlink.Text = "<b>Location:</b> " + r("Location").ToString + "   <b>Geo-Coordinate</b>- Lat:" + r("Latitude").ToString + ", Long:" + r("Longitude").ToString
                cf.Controls.Add(hlink)


                Dim tmr As New Table
                tmr.CellPadding = 5
                tmr.CellSpacing = 0
                tmr.Width = Unit.Percentage(100)
                Dim rhmr As New TableRow
                rhmr.HorizontalAlign = HorizontalAlign.Center
                For i As Integer = 0 To 7
                    Dim cmr As New TableCell
                    cmr.Style.Add("border", "Solid 0.1em Black;")
                    cmr.Font.Bold = True
                    Select Case i
                        Case 0
                            cmr.Text = "Parameter"
                            cmr.Width = Unit.Percentage(30)
                            cmr.HorizontalAlign = HorizontalAlign.Left
                        Case 1
                            cmr.Text = "Period"
                            cmr.Width = Unit.Percentage(8)
                        Case 2
                            cmr.Text = "Baseline"
                            cmr.Width = Unit.Percentage(8)
                        Case 3
                            cmr.Text = "Result"
                            cmr.Width = Unit.Percentage(8)
                        Case 4
                            cmr.Text = "Standard"
                            cmr.Width = Unit.Percentage(8)
                        Case 5
                            cmr.Text = "Within Standard"
                            cmr.Width = Unit.Percentage(12)
                        Case 6
                            cmr.Text = "EQPL"
                        Case 7
                            cmr.Text = "Remarks"
                            cmr.HorizontalAlign = HorizontalAlign.Left


                    End Select

                    rhmr.Cells.Add(cmr)
                Next

                tmr.Rows.Add(rhmr)

                Dim mRes As New MonResult
                Dim dsmNoiseEffs = mRes.getMonResult(r("GUID").ToString)
                For Each drms As DataRow In dsmNoiseEffs.Rows
                    Dim rmr As New TableRow
                    For i As Integer = 0 To 7
                        Dim cmr As New TableCell
                        cmr.Style.Add("border", "Solid 0.1em Black;")
                        cmr.HorizontalAlign = HorizontalAlign.Center

                        Select Case i
                            Case 0
                                cmr.Text = drms("Param").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left

                            Case 1
                                cmr.Text = drms("MonPeriod").ToString
                            Case 2
                                cmr.Text = drms("Baseline").ToString
                            Case 3
                                cmr.Text = drms("ResultCur").ToString
                            Case 4
                                cmr.Text = drms("Standard").ToString
                            Case 5
                                cmr.Text = drms("WithinStandard").ToString
                            Case 6
                                cmr.Text = drms("EQPL").ToString
                            Case 7
                                cmr.Text = drms("Remarks").ToString
                                cmr.HorizontalAlign = HorizontalAlign.Left


                        End Select

                        rmr.Cells.Add(cmr)
                    Next


                    tmr.Rows.Add(rmr)
                Next


                cf.Controls.Add(tmr)
                rf.Cells.Add(cf)

                tstatNoiseEff.Rows.Add(rf)

            End If
        Next
        dvNoiseResEff.Controls.Add(tstatNoiseEff)



        'Noise quality remarks
        Dim dvNoiseRemarks As New HtmlGenericControl("div")
        dvNoiseRemarks.InnerHtml = "<div style='padding-top:20px; padding-bottom:10px; font-weight:bold; '>Overall Remarks on Noise Level Monitoring</div>" + cmrb.NoiseRemarks.ToString
        dvNoiseResEff.Controls.Add(dvNoiseRemarks)
        dvMon.Controls.Add(dvNoiseResEff)


        'Charting for Noise
        dvMon.Controls.Add(GenerateChart(CMRGUID.ToString, "Noise", False))













        'Table 3    Budget Allocations and Expenses
        Dim dvBudget As New HtmlGenericControl("div")
        dvBudget.Style.Add("padding", "5px")
        dvBudget.InnerHtml += "<div style='text-align:left; font-size:12pt; font-weight:bold; padding-top:10px; padding-left:20px;'>Table 3. Report on Status of Environmental Budget Allocations and Expenses</div>"
        panel1.Controls.Add(dvBudget)


        Dim dvBudgetExp As New HtmlGenericControl("div")
        dvBudgetExp.Style.Add("padding", "20px")

        Dim texp As New Table
        texp.CellPadding = 5
        texp.CellSpacing = 0
        texp.Width = Unit.Percentage(100)

        Dim h1 As New TableRow
        For i As Integer = 0 To 2
            Dim c As New TableCell
            c.Font.Bold = True

            c.Style.Add("border", "Solid 0.1em black")
            c.HorizontalAlign = HorizontalAlign.Center
            Select Case i
                Case 0
                    c.Text = "Expense Item"
                    c.RowSpan = 2
                Case 1
                    c.Text = "Budget"
                    c.ColumnSpan = 2
                Case 2
                    c.Text = "Actual Expenses"
                    c.ColumnSpan = 2
            End Select

            h1.Cells.Add(c)


        Next
        texp.Rows.Add(h1)

        Dim h2 As New TableRow
        For i As Integer = 0 To 3
            Dim c As New TableCell
            c.Style.Add("border", "Solid 0.1em black")
            c.HorizontalAlign = HorizontalAlign.Center
            c.Font.Bold = True
            Select Case i
                Case 0
                    c.Text = "Direct from Co."
                Case 1
                    c.Text = "Budget for MMT"
                Case 2
                    c.Text = "Direct Co. Expense"
                Case 3
                    c.Text = "MMT Expense"
            End Select

            h2.Cells.Add(c)
        Next
        texp.Rows.Add(h2)

        Dim expPlans As New Expense
        Dim dsexp As DataSet = expPlans.GetExpense(CMRGUID.ToString, "ManPlans")
        Dim r1a As New TableRow
        Dim c1a As New TableCell
        c1a.Style.Add("border", "Solid 0.1em black")

        Dim bdco As Decimal = 0
        Dim bmmt As Decimal = 0
        Dim edco As Decimal = 0
        Dim emmt As Decimal = 0

        c1a.Text = "<b>A. Implementation of Management Plans & Programs</b>"
        c1a.ColumnSpan = 5
        r1a.Cells.Add(c1a)
        texp.Rows.Add(r1a)
        Dim z As Integer = 1
        For Each rexp As DataRow In dsexp.Tables(0).Rows

            If Not String.IsNullOrEmpty(rexp("ExpenseItem").ToString) Then
                Dim r As New TableRow
                For i As Integer = 0 To 4
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em black")
                    c.HorizontalAlign = HorizontalAlign.Center

                    Select Case i
                        Case 0
                            c.Text = z.ToString + ". " + rexp("ExpenseItem").ToString
                            c.HorizontalAlign = HorizontalAlign.Left

                        Case 1
                            c.Text = rexp("BudgetDirectCO").ToString
                            If IsNumeric(rexp("BudgetDirectCO")) Then
                                bdco += rexp("BudgetDirectCO")

                            End If
                        Case 2
                            c.Text = rexp("BudgetMMT").ToString
                            If IsNumeric(rexp("BudgetMMT")) Then
                                bmmt += rexp("BudgetMMT")
                            End If
                        Case 3
                            c.Text = rexp("ExpenseDirectCO").ToString
                            If IsNumeric(rexp("ExpenseDirectCO")) Then
                                edco += rexp("ExpenseDirectCO")
                            End If
                        Case 4
                            c.Text = rexp("ExpenseMMT").ToString
                            If IsNumeric(rexp("ExpenseMMT")) Then
                                emmt += rexp("ExpenseMMT")

                            End If

                    End Select
                    r.Cells.Add(c)
                Next

                texp.Rows.Add(r)
                z += 1

            End If

        Next
        z = 1

        dsexp = expPlans.GetExpense(CMRGUID.ToString, "MonPlans")
        Dim r1b As New TableRow
        Dim c1b As New TableCell
        c1b.Style.Add("border", "Solid 0.1em black")
        c1b.Text = "<b>B. Implementation of Monitoring Plans</b>"
        c1b.ColumnSpan = 5
        r1b.Cells.Add(c1b)
        texp.Rows.Add(r1b)

        For Each rexp As DataRow In dsexp.Tables(0).Rows
            If Not String.IsNullOrEmpty(rexp("ExpenseItem").ToString) Then
                Dim r As New TableRow
                For i As Integer = 0 To 4
                    Dim c As New TableCell
                    c.Style.Add("border", "Solid 0.1em black")
                    c.HorizontalAlign = HorizontalAlign.Center

                    Select Case i
                        Case 0
                            c.Text = z.ToString + ". " + rexp("ExpenseItem").ToString
                            c.HorizontalAlign = HorizontalAlign.Left

                        Case 1
                            c.Text = rexp("BudgetDirectCO").ToString
                            If IsNumeric(rexp("BudgetDirectCO")) Then
                                bdco += rexp("BudgetDirectCO")

                            End If
                        Case 2
                            c.Text = rexp("BudgetMMT").ToString
                            If IsNumeric(rexp("BudgetMMT")) Then
                                bmmt += rexp("BudgetMMT")
                            End If
                        Case 3
                            c.Text = rexp("ExpenseDirectCO").ToString
                            If IsNumeric(rexp("ExpenseDirectCO")) Then
                                edco += rexp("ExpenseDirectCO")
                            End If
                        Case 4
                            c.Text = rexp("ExpenseMMT").ToString
                            If IsNumeric(rexp("ExpenseMMT")) Then
                                emmt += rexp("ExpenseMMT")

                            End If

                    End Select
                    r.Cells.Add(c)
                Next

                texp.Rows.Add(r)
                z += 1

            End If
        Next

        Dim rexptot As New TableRow
        For i As Integer = 0 To 4
            Dim c As New TableCell
            c.HorizontalAlign = HorizontalAlign.Center
            c.Font.Bold = True
            c.Style.Add("border", "Solid 0.1em black")
            Select Case i
                Case 0
                    c.Text = "TOTAL"
                    c.HorizontalAlign = HorizontalAlign.Right
                Case 1
                    c.Text = bdco.ToString
                Case 2
                    c.Text = bmmt.ToString
                Case 3
                    c.Text = edco.ToString
                Case 4
                    c.Text = emmt.ToString

            End Select
            rexptot.Cells.Add(c)
        Next
        texp.Rows.Add(rexptot)
        dvBudgetExp.Controls.Add(texp)

        panel1.Controls.Add(dvBudgetExp)



        'iv conclusions and recommendations

        Dim dvconc As New HtmlGenericControl("div")
        dvconc.Style.Add("padding", "5px")
        dvconc.InnerHtml = "<div style='text-align:left; font-size:16pt; font-weight:bold; padding-top:10px;'>IV. CONCLUSIONS AND RECOMMENDATIONS</div>"

        'A. Compliance Status
        dvconc.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>A. Compliance Status</div>"
        panel1.Controls.Add(dvconc)

        Dim dvconcD As New HtmlGenericControl("div")
        dvconcD.Style.Add("padding-left", "20px")
        dvconcD.Style.Add("padding-right", "20px")
        dvconcD.InnerHtml = "<div style='border:Solid 1px black; padding:5px;'>" + cmrb.CompStatus.ToString.Replace(Environment.NewLine, "<br />") + "</div>"
        panel1.Controls.Add(dvconcD)


        'B. Environmental Quality Status (applicable only if EQPLs have been set by the Proponent as its commitment or if opted to be mutually agreed upon by Proponent with the EMB and other members of the MMT) 
        Dim dvconc1 As New HtmlGenericControl("div")
        dvconc1.Style.Add("padding", "5px")
        dvconc1.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>B. Environmental Quality Status (applicable only if EQPLs have been set by the Proponent as its commitment or if opted to be mutually agreed upon by Proponent with the EMB and other members of the MMT) </div>"
        panel1.Controls.Add(dvconc1)


        Dim dvconcD1 As New HtmlGenericControl("div")
        dvconcD1.Style.Add("padding-left", "20px")
        dvconcD1.Style.Add("padding-right", "20px")
        dvconcD1.InnerHtml = "<div style='border:Solid 1px black;  padding:5px;'>" + cmrb.EnviQuaStatus.ToString.Replace(Environment.NewLine, "<br />") + "</div>"
        panel1.Controls.Add(dvconcD1)


        'C. Environmental Management Plan Status
        Dim dvconc2 As New HtmlGenericControl("div")
        dvconc2.Style.Add("padding", "5px")
        dvconc2.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>C. Environmental Management Plan Status</div>"
        panel1.Controls.Add(dvconc2)


        Dim dvconcD2 As New HtmlGenericControl("div")
        dvconcD2.Style.Add("padding-left", "20px")
        dvconcD2.Style.Add("padding-right", "20px")
        dvconcD2.InnerHtml = "<div style='border:Solid 1px black; padding:5px;'>" + cmrb.EMPStatus.ToString.Replace(Environment.NewLine, "<br />") + "</div>"
        panel1.Controls.Add(dvconcD2)

        'D. Environmental Risk Categorization
        Dim dvconc3 As New HtmlGenericControl("div")
        dvconc3.Style.Add("padding", "5px")
        dvconc3.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>D. Environmental Risk Categorization</div>"
        panel1.Controls.Add(dvconc3)


        Dim dvconcD3 As New HtmlGenericControl("div")
        dvconcD3.Style.Add("padding-left", "20px")
        dvconcD3.Style.Add("padding-right", "20px")
        dvconcD3.InnerHtml = "<div style='border:Solid 1px black; padding:5px;'>" + cmrb.EnviRiskCat.ToString.Replace(Environment.NewLine, "<br />") + "</div>"
        panel1.Controls.Add(dvconcD3)


        'E. Work Plan for Next Monitoring Period
        Dim dvconc4 As New HtmlGenericControl("div")
        dvconc4.Style.Add("padding", "5px")
        dvconc4.InnerHtml += "<div style='text-align:left; font-size:13pt; font-weight:bold; padding-top:10px; padding-left:20px;'>E. Work Plan for Next Monitoring Period</div>"
        panel1.Controls.Add(dvconc4)


        Dim dvconcD4 As New HtmlGenericControl("div")
        dvconcD4.Style.Add("padding-left", "20px")
        dvconcD4.Style.Add("padding-right", "20px")
        dvconcD4.InnerHtml = "<div style='border:Solid 1px black; padding:5px;'>" + cmrb.WPNextMonPeriod.ToString.Replace(Environment.NewLine, "<br />") + "</div>"
        panel1.Controls.Add(dvconcD4)

        'V. Attachments
        Dim dvatta As New HtmlGenericControl("div")
        dvatta.Style.Add("padding", "5px")
        dvatta.InnerHtml = "<div style='text-align:left; font-size:16pt; font-weight:bold; padding-top:10px;'>V. ATTACHMENTS</div>"
        panel1.Controls.Add(dvatta)

        Dim att As New CMRAttachment
        Dim dsatt As DataSet = att.GetListTemp(CMRGUID.ToString)

        z = 1
        Dim dtatta As New Table
        For Each r As DataRow In dsatt.Tables(0).Rows
            If Not String.IsNullOrEmpty(r("Description").ToString) Then
                Dim dratta As New TableRow
                Dim catt As New TableCell
                Dim hlk As New HyperLink
                hlk.Text = z.ToString + ". " + r("Description").ToString
                hlk.NavigateUrl = r("FilePath").ToString

                hlk.Target = "_Blank"
                catt.Controls.Add(hlk)
                dratta.Cells.Add(catt)
                dtatta.Rows.Add(dratta)
                z += 1

            End If
        Next

        Dim dvattaD As New HtmlGenericControl("div")
        dvattaD.Style.Add("padding-bottom", "30px")
        dvattaD.Style.Add("padding-left", "20px")
        dvattaD.Style.Add("padding-right", "20px")
        dvattaD.Controls.Add(dtatta)
        panel1.Controls.Add(dvattaD)



        Return panel1
    End Function
    Private Function GenerateChart(CMRGUID As String, Category As String, Ambient As Boolean) As Table
        '1. Retrieve All station from CMR under given category and type (ambient)
        Dim stat As New Station
        Dim ds As DataSet = CType(stat.getCMRStations(CMRGUID.ToString, Category, Ambient), DataSet)
        Dim mRes As New MonResult

        '2. Loop through stations
        Dim tchart As New Table
        tchart.Width = Unit.Percentage(100)

        For Each dr As DataRow In ds.Tables(0).Rows

            Dim tr As New TableRow
            Dim tc As New TableCell
            tc.HorizontalAlign = HorizontalAlign.Center

            Dim nchart As New Chart
            nchart.Width = 1200

            Dim nchartA As New ChartArea
            nchart.ChartAreas.Add(nchartA)

            Dim lbl As New Label
            lbl.Text = "<div style='padding:5px; color:Black; font-size:xx-Large; font-weight:bold; text-alight:left;'>" + dr("Location").ToString + "</div><div>Latitude: " + dr("Latitude").ToString + "  Longitude : " + dr("Longitude").ToString + "</div>"

            Dim dt As DataTable = CType(mRes.getMonResult(dr("GUID").ToString), DataTable)

            Dim s As New Series
            s.ChartType = SeriesChartType.Bar
            Dim s1 As New Series
            s1.ChartType = SeriesChartType.Bar

            s.ChartArea = nchartA.Name
            s.IsValueShownAsLabel = True
            s.LegendText = "Quarter"
            s.IsVisibleInLegend = True


            s1.ChartArea = nchartA.Name
            s1.IsValueShownAsLabel = True
            s1.LegendText = "Standard"
            s1.IsVisibleInLegend = True
            s1.Color = Drawing.Color.Red

            For Each dr1 As DataRow In dt.Rows
                s.Points.AddXY(dr1("Param") + " (" + dr1("MonPeriod") + ")", dr1("ResultCur"))
                s1.Points.AddXY(dr1("Param") + " (" + dr1("MonPeriod") + ")", dr1("Standard"))

            Next


            nchart.Series.Add(s)
            nchart.Series.Add(s1)
            tc.Controls.Add(lbl)
            tc.Controls.Add(nchart)
            tr.Cells.Add(tc)
            tchart.Rows.Add(tr)

        Next
        Return tchart
    End Function

End Class
2
Contributors
1
Reply
16
Views
1 Year
Discussion Span
Last Post by rproffitt
1

Try to avoid many thousand long code dumps. Your question is one thing but where do you think there is a problem in that code? Surely it's not in all functions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.