<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmPlanDeCuentas.aspx.cs" Inherits="frmPlanDeCuentas" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Plan de Cuentas</title>
    <link href="estilos/Estilos.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="JavaScript/actb.js"></script>
    <script language="javascript" type="text/javascript" src="JavaScript/common.js"></script>
    <script language="javascript" type="text/javascript" src="JavaScript/SGH_Script.js"></script>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    
    function RadGrid_RowSelected(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        cell_valor = MasterTable.getCellByColumnUniqueName(row, "PlanCuentaID");
        cell_valor = cell_valor.innerHTML;
        $find("<%= RadAjaxManager1.ClientID%>").ajaxRequest("seleccionaFila," + cell_valor);
        CloseAndRebind('PC');
    }

    function RowSelected(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "PlanCuentaID");
        CloseAndRebind('PC');
    }

    function CloseAndRebind(args) {
        GetRadWindow().Close();
        GetRadWindow().BrowserWindow.refreshGrid(args);
    }

    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)

        return oWindow;
    }

    function CancelEdit() {
        GetRadWindow().Close();
    }
</script> 
</telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
        
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
    <div>
    
            <telerik:RadGrid 
                AutoGenerateColumns="False" ID="tk_Grid" AllowPaging="True" PageSize="20" AllowSorting="True" 
                runat="server" Height="530" Width="500px" AllowFilteringByColumn="True" Skin="Office2007" 
                onneeddatasource="tk_Grid_NeedDataSource" OnItemCommand="tk_Grid_ItemCommand" 
                onitemdatabound="tk_Grid_ItemDataBound" ClientSettings-DataBinding-EnableCaching="true" 
                onprerender="tk_Grid_PreRender" >
                <PagerStyle Mode="NumericPages" PageButtonCount="15" />
                <HeaderStyle CssClass="arial10bold" Font-Bold="true"/>
                <FilterItemStyle HorizontalAlign="Right" />
                <ExportSettings  ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" >
                    <Pdf PageWidth="480mm" Creator="SGH-Peru" Author="Sistema de Contabilidad" PageBottomMargin="5px" PageTopMargin="5px" PageLeftMargin="5px" PageRightMargin="5px" />
                </ExportSettings>
                <GroupingSettings CaseSensitive="False" />
                <ClientSettings EnableRowHoverStyle="true">
                    <DataBinding EnableCaching="True"></DataBinding>
                    <Selecting AllowRowSelect="true" />
                    <Scrolling AllowScroll="true" UseStaticHeaders="true"/>
                    <ClientEvents  OnRowSelected="RadGrid_RowSelected" />
                </ClientSettings>
                <MasterTableView DataKeyNames="PlanCuentaID" CellSpacing="0">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="PlanCuentaID" DataField="PlanCuentaID" DataType="System.String" 
                            UniqueName="PlanCuentaID" SortExpression="PlanCuentaID" AutoPostBackOnFilter="true" 
                            CurrentFilterFunction="StartsWith" ShowFilterIcon="false" HeaderStyle-Width="50px" 
                            FilterControlWidth="100%" Display="false">
                            <HeaderStyle Width="60px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Left" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Codigo" DataField="CodigoPlanCuenta" DataType="System.String" UniqueName="CodigoPlanCuenta"
                            SortExpression="CodigoPlanCuenta" AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith"  
                            ShowFilterIcon="false" HeaderStyle-Width="50px" FilterControlWidth="100%">
                            <HeaderStyle Width="60px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Left" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Nombre" DataField="NombrePlanCuenta" UniqueName="NombrePlanCuenta"
                            SortExpression="NombrePlanCuenta" AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith"
                            ShowFilterIcon="false" HeaderStyle-Width="170px" FilterControlWidth="100%">
                            <HeaderStyle Width="320px" />
                            <ItemStyle HorizontalAlign="Left" />
                        </telerik:GridBoundColumn>

                    </Columns>
                </MasterTableView>
        </telerik:RadGrid>
        <asp:Button ID="btnSelect" runat="server" Text="Seleccionar" CssClass="Button" onclick="btnSelect_Click"/>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        </telerik:RadAjaxManager>
    </div>
    </form>
</body>
</html>
