<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_stackList.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_stackList" %>

<div class="row">
  <div class="col-12">
    <div runat="server" id="divTitle">
      <div class="col-6 pr-0 font-weight-bold">
           <%: traduci("BunkList") %>
      </div>
      <div class="col-6 pl-0 text-right" runat="server" id="divSelected">
        <asp:Label runat="server" ID="lblStack" />
        <asp:LinkButton ID="lbtResetGlob" runat="server" OnClick="lbtReset_Click" CssClass="btn btn-sm btn-info" Visible="true" ToolTip="Reset"><i class="fa fa-refresh"></i></asp:LinkButton>
      </div>
    </div>
  </div>
  <div class="col-12">
    <asp:GridView ID="grView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="StackID" DataSourceID="ods" CssClass="table table-sm table-striped" AllowSorting="True" OnSelectedIndexChanged="grView_SelectedIndexChanged" OnRowCommand="grView_RowCommand">
      <HeaderStyle CssClass="default" />
      <PagerStyle CssClass="active GridPager" />
      <PagerSettings Mode="NumericFirstLast" />
      <SelectedRowStyle CssClass="table-info" />
      <EmptyDataTemplate>
           <%: traduci("NoRecord") %>
      </EmptyDataTemplate>
      <Columns>
        <asp:TemplateField ShowHeader="False">
          <HeaderTemplate>
            <asp:LinkButton ID="lbtReset" runat="server" OnClick="lbtReset_Click" CssClass="btn btn-sm btn-primary" Visible="true" ToolTip="Reset"><i class="fa fa-refresh"></i></asp:LinkButton>
          </HeaderTemplate>
          <ItemTemplate>
            <asp:LinkButton ID="lbSelect" runat="server" CausesValidation="False" CommandName="Select" CommandArgument='<%# Eval("StackIndex") %>' CssClass="btn btn-sm btn-primary"><i class="fa fa-search" aria-hidden="true"></i></asp:LinkButton>
          </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="StackIndex" HeaderText="#" ReadOnly="True" SortExpression="StackIndex" />
        <asp:TemplateField HeaderText="Sheets (Prepared / Total)" SortExpression="NumSheets">
          <ItemTemplate>
            <div runat="server" id="divMain" class='<%# "row mx-1 " + cssByPrepared(Eval("NumSheets"),Eval("NumSheetsPrepared")) %>'>
              <div class="col-6 pl-1 text-left">Sheets: <b><%# Eval("NumSheetsPrepared") %></b> / <%# Eval("NumSheets") %></div>
              <div class="col-6 pr-1">items: <b><%# Eval("NumItems") %></b></div>
            </div>
          </ItemTemplate>
          <ItemStyle CssClass="text-right" />
        </asp:TemplateField>
       
      </Columns>
    </asp:GridView>
    <asp:HiddenField ID="hfBatchId" runat="server" />
    <asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByBatch" TypeName="AppData.DS_AppTableAdapters.StackListTableAdapter">
      <SelectParameters>
        <asp:ControlParameter ControlID="hfBatchId" DefaultValue="0" Name="BatchID" PropertyName="Value" Type="Int32" />
      </SelectParameters>
    </asp:ObjectDataSource>
  </div>
</div>
