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

<div class="row">
    <div class="col-sm-8">
        <asp:DropDownList runat="server" ID="ddlFiltroMag" AutoPostBack="True" DataSourceID="odsFiltroMag" DataTextField="label" DataValueField="value" OnSelectedIndexChanged="ddlFiltroMag_SelectedIndexChanged" OnDataBound="ddlFiltroMag_DataBound" CssClass="btn btn-default dropdown-toggle"></asp:DropDownList>
        <asp:ObjectDataSource ID="odsFiltroMag" runat="server" OldValuesParameterFormatString="Original_{0}"
            SelectMethod="getByConditio" TypeName="GMW_data.DS_UtilityTableAdapters.v_selMagTableAdapter">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="MM" Name="conditio" SessionField="CodCS" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:DropDownList runat="server" ID="ddlFiltroBlock" AutoPostBack="True" DataSourceID="odsFiltroBlock" DataTextField="label" DataValueField="value" OnSelectedIndexChanged="ddlFiltroBlock_SelectedIndexChanged" OnDataBound="ddlFiltroBlock_DataBound" CssClass="btn btn-default dropdown-toggle"></asp:DropDownList>
        <asp:ObjectDataSource ID="odsFiltroBlock" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="getByConditio" TypeName="GMW_data.DS_UtilityTableAdapters.v_selBloccoTableAdapter">
            <SelectParameters>
                <asp:SessionParameter DefaultValue="MM" Name="CodCS" SessionField="CodCS" Type="String" />
                <asp:ControlParameter ControlID="ddlFiltroMag" DefaultValue="MM" Name="CodMag" PropertyName="SelectedValue"
                    Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</div>
