Posted By

staley412 on 11/24/09


Tagged

table


Versions (?)

Create HTML Table in VB


 / Published in: Visual Basic
 

Creates the table using the VB

  1. Public Function loadStuff(ByVal start_index As Integer, ByVal stop_index As Integer, ByVal pageSize As Integer) As String
  2. Dim outStr As New System.Text.StringBuilder
  3.  
  4. Try
  5. Dim i = 0
  6. Dim k = 0
  7. Dim rowStr As String
  8. Dim columnName As String
  9. Dim ResultsTBL As New HtmlTable
  10. Dim tr As New HtmlTableRow
  11. Dim tdStuffCount As New HtmlTableCell
  12. Dim tdStuffCount1 As New HtmlTableCell
  13. Dim tdStuffCount2 As New HtmlTableCell
  14. Dim tdManufacturer As New HtmlTableCell
  15. Dim tdPartNumber As New HtmlTableCell
  16. Dim tdDescription As New HtmlTableCell
  17. Dim tdBomSiteCount As New HtmlTableCell
  18. Dim tdInvSiteCount As New HtmlTableCell
  19. Dim tdEquipCount As New HtmlTableCell
  20. Dim tdObsolete As New HtmlTableCell
  21. Dim tdOIRDObs As New HtmlTableCell
  22.  
  23. Dim outString As String
  24. Dim dv As DataView
  25. Dim totalPages As Integer
  26. Dim totalItems As Integer
  27. Dim curPage As Integer
  28. Dim stockFromBOM As String
  29. Dim stockFromWO As String
  30. Dim stockFromBOMCount As Integer
  31. Dim stockFromWOCount As Integer
  32. Dim filterSelected As String
  33. Dim filterPositiveValue As String
  34.  
  35. dv = gBOM.modelSession.bomTable.DefaultView
  36.  
  37. If (Not bomfilter = "retain filter") Then
  38. dv.RowFilter = bomfilter
  39. End If
  40. totalItems = dv.Count
  41. totalPages = Math.Ceiling(totalItems / pageSize)
  42. curPage = (start_index / pageSize) + 1
  43. gBOM.modelSession.curPageBom = curPage
  44.  
  45. If sortColumn <> "" And Not sortColumn = Nothing Then
  46. gBOM.modelSession.bomSort = sortColumn
  47. gBOM.modelSession.bomOrder = IIf(sortDirection.ToUpper = "DESC", "DESC", "ASC")
  48. End If
  49.  
  50. dv.Sort = gBOM.modelSession.bomSort & " " & gBOM.modelSession.bomOrder
  51.  
  52. If stop_index > dv.Count - 1 Then
  53. stop_index = dv.Count - 1
  54. End If
  55.  
  56. If dv.Count > 0 Then
  57.  
  58. ResultsTBL.Attributes.Add("class", "dgFormat")
  59. ResultsTBL.Attributes.Add("cellspacing", "0")
  60. ResultsTBL.Attributes.Add("border", "0")
  61. ResultsTBL.Attributes.Add("rules", "rows")
  62. ResultsTBL.Attributes.Add("width", "97%")
  63. ResultsTBL.Style.Add("table-layout", "fixed")
  64. ResultsTBL.Attributes.Add("font-size", "7.5pt")
  65. ResultsTBL.Attributes.Add("font-weight", "bold")
  66.  
  67. tdBOMCount.InnerHtml = "Relevancy" & IIf(gBOM.modelSession.bomSort = "bom_count", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
  68. tdBOMCount.Attributes.Add("onclick", "sortData('bom','bom_count','" & IIf(gBOM.modelSession.bomSort = "bom_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  69. tdBOMCount.Style.Add("cursor", "pointer")
  70. tdBOMCount.Style.Add("font-size", "7.5pt")
  71. tdBOMCount.Style.Add("font-weight", "bold")
  72. tdBOMCount.Style.Add("width", "85px")
  73.  
  74. 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>"), "")
  75. tdManufacturer.Attributes.Add("onclick", "sortData('bom','s_manufacturer_key','" & IIf(gBOM.modelSession.bomSort = "s_manufacturer_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  76. tdManufacturer.Style.Add("cursor", "pointer")
  77. tdManufacturer.Style.Add("font-size", "7.5pt")
  78. tdManufacturer.Style.Add("font-weight", "bold")
  79. tdManufacturer.Style.Add("width", "100px")
  80.  
  81. 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>"), "")
  82. tdPartNumber.Attributes.Add("onclick", "sortData('bom','s_mpn_key','" & IIf(gBOM.modelSession.bomSort = "s_mpn_key" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  83. tdPartNumber.Style.Add("cursor", "pointer")
  84. tdPartNumber.Style.Add("font-size", "7.5pt")
  85. tdPartNumber.Style.Add("font-weight", "bold")
  86. tdPartNumber.Style.Add("width", "70px")
  87.  
  88. tdDescription.InnerHtml = "Description" & IIf(gBOM.modelSession.bomSort = "description", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
  89. tdDescription.Attributes.Add("onclick", "sortData('bom','description','" & IIf(gBOM.modelSession.bomSort = "description" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  90. tdDescription.Style.Add("cursor", "pointer")
  91. tdDescription.Style.Add("overflow", "hidden")
  92. tdDescription.Style.Add("font-size", "7.5pt")
  93. tdDescription.Style.Add("font-weight", "bold")
  94. tdDescription.Style.Add("width", "250px")
  95.  
  96. 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>"), "")
  97. tdBomSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  98. tdBomSiteCount.Style.Add("cursor", "pointer")
  99. tdBomSiteCount.Style.Add("font-size", "7.5pt")
  100. tdBomSiteCount.Style.Add("font-weight", "bold")
  101. tdBomSiteCount.Style.Add("width", "70px")
  102.  
  103. 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>"), "")
  104. tdInvSiteCount.Attributes.Add("onclick", "sortData('bom','inv_site_count','" & IIf(gBOM.modelSession.bomSort = "inv_site_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  105. tdInvSiteCount.Style.Add("cursor", "pointer")
  106. tdInvSiteCount.Style.Add("font-size", "7.5pt")
  107. tdInvSiteCount.Style.Add("font-weight", "bold")
  108. tdInvSiteCount.Style.Add("width", "70px")
  109.  
  110. 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>"), "")
  111. tdEquipCount.Attributes.Add("onclick", "sortData('bom','component_count','" & IIf(gBOM.modelSession.bomSort = "component_count" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  112. tdEquipCount.Style.Add("cursor", "pointer")
  113. tdEquipCount.Style.Add("font-size", "7.5pt")
  114. tdEquipCount.Style.Add("font-weight", "bold")
  115. tdEquipCount.Style.Add("width", "70px")
  116.  
  117. tdObsolete.InnerHtml = "Obsolete" & IIf(gBOM.modelSession.bomSort = "obsolete", IIf(gBOM.modelSession.bomOrder = "ASC", "<font face=""webdings"">5</font>", "<font face=""webdings"">6</font>"), "")
  118. tdObsolete.Attributes.Add("onclick", "sortData('bom','obsolete','" & IIf(gBOM.modelSession.bomSort = "obsolete" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  119. tdObsolete.Style.Add("cursor", "pointer")
  120. tdObsolete.Style.Add("font-size", "7.5pt")
  121. tdObsolete.Style.Add("font-weight", "bold")
  122. tdObsolete.Style.Add("width", "70px")
  123.  
  124. 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>"), "")
  125. tdOIRDObs.Attributes.Add("onclick", "sortData('bom','oird_replacement','" & IIf(gBOM.modelSession.bomSort = "oird_replacement" And gBOM.modelSession.bomOrder = "ASC", "DESC", "ASC") & "');")
  126. tdOIRDObs.Style.Add("cursor", "pointer")
  127. tdOIRDObs.Style.Add("font-size", "7.5pt")
  128. tdOIRDObs.Style.Add("font-weight", "bold")
  129. tdOIRDObs.Style.Add("width", "80px")
  130.  
  131.  
  132.  
  133. tr.Cells.Add(tdBOMCount)
  134. tr.Cells.Add(tdManufacturer)
  135. tr.Cells.Add(tdPartNumber)
  136. tr.Cells.Add(tdDescription)
  137. tr.Cells.Add(tdBomSiteCount)
  138. tr.Cells.Add(tdInvSiteCount)
  139. tr.Cells.Add(tdEquipCount)
  140. tr.Cells.Add(tdObsolete)
  141. tr.Cells.Add(tdOIRDObs)
  142. tr.Attributes.Add("class", "poms_title_back_candy")
  143.  
  144. ResultsTBL.Rows.Add(tr)
  145.  
  146. Dim aryData As New ArrayList
  147.  
  148. For i = start_index To stop_index
  149. Dim classString As String = ""
  150.  
  151. tr = New HtmlTableRow
  152. tdBOMCount = New HtmlTableCell
  153. tdBOMCount1 = New HtmlTableCell
  154. tdManufacturer = New HtmlTableCell
  155. tdPartNumber = New HtmlTableCell
  156. tdDescription = New HtmlTableCell
  157. tdBomSiteCount = New HtmlTableCell
  158. tdInvSiteCount = New HtmlTableCell
  159. tdEquipCount = New HtmlTableCell
  160. tdObsolete = New HtmlTableCell
  161. tdOIRDObs = New HtmlTableCell
  162.  
  163. If i Mod 2 = 0 Then
  164. classString = "poms_even "
  165. Else
  166. classString = "poms_odd "
  167. End If
  168.  
  169. 'Color Bar for percent match of BOMs
  170. Dim matchPercent As Double
  171. Dim bgColor As String
  172. Dim toolTip As String
  173. Dim szTotalBOM As String
  174. Dim totalBOM As Integer
  175. Dim szBOMCount As String
  176. Dim bomCount As Integer
  177.  
  178. bgColor = "#6699CC"
  179.  
  180. If (gBOM.modelSession.totalBOMTable.Rows.Count > 0) Then
  181. szTotalBOM = gBOM.modelSession.totalBOMTable.Rows(0).Item("totalBOM")
  182. Else
  183. szTotalBOM = "0"
  184. End If
  185. totalBOM = CType(szTotalBOM, Integer)
  186.  
  187. szBOMCount = IIf(IsDBNull(dv(i).Item("bom_count")), "0", dv(i).Item("bom_count"))
  188. bomCount = CType(szBOMCount, Integer)
  189. matchPercent = ((bomCount / (IIf(totalBOM = 0, bomCount, totalBOM)))) * 100
  190.  
  191. If matchPercent = 0 Then
  192. bgColor = "white"
  193. End If
  194. toolTip = gBOM.NullSafeString(dv(i).Item("bom_count")) + " out of " + totalBOM.ToString() + " BOM(s) "
  195. toolTip += "contain this part matching the selected equipment's Manufacturer and Model Number."
  196.  
  197. tdBOMCount1.InnerHtml = "<td bgcolor=""" + bgColor + """ cellspacing=""0"" cellpadding=""0"" height=""10"""
  198. tdBOMCount1.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
  199. tdBOMCount1.InnerHtml += "width=" + matchPercent.ToString() + "%"">"
  200. tdBOMCount2.InnerHtml = "<td bgcolor=""white"" cellspacing=""0"" cellpadding=""0"" height=""10"""
  201. tdBOMCount2.InnerHtml += "style=""border-bottom-width: 0px; padding: 0;"" "
  202. tdBOMCount2.InnerHtml += "width=" + (100 - matchPercent).ToString() + "%"">"
  203. tdBOMCount.InnerHtml += "<div onmouseover=""javascript:addTip(event);"" tiptext = """ & gBOM.tiptextSafeString(toolTip) & """><table cellspacing=""0"" cellpadding=""0"" "
  204. tdBOMCount.InnerHtml += "height=""10"" width=""40"" style="" padding: 0;"
  205. tdBOMCount.InnerHtml += "border:solid 1px black; "">"
  206. tdBOMCount.InnerHtml += "<tr tiptext = """ & gBOM.tiptextSafeString(toolTip) & """>" & tdBOMCount1.InnerHtml() & tdBOMCount2.InnerHtml() & "</tr></table></div>"
  207.  
  208. tr.Cells.Add(tdBOMCount)
  209. 'End Color Bar for percent match BOMs
  210.  
  211. 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>"
  212. tr.Cells.Add(tdManufacturer)
  213.  
  214. 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>"
  215. tr.Cells.Add(tdPartNumber)
  216.  
  217. tdDescription.InnerHtml = "<div class=""ellipsis"" tiptext=""" & gBOM.tiptextSafeString(gBOM.NullSafeString(dv(i).Item("description"))) & """>" & gBOM.NullSafeString(dv(i).Item("description")) & "</div>"
  218. tr.Cells.Add(tdDescription)
  219.  
  220. 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>"
  221. tr.Cells.Add(tdBomSiteCount)
  222.  
  223. 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>"
  224. tr.Cells.Add(tdInvSiteCount)
  225.  
  226. 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>"
  227. tr.Cells.Add(tdEquipCount)
  228.  
  229. If gBOM.NullSafeString(dv(i).Item("obsolete")) = "YES" Then
  230. tdObsolete.InnerHtml = "<img src=""./../../images/redFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is OBSOLETE"" />"
  231. Else
  232. tdObsolete.InnerHtml = "<img src=""./../../images/greenFlag.png"" onmouseover=""addTip(event)"" tiptext=""Item Is NOT OBSOLETE"" />"
  233. End If
  234. tr.Cells.Add(tdObsolete)
  235.  
  236. 'Build link to RAPID
  237. Dim tdOIRDsb As New System.Text.StringBuilder
  238. With tdOIRDsb
  239. .Append("<div class=""ellipsis""")
  240.  
  241. 'Check if item is in rapid
  242. If gBOM.NullSafeString(dv(i).Item("oird_replacement")) = "Y" Then
  243. .Append(" class=""linkBody"" onmouseover=""this.className='linkBodyHover'"" onmouseout=""this.className='linkBody'"" onclick=""")
  244. 'Check if user has a rapid account
  245. If CType(Session("rkey"), String) <> Nothing Then
  246. 'User had rapid account, build URL for part
  247. .Append("javascript:window.open('http://www.rapidpartsmart.com/rapid/")
  248. .Append("ALogin.jsp?keyType=POMS&action=pomsShowSolution&rapid_numbers=")
  249. .Append(gBOM.NullSafeString(dv(i).Item("db_id")))
  250. .Append("&rKey=")
  251. .Append(CType(Session("rkey"), String).Replace("&", "%26"))
  252. .Append("'")
  253. .Append(",'', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no,width=1000,height=550');")
  254. .Append("""")
  255. .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
  256. .Append(" tiptext=""Click to View Entry in OIRD"">")
  257. .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
  258. Else
  259. 'User does not have rapid account, build URL for rapid access request
  260. .Append("javascript:window.open('/POMS/RequestAccess.aspx?src=POMS','', '');")
  261. .Append("""")
  262. .Append(" style=""cursor:pointer; text-decoration: underline; color: blue;""")
  263. .Append(" tiptext=""Click to request RAPID access to view data"">")
  264. .Append("<img src=""./../../images/redflag.png"" onmouseover=""addTip(event)"" tiptext=""Click to view OIRD"" />")
  265. End If
  266. Else
  267. 'There is no rapid data
  268. .Append("tiptext=""No OIRD information available."">")
  269. .Append("No OIRD information available.")
  270. End If
  271. .Append("</div>")
  272. End With
  273.  
  274. tdOIRDObs.InnerHtml = tdOIRDsb.ToString
  275. tr.Cells.Add(tdOIRDObs)
  276.  
  277. If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
  278. classString = "from_bom_table" ' & classString
  279. Else
  280. classString = "from_wo_table" ' & classString
  281. End If
  282. tr.Attributes.Add("class", classString)
  283.  
  284. ResultsTBL.Rows.Add(tr)
  285. Next
  286.  
  287. For i = 0 To (dv.Count - 1)
  288. If (gBOM.NullSafeString(dv(i).Item("from_bom")) = "1") Then
  289. stockFromBOMCount += 1
  290. Else
  291. stockFromWOCount += 1
  292. End If
  293. Next
  294.  
  295. stockFromBOM = stockFromBOMCount.ToString
  296. stockFromWO = stockFromWOCount.ToString
  297.  
  298. Else
  299.  
  300. stockFromBOM = ""
  301. stockFromWO = ""
  302. End If
  303.  
  304. With outStr
  305. .Append("{status:""success""")
  306. .Append(",message:""")
  307. .Append("success")
  308. .Append(""",")
  309. .Append("table:""")
  310. .Append(gBOM.JsonSafeString(gBOM.controlHTML(ResultsTBL)))
  311. .Append(""",totalPages:""" & totalPages.ToString)
  312. .Append(""",totalItems:""" & totalItems.ToString)
  313. .Append(""",curPage:""" & curPage.ToString)
  314. .Append(""",stockFromBOM: """ & gBOM.JsonSafeString(stockFromBOM))
  315. .Append(""",stockFromWO: """ & gBOM.JsonSafeString(stockFromWO))
  316. .Append("""}")
  317. End With
  318.  
  319. Return outStr.ToString
  320.  
  321. Catch ex As Exception
  322. Throw
  323. End Try
  324. End Function

Report this snippet  

You need to login to post a comment.