<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_elencoNC.ascx.cs" Inherits="GMW.WebUserControls.mod_elencoNC" %>
<%@ Register Src="~/WebUserControls/mod_righePag.ascx" TagPrefix="uc1" TagName="mod_righePag" %>

<div runat="server" id="divSelezione" class="row">
  <div class="col-12">
    <div class="input-group input-group-sm">
      <span class="input-group-prepend" id="grpSel" style="min-width: 110px;">SELEZIONE</span>
      <asp:Label runat="server" ID="lblSel" class="form-control" aria-describedby="grpSel">Cod NC - Descrizione NC</asp:Label>
      <span class="input-group-btn">
        <asp:LinkButton runat="server" ID="lbReset" class="btn btn-default" OnClick="lbReset_Click"><i class="fa fa-close"></i> <%: traduci("Cancel") %></asp:LinkButton></span>
    </div>
  </div>
</div>
<div runat="server" id="divElenco">
  <div class="row pb-1">
    <div class="col-1">
    </div>
    <div class="col-10">
      <div class="input-group input-group-sm">
        <div class="input-group-prepend" id="grpAdd">
          <span class="input-group-text">RICERCA</span>
        </div>
        <asp:TextBox runat="server" ID="txtSearch" class="form-control" placeholder="Ricerca per Codice NC / derscrizione" aria-describedby="grpAdd" AutoPostBack="True" OnTextChanged="txtSearch_TextChanged"></asp:TextBox>
        <div class="input-group-append">
          <asp:LinkButton runat="server" ID="lbAdd" class="btn btn-default" OnClick="lbAdd_Click"><i class="fa fa-plus"></i> <%: traduci("AddNew") %></asp:LinkButton>
        </div>
      </div>
    </div>
    <div class="col-1">
      <uc1:mod_righePag runat="server" ID="mod_righePag" />
    </div>
  </div>
  <div class="row">
    <div class="col-12">
      <asp:GridView ID="grView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="IdxNC" DataSourceID="ods" Width="100%" OnSelectedIndexChanged="grView_SelectedIndexChanged">
        <RowStyle CssClass="ctrRowStyle" />
        <AlternatingRowStyle CssClass="ctrAltRowStyle" />
        <EditRowStyle CssClass="ctrEditRowStyle" />
        <SelectedRowStyle CssClass="ctrSelRowStyle" />
        <FooterStyle CssClass="ctrFooter" />
        <PagerStyle CssClass="ctrHeaderPager" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle CssClass="ctrHeaderPager" ForeColor="White" Font-Bold="True" />
        <EmptyDataRowStyle CssClass="ctrRowStyle" />
        <EmptyDataTemplate>
          <asp:Label runat="server" ID="lblNoRecord" Text="Nessun record trovato" />
        </EmptyDataTemplate>
        <Columns>
          <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
            <EditItemTemplate>
              <asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="True" CommandName="Update" ToolTip="Update" CssClass="fa fa-check fa-2x" />
              &nbsp;<asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False" CommandName="Cancel" ToolTip="Cancel" CssClass="fa fa-undo fa-2x" />
            </EditItemTemplate>
            <ItemTemplate>
              <asp:LinkButton ID="lbSelect" runat="server" CausesValidation="False" CommandName="Select" CssClass="fa fa-search fa-2x" />
              &nbsp;
                        <asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" ToolTip="Edit" CssClass="fa fa-edit fa-2x" Visible='<%# editEnabNC(Eval("idxNC")) %>' />
            </ItemTemplate>
            <HeaderTemplate>
              <div style="text-align: center; margin: auto;">
                <asp:LinkButton ID="lbReset" runat="server" OnClick="btnReset_Click"><i class="fa fa-refresh fa-2x"></i></asp:LinkButton>
              </div>
            </HeaderTemplate>
            <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <HeaderStyle HorizontalAlign="Center" />
          </asp:TemplateField>
          <asp:BoundField DataField="IdxNC" HeaderText="#" SortExpression="IdxNC" ReadOnly="true" ItemStyle-HorizontalAlign="Center" />
          <asp:BoundField DataField="DtCreaz" HeaderText="Creato" SortExpression="DtCreaz" DataFormatString="{0:yyyy/MM/dd} {0:HH:mm}" ReadOnly="true" ControlStyle-Width="10em" ItemStyle-Width="10em" />
          <asp:BoundField DataField="CodNC" HeaderText="Cod NC" SortExpression="CodNC" ControlStyle-Width="20em" />
          <asp:BoundField DataField="DescrNC" HeaderText="Descrizione" SortExpression="DescrNC" ControlStyle-Width="50em" />
          <asp:TemplateField HeaderText="Criteri" SortExpression="">
            <ItemTemplate>
              <div>
                <asp:Label ID="lblTipoCart" runat="server" Text='<%# Eval("TipoCart") + " - " + Eval("SearchNote") %>' />
              </div>
              <div>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("DataFrom", "{0:yyyy/MM/dd} {0:HH:mm}") + " --> " + Eval("DataTo", "{0:yyyy/MM/dd} {0:HH:mm}") %>' />
              </div>
            </ItemTemplate>
          </asp:TemplateField>
        </Columns>
      </asp:GridView>
      <asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="Original_{0}" SelectMethod="getLastOnes" TypeName="GMW_data.DS_ApplicazioneTableAdapters.ElencoNCTableAdapter" DeleteMethod="deleteQuery" UpdateMethod="updNome" FilterExpression=" CodNC LIKE '%{0}%' OR DescrNC LIKE '%{0}%' OR TipoCart LIKE '%{0}%' OR SearchNote LIKE '%{0}%' ">
        <FilterParameters>
          <asp:ControlParameter ControlID="txtSearch" DefaultValue="*" Type="String" Name="search" PropertyName="Text" />
        </FilterParameters>
        <DeleteParameters>
          <asp:Parameter Name="Original_IdxNC" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
          <asp:Parameter DefaultValue="200" Name="num2show" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
          <asp:Parameter Name="CodNC" Type="String" />
          <asp:Parameter Name="DescrNC" Type="String" />
          <asp:Parameter Name="Original_IdxNC" Type="Int32" />
        </UpdateParameters>
      </asp:ObjectDataSource>
    </div>
  </div>
</div>
