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

<%@ Register Src="../../Controls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divMain">

        <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;
                }
            }
            if(event.keyCode == 13)
            {
                var tablet = document.getElementById('eventSRC');
                if(tablet.contains(event.srcElement)){
                    __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuQuery');
                }
            }
        }
        function fcnOnkeypress()
        {
            if(event.keyCode == 13)
            {
                __doPostBack('ctl00$ContentPlaceHolder1$Menu1','mnuQuery');
                return false;
            }
        }
        </script>

        <script type="text/javascript">
	    //window.document.onkeydown=KeyDown;
	    //=====================================
	    function formload()
	    {
	        document.getElementById('<%=txtRelation_No.ClientID %>').focus();
	    }
        window.document.onload = formload;
        </script>

        <ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1" EnableScriptGlobalization="True"
            EnableScriptLocalization="True" CombineScripts="True" EnablePageMethods="true"
            EnablePartialRendering="true" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <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"
                                StaticHoverStyle-CssClass="citad-menu-hover" StaticMenuStyle-CssClass="citad-menu"
                                StaticSelectedStyle-CssClass="citad-menu-selected" StaticMenuItemStyle-HorizontalPadding="5px"
                                StaticMenuItemStyle-VerticalPadding="2px">
                                <Items>
                                    <asp:MenuItem Text="Thoá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>
                                </Items>
                                <StaticMenuStyle CssClass="citad-menu" />
                                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                                <StaticSelectedStyle CssClass="citad-menu-selected" />
                                <StaticHoverStyle CssClass="citad-menu-hover" />
                            </asp:Menu>
                        </td>
                    </tr>
                </table>
                <table id="eventSRC">
                    <tr>
                        <td style="width: 83px">
                            <asp:Label ID="lblRelation_No" runat="server" meta:resourcekey="Label1Resource1"
                                Text="Số bút toán"></asp:Label></td>
                        <td style="width: 178px">
                            <asp:TextBox ID="txtRelation_No" CssClass="citad-txt" runat="server" meta:resourcekey="txtRelation_NoResource1"
                                Width="135px" onpropertychange="Upper()" onkeypress="return fcnOnkeypress();"
                                MaxLength="40"></asp:TextBox></td>
                        <td style="width: 97px">
                            <asp:Label ID="lblTrx_Status" runat="server" meta:resourcekey="lblTrx_StatusResource1"
                                Text="Tình trạng"></asp:Label></td>
                        <td colspan="2">
                            <asp:DropDownList ID="cboTrx_Status" runat="server" Width="232px" meta:resourcekey="cboTrx_StatusResource1">
                            </asp:DropDownList></td>
                        <td colspan="1">
                            <asp:CheckBox ID="chkTimChinhXac" runat="server" Checked="True" Text="Tìm chính xác"
                                meta:resourcekey="chkTimChinhXacResource1" /></td>
                    </tr>
                    <tr>
                        <td colspan="2" valign="middle">
                            <fieldset>
                                <legend>
                                    <asp:Label ID="grbTrxType" runat="server" meta:resourcekey="grbTrxTypeResource1"
                                        Text="Loại giao dịch"></asp:Label></legend>
                                <asp:RadioButton ID="rdbLV" runat="server" meta:resourcekey="rdbLVResource1" Text="Giá trị thấp"
                                    GroupName="TrxType" />
                                <asp:RadioButton ID="rdbHV" runat="server" meta:resourcekey="rdbHVResource1" Text="Giá trị cao"
                                    GroupName="TrxType" />
                                <asp:RadioButton ID="rdbAll" runat="server" meta:resourcekey="rdbAllResource1" Checked="True"
                                    Text="Tất cả" GroupName="TrxType" />
                            </fieldset>
                        </td>
                        <td style="width: 97px" valign="middle">
                            <asp:Label ID="lblRCI" runat="server" meta:resourcekey="lblRCIResource1" Text="Ngân hàng nhận"></asp:Label></td>
                        <td style="width: 135px" valign="middle">
                            <asp:TextBox ID="txtRCICode" CssClass="citad-txt" runat="server" meta:resourcekey="TextBox1Resource1"
                                Width="135px" MaxLength="12"></asp:TextBox></td>
                        <td style="width: 105px" valign="middle">
                            <asp:Label ID="lblSerial_No" runat="server" meta:resourcekey="lblSerial_NoResource1"
                                Text="Số hiệu giao dịch"></asp:Label></td>
                        <td style="width: 125px" valign="middle">
                            <asp:TextBox ID="txtSerial_No" CssClass="citad-txt" runat="server" meta:resourcekey="TextBox2Resource1"
                                Width="135px" MaxLength="8"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td align="right" colspan="5" valign="middle">
                        </td>
                    </tr>
                </table>
                <div style="float: left;">
                    <asp:CheckBox ID="chkAutoApprove" runat="server" visible="false" 
                        AutoPostBack="true" 
                        Text="Tự động duyệt"
                        ForeColor="Blue" 
                        OnCheckedChanged="chkAutoApprove_CheckedChanged" 
                        meta:resourcekey="chkAutoApproveResource1" />
                </div>
                <div style="float: right;">
                    <asp:Label ID="lblTongSo" runat="server" Text="Tổng số: " Font-Bold="True" meta:resourcekey="lblTongSo"></asp:Label>
                    <asp:Label ID="lblCount" runat="server" Font-Bold="True"></asp:Label>
                </div>
                <asp:GridView DataKeyNames="ID,MAC,SERIAL_NO" ID="grvListTrx" runat="server" CellPadding="1"
                    meta:resourcekey="dgvListTrxResource1" AllowPaging="True" OnPageIndexChanging="grvListTrx_PageIndexChanging"
                    OnRowDataBound="grvListTrx_RowDataBound" AutoGenerateColumns="False" CssClass="grid"
                    AllowSorting="true" OnSelectedIndexChanged="grvListTrx_SelectedIndexChanged"
                    OnSorting="grvListTrx_Sorting">
                    <FooterStyle CssClass="grid-footer" />
                    <RowStyle CssClass="grid-row" />
                    <SelectedRowStyle CssClass="grid-selectedRow" />
                    <PagerStyle HorizontalAlign="Center" CssClass="grid-pager" />
                    <HeaderStyle CssClass="grid-header" />
                    <AlternatingRowStyle CssClass="grid-alternating" />
                    <Columns>
                        <asp:TemplateField meta:resourcekey="TemplateFieldResource1">
                            <HeaderTemplate>
                                <asp:CheckBox ID="chkCheckAll" runat="server" onclick="return CheckAll(this,'chkOne');"
                                    meta:resourcekey="chkCheckAllResource1" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="chkOne" type="checkbox" runat="server" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle Width="20px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="STT" meta:resourcekey="TemplateFieldResource11">
                            <HeaderTemplate>
                                <asp:Label ID="lblSTT" Text="STT" runat="server" meta:resourcekey="lblSTTResource1"></asp:Label>
                            </HeaderTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="30px" />
                            <ItemStyle HorizontalAlign="Center" Width="30px" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="RELATION_NO" HeaderText="Số b&#250;t to&#225;n" meta:resourcekey="BoundFieldResource1"
                            SortExpression="RELATION_NO">
                            <HeaderStyle Width="60px" HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:TemplateField meta:resourcekey="TemplateFieldResource1" SortExpression="SERIAL_NO">
                            <HeaderTemplate>
                                <%--<asp:Label runat="server" ID="lblSERIAL_NO_GRID" Text="Số hiệu giao dịch" meta:resourcekey="lblSerial_NoResource1"></asp:Label>--%>
                                <asp:LinkButton runat="server" ID="lblSERIAL_NO_GRID" Text="Số hiệu giao dịch" CommandName="Sort"
                                    CommandArgument="SERIAL_NO" meta:resourcekey="lblSerial_NoResource1" />
                            </HeaderTemplate>
                            <HeaderStyle Width="70px" 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="Loại giao dịch" meta:resourcekey="BoundFieldResource3">
                            <HeaderStyle Width="100px" HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField HeaderText="Nợ c&#243;" meta:resourcekey="BoundFieldResource4">
                            <HeaderStyle Width="100px" HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField HeaderText="Số tiền" DataField="AMOUNT" meta:resourcekey="BoundFieldResource5"
                            SortExpression="AMOUNT">
                            <HeaderStyle Width="100px" HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Right" />
                        </asp:BoundField>
                        <asp:BoundField HeaderText="T&#236;nh trạng" meta:resourcekey="BoundFieldResource6">
                            <HeaderStyle Width="180px" HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField HeaderText="M&#227; ng&#226;n h&#224;ng nhận" DataField="CI_CODE"
                            meta:resourcekey="BoundFieldResource7" SortExpression="CI_CODE">
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField ItemStyle-CssClass="invisible" HeaderStyle-CssClass="invisible">
                            <ItemTemplate>
                                <asp:HiddenField ID="hidESIGN_MESSAGE" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-CssClass="invisible" HeaderStyle-CssClass="invisible">
                            <ItemTemplate>
                                <asp:HiddenField ID="hidESIGN_CONTENT" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </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>
                <asp:HiddenField ID="txtRCIID" runat="server" />
                <uc1:MessageBox ID="MessageBox1" runat="server" />
                <asp:Timer ID="Timer1" runat="server" Interval="5000" Enabled="False" OnTick="Timer1_Tick">
                </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;

        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>
