<asp:GridView runat="server" ID="grdLaneDoors" ShowHeaderWhenEmpty="true"
AutoGenerateColumns="false" DataKeyNames="lane_assignment_id">
<Columns>
<asp:ButtonField Text="Print BOL" CommandName="p" HeaderText="" ButtonType="Button"
ControlStyle-Width="70Px">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Center"
ForeColor="Black" BorderColor="LightSkyBlue" BorderWidth="1px" />
<ItemStyle BorderColor="LightSkyBlue" BorderWidth="1px" HorizontalAlign="Center" />
</asp:ButtonField>
<asp:BoundField DataField="Created_dt" HeaderText="Created" DataFormatString="{0:MM/dd/yy hh:mm tt}"
HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="door_no" HeaderText="Door #" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Center"
BorderColor="LightSkyBlue" BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Center" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="door_name" HeaderText="Name" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="direction" HeaderText="Direction" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="Trailer_no" HeaderText="Trailer" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="carrier" HeaderText="Carrier" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="Going_to" HeaderText="Destination" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="SupplierCustomer_name" HeaderText="Company" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="supcustloc_name" HeaderText="Company Loc" HeaderStyle-Wrap="false"
ItemStyle-Wrap="true">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
<asp:BoundField DataField="Clear_dt" HtmlEncode="false" HeaderText="Clear Date" DataFormatString="{0:MM/dd/yy hh:mm tt}"
HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
<HeaderStyle BackColor="LightSkyBlue" Font-Bold="False" HorizontalAlign="Left" BorderColor="LightSkyBlue"
BorderWidth="1px" ForeColor="Black" />
<ItemStyle HorizontalAlign="Left" BorderColor="LightSkyBlue" />
</asp:BoundField>
</Columns>
</asp:GridView>
Public Sub fillGrid()
grdLaneDoors.DataSource = Nothing
Dim cmd As New SqlCommand("select * from [fnLaneAssignmentDoorsList]() where location_id=" & hdnLocationID.Value & " and facility_id=" & hdnFacilityID.Value & " and convert(date,Update_dt)<=convert(date,GETDATE()) order by Update_dt desc")
Dim dt As DataTable = DataConnect.GetInstance.GetDt(cmd)
grdLaneDoors.DataSource = dt
grdLaneDoors.DataBind()
End Sub
Private Sub grdLaneDoors_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdLaneDoors.RowCommand
Try
If e.CommandName = "p" Then
Dim id As Integer
id = Convert.ToInt32(grdLaneDoors.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)
grdLaneDoors.SelectRow(Int32.Parse(e.CommandArgument.ToString()))
Dim html As String = createHTML(id)
Print(html)
End If
Catch ex As Exception
pnlGlobalMessage.Visible = True
lblGlobalMessage.Text = "A technical issue has occurred. A message has been sent to the development team. Sorry for the inconvenience."
lblGlobalMessage.Visible = True
Dim dt As DataTable = Session("user_session")
Worker.HandleError(ex, "Lane History Print", Int64.Parse(dt.Rows(0)("user_id")), Request.Browser.Browser.ToString())
End Try
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
'Verifies that the control is rendered
End Sub
Protected Function createHTML(ByVal id As Integer) As String
Dim html As String = "<table cellspacing='0' cellpadding='0' border='1'><tbody>" &
"<tr>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(3).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(4).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(5).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(6).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(7).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(8).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.HeaderRow.Cells(9).Text &
"</td>" &
"</tr>" &
"<tr>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(3).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(4).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(5).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(6).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(7).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(8).Text &
"</td>" &
"<td valign='top' align='left'>" &
grdLaneDoors.SelectedRow.Cells(9).Text &
"</td>" &
"</tr>" &
"</tbody></table>"
Dim con As String = "<table cellpadding='0' cellspacing='0' border='1'><tbody>" &
"<tr>" &
"<td valign='top' align='left'>Container ID</td>" &
"<td valign='top' align='left'>Container Number</td>" &
"<td valign='top' align='left'>Length</td>" &
"<td valign='top' align='left'>Width</td>" &
"<td valign='top' align='left'>Height</td>" &
"</tr>"
Dim ast As String = "<table cellpadding='0' cellspacing='0' border='1'><tbody>" &
"<tr>" &
"<td valign='top' align='left'>Container ID</td>" &
"<td valign='top' align='left'>Asset ID</td>" &
"<td valign='top' align='left'>Total</td>" &
"</tr>"
Dim astCntS As String = ""
Dim astCnt As Integer = 0
Dim dtCon As New DataTable
Dim dtAst As New DataTable
dtCon = DataConnect.GetInstance.GetDt("select tra.container_id,container_nbr,length,width,height, COUNT(*) from transactions tra" &
" inner join container con on tra.container_id=con.container_id" &
" where lane_assignment_id = " &
id.ToString() &
" group by tra.container_id,container_nbr,length,width,height")
For Each dr As DataRow In dtCon.Rows
con = con & "<tr>" &
"<td valign='top' align='left'>" &
dr("container_id").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr("container_nbr").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr("length").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr("width").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr("height").ToString() &
"</td>" &
"</tr>"
dtAst = DataConnect.GetInstance.GetDt("select distinct ast.container_id,ast.asset_id,ast.total from transactions tra" &
" inner join asset ast on ast.asset_id=tra.asset_id" &
" where lane_assignment_id=" &
id.ToString() &
" and tra.container_id=" &
dr("container_id").ToString())
astCnt += dtAst.Rows.Count
For Each dr1 As DataRow In dtAst.Rows
ast = ast & "<tr>" &
"<td valign='top' align='left'>" &
dr1("container_id").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr1("asset_id").ToString() &
"</td>" &
"<td valign='top' align='left'>" &
dr1("total").ToString() &
"</td>" &
"</tr>"
Next
Next
con = con & "</tbody></table>"
ast = ast & "</tbody></table>"
astCntS = "Total number of assets: " & astCnt
html = html & "<br />" & con & "<br />" & astCntS & "<br />" & ast
Return html
End Function
Protected Sub Print(ByVal html As String)
Dim sb As New StringBuilder()
sb.Append("<script type = 'text/javascript'>")
sb.Append("window.onload = new function(){")
sb.Append("var printWin = window.open('','','left=0")
sb.Append(",top=0,width=900,height=800');")
sb.Append("printWin.document.write(""")
sb.Append(html)
sb.Append(""");")
sb.Append("printWin.document.close();")
sb.Append("printWin.focus();")
sb.Append("printWin.print();")
sb.Append("printWin.close();")
sb.Append("};")
sb.Append("</script>")
ClientScript.RegisterStartupScript(Me.[GetType](), "GridPrint", sb.ToString())
End Sub