Imports System
Imports System.Data
Imports System.Data.OleDb
Partial Class dkinventory
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("catid") & "" = "" Then
getCats()
Else
getProds()
End If
End Sub
Private Sub getProds()
Dim oleConn As New OleDb.OleDbConnection
Dim objComm As OleDbCommand
Dim SQLString As String
Dim err As Integer = 0
Dim tempSet As DataSet = New DataSet
Dim objrow As DataRow
Dim htmlString As String = "
| Model | " _
& "Description | Digi-Key Inventory | PDF | " _
& "RoHS | RFQ | " _
& "Connector Mate |
"
SQLString = "select * from Products where cat_id = " & Request.QueryString("catid") & " order by model"
oleConn.ConnectionString = Application("DSN")
oleConn.Open()
objComm = New OleDbCommand(SQLString, oleConn)
objComm.CommandTimeout = 30
Dim objDA As OleDbDataAdapter = New OleDbDataAdapter
objDA.SelectCommand = objComm
Dim objDS As DataSet = New DataSet
Try
objDA.Fill(objDS, 0)
oleConn.Close()
Catch ex As Exception
Response.Write(ex.ToString())
End Try
Dim cInc As Integer = 0
Dim altColor As String
Dim digikeylink As String = ""
dkContent.InnerHtml = getContent()
For Each objrow In objDS.Tables(0).Rows
If cInc = 0 Then
cInc = 1
altColor = "#fafafa"
Else
cInc = 0
altColor = "#ffffff"
End If
If objrow("isdk") = 1 Then
digikeylink = "http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&site=us&keywords=" & objrow("dkmodel")
End If
htmlString += "| " & objrow("model") & " | " _
& "" & objrow("listdesc") & " | " _
& ""
If objrow("isdk") = 1 Then
htmlString += " "
End If
htmlString += " | ![]() | " _
& ""
If objrow("rohspath") & "" <> "" Then
htmlString += objrow("rohspath")
End If
htmlString += " | " _
& "request quote | "
If objrow("connmate") & "" <> "" Then
htmlString += "" & objrow("connmate") & " | "
Else
htmlString += "N/A | "
End If
htmlString += "
"
Next
htmlString += "
"
dkInv.InnerHtml = htmlString
End Sub
Private Function getContent() As String
Dim sqlstring As String = "select content from categories where cat_id = " & Request.QueryString("catid")
Dim oleConn As New OleDb.OleDbConnection
Dim objComm As OleDbCommand
Dim err As Integer = 0
Dim tempSet As DataSet = New DataSet
Dim objrow As DataRow
oleConn.ConnectionString = Application("DSN")
oleConn.Open()
objComm = New OleDbCommand(sqlstring, oleConn)
objComm.CommandTimeout = 30
Dim objDA As OleDbDataAdapter = New OleDbDataAdapter
objDA.SelectCommand = objComm
Dim objDS As DataSet = New DataSet
Try
objDA.Fill(objDS, 0)
oleConn.Close()
Return objDS.Tables(0).Rows(0).Item(0).ToString()
Catch ex As Exception
Response.Write(ex.ToString())
End Try
End Function
Private Sub getCats()
Dim oleConn As New OleDb.OleDbConnection
Dim objComm As OleDbCommand
Dim SQLString As String
Dim err As Integer = 0
Dim tempSet As DataSet = New DataSet
Dim objrow As DataRow
Dim htmlString As String = "Click a category below to begin..."
SQLString = "select * from categories order by cat_name"
oleConn.ConnectionString = Application("DSN")
oleConn.Open()
objComm = New OleDbCommand(SQLString, oleConn)
objComm.CommandTimeout = 30
Dim objDA As OleDbDataAdapter = New OleDbDataAdapter
objDA.SelectCommand = objComm
Dim objDS As DataSet = New DataSet
Try
objDA.Fill(objDS, 0)
oleConn.Close()
Catch ex As Exception
Response.Write(ex.ToString())
End Try
For Each objrow In objDS.Tables(0).Rows
htmlString += "- " & objrow("cat_name") & "
"
Next
htmlString += " |
"
dkInv.InnerHtml = htmlString
End Sub
End Class