Return to Snippet

Revision: 20766
at May 17, 2012 23:24 by staley412


Updated Code
Public Function loadStuff(ByVal start_index As Integer, ByVal stop_index As Integer, ByVal pageSize As Integer) As String
        Dim outStr As New System.Text.StringBuilder

        Try
            Dim i = 0
            Dim k = 0
            Dim rowStr As String
            Dim columnName As String
            Dim ResultsTBL As New HtmlTable
            Dim tr As New HtmlTableRow
            Dim tdStuffCount As New HtmlTableCell
            Dim tdStuffCount1 As New HtmlTableCell
            Dim tdStuffCount2 As New HtmlTableCell
            Dim tdManufacturer As New HtmlTableCell
            Dim tdPartNumber As New HtmlTableCell
            Dim tdDescription As New HtmlTableCell
            Dim tdBomSiteCount As New HtmlTableCell
            Dim tdInvSiteCount As New HtmlTableCell
            Dim tdEquipCount As New HtmlTableCell
            Dim tdObsolete As New HtmlTableCell
            Dim tdOIRDObs As New HtmlTableCell

            Dim outString As String
            Dim dv As DataView
            Dim totalPages As Integer
            Dim totalItems As Integer
            Dim curPage As Integer
            Dim stockFromBOM As String
            Dim stockFromWO As String
            Dim stockFromBOMCount As Integer
            Dim stockFromWOCount As Integer
            Dim filterSelected As String
            Dim filterPositiveValue As String

            dv = gBOM.modelSession.bomTable.DefaultView

            If (Not bomfilter = "retain filter") Then
                dv.RowFilter = bomfilter
            End If
            totalItems = dv.Count
            totalPages = Math.Ceiling(totalItems / pageSize)
            curPage = (start_index / pageSize) + 1
            gBOM.modelSession.curPageBom = curPage

            If sortColumn <> "" And Not sortColumn = Nothing Then
                gBOM.modelSession.bomSort = sortColumn
                gBOM.modelSession.bomOrder = IIf(sortDirection.ToUpper = "DESC", "DESC", "ASC")
            End If

            dv.Sort = gBOM.modelSession.bomSort & " " & gBOM.modelSession.bomOrder

            If stop_index > dv.Count - 1 Then
                stop_index = dv.Count - 1
            End If

            If dv.Count > 0 Then

                ResultsTBL.Attributes.Add("class", "dgFormat")
                ResultsTBL.Attributes.Add("cellspacing", "0")
                ResultsTBL.Attributes.Add("border", "0")
                ResultsTBL.Attributes.Add("rules", "rows")
                ResultsTBL.Attributes.Add("width", "97%")
                ResultsTBL.Style.Add("table-layout", "fixed")
                ResultsTBL.Attributes.Add("font-size", "7.5pt")
                ResultsTBL.Attributes.Add("font-weight", "bold")

                tdBOMCount.InnerHtml = "Relevancy" & IIf(gBOM.modelSession.bomSort = "bom_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdBOMCount.Attributes.Add("onclick", "sortData('bom','bom_count','" & IIf(gBOM.modelSession.bomSort = "bom_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdBOMCount.Style.Add("cursor", "pointer")
                tdBOMCount.Style.Add("font-size", "7.5pt")
                tdBOMCount.Style.Add("font-weight", "bold")
                tdBOMCount.Style.Add("width", "85px")

                tdManufacturer.InnerHtml = "Manufacturer" & IIf(gBOM.modelSession.bomSort = "s_manufacturer_key", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdManufacturer.Attributes.Add("onclick", "sortData('bom','s_manufacturer_key','" & IIf(gBOM.modelSession.bomSort = "s_manufacturer_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdManufacturer.Style.Add("cursor", "pointer")
                tdManufacturer.Style.Add("font-size", "7.5pt")
                tdManufacturer.Style.Add("font-weight", "bold")
                tdManufacturer.Style.Add("width", "100px")

                tdPartNumber.InnerHtml = "Part Number" & IIf(gBOM.modelSession.bomSort = "s_mpn_key", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdPartNumber.Attributes.Add("onclick", "sortData('bom','s_mpn_key','" & IIf(gBOM.modelSession.bomSort = "s_mpn_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdPartNumber.Style.Add("cursor", "pointer")
                tdPartNumber.Style.Add("font-size", "7.5pt")
                tdPartNumber.Style.Add("font-weight", "bold")
                tdPartNumber.Style.Add("width", "70px")

                tdDescription.InnerHtml = "Description" & IIf(gBOM.modelSession.bomSort = "description", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdDescription.Attributes.Add("onclick", "sortData('bom','description','" & IIf(gBOM.modelSession.bomSort = "description" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdDescription.Style.Add("cursor", "pointer")
                tdDescription.Style.Add("overflow", "hidden")
                tdDescription.Style.Add("font-size", "7.5pt")
                tdDescription.Style.Add("font-weight", "bold")
                tdDescription.Style.Add("width", "250px")

                tdBomSiteCount.InnerHtml = "BOM Site Count" & IIf(gBOM.modelSession.bomSort = "inv_site_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdBomSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdBomSiteCount.Style.Add("cursor", "pointer")
                tdBomSiteCount.Style.Add("font-size", "7.5pt")
                tdBomSiteCount.Style.Add("font-weight", "bold")
                tdBomSiteCount.Style.Add("width", "70px")

                tdInvSiteCount.InnerHtml = "Inventory Site Count" & IIf(gBOM.modelSession.bomSort = "inv_site_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdInvSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdInvSiteCount.Style.Add("cursor", "pointer")
                tdInvSiteCount.Style.Add("font-size", "7.5pt")
                tdInvSiteCount.Style.Add("font-weight", "bold")
                tdInvSiteCount.Style.Add("width", "70px")

                tdEquipCount.InnerHtml = "Equipment Count" & IIf(gBOM.modelSession.bomSort = "component_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdEquipCount.Attributes.Add("onclick", "sortData('bom','component_count','" & IIf(gBOM.modelSession.bomSort = "component_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdEquipCount.Style.Add("cursor", "pointer")
                tdEquipCount.Style.Add("font-size", "7.5pt")
                tdEquipCount.Style.Add("font-weight", "bold")
                tdEquipCount.Style.Add("width", "70px")

                tdObsolete.InnerHtml = "Obsolete" & IIf(gBOM.modelSession.bomSort = "obsolete", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdObsolete.Attributes.Add("onclick", "sortData('bom','obsolete','" & IIf(gBOM.modelSession.bomSort = "obsolete" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdObsolete.Style.Add("cursor", "pointer")
                tdObsolete.Style.Add("font-size", "7.5pt")
                tdObsolete.Style.Add("font-weight", "bold")
                tdObsolete.Style.Add("width", "70px")

                tdOIRDObs.InnerHtml = "OIRD Obsolete" & IIf(gBOM.modelSession.bomSort = "oird_replacement", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdOIRDObs.Attributes.Add("onclick", "sortData('bom','oird_replacement','" & IIf(gBOM.modelSession.bomSort = "oird_replacement" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdOIRDObs.Style.Add("cursor", "pointer")
                tdOIRDObs.Style.Add("font-size", "7.5pt")
                tdOIRDObs.Style.Add("font-weight", "bold")
                tdOIRDObs.Style.Add("width", "80px")



                tr.Cells.Add(tdBOMCount)
                tr.Cells.Add(tdManufacturer)
                tr.Cells.Add(tdPartNumber)
                tr.Cells.Add(tdDescription)
                tr.Cells.Add(tdBomSiteCount)
                tr.Cells.Add(tdInvSiteCount)
                tr.Cells.Add(tdEquipCount)
                tr.Cells.Add(tdObsolete)
                tr.Cells.Add(tdOIRDObs)
                tr.Attributes.Add("class", "poms_title_back_candy")

                ResultsTBL.Rows.Add(tr)

                Dim aryData As New ArrayList

                For i = start_index To stop_index
                    Dim classString As String = ""

                    tr = New HtmlTableRow
                    tdBOMCount = New HtmlTableCell
                    tdBOMCount1 = New HtmlTableCell
                    tdManufacturer = New HtmlTableCell
                    tdPartNumber = New HtmlTableCell
                    tdDescription = New HtmlTableCell
                    tdBomSiteCount = New HtmlTableCell
                    tdInvSiteCount = New HtmlTableCell
                    tdEquipCount = New HtmlTableCell
                    tdObsolete = New HtmlTableCell
                    tdOIRDObs = New HtmlTableCell

                    If i Mod 2 = 0 Then
                        classString = "poms_even "
                    Else
                        classString = "poms_odd "
                    End If

                    'Color Bar for percent match of BOMs
                    Dim matchPercent As Double
                    Dim bgColor As String
                    Dim toolTip As String
                    Dim szTotalBOM As String
                    Dim totalBOM As Integer
                    Dim szBOMCount As String
                    Dim bomCount As Integer

                    bgColor = "#6699CC"

                    If (gBOM.modelSession.totalBOMTable.Rows.Count > 0) Then
                        szTotalBOM = gBOM.modelSession.totalBOMTable.Rows(0).Item("totalBOM")
                    Else
                        szTotalBOM = "0"
                    End If
                    totalBOM = CType(szTotalBOM, Integer)

                    szBOMCount = IIf(IsDBNull(dv(i).Item("bom_count")), "0", dv(i).Item("bom_count"))
                    bomCount = CType(szBOMCount, Integer)
                    matchPercent = ((bomCount / (IIf(totalBOM = 0, bomCount, totalBOM)))) * 100

                    If matchPercent = 0 Then
                        bgColor = "white"
                    End If
                    toolTip = gBOM.NullSafeString(dv(i).Item("bom_count")) + " out of " + totalBOM.ToString() + " BOM(s) "
                    toolTip += "contain this part matching the selected equipment's Manufacturer and Model Number."

                    tdBOMCount1.InnerHtml = "<td bgcolor=""" + bgColor + """ cellspacing=""0"" cellpadding=""0"" height=""10"""
                    tdBOMCount1.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
                    tdBOMCount1.InnerHtml += "width=" + matchPercent.ToString() + "%"">"
                    tdBOMCount2.InnerHtml = "<td bgcolor=""white"" cellspacing=""0"" cellpadding=""0"" height=""10"""
                    tdBOMCount2.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
                    tdBOMCount2.InnerHtml += "width=" + (100 - matchPercent).ToString() + "%"">"
                    tdBOMCount.InnerHtml += "<div onmouseover=""javascript:addTip(event);"" tiptext = """ & gBOM.tiptextSafeString(toolTip) & """><table cellspacing=""0"" cellpadding=""0"" "
                    tdBOMCount.InnerHtml += "height=""10"" width=""40"" style="" padding: 0;"
                    tdBOMCount.InnerHtml += "border:solid 1px black; "">"
                    tdBOMCount.InnerHtml += "<tr tiptext = """ & gBOM.tiptextSafeString(toolTip) & """>" & tdBOMCount1.InnerHtml() & tdBOMCount2.InnerHtml() & "</tr></table></div>"

                    tr.Cells.Add(tdBOMCount)
                    'End Color Bar for percent match BOMs

                    tdManufacturer.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("s_manufacturer_key"))) & """>" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "</div>"
                    tr.Cells.Add(tdManufacturer)

                    tdPartNumber.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("s_mpn_key"))) & """>" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "</div>"
                    tr.Cells.Add(tdPartNumber)

                    tdDescription.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("description"))) & """>" & gBOM.NullSafeString(dv(i).Item("description")) & "</div>"
                    tr.Cells.Add(tdDescription)

                    tdBomSiteCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadBomSiteCountPopup('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "','" & gBOM.NullSafeString(dv(i).Item("inv_site_count")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("inv_site_count")) + "</span>"
                    tr.Cells.Add(tdBomSiteCount)

                    tdInvSiteCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadInvSiteCountPopup('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "','" & gBOM.NullSafeString(dv(i).Item("inv_site_count")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("inv_site_count")) + "</span>"
                    tr.Cells.Add(tdInvSiteCount)

                    tdEquipCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadMatchingEquip('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("component_count")) + "</span>"
                    tr.Cells.Add(tdEquipCount)

                    If gBOM.NullSafeString(dv(i).Item("obsolete")) = "YES" Then
                        tdObsolete.InnerHtml = "<img src=""./../../images/redFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is OBSOLETE"" />"
                    Else
                        tdObsolete.InnerHtml = "<img src=""./../../images/greenFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is NOT OBSOLETE"" />"
                    End If
                    tr.Cells.Add(tdObsolete)

                    'Build link to RAPID
                    Dim tdOIRDsb As New System.Text.StringBuilder
                    With tdOIRDsb
                        .Append("<div class=""ellipsis""")

                        'Check if item is in rapid
                        If gBOM.NullSafeString(dv(i).Item("oird_replacement")) = "Y" Then
                            .Append(" class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'""  onclick=""")
                            'Check if user has a rapid account
                            If CType(Session("rkey"), String) <> Nothing Then
                                'User had rapid account, build URL for part
                                .Append("javascript:window.open('http://www.rapidpartsmart.com/rapid/")
                                .Append("ALogin.jsp?keyType=POMS&action=pomsShowSolution&rapid_numbers=")
                                .Append(gBOM.NullSafeString(dv(i).Item("db_id")))
                                .Append("&rKey=")
                                .Append(CType(Session("rkey"), String).Replace("&", "%26"))
                                .Append("'")
                                .Append(",'', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=1000,height=550');")
                                .Append("""")
                                .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
                                .Append(" tiptext=""Click to View Entry in OIRD"">")
                                .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
                            Else
                                'User does not have rapid account, build URL for rapid access request
                                .Append("javascript:window.open('/POMS/RequestAccess.aspx?src=POMS','', '');")
                                .Append("""")
                                .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
                                .Append(" tiptext=""Click to request RAPID access to view data"">")
                                .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
                            End If
                        Else
                            'There is no rapid data
                            .Append("tiptext=""No OIRD information available."">")
                            .Append("No OIRD information available.")
                        End If
                        .Append("</div>")
                    End With

                    tdOIRDObs.InnerHtml = tdOIRDsb.ToString
                    tr.Cells.Add(tdOIRDObs)

                    If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
                        classString = "from_bom_table" '  & classString
                    Else
                        classString = "from_wo_table" ' & classString
                    End If
                    tr.Attributes.Add("class", classString)

                    ResultsTBL.Rows.Add(tr)
                Next

                For i = 0 To (dv.Count - 1)
                    If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
                        stockFromBOMCount += 1
                    Else
                        stockFromWOCount += 1
                    End If
                Next

                stockFromBOM = stockFromBOMCount.ToString
                stockFromWO = stockFromWOCount.ToString

            Else

                stockFromBOM = ""
                stockFromWO = ""
            End If

            With outStr
                .Append("{status:""success""")
                .Append(",message:""")
                .Append("success")
                .Append(""",")
                .Append("table:""")
                .Append(gBOM.JsonSafeString(gBOM.controlHTML(ResultsTBL)))
                .Append(""",totalPages:""" & totalPages.ToString)
                .Append(""",totalItems:""" & totalItems.ToString)
                .Append(""",curPage:""" & curPage.ToString)
                .Append(""",stockFromBOM: """ & gBOM.JsonSafeString(stockFromBOM))
                .Append(""",stockFromWO: """ & gBOM.JsonSafeString(stockFromWO))
                .Append("""}")
            End With

            Return outStr.ToString

        Catch ex As Exception
            Throw
        End Try
    End Function

Revision: 20765
at November 24, 2009 14:43 by staley412


Initial Code
Public Function loadBOM(ByVal start_index As Integer, ByVal stop_index As Integer, ByVal pageSize As Integer) As String
        Dim outStr As New System.Text.StringBuilder

        Try
            Dim i = 0
            Dim k = 0
            Dim rowStr As String
            Dim columnName As String
            Dim ResultsTBL As New HtmlTable
            Dim tr As New HtmlTableRow
            Dim tdBOMCount As New HtmlTableCell
            Dim tdBOMCount1 As New HtmlTableCell
            Dim tdBOMCount2 As New HtmlTableCell
            Dim tdManufacturer As New HtmlTableCell
            Dim tdPartNumber As New HtmlTableCell
            Dim tdDescription As New HtmlTableCell
            Dim tdBomSiteCount As New HtmlTableCell
            Dim tdInvSiteCount As New HtmlTableCell
            Dim tdEquipCount As New HtmlTableCell
            Dim tdObsolete As New HtmlTableCell
            Dim tdOIRDObs As New HtmlTableCell

            Dim outString As String
            Dim dv As DataView
            Dim totalPages As Integer
            Dim totalItems As Integer
            Dim curPage As Integer
            Dim stockFromBOM As String
            Dim stockFromWO As String
            Dim stockFromBOMCount As Integer
            Dim stockFromWOCount As Integer
            Dim filterSelected As String
            Dim filterPositiveValue As String

            dv = gBOM.modelSession.bomTable.DefaultView

            If (Not bomfilter = "retain filter") Then
                dv.RowFilter = bomfilter
            End If
            totalItems = dv.Count
            totalPages = Math.Ceiling(totalItems / pageSize)
            curPage = (start_index / pageSize) + 1
            gBOM.modelSession.curPageBom = curPage

            If sortColumn <> "" And Not sortColumn = Nothing Then
                gBOM.modelSession.bomSort = sortColumn
                gBOM.modelSession.bomOrder = IIf(sortDirection.ToUpper = "DESC", "DESC", "ASC")
            End If

            dv.Sort = gBOM.modelSession.bomSort & " " & gBOM.modelSession.bomOrder

            If stop_index > dv.Count - 1 Then
                stop_index = dv.Count - 1
            End If

            If dv.Count > 0 Then

                ResultsTBL.Attributes.Add("class", "dgFormat")
                ResultsTBL.Attributes.Add("cellspacing", "0")
                ResultsTBL.Attributes.Add("border", "0")
                ResultsTBL.Attributes.Add("rules", "rows")
                ResultsTBL.Attributes.Add("width", "97%")
                ResultsTBL.Style.Add("table-layout", "fixed")
                ResultsTBL.Attributes.Add("font-size", "7.5pt")
                ResultsTBL.Attributes.Add("font-weight", "bold")

                tdBOMCount.InnerHtml = "Relevancy" & IIf(gBOM.modelSession.bomSort = "bom_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdBOMCount.Attributes.Add("onclick", "sortData('bom','bom_count','" & IIf(gBOM.modelSession.bomSort = "bom_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdBOMCount.Style.Add("cursor", "pointer")
                tdBOMCount.Style.Add("font-size", "7.5pt")
                tdBOMCount.Style.Add("font-weight", "bold")
                tdBOMCount.Style.Add("width", "85px")

                tdManufacturer.InnerHtml = "Manufacturer" & IIf(gBOM.modelSession.bomSort = "s_manufacturer_key", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdManufacturer.Attributes.Add("onclick", "sortData('bom','s_manufacturer_key','" & IIf(gBOM.modelSession.bomSort = "s_manufacturer_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdManufacturer.Style.Add("cursor", "pointer")
                tdManufacturer.Style.Add("font-size", "7.5pt")
                tdManufacturer.Style.Add("font-weight", "bold")
                tdManufacturer.Style.Add("width", "100px")

                tdPartNumber.InnerHtml = "Part Number" & IIf(gBOM.modelSession.bomSort = "s_mpn_key", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdPartNumber.Attributes.Add("onclick", "sortData('bom','s_mpn_key','" & IIf(gBOM.modelSession.bomSort = "s_mpn_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdPartNumber.Style.Add("cursor", "pointer")
                tdPartNumber.Style.Add("font-size", "7.5pt")
                tdPartNumber.Style.Add("font-weight", "bold")
                tdPartNumber.Style.Add("width", "70px")

                tdDescription.InnerHtml = "Description" & IIf(gBOM.modelSession.bomSort = "description", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdDescription.Attributes.Add("onclick", "sortData('bom','description','" & IIf(gBOM.modelSession.bomSort = "description" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdDescription.Style.Add("cursor", "pointer")
                tdDescription.Style.Add("overflow", "hidden")
                tdDescription.Style.Add("font-size", "7.5pt")
                tdDescription.Style.Add("font-weight", "bold")
                tdDescription.Style.Add("width", "250px")

                tdBomSiteCount.InnerHtml = "BOM Site Count" & IIf(gBOM.modelSession.bomSort = "inv_site_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdBomSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdBomSiteCount.Style.Add("cursor", "pointer")
                tdBomSiteCount.Style.Add("font-size", "7.5pt")
                tdBomSiteCount.Style.Add("font-weight", "bold")
                tdBomSiteCount.Style.Add("width", "70px")

                tdInvSiteCount.InnerHtml = "Inventory Site Count" & IIf(gBOM.modelSession.bomSort = "inv_site_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdInvSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdInvSiteCount.Style.Add("cursor", "pointer")
                tdInvSiteCount.Style.Add("font-size", "7.5pt")
                tdInvSiteCount.Style.Add("font-weight", "bold")
                tdInvSiteCount.Style.Add("width", "70px")

                tdEquipCount.InnerHtml = "Equipment Count" & IIf(gBOM.modelSession.bomSort = "component_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdEquipCount.Attributes.Add("onclick", "sortData('bom','component_count','" & IIf(gBOM.modelSession.bomSort = "component_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdEquipCount.Style.Add("cursor", "pointer")
                tdEquipCount.Style.Add("font-size", "7.5pt")
                tdEquipCount.Style.Add("font-weight", "bold")
                tdEquipCount.Style.Add("width", "70px")

                tdObsolete.InnerHtml = "Obsolete" & IIf(gBOM.modelSession.bomSort = "obsolete", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdObsolete.Attributes.Add("onclick", "sortData('bom','obsolete','" & IIf(gBOM.modelSession.bomSort = "obsolete" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdObsolete.Style.Add("cursor", "pointer")
                tdObsolete.Style.Add("font-size", "7.5pt")
                tdObsolete.Style.Add("font-weight", "bold")
                tdObsolete.Style.Add("width", "70px")

                tdOIRDObs.InnerHtml = "OIRD Obsolete" & IIf(gBOM.modelSession.bomSort = "oird_replacement", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
                tdOIRDObs.Attributes.Add("onclick", "sortData('bom','oird_replacement','" & IIf(gBOM.modelSession.bomSort = "oird_replacement" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
                tdOIRDObs.Style.Add("cursor", "pointer")
                tdOIRDObs.Style.Add("font-size", "7.5pt")
                tdOIRDObs.Style.Add("font-weight", "bold")
                tdOIRDObs.Style.Add("width", "80px")



                tr.Cells.Add(tdBOMCount)
                tr.Cells.Add(tdManufacturer)
                tr.Cells.Add(tdPartNumber)
                tr.Cells.Add(tdDescription)
                tr.Cells.Add(tdBomSiteCount)
                tr.Cells.Add(tdInvSiteCount)
                tr.Cells.Add(tdEquipCount)
                tr.Cells.Add(tdObsolete)
                tr.Cells.Add(tdOIRDObs)
                tr.Attributes.Add("class", "poms_title_back_candy")

                ResultsTBL.Rows.Add(tr)

                Dim aryData As New ArrayList

                For i = start_index To stop_index
                    Dim classString As String = ""

                    tr = New HtmlTableRow
                    tdBOMCount = New HtmlTableCell
                    tdBOMCount1 = New HtmlTableCell
                    tdManufacturer = New HtmlTableCell
                    tdPartNumber = New HtmlTableCell
                    tdDescription = New HtmlTableCell
                    tdBomSiteCount = New HtmlTableCell
                    tdInvSiteCount = New HtmlTableCell
                    tdEquipCount = New HtmlTableCell
                    tdObsolete = New HtmlTableCell
                    tdOIRDObs = New HtmlTableCell

                    If i Mod 2 = 0 Then
                        classString = "poms_even "
                    Else
                        classString = "poms_odd "
                    End If

                    'Color Bar for percent match of BOMs
                    Dim matchPercent As Double
                    Dim bgColor As String
                    Dim toolTip As String
                    Dim szTotalBOM As String
                    Dim totalBOM As Integer
                    Dim szBOMCount As String
                    Dim bomCount As Integer

                    bgColor = "#6699CC"

                    If (gBOM.modelSession.totalBOMTable.Rows.Count > 0) Then
                        szTotalBOM = gBOM.modelSession.totalBOMTable.Rows(0).Item("totalBOM")
                    Else
                        szTotalBOM = "0"
                    End If
                    totalBOM = CType(szTotalBOM, Integer)

                    szBOMCount = IIf(IsDBNull(dv(i).Item("bom_count")), "0", dv(i).Item("bom_count"))
                    bomCount = CType(szBOMCount, Integer)
                    matchPercent = ((bomCount / (IIf(totalBOM = 0, bomCount, totalBOM)))) * 100

                    If matchPercent = 0 Then
                        bgColor = "white"
                    End If
                    toolTip = gBOM.NullSafeString(dv(i).Item("bom_count")) + " out of " + totalBOM.ToString() + " BOM(s) "
                    toolTip += "contain this part matching the selected equipment's Manufacturer and Model Number."

                    tdBOMCount1.InnerHtml = "<td bgcolor=""" + bgColor + """ cellspacing=""0"" cellpadding=""0"" height=""10"""
                    tdBOMCount1.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
                    tdBOMCount1.InnerHtml += "width=" + matchPercent.ToString() + "%"">"
                    tdBOMCount2.InnerHtml = "<td bgcolor=""white"" cellspacing=""0"" cellpadding=""0"" height=""10"""
                    tdBOMCount2.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
                    tdBOMCount2.InnerHtml += "width=" + (100 - matchPercent).ToString() + "%"">"
                    tdBOMCount.InnerHtml += "<div onmouseover=""javascript:addTip(event);"" tiptext = """ & gBOM.tiptextSafeString(toolTip) & """><table cellspacing=""0"" cellpadding=""0"" "
                    tdBOMCount.InnerHtml += "height=""10"" width=""40"" style="" padding: 0;"
                    tdBOMCount.InnerHtml += "border:solid 1px black; "">"
                    tdBOMCount.InnerHtml += "<tr tiptext = """ & gBOM.tiptextSafeString(toolTip) & """>" & tdBOMCount1.InnerHtml() & tdBOMCount2.InnerHtml() & "</tr></table></div>"

                    tr.Cells.Add(tdBOMCount)
                    'End Color Bar for percent match BOMs

                    tdManufacturer.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("s_manufacturer_key"))) & """>" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "</div>"
                    tr.Cells.Add(tdManufacturer)

                    tdPartNumber.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("s_mpn_key"))) & """>" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "</div>"
                    tr.Cells.Add(tdPartNumber)

                    tdDescription.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("description"))) & """>" & gBOM.NullSafeString(dv(i).Item("description")) & "</div>"
                    tr.Cells.Add(tdDescription)

                    tdBomSiteCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadBomSiteCountPopup('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "','" & gBOM.NullSafeString(dv(i).Item("inv_site_count")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("inv_site_count")) + "</span>"
                    tr.Cells.Add(tdBomSiteCount)

                    tdInvSiteCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadInvSiteCountPopup('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "','" & gBOM.NullSafeString(dv(i).Item("inv_site_count")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("inv_site_count")) + "</span>"
                    tr.Cells.Add(tdInvSiteCount)

                    tdEquipCount.InnerHtml = "<span class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""javascript:loadMatchingEquip('" & gBOM.NullSafeString(dv(i).Item("s_manufacturer_key")) & "','" & gBOM.NullSafeString(dv(i).Item("s_mpn_key")) & "');"" style=""pointer:cursor; color:Blue;"">" + gBOM.NullSafeString(dv(i).Item("component_count")) + "</span>"
                    tr.Cells.Add(tdEquipCount)

                    If gBOM.NullSafeString(dv(i).Item("obsolete")) = "YES" Then
                        tdObsolete.InnerHtml = "<img src=""./../../images/redFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is OBSOLETE"" />"
                    Else
                        tdObsolete.InnerHtml = "<img src=""./../../images/greenFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is NOT OBSOLETE"" />"
                    End If
                    tr.Cells.Add(tdObsolete)

                    'Build link to RAPID
                    Dim tdOIRDsb As New System.Text.StringBuilder
                    With tdOIRDsb
                        .Append("<div class=""ellipsis""")

                        'Check if item is in rapid
                        If gBOM.NullSafeString(dv(i).Item("oird_replacement")) = "Y" Then
                            .Append(" class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'""  onclick=""")
                            'Check if user has a rapid account
                            If CType(Session("rkey"), String) <> Nothing Then
                                'User had rapid account, build URL for part
                                .Append("javascript:window.open('http://www.rapidpartsmart.com/rapid/")
                                .Append("ALogin.jsp?keyType=POMS&action=pomsShowSolution&rapid_numbers=")
                                .Append(gBOM.NullSafeString(dv(i).Item("db_id")))
                                .Append("&rKey=")
                                .Append(CType(Session("rkey"), String).Replace("&", "%26"))
                                .Append("'")
                                .Append(",'', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=1000,height=550');")
                                .Append("""")
                                .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
                                .Append(" tiptext=""Click to View Entry in OIRD"">")
                                .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
                            Else
                                'User does not have rapid account, build URL for rapid access request
                                .Append("javascript:window.open('/POMS/RequestAccess.aspx?src=POMS','', '');")
                                .Append("""")
                                .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
                                .Append(" tiptext=""Click to request RAPID access to view data"">")
                                .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
                            End If
                        Else
                            'There is no rapid data
                            .Append("tiptext=""No OIRD information available."">")
                            .Append("No OIRD information available.")
                        End If
                        .Append("</div>")
                    End With

                    tdOIRDObs.InnerHtml = tdOIRDsb.ToString
                    tr.Cells.Add(tdOIRDObs)

                    If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
                        classString = "from_bom_table" '  & classString
                    Else
                        classString = "from_wo_table" ' & classString
                    End If
                    tr.Attributes.Add("class", classString)

                    ResultsTBL.Rows.Add(tr)
                Next

                For i = 0 To (dv.Count - 1)
                    If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
                        stockFromBOMCount += 1
                    Else
                        stockFromWOCount += 1
                    End If
                Next

                stockFromBOM = stockFromBOMCount.ToString
                stockFromWO = stockFromWOCount.ToString

            Else

                stockFromBOM = ""
                stockFromWO = ""
            End If

            With outStr
                .Append("{status:""success""")
                .Append(",message:""")
                .Append("success")
                .Append(""",")
                .Append("table:""")
                .Append(gBOM.JsonSafeString(gBOM.controlHTML(ResultsTBL)))
                .Append(""",totalPages:""" & totalPages.ToString)
                .Append(""",totalItems:""" & totalItems.ToString)
                .Append(""",curPage:""" & curPage.ToString)
                .Append(""",stockFromBOM: """ & gBOM.JsonSafeString(stockFromBOM))
                .Append(""",stockFromWO: """ & gBOM.JsonSafeString(stockFromWO))
                .Append("""}")
            End With

            Return outStr.ToString

        Catch ex As Exception
            Throw
        End Try
    End Function

Initial URL

                                

Initial Description
Creates the table using the VB

Initial Title
Create HTML Table in VB

Initial Tags
table

Initial Language
Visual Basic