<%@ Page EnableEventValidation="false" Language="C#" 
    MasterPageFile="~/CITAD.Master" 
    AutoEventWireup="true" 
    CodeBehind="frmApprove_TrxIncom.aspx.cs" 
    Inherits="CITAD.Modules.KiemSoatLenhChuyenDen.Web.frmApprove_TrxIncom" 
    Title="Kiểm soát lệnh chuyển đến" 
    Culture="auto" 
    UICulture="auto"
    meta:resourcekey="PageResource1" %>

<%@ Register Src="../../Controls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language ="javascript" type ="text/javascript" >
	    //Cài đặt sự kiện phím tắt
        window.document.onkeyup=ShortcutKeys;
        function ShortcutKeys()
        {
            if(event.ctrlKey)
            {
                switch (event.keyCode)
                {
                    case 54://Ctrl + 6
                        __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuApprove');
                        break;
                    case 50://Ctrl + 2
                        __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuDetail');
                        break;
                    case 52://Ctrl + 4
                        __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuQuery');
                        break;
                    case 69://Ctrl + E
                        __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuClose');
                        break;
                }
            }
        }
    </script>
    <div class="divMain">
        <div style="position:absolute;top:-200px;">
            <ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1" EnableScriptGlobalization="True"
             EnableScriptLocalization="True" CombineScripts="True" EnablePageMethods="true"  />
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="rdbPayment" EventName="CheckedChanged" />
            <asp:AsyncPostBackTrigger ControlID="Menu1" EventName="MenuItemClick" />
        </Triggers>
        <ContentTemplate> 
    <div>
        <table class="toolbar" cellpadding="0" cellspacing="0" >
        <tr><td class="toolbar-tdleft"></td>
        <td class="toolbar-tdmain">
        <asp:Menu ID="Menu1" runat="server" 
            DynamicHorizontalOffset="2" 
            Font-Names="Verdana"
            Font-Size="11px"
            OnMenuItemClick="Menu1_MenuItemClick"
            Orientation="Horizontal" 
            CssClass="citad-menu" 
            StaticSubMenuIndent="10px" 
            meta:resourcekey="Menu1Resource1"
            >
                <Items>
                    <asp:MenuItem Text="Tho&#225;t" Value="mnuClose" meta:resourcekey="MenuItemResource5" ImageUrl="~/Images/Menu/home.gif" SeparatorImageUrl="~/Images/menu/separator_h.gif"></asp:MenuItem>
                    <asp:MenuItem Text="Duyệt" Value="mnuApprove" meta:resourcekey="MenuItemResource2" ImageUrl="~/Images/Menu/approve.gif" SeparatorImageUrl="~/Images/menu/separator_h.gif"></asp:MenuItem>
                    <asp:MenuItem Text="Chi tiết" Value="mnuDetail" meta:resourcekey="MenuItemResource3" ImageUrl="~/Images/Menu/open.gif" SeparatorImageUrl="~/Images/menu/separator_h.gif"></asp:MenuItem>
                    <asp:MenuItem Text="Truy vấn" Value="mnuQuery" meta:resourcekey="MenuItemResource4" ImageUrl="~/Images/Menu/search.gif"></asp:MenuItem>
                    <asp:MenuItem Text="Tho&#225;i" Value="mnuReject" Enabled="false" ></asp:MenuItem>
                </Items>
            <StaticMenuStyle CssClass="citad-menu" />
            <StaticSelectedStyle CssClass="citad-menu-selected" />
            <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
            <StaticHoverStyle CssClass="citad-menu-hover" />
            </asp:Menu>
       </td>
       </tr>
    </table>
    </div>
     
    <div>
        <table width="100%">
            <tr>
                <td colspan="2">
                <fieldset style="padding-left:15px;"><legend>
                    <asp:Label ID="lblServiceType" runat="server" Text="Loại dịch vụ" meta:resourcekey="lblServiceTypeResource1"></asp:Label></legend>
                    <table>
                        <tr>
                            <td style="width: 100px;">
                                <asp:RadioButton ID="rdbPayment" runat="server" Text="Chuyển tiền" Checked="True" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbPayment_CheckedChanged" meta:resourcekey="rdbPaymentResource1" /></td>
                            <td style="width: 100px;">
                                <asp:RadioButton ID="rdbLM" runat="server" Text="Tra so&#225;t" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbLM_CheckedChanged" meta:resourcekey="rdbLMResource1" /></td>
                            <td style="width: 120px;">
                                <asp:RadioButton ID="rdbFR" runat="server" Text="Ho&#224;n chuyển" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbFR_CheckedChanged" meta:resourcekey="rdbFRResource1" /></td>
                            <td style="width: 125px;">
                                <asp:RadioButton ID="rdbPADX" runat="server" Text="Trả lời chuyển nợ" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbPADX_CheckedChanged" meta:resourcekey="rdbPADXResource1" /></td>
                            <td style="width: 136px;">
                                <asp:RadioButton ID="rdbFRX" runat="server" Text="Trả lời ho&#224;n chuyển" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbFRX_CheckedChanged" meta:resourcekey="rdbFRXResource1" /></td>
                            <td>
                                <asp:RadioButton ID="rdbLMX" runat="server" Text="Trả lời tra so&#225;t" GroupName="TrxType" AutoPostBack="True" OnCheckedChanged="rdbLMX_CheckedChanged" meta:resourcekey="rdbLMXResource1" /></td>
                        </tr>
                    </table>
                </fieldset>
                </td>
            </tr>
            <tr>
                <td style="width: 50%">
                    <fieldset style="padding-left:15px;"><legend>
                        <asp:Label ID="lblTrxType" runat="server" Text="Loại dịch vụ" meta:resourcekey="lblTrxTypeResource1"></asp:Label></legend>
                        <table>
                            <tr>
                                <td style="width: 100px">
                                    <asp:RadioButton ID="rdbLV" runat="server" Text="Gi&#225; trị thấp" GroupName="ServiceType" AutoPostBack="True" OnCheckedChanged="rdbLV_CheckedChanged" meta:resourcekey="rdbLVResource1" /></td>
                                <td style="width: 100px">
                                    <asp:RadioButton ID="rdbHV" runat="server" Text="Gi&#225; trị cao" GroupName="ServiceType" AutoPostBack="True" OnCheckedChanged="rdbHV_CheckedChanged" meta:resourcekey="rdbHVResource1" /></td>
                                <td>
                                    <asp:RadioButton ID="rdbAll" runat="server" Text="Tất cả" Checked="True" GroupName="ServiceType" AutoPostBack="True" OnCheckedChanged="rdbAll_CheckedChanged" meta:resourcekey="rdbAllResource1" /></td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
                <td>
                    <fieldset style="padding-left:15px;"><legend>
                        <asp:Label ID="lblTrxStatus" runat="server" Text="Trạng th&#225;i" meta:resourcekey="lblTrxStatusResource1"></asp:Label></legend>
                        <table>
                            <tr>
                                <td style="width: 120px;">
                                    <asp:RadioButton ID="rdbNotApprove" runat="server" Text="Chưa kiểm so&#225;t" Checked="True" GroupName="TrxStatus" AutoPostBack="True" OnCheckedChanged="rdbNotApprove_CheckedChanged" meta:resourcekey="rdbNotApproveResource1" /></td>
                                <td style="width: 120px;">
                                    <asp:RadioButton ID="rdbApprove" runat="server" Text="Đ&#227; kiểm so&#225;t" GroupName="TrxStatus" AutoPostBack="True" OnCheckedChanged="rdbApprove_CheckedChanged" meta:resourcekey="rdbApproveResource1" /></td>
                                <td>
                                    <asp:RadioButton ID="rdbAllTrxStatus" runat="server" Text="Tất cả" GroupName="TrxStatus" AutoPostBack="True" OnCheckedChanged="rdbAllTrxStatus_CheckedChanged" meta:resourcekey="rdbAllTrxStatusResource1" /></td>
                            </tr>
                        </table>
                    </fieldset>
                </td>
            </tr>
            <tr>
                <td style="width: 50%">
                    <asp:CheckBox ID="chkAutoApprove" runat="server" visible="false" 
                        AutoPostBack="true" 
                        ForeColor="Blue" 
                        Text="Tự động duyệt" 
                        OnCheckedChanged="chkAutoApprove_CheckedChanged" 
                        meta:resourcekey="chkAutoApproveResource1" /></td>
                <td align="right">
                    <asp:Label ID="lblTongSo" runat="server" meta:resourcekey="lblTongSoResource1" Text="Tổng số" Font-Bold="True"></asp:Label>
                    <asp:Label ID="lblCount" runat="server" Font-Bold="True"></asp:Label></td>
            </tr>
        </table>
    </div>
           
    <div style="overflow-x:scroll;width:770px;">            
        <asp:GridView ID="grvListTrx" runat="server" 
            AllowPaging="True" 
            AutoGenerateColumns="False"
            CellPadding="1" 
            DataKeyNames="MSG_KEY,TRX_STATUS,E_SIGN,SERIAL_NO,MAC" 
            meta:resourcekey="dgvListTrxResource1"
            OnPageIndexChanging="grvListTrx_PageIndexChanging" 
            OnRowDataBound="grvListTrx_RowDataBound" 
            Width="1424px"
            CssClass="grid" 
            OnSelectedIndexChanged="grvListTrx_SelectedIndexChanged" 
            AllowSorting="True" 
            OnSorting="grvListTrx_Sorting">
                <FooterStyle CssClass="grid-footer" />
                <RowStyle CssClass="grid-row" />
                <SelectedRowStyle CssClass="grid-selectedRow" />
                <PagerStyle HorizontalAlign="Left" CssClass="grid-pager" />
                <HeaderStyle CssClass="grid-header" />
                <AlternatingRowStyle CssClass="grid-alternating" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HiddenField ID="hidESIGN_MESSAGE" runat="server" />
                    </ItemTemplate>
                    <ItemStyle CssClass="invisible" />
                    <HeaderStyle CssClass="invisible" />
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HiddenField ID="hidESIGN_CONTENT" runat="server" />
                    </ItemTemplate>
                    <ItemStyle CssClass="invisible" />
                    <HeaderStyle CssClass="invisible" />
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HiddenField ID="hidUSER_CERT_APPR" runat="server" />
                    </ItemTemplate>
                    <ItemStyle CssClass="invisible" />
                    <HeaderStyle CssClass="invisible" />
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HiddenField ID="hidRESULT_VALID_ESIGN" runat="server" />
                    </ItemTemplate>
                    <ItemStyle CssClass="invisible" />
                    <HeaderStyle CssClass="invisible" />
                </asp:TemplateField>

                <asp:TemplateField meta:resourcekey="TemplateFieldResource1">
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkCheckAll" runat="server" onclick="CheckAll(this,'chkOne');" meta:resourcekey="chkCheckAllResource1"/>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input id="chkOne" runat="server" type="checkbox" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                    <HeaderStyle Width="20px" HorizontalAlign="Center" />
                </asp:TemplateField>
               
                 <asp:BoundField DataField="STT" HeaderText="STT" meta:resourcekey="BoundFieldResource15">
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>  
                                                        
               <asp:BoundField HeaderText="Số b&#250;t to&#225;n" meta:resourcekey="BoundFieldResource1">
                    <HeaderStyle Width="100px" />
                    <ItemStyle HorizontalAlign="Left" Width="100px"  />
                </asp:BoundField>
                
                <asp:TemplateField meta:resourcekey="TemplateFieldResource1">
                        <HeaderTemplate>
                            <%--<asp:Label runat="server" ID="lblSERIAL_NO1" Text="Số hiệu giao dịch" meta:resourcekey="Label1Resource1"></asp:Label>--%>
                            <asp:LinkButton runat="server" ID="lblSERIAL_NO1" Text="Số hiệu giao dịch" CommandName="Sort" CommandArgument="SERIAL_NO" meta:resourcekey="Label1Resource1" />
                        </HeaderTemplate>
                        <HeaderStyle Width="60px" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:LinkButton ID="lbtSERIAL_NO" runat="server" CommandName="Select" Text='<%# Bind("SERIAL_NO") %>'></asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                     </asp:TemplateField>
                
                <asp:BoundField HeaderText="Ng&#224;y lệnh" meta:resourcekey="BoundFieldResource3">
                    <HeaderStyle Width="100px" />
                    <ItemStyle HorizontalAlign="Center" Width="100px"  />
                </asp:BoundField>
                <asp:BoundField HeaderText="Loại giao dịch" meta:resourcekey="BoundFieldResource31">
                    <HeaderStyle Width="110px" />
                    <ItemStyle HorizontalAlign="Left" Width="110px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="T&#236;nh trạng" meta:resourcekey="BoundFieldResource6">
                    <HeaderStyle Width="120px" />
                    <ItemStyle HorizontalAlign="Left" Width="120px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="M&#227; ng&#226;n h&#224;ng gửi"
                    meta:resourcekey="BoundFieldResource7">
                    <ItemStyle HorizontalAlign="Center" Width="100px" />
                    <HeaderStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Số tiền" meta:resourcekey="BoundFieldResource5">
                    <HeaderStyle Width="110px" />
                    <ItemStyle HorizontalAlign="Right" Width="110px" />
                </asp:BoundField>                    
                <asp:BoundField HeaderText="Người gửi" meta:resourcekey="BoundFieldResource4">
                    <HeaderStyle Width="230px" />
                    <ItemStyle Width="230px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="Người nhận" meta:resourcekey="BoundFieldResource8">
                    <HeaderStyle Width="230px" />
                    <ItemStyle Width="230px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="T&#224;i khoản người gửi" meta:resourcekey="BoundFieldResource9">
                    <HeaderStyle Width="130px" />
                    <ItemStyle Width="130px" />
                </asp:BoundField>
                <asp:BoundField HeaderText="T&#224;i khoản người nhận" meta:resourcekey="BoundFieldResource10">
                    <HeaderStyle Width="130px" />
                    <ItemStyle Width="130px" />
                </asp:BoundField>                
                <asp:BoundField HeaderText="T&#234;n file GD" meta:resourcekey="BoundFieldResource12" DataField="TRX_FILE_NAME" />                
            </Columns>
            <EmptyDataTemplate>
                <asp:Label ID="lblEmptyDataGrid" runat="server" meta:resourcekey="lblEmptyDataGridResource1"
                    Text="Kh&#244;ng tồn tại"></asp:Label>
            </EmptyDataTemplate>
            <PagerSettings Mode="NumericFirstLast" />
        </asp:GridView></div>
            <uc1:MessageBox ID="MessageBox1" runat="server" />
            <asp:Timer ID="Timer1" Enabled="false" runat="server" OnTick="Timer1_Tick" Interval="5000">
        </asp:Timer>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
