Imports Predictive.DAL
Partial Class DesktopModules_PredictiveMaintenance_BatchesSearch_BatchesSearch
Inherits Entities.Modules.PortalModuleBase
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Try
BindGrid("Where BATCHNO='-1'")
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End If
End Sub
Private Sub BindGrid(ByVal whereClause As String)
Dim sampleCtrl As New SampleController
Dim samples As List(Of Sample)
samples = sampleCtrl.GetSampleFiles(whereClause)
gvBatches.DataSource = samples
gvBatches.DataBind()
End Sub
Protected Sub btnSend_Click(sender As Object, e As ImageClickEventArgs) Handles btnSend.Click
Dim whereclause As String = ""
Dim custnum As String = txtCustNum.Text.Trim
Dim unum As String = txtUnum.Text.Trim
If custnum <> "" Then
If InStr(custnum, "%") > 0 Then
whereclause = whereclause & " AND CUSTNUM LIKE '" & custnum & "'"
Else
whereclause = whereclause & " AND CUSTNUM LIKE '" & custnum & "%'"
End If
End If
If unum <> "" Then
If InStr(unum, "%") > 0 Then
whereclause = whereclause & " AND UNUM LIKE '" & unum & "'"
Else
whereclause = whereclause & " AND UNUM LIKE '" & unum & "%'"
End If
End If
If whereclause <> "" Then
whereclause = " WHERE " & Right(whereclause, Len(whereclause) - 5)
End If
BindGrid(whereclause)
End Sub
Protected Sub gvBatches_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles gvBatches.PageIndexChanging
Dim whereclause As String = ""
Dim custnum As String = txtCustNum.Text.Trim
Dim unum As String = txtUnum.Text.Trim
If custnum <> "" Then
If InStr(custnum, "%") > 0 Then
whereclause = whereclause & " AND CUSTNUM LIKE '" & custnum & "'"
Else
whereclause = whereclause & " AND CUSTNUM LIKE '" & custnum & "%'"
End If
End If
If unum <> "" Then
If InStr(unum, "%") > 0 Then
whereclause = whereclause & " AND UNUM LIKE '" & unum & "'"
Else
whereclause = whereclause & " AND UNUM LIKE '" & unum & "%'"
End If
End If
If whereclause <> "" Then
whereclause = " WHERE " & Right(whereclause, Len(whereclause) - 5)
End If
Dim sampleCtrl As New SampleController
Dim samples As List(Of Sample)
samples = sampleCtrl.GetSampleFiles(whereClause)
gvBatches.PageIndex = e.NewPageIndex
gvBatches.DataSource = samples
gvBatches.DataBind()
End Sub
End Class