<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmEmpresa.aspx.cs" Inherits="frmEmpresa" %>
<%@ 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>Empresas</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, "EmpresaID");
            cell_valor = cell_valor.innerHTML;
            $find("<%= RadAjaxManager1.ClientID%>").ajaxRequest("seleccionaFila," + cell_valor);
            CloseAndRebind('EMP');
        }
        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">    
    <div>
         <telerik:RadGrid AutoGenerateColumns="False" ID="tk_Grid" AllowPaging="True" PageSize="40" 
                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">
                    <Selecting AllowRowSelect="true" />
                    <Scrolling AllowScroll="true" UseStaticHeaders="true"/>
                    <ClientEvents OnRowSelected="RadGrid_RowSelected" />
                </ClientSettings>
                <MasterTableView DataKeyNames="EmpresaID" CellSpacing="0" ClientDataKeyNames="EmpresaID">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="EmpresaID" DataField="EmpresaID" DataType="System.String" 
                            UniqueName="EmpresaID" SortExpression="EmpresaID" AutoPostBackOnFilter="true" 
                            CurrentFilterFunction="StartsWith" ShowFilterIcon="false" HeaderStyle-Width="100px" 
                            FilterControlWidth="100%" Display="false">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Left" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Ruc" DataField="Ruc" DataType="System.String" UniqueName="Ruc"
                            SortExpression="Ruc" AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith"  
                            ShowFilterIcon="false" HeaderStyle-Width="100px" FilterControlWidth="100%">
                            <HeaderStyle Width="100px"></HeaderStyle>
                            <ItemStyle HorizontalAlign="Left" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Razonsocial" DataField="Razonsocial" UniqueName="Razonsocial"
                            SortExpression="Razonsocial" 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"/>
    </div>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="tk_Grid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="tk_Grid" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls> 
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Telerik" />

    </form>
</body>
</html>
