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("Resu

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.