<script type="text/javascript">

    var postbackElement;
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

    function beginRequest(sender, args)
    {
        postbackElement = args.get_postBackElement();
    }

    function pageLoaded(sender, args)
    {
        var chkAutoApprove = document.getElementById('<%=chkAutoApprove.ClientID %>');

        if(!chkAutoApprove) return;
        DV_isCHECK_USER_PIN = true;
        if(chkAutoApprove.checked)
        {
            var k = 0;
            switch(postbackElement.id)
            {
                case '<%=Timer1.ClientID %>':
                    k = CheckAllGrid('chkOne');
                    if(k!=0)
                    {
                        setTimeout("fcnSign()",0)
                    }
                    break;
                case '<%=chkAutoApprove.ClientID %>':
                    if(DV_isFirstCheckPalmvein)
                    {
                        DV_isFirstCheckPalmvein = false;
                    }
                    else
                    {
                        k = CheckAllGrid('chkOne');
                        if(k!=0)
                        {
                            setTimeout("fcnSign()",0)
                        }
                    }
                    break;
            }
        }
        else
        {
            var TimerID = '<%=Timer1.ClientID %>';
            var timer = $find(TimerID);
            EnableTimer(timer, false);
        }
    }
//Hàm lập trạng thái cho timer
//input: timer, flag (true,false))
function EnableTimer(timer, flag)
{
    try
    {
        timer.set_enabled(flag);

        if (timer.get_enabled())
            timer._startTimer();
        else
            timer._stopTimer();
    }
    catch(err){}
}

function CheckAllGrid(chkBoxID) 
{
    var k = 0;
    for (var i=0;i<document.forms[0].elements.length;i++) 
    {
        var e = document.forms[0].elements[i];
        if(e.type=='checkbox')
        {
            if(e.name.match(chkBoxID) !=null)
            {
                e.checked = true;
                k++;
            }
        }
    }
    return k;
}
    </script>
</asp:Content>