<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MstIntBankAccountList.ascx.cs" Inherits="APC.Forms.UserControls.MstIntBankAccountList" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script language="javascript">
    var prepareCommand = function (grid, command, record, row) 
    {
        if (command.command == 'Delete' && !grid.allowEdit) {
            command.hidden = true;
            command.hideMode = 'display'; //you can try 'visibility' also                 
        }
    };
</script>
 <ext:GridPanel ID="grdBankList" runat="server" AnchorHorizontal="100%" AnchorVertical="100%" AutoScroll="true" runat="server" Height="100">
 <TopBar>
            <ext:Toolbar ID="Toolbar2" runat="server">
            <Items>
                <ext:Button ID="btnAdd" runat="server" Text="Add..." Icon="Add" Disabled="True">
                <DirectEvents>
                    <Click OnEvent="AddBank_Click">
                        <EventMask ShowMask="true"/>
                    </Click>
                </DirectEvents>
                </ext:Button>
            </Items>
            </ext:Toolbar>
 </TopBar>
 <Store>
<ext:Store ID="Store1" runat="server" OnReadData="BankList_Refresh">
    <Model>
        <ext:Model ID="Model1" runat="server" IDProperty="Id">
     <Fields>
        <ext:ModelField Name="BankName"/>
        <ext:ModelField Name="AccountName" />
        <ext:ModelField Name="AccountNumber" />
        <ext:ModelField Name="BankSwift" />
        <ext:ModelField Name="LoadDate" SortType="AsDate" Type="Date"/>
        <ext:ModelField Name="LoadUser"/>
    </Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
       <ColumnModel>
            <Columns>
                 <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="15" />
                  <ext:ImageCommandColumn ID="ImageCommandColumn1" runat="server" Width="40">
                            <Commands>
                                <ext:ImageCommand Icon="Magnifier" CommandName="Edit">
                                    
                                    <ToolTip Text="View/Edit"/>
                                </ext:ImageCommand>
                                <ext:ImageCommand Icon="Delete" CommandName="Delete">
                                    <ToolTip Text="Delete this Bank Account" />
                                </ext:ImageCommand>
                            </Commands>
                            <PrepareCommand Fn="prepareCommand" />
                                           <DirectEvents>
                        <Command OnEvent="Command" Timeout="200000" Success="#{grdBankList}.store.reload();">
                            <Confirmation ConfirmRequest="True" BeforeConfirm="return (command != 'Edit');" Message="Are you sure ?" Title="Bank Account Delete"></Confirmation>
                            <EventMask ShowMask="True"></EventMask>
                            <ExtraParams>
                                <ext:Parameter Name="id" Value="record.data.Id" Mode="Raw" />
                                <ext:Parameter Name="command" Value="command" Mode="Raw" />
                            </ExtraParams>
                        </Command>
                       </DirectEvents>

                 </ext:ImageCommandColumn>                      
                 <ext:Column ID="colAccountNumber" runat="server" Text="Number" DataIndex="AccountNumber" Width="100" Sortable="True"/>
                 <ext:Column ID="colAccountName" runat="server" Text="Name" DataIndex="AccountName" Width="200" Sortable="True" Flex="1"/>       
                 <ext:Column ID="colBankName" runat="server" Text="Bank" DataIndex="BankName" Width="100"/>       
                 <ext:Column ID="colBankSwift" runat="server" Text="Swift Code" DataIndex="BankSwift" Width="100"/>       
                 <ext:DateColumn ID="DateColumn1" runat="server" Format="yyyy-MM-dd hh:mmtt" Text="Load Date" DataIndex="LoadDate" Width="120" Sortable="True"/>
                 <ext:Column ID="colBankUser" runat="server" Text="Load User" DataIndex="LoadUser" Width="150"/>       
            </Columns>            
        </ColumnModel>       
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
        </SelectionModel>
            <Features>
            <ext:GridFilters Local="true">
            <Filters>
            <ext:StringFilter DataIndex="AccountNumber" />
            </Filters>
            </ext:GridFilters>
            </Features>
</ext:GridPanel>
<ext:Window ID="BankForm2" Height="300" Width="400" Title="Banking Details" Closable="true" CloseAction=Hide runat="server" Hidden="true" Modal="true" Layout="FitLayout" Constrain="false" Floating="True" Frame="False" ResizeHandles="All" Y="-10">
 <Listeners>
 <Close Handler="#{grdBankList}.store.reload();"></Close>
 </Listeners>
<Items>
    

    <ext:UserControlLoader Path="~/Forms/UserControls/MstIntBankAccountCapture.ascx" runat="server" ID="BankControl" />
</Items>
<TopBar>
<ext:Toolbar ID="toolEdit" runat="server">
<Items>
    <ext:Button runat="server" Text="Save" Icon="Disk" ID="btnSave">
    <DirectEvents>
     <Click OnEvent="SaveBank" Before="return #{BankCapturePanel}.isValid();" Success="#{BankForm2}.close();">
                                            <ExtraParams>
                                                <ext:Parameter Name="values" Value="#{BankCapturePanel}.getForm().getValues()" Mode="Raw" Encode="true"/>
                                            </ExtraParams>
                                            </Click>
                                            </DirectEvents>
                                          </ext:Button>     
                                <ext:ToolbarFill />
                              </Items>
                              </ext:Toolbar>                        
                            </TopBar>

</ext:Window>