<br />
<div class="row">
    <div class="col-sm-12">
        <asp:GridView ID="grView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" OnSelectedIndexChanged="grView_SelectedIndexChanged" OnDataBound="grView_DataBound" DataKeyNames="IdxCella" DataSourceID="ods" OnPageIndexChanged="grView_PageIndexChanged" OnSorted="grView_Sorted" OnRowEditing="grView_RowEditing" OnRowUpdated="grView_RowUpdated" OnRowCancelingEdit="grView_RowCancelingEdit">
            <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='<%# traduci("noRecord") %>' />
            </EmptyDataTemplate>
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <HeaderTemplate>
                        <asp:LinkButton ID="lbtReset" runat="server" OnClick="btnReset_Click" CssClass="btn btn-default btn-sm" Visible="false"><i class="fa fa-refresh"></i> <%: traduci("Reset") %></asp:LinkButton>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:ImageButton ID="imgSelect" runat="server" CausesValidation="False" CommandName="Select"
                            ToolTip='<%# traduci("Select") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.seleziona, SteamWare.dimImg.small) %>' />
                        &nbsp;
                <asp:ImageButton ID="imgEdit" runat="server" CausesValidation="False" CommandName="Edit"
                    ToolTip='<%# traduci("Edit") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.modifica, SteamWare.dimImg.small) %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:ImageButton ID="imgUpdate" runat="server" CausesValidation="False" CommandName="Update"
                            ToolTip='<%# traduci("Update")%>' ImageUrl='<%# imgPath(SteamWare.tipoImg.conferma , SteamWare.dimImg.small) %>' />
                        <asp:ImageButton ID="imgCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                            ToolTip='<%# traduci("Cancel") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.annulla , SteamWare.dimImg.small) %>' />
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:ImageButton ID="imgInsert" runat="server" CausesValidation="False" CommandName="Insert"
                            ToolTip='<%# traduci("insert") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.nuovo , SteamWare.dimImg.small) %>'
                            OnClick="lblIns_click" />
                        <asp:ImageButton ID="imgCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                            ToolTip='<%# traduci("Cancel") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.annulla , SteamWare.dimImg.small) %>' />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IdxBlocco" SortExpression="IdxBlocco">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dlIdxBlocco" runat="server" DataSourceID="odsBlocco" DataTextField="label"
                            DataValueField="value" SelectedValue='<%# Bind("IdxBlocco") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblIdxBlocco" runat="server" Text='<%# CodBloccoDaIdx(Eval("IdxBlocco")) %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="dlIdxBlocco" runat="server" DataSourceID="odsBlocco" DataTextField="label"
                            DataValueField="value" SelectedValue='<%# Bind("IdxBlocco") %>' />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="CodCella" SortExpression="CodCella">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCodCella" runat="server" Text='<%# Bind("CodCella") %>' Width="10em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCodCella" runat="server" Text='<%# Bind("CodCella") %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtCodCella" runat="server" Text='<%# Bind("CodCella") %>' Width="10em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="IdxTipoCella" SortExpression="IdxTipoCella">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dlIdxTipoCella" runat="server" DataSourceID="odsTipoCella"
                            DataTextField="label" DataValueField="value" SelectedValue='<%# Bind("IdxTipoCella") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblIdxTipoCella" runat="server" Text='<%# TipoCellaDaIdx(Eval("IdxTipoCella")) %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtIdxTipoCella" runat="server" Text='<%# Bind("IdxTipoCella") %>'
                            Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="attiva" SortExpression="Attiva">
                    <EditItemTemplate>
                        <asp:CheckBox ID="chkAttiva" runat="server" Checked='<%# Bind("Attiva") %>' Width="3em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkAttiva" runat="server" Checked='<%# Bind("Attiva") %>' Enabled="false" />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:CheckBox ID="chkAttiva" runat="server" Checked='<%# Bind("Attiva") %>' Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Piena" SortExpression="Piena">
                    <EditItemTemplate>
                        <asp:CheckBox ID="chkPiena" runat="server" Checked='<%# Bind("Piena") %>' Width="3em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkPiena" runat="server" Checked='<%# Bind("Piena") %>' Enabled="false" />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:CheckBox ID="chkPiena" runat="server" Checked='<%# Bind("Piena") %>' Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="X" SortExpression="X">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtX" runat="server" Text='<%# Bind("X") %>' Width="3em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblX" runat="server" Text='<%# Bind("X") %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtX" runat="server" Text='<%# Bind("X") %>' Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Y" SortExpression="Y">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtY" runat="server" Text='<%# Bind("Y") %>' Width="3em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblY" runat="server" Text='<%# Bind("Y") %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtY" runat="server" Text='<%# Bind("Y") %>' Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Z" SortExpression="Z">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtZ" runat="server" Text='<%# Bind("Z") %>' Width="3em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblZ" runat="server" Text='<%# Bind("Z") %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtZ" runat="server" Text='<%# Bind("Z") %>' Width="3em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="descrizione" SortExpression="Descrizione">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtDescrizione" runat="server" Text='<%# Bind("Descrizione") %>'
                            Width="15em" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblDescrizione" runat="server" Text='<%# Bind("Descrizione") %>' />
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtDescrizione" runat="server" Text='<%# Bind("Descrizione") %>'
                            Width="15em" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <HeaderTemplate>
                        <asp:LinkButton ID="btnNew" runat="server" OnClick="btnNew_Click" CssClass="btn btn-default btn-sm" Visible="true"><i class="fa fa-plus"></i> <%: traduci("New") %></asp:LinkButton>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"
                            CommandArgument='<%# Eval("IdxBlocco") %>' ToolTip='<%# traduci("Delete") %>'
                            Visible='<%# delEnabled(Eval("IdxBlocco")) %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.elimina , SteamWare.dimImg.small) %>' OnClientClick='<%# SteamWare.jsUtils.getCBE("confermaDel") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:ImageButton ID="imgUpdate2" runat="server" CausesValidation="False" CommandName="Update"
                            ToolTip='<%# traduci("Update")%>' ImageUrl='<%# imgPath(SteamWare.tipoImg.conferma , SteamWare.dimImg.small) %>' />
                        <asp:ImageButton ID="imgCancel2" runat="server" CausesValidation="False" CommandName="Cancel"
                            ToolTip='<%# traduci("Cancel") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.annulla , SteamWare.dimImg.small) %>' />
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:ImageButton ID="imgInsert2" runat="server" CausesValidation="False" CommandName="Insert"
                            ToolTip='<%# traduci("insert") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.nuovo , SteamWare.dimImg.small) %>'
                            OnClick="lblIns_click" />
                        <asp:ImageButton ID="imgCancel2" runat="server" CausesValidation="False" CommandName="Cancel"
                            ToolTip='<%# traduci("Cancel") %>' ImageUrl='<%# imgPath(SteamWare.tipoImg.annulla , SteamWare.dimImg.small) %>' />
                    </FooterTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="Original_{0}" SelectMethod="getByCodMag" TypeName="GMW_data.DS_magazzinoTableAdapters.CelleTableAdapter" OnInserting="recuperaFooter" OnInserted="ods_Updated" OnUpdated="ods_Updated" FilterExpression=" CodCella LIKE '%{0}%' OR Descrizione LIKE '%{0}%' " DeleteMethod="DeleteQuery" UpdateMethod="UpdateQuery" InsertMethod="Insert">
            <FilterParameters>
                <asp:SessionParameter DefaultValue="*" Name="ricerca" SessionField="valoreCercato" />
                <asp:SessionParameter Name="IdxBlocco" Type="Int32" SessionField="IdxBlocco_sel" DefaultValue="0" />
            </FilterParameters>
            <DeleteParameters>
                <asp:Parameter Name="Original_IdxCella" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Original_IdxCella" Type="Int32" />
                <asp:SessionParameter Name="CodCS" Type="String" SessionField="CodCS" DefaultValue="MM" />
                <asp:Parameter Name="CodCella" Type="String" />
                <asp:Parameter Name="IdxTipoCella" Type="Int32" />
                <asp:Parameter Name="Descrizione" Type="String" />
                <asp:Parameter Name="Attiva" Type="Boolean" />
                <asp:Parameter Name="Piena" Type="Boolean" />
                <asp:Parameter Name="IdxBlocco" Type="Int32" />
                <asp:Parameter Name="X" Type="Int32" />
                <asp:Parameter Name="Y" Type="Int32" />
                <asp:Parameter Name="Z" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:SessionParameter Name="CodCS" Type="String" SessionField="CodCS" DefaultValue="MM" />
                <asp:SessionParameter Name="CodMag" Type="String" SessionField="CodMag_sel" DefaultValue="MM" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="CodCS" Type="String" />
                <asp:Parameter Name="CodCella" Type="String" />
                <asp:Parameter Name="IdxTipoCella" Type="Int32" />
                <asp:Parameter Name="Descrizione" Type="String" />
                <asp:Parameter Name="Attiva" Type="Boolean" />
                <asp:Parameter Name="Piena" Type="Boolean" />
                <asp:Parameter Name="IdxBlocco" Type="Int32" />
                <asp:Parameter Name="X" Type="Int32" />
                <asp:Parameter Name="Y" Type="Int32" />
                <asp:Parameter Name="Z" Type="Int32" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:Label ID="lblNumRec" runat="server" CssClass="didascalia" />&nbsp;&nbsp;
    <asp:Label ID="lblWarning" runat="server" Visible="false" CssClass="erroreMid" />
        <asp:ObjectDataSource ID="odsBlocco" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="getByConditio" TypeName="GMW_data.DS_UtilityTableAdapters.v_selBloccoTableAdapter">
            <SelectParameters>
                <asp:SessionParameter Name="CodCS" Type="String" SessionField="CodCS" DefaultValue="MM" />
                <asp:SessionParameter Name="CodMag" Type="String" SessionField="CodMag_sel" DefaultValue="MM" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsTipoCella" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="getByConditio" TypeName="GMW_data.DS_UtilityTableAdapters.v_selTipoCellaTableAdapter">
            <SelectParameters>
                <asp:SessionParameter Name="CodMag" Type="String" SessionField="CodMag_sel" DefaultValue="MM" />
                <asp:SessionParameter Name="CodCS" Type="String" SessionField="CodCS" DefaultValue="MM" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</div>
