Private Sub FillDataGrid()
Dim DeployId As String = Convert.ToInt16(ddlDeployment.SelectedValue.ToString())
pnlDatagrid.Visible = True
Dim theCounter As Integer
Dim SqlWhere As String
If CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue = Nothing And ddlUic.SelectedValue = Nothing Then
SqlWhere = "ud.intMobilizationId = " & ddlDeployment.SelectedValue
ElseIf CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue > "0" And ddlUic.SelectedValue = Nothing Then
Dim BnId As String = ddlBn.SelectedValue.ToString
SqlWhere = "ud.strAAUic = " & ddlBn.SelectedValue
ElseIF CInt(ddlDeployment.SelectedValue) > 0 And ddlBn.SelectedValue > "0" And Cint(ddlUic.SelectedValue)> 0 Then
SqlWhere = "ud.intUnitMobId = " & ddlUic.SelectedValue
End If
sql = "Select Distinct intPermTaskId, ud.strUic, pt.strTaskName, DateDiff(day, dtFound, Getdate()) as Days_Old, pt.strName, pt.strProponent from tblPermTask as pt INNER JOIN " _
& "tblSoldierFilters as uf on uf.intAssignedId = pt.intAssignedId INNER JOIN tblUnitDeployData as ud on ud.intUnitMobId = uf.intUnitMobid INNER JOIN tblUnitPersonnel as p " _
& "on pt.intpositionId = p.intPositionId and pt.strSSN = p.strSSN where pt.dtCompleted IS NULL AND pt.intElevated = 1 AND pt.dtCompleteTask < getdate() AND (p.bitrefrad IS NULL " _
& "AND p.bitRearDet IS NULL) AND " & SqlWhere & " Order by strTaskname, DateDiff(day, dtFound, Getdate()) desc"
myDataTable = New DataTable
myDataTable = getData(sql)
myDataGrid.DataSource = myDataTable
myDataGrid.DataBind()
End Sub
|