Inherits System.Web.UI.Page Dim Q As New clsConnect Dim T As New clsTools
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Init If Me.IsPostBack = False Then Try PHSearch.Controls.Clear() Dim ts As String = Request.QueryString("filter").ToString SearchTicket() SearchCaller() SearchProduct() If PHSearch.Controls.Count = 0 Then PHSearch.Controls.Add(New LiteralControl("<span class=""islink bold"">No results found based on your search settings</span>")) Else If PHSearch.Controls.Count > 1 Then For i As Integer = PHSearch.Controls.Count - 1 To 1 Step -1 PHSearch.Controls.AddAt(i, New LiteralControl("<hr class=""normal""/>")) Next End If End If Catch ex As Exception Me.Response.Redirect("announcement.aspx") End Try End If End Sub
Protected Sub SearchTicket()
Dim ss As String = Trim(Request.QueryString("keyword").ToString) Dim _splitmes As String() ' Split string based on spaces as delimiter _splitmes = ss.Split(New Char() {" "c}) ' Use For Each loop over words and display them Dim _param As String = ""
Dim _flg As Boolean = False
For Each _word As String In _splitmes 'create a dynamic parameter for database search If _flg = True Then _param &= " OR " Else _flg = True End If '_param &= "concerns.TicketNo=" & Val(_word) & " OR concerns.CallType='" & T.EscString(_word) & "' OR concerns.Concern LIKE '%" & T.EscString(_word) & "%' OR callhistory.Description LIKE '%" & T.EscString(_word) & "%' OR callhistory.Remarks LIKE '%" & T.EscString(_word) & "%'" _param &= "concerns.TicketNo=" & Val(_word) & " OR concerns.CallType='" & T.EscString(_word) & "' OR concerns.Concern LIKE '%" & T.EscString(_word) & "%'" Next Try Q.EQ("SELECT concerns.CallerId,concerns.TicketNo,callhistory.CallerName,callhistory.NumberUsed,c oncerns.Concern,concerns.CallType,concerns.CreatedBy,concerns.CreatedOn FROM concerns INNER JOIN callhistory ON concerns.TicketNo=callhistory.TicketNo AND (" & _param & ") GROUP BY TicketNo") lnkFilter2.Text = "Cases (" & Q.DR.RecordsAffected & ")" If Request.QueryString("filter").ToString <> "ticket" And Request.QueryString("filter").ToString <> "all" Then Exit Sub End If PHSearch.Controls.Clear() While Q.DR.Read() Dim obj As New Control obj = LoadControl("~/controls/search.ascx") Dim lbl1 As HyperLink = obj.FindControl("lnkHead") Dim lbl2 As Label = obj.FindControl("lblSub") Dim lbl3 As Label = obj.FindControl("lblDetails") Dim lbl4 As Label = obj.FindControl("lblWhen") Dim img1 As ImageButton = obj.FindControl("imgWhat") Dim tkt As Long = Q.DR("TicketNo") lbl1.Text = "Case No: " & tkt lbl1.NavigateUrl = "~/customerinfo.aspx?cid=" & Val(Q.DR("CallerId")) & "&ticket=" & tkt lbl2.Text = Q.DR("CallerName") & " (" & Q.DR("NumberUsed") & ")" lbl3.Text = Q.DR("CallType") & " - " & Q.DR("Concern") lbl4.Text = T.DateCalculate(Q.DR("CreatedOn")) img1.ImageUrl = "~/images/newticket.png" img1.PostBackUrl = lbl1.NavigateUrl PHSearch.Controls.Add(obj) End While Catch ex As Exception ' MsgBox(ex.ToString) End Try End Sub
Protected Sub SearchCaller()
Dim ss As String = Trim(Request.QueryString("keyword").ToString) Dim _splitmes As String() ' Split string based on spaces as delimiter _splitmes = ss.Split(New Char() {" "c}) ' Use For Each loop over words and display them Dim _param As String = ""
Dim _flg As Boolean = False
For Each _word As String In _splitmes 'create a dynamic parameter for database search If _flg = True Then _param &= " OR " Else _flg = True End If '_param &= "FullName LIKE '%" & T.EscString(_word) & "%' OR ContactNo LIKE '%" & T.EscString(_word) & "%' OR ShippingAddress LIKE '%" & T.EscString(_word) & "%' OR Fax LIKE '%" & T.EscString(_word) & "%' OR Email LIKE '%" & T.EscString(_word) & "%'" _param &= "FullName LIKE '%" & T.EscString(_word) & "%' OR ContactNo LIKE '%" & T.EscString(_word) & "%' OR MobileNo LIKE '%" & T.EscString(_word) & "%' OR Email LIKE '%" & T.EscString(_word) & "%'" Next Try Q.EQ("SELECT CustomerId,FullName,ContactNo,MobileNo,CallerType,CreatedBy,CreatedOn FROM customers WHERE STATUS='A' AND (" & _param & ")") lnkFilter3.Text = "Consumers (" & Q.DR.RecordsAffected & ")" If Request.QueryString("filter").ToString <> "caller" And Request.QueryString("filter").ToString <> "all" Then Exit Sub End If While Q.DR.Read() Dim obj As New Control obj = LoadControl("~/controls/search.ascx") Dim lbl1 As HyperLink = obj.FindControl("lnkHead") Dim lbl2 As Label = obj.FindControl("lblSub") Dim lbl3 As Label = obj.FindControl("lblDetails") Dim lbl4 As Label = obj.FindControl("lblWhen") Dim img1 As ImageButton = obj.FindControl("imgWhat") lbl1.Text = Q.DR("FullName") lbl1.NavigateUrl = "~/customerinfo.aspx?cid=" & Val(Q.DR("CustomerId")) lbl2.Text = Q.DR("ContactNo") & " " & Q.DR("MobileNo") lbl3.Text = Q.DR("CallerType") lbl4.Text = T.DateCalculate(Q.DR("CreatedOn")) img1.ImageUrl = "~/images/cust.png" img1.PostBackUrl = lbl1.NavigateUrl PHSearch.Controls.Add(obj) End While Catch ex As Exception ' MsgBox(ex.ToString) End Try
End Sub
Protected Sub SearchProduct()
Dim ss As String = Trim(Request.QueryString("keyword").ToString) Dim _splitmes As String() ' Split string based on spaces as delimiter _splitmes = ss.Split(New Char() {" "c}) ' Use For Each loop over words and display them Dim _param As String = ""
Dim _flg As Boolean = False
For Each _word As String In _splitmes 'create a dynamic parameter for database search If _flg = True Then _param &= " OR " Else _flg = True End If '_param &= "CategoryName LIKE '%" & T.EscString(_word) & "%' OR ProductName LIKE '%" & T.EscString(_word) & "%' OR Intro LIKE '%" & T.EscString(_word) & "%' OR MoreInfo LIKE '%" & T.EscString(_word) & "%' OR ComfortLevel LIKE '%" & T.EscString(_word) & "%' OR Warranty LIKE '%" & T.EscString(_word) & "%' OR Color LIKE '%" & T.EscString(_word) & "%' OR Fabric LIKE '%" & T.EscString(_word) & "%'" _param &= "CategoryName LIKE '%" & T.EscString(_word) & "%' OR ProductName LIKE '%" & T.EscString(_word) & "%' OR Intro LIKE '%" & T.EscString(_word) & "%' OR MoreInfo LIKE '%" & T.EscString(_word) & "%' OR ComfortLevel LIKE '%" & T.EscString(_word) & "%' OR Warranty LIKE '%" & T.EscString(_word) & "%' OR Color LIKE '%" & T.EscString(_word) & "%' OR Fabric LIKE '%" & T.EscString(_word) & "%'" Next Try Q.EQ("SELECT ProductName,CategoryName,products.Status,products.CreatedOn FROM products INNER JOIN productcategory ON products.CategoryId=productcategory.CategoryId AND products.Status<>'Deleted' AND (" & _param & ")") lnkFilter6.Text = "Products (" & Q.DR.RecordsAffected & ")" If Request.QueryString("filter").ToString <> "product" And Request.QueryString("filter").ToString <> "all" Then Exit Sub End If While Q.DR.Read() Dim obj As New Control obj = LoadControl("~/controls/search.ascx") Dim lbl1 As HyperLink = obj.FindControl("lnkHead") Dim lbl2 As Label = obj.FindControl("lblSub") Dim lbl3 As Label = obj.FindControl("lblDetails") Dim lbl4 As Label = obj.FindControl("lblWhen") Dim img1 As ImageButton = obj.FindControl("imgWhat") lbl1.Text = Q.DR("ProductName") lbl1.NavigateUrl = "~/prodinfo.aspx?product=" & lbl1.Text lbl2.Text = Q.DR("CategoryName") lbl3.Text = "Status: " & Q.DR("Status") lbl4.Text = T.DateCalculate(Q.DR("CreatedOn")) img1.ImageUrl = "~/images/form_blue.png" img1.PostBackUrl = lbl1.NavigateUrl PHSearch.Controls.Add(obj) End While Catch ex As Exception ' MsgBox(ex.ToString) End Try
End Sub
Protected Sub lnkFilter2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lnkFilter2.Click, lnkFilter3.Click, lnkFilter4.Click, lnkFilter5.Click, lnkFilter6.Click Dim obj As LinkButton = sender Dim fltr As String = "" Select Case obj.ID Case "lnkFilter2" fltr = "ticket" Case "lnkFilter3" fltr = "caller" Case "lnkFilter4" fltr = "order" Case "lnkFilter5" fltr = "dealer" Case "lnkFilter6" fltr = "product" End Select Session("srchfltr") = fltr Me.Response.Redirect("search.aspx?keyword=" & Request.QueryString("keyword").ToString & "&filter=" & fltr) End Sub