jueves, 7 de abril de 2016

C# - Devexpress exportar excel con update panel y callback panel

* segundo update panel afuera del update panel y callback que envuelven la página, con un botón exportar dentro
*boton exportar gatilla el click del botón que esta en el update panel de fuera.

.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Ingresados.aspx.cs" Inherits="LeaseOperWeb.Paginas.Compras.CargaFacturasCompra.Ingresados" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1" Namespace="DevExpress.Web.ASPxGridView"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%--<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>--%>
<%@ Register TagPrefix="dxp" Namespace="DevExpress.Web.ASPxPanel" %>
<%@ Register Assembly="SmComponents" Namespace="SmComponents.SmComponent" TagPrefix="cc1" %>
<%@ Register TagPrefix="cc2" Namespace="SmComponents.SmComponent" Assembly="SmComponents" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="../../../Scripts/JSValidadores.js" type="text/javascript"></script>
    <script src="../../../Scripts/JSDocumentos.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery-1.5.2.js" type="text/javascript"></script>
    <!--#include file="~/Scripts/jquery.includes.htm"-->
    <link href="~/css/style-css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .elementoIzq
        {
            float: left;
        }
    </style>
    <script type="text/javascript" language="javascript">

        function EndCallBackGv(s, e) {
            if (s.cpError != null && s.cpError == 'true') {
                eval(s.cpMensaje);
                s.cpError = null;
                s.cpMensaje = null;
            }

            if (s.cpActualizar != null && s.cpActualizar == 'true') {
                eval(s.cpMensaje);
                s.cpActualizar = null;
                s.cpMensaje = null;
            }
            if (s.cpEliminar != null && s.cpEliminar == 'true') {
                eval(s.cpMensaje);
                s.cpEliminar = null;
                s.cpMensaje = null;
            }
            if (s.cpLimpiar != null && s.cpLimpiar == 'true') {
                s.cpLimpiar = null;
            }
        }

        function EndCallBackTxt(s, e) {
            if (s.cpOk != null && s.cpOk == 'true') {

            }
        }

        function EndCallback(s, e) {
            if (s.cpFlag != null && s.cpFlag == 'true') {
                eval(s.cpReturn);
                s.cpFlag = null;
                s.cpReturn = null;
            }
            else if (s.cpOk != null && s.cpOk == 'true') {
                eval(s.cpReturn);
                s.cpOk = null;
                s.cpReturn = null;

            }

        }

        function ShowPopUpCargaFacturas() {
            popUpFacturas.SetWindowContentHtml = '';
            popUpFacturas.Show();
            popUpFacturas.SetContentUrl('PopUpCargaFactura.aspx');
            var titulo = 'Carga Facturas Compras';
            popUpFacturas.SetHeaderText(titulo);
            centerPopup(900, 620);
        }

        function centerPopup(w, h) {
            var LeftValue = (screen.width - w) / 2;
            var TopValue = (screen.height - h) / 2;
            popUpFacturas.SetWidth(w);
            popUpFacturas.SetHeight(h);
            popUpFacturas.SetWindowLeft(LeftValue);
            popUpFacturas.SetWindowTop(TopValue);
            popUpFacturas.Hide();
            popUpFacturas.Show();
        }

        function Valorizar() {
            //lleno session con los datos que necesito
            if (gvFacturasCompra.GetFocusedRowIndex() >= 0) {
                var indice = gvFacturasCompra.GetFocusedRowIndex();

                gvFacturasCompra.GetRowValues(indice, '' +
                    'operacion;orden_compra;tipo;num_docum;provision;fecha_emision;fecha_signature;dias_disp;estado;rut_proveedor;proveedor;valor_neto;valor_impuesto;valor_exento;valor_total;comentarios;estado_recibo;fecha_envio;id_tipo', OnGetRowValues);

            } else {
                showMessage('No hay un registro seleccionado para Valorizar');

            }
        }

        function OnGetRowValues(values) {
            var origen = 'CargaFactura';
            var operacion = values[0];
            var ordenCompra = values[1];
            var tipo = values[2];
            var numDocum = values[3];
            var provision = values[4];
            var fechaEmision = values[5].format("yyyy/MM/dd");
            var fechaSignature = values[6].format("yyyy/MM/dd");
            var diasDisp = values[7];
            var estado = values[8];
            var rutProveedor = values[9];
            var proveedor = values[10];
            var valorNeto = values[14];
            var valorImpuesto = values[12];
            var valorExento = values[13];
            var valorTotal = values[11];
            var comentarios = values[15];
            var estadoRecibo = values[16];
            var fechaEnvio = values[17].format("yyyy/MM/dd");
            var idTipoDocum = values[18];

            var params = JSON.stringify({ operacion: operacion, ordenCompra: ordenCompra, tipo: tipo, numDocum: numDocum, provision: provision, fechaEmision: fechaEmision, fechaSignature: fechaSignature, diasDisp: diasDisp, estado: estado, rutProveedor: rutProveedor, proveedor: proveedor, valorNeto: valorNeto, valorImpuesto: valorImpuesto, valorExento: valorExento, valorTotal: valorTotal, comentarios: comentarios, estadoRecibo: estadoRecibo, fechaEnvio: fechaEnvio, idTipoDocum: idTipoDocum, origen: origen });
            jutils.ajax.callServer("CargaDatosSession", params, "OnGetRowValues");


            //JC JAVASCRIPT LLAMADO  URL UNICA
//            var capas = document.location.href.split('/');
//            var niveles = '';
//            for (var i = capas.length - 1; i >= 0; i--) {
//                if (capas[i] == 'Paginas') break;
//                niveles = niveles + "../";
//            }
//            var msgBoxImagePath = niveles + "Paginas/Compras/Ingresar/Ingresar.aspx";

            //            this.parent.window.location.href = msgBoxImagePath;

            var ruta = jutils.GetPathURLUnica('Paginas/Compras/Ingresar/Ingresar.aspx');
            this.parent.window.location.href = ruta;

        }

     
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="udp" runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="btnxExportarExcel" />
        </Triggers>
        <ContentTemplate>
            <div id="parteDosGrilla" style="display: display" runat="server">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td valign="top">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td width="10">
                                        &nbsp;
                                    </td>
                                    <td>
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td>
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="borde">
                                                        <tr>
                                                            <td>
                                                                <div class="modul">
                                                                    <div class="modul_top">
                                                                        <div class="modul_top_right">
                                                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                <tr>
                                                                                    <td width="9">
                                                                                    </td>
                                                                                    <td class="modul_fd">
                                                                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                            <tr>
                                                                                                <td class="modul_fd_tit">
                                                                                                    FACTURAS DE COMPRA
                                                                                                </td>
                                                                                            </tr>
                                                                                        </table>
                                                                                    </td>
                                                                                    <td width="9">
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </div>
                                                                    </div>
                                                                    <div class="modul_content">
                                                                    </div>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="modul_bordes">
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="caja-datos">
                                                        <tr>
                                                            <td width="10">
                                                            </td>
                                                            <td height="10">
                                                            </td>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                            <td>
                                                                <!-- Inicio controles para los parámtros de consulta -->
                                                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                    <tr>
                                                                        <td width="80" align="center">
                                                                            &nbsp;
                                                                        </td>
                                                                        <td width="180">
                                                                        </td>
                                                                        <td>
                                                                            <table width="200" border="0" align="right" cellpadding="0" cellspacing="0">
                                                                                <tr>
                                                                                    <td style="padding-left: 5px; padding-right: 5px;">
                                                                                        <dx:ASPxButton ID="btnCargaDetalle" runat="server" AutoPostBack="False" ClientInstanceName="btnCargaDetalle"
                                                                                            class="boton-full" Cursor="pointer" EnableDefaultAppearance="False" EnableTheming="False"
                                                                                            Text="Carga Planilla DTE´s" VerticalAlign="Middle" ToolTip="Carga Planilla DTE´s"
                                                                                            Width="190px">
                                                                                            <ClientSideEvents Click="ShowPopUpCargaFacturas" />
                                                                                            <Image Url="~/img/icon/application_add.png" />
                                                                                        </dx:ASPxButton>
                                                                                    </td>
                                                                                    <td style="padding-left: 5px; padding-right: 5px;">
                                                                                        <dx:ASPxButton ID="btnModificar" runat="server" ClientIDMode="AutoID" Cursor="pointer"
                                                                                            ClientInstanceName="btnModificar" class="boton-full" EnableDefaultAppearance="False"
                                                                                            EnableTheming="False" Text="Modificar" AutoPostBack="false" ToolTip="Mantenedor de Documentos Electrónicos"
                                                                                            OnClick="btnModificar_Click">
                                                                                            <Image Url="~/img/icon/application_form.png" />
                                                                                        </dx:ASPxButton>
                                                                                    </td>
                                                                                    <td style="padding-left: 5px; padding-right: 5px;">
                                                                                        <dx:ASPxButton ID="btnValorizar" runat="server" Text="Valorizar" AutoPostBack="False"
                                                                                            ClientVisible="true" ClientEnabled="True" Enabled="true" ClientIDMode="AutoID"
                                                                                            Cursor="pointer" ClientInstanceName="btnValorizar" class="boton-full" EnableDefaultAppearance="False"
                                                                                            EnableTheming="False" ToolTip="Presione para ir a Ingresar Documento">
                                                                                            <Image Url="~/img/icon/drive_go.png" />
                                                                                            <ClientSideEvents Click="Valorizar"></ClientSideEvents>
                                                                                        </dx:ASPxButton>
                                                                                    </td>
                                                                                    <td style="padding-left: 5px; padding-right: 5px;">
                                                                                        <dx:ASPxButton ID="btnxExportarExcel" runat="server" Text="Excel" AutoPostBack="False"
                                                                                            ClientVisible="true" ClientEnabled="True" Enabled="true" ClientIDMode="AutoID"
                                                                                            Cursor="pointer" ClientInstanceName="btnxExportarExcel" class="boton-full" EnableDefaultAppearance="False"
                                                                                            EnableTheming="False" OnClick="btnExportar_Click" ToolTip="Presione para Exportar a Excel">
                                                                                            <Image Url="~/img/icon/Excel-icon.png" />
                                                                                        </dx:ASPxButton>
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                                <!-- Fin controles para los parámtros de consulta -->
                                                            </td>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="modul_bordes">
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="caja-datos">
                                                        <tr>
                                                            <td width="10">
                                                            </td>
                                                            <td height="10">
                                                            </td>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="modul_bordes">
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="caja-datos">
                                                        <tr>
                                                            <td width="10">
                                                                <td width="150" align="center">
                                                                    &nbsp;
                                                                </td>
                                                            </td>
                                                            <td height="10">
                                                                &nbsp;
                                                            </td>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr style="height: 20px;">
                                                <td class="modul_bordes">
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="caja-datos">
                                                        <tr>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                            <td class="fd_borde">
                                                                <dx:ASPxGridViewExporter ID="gvexExportarExcel" runat="server">
                                                                </dx:ASPxGridViewExporter>
                                                                <dx:ASPxGridView ID="gvFacturasCompra" ClientInstanceName="gvFacturasCompra" runat="server"
                                                                    DataSourceID="" Width="100%" KeyFieldName="num_docum" AutoGenerateColumns="False" >
                                                                    <SettingsText EmptyDataRow="No existen Facturas de Compra." />
                                                                    <SettingsEditing Mode="Inline" />
                                                                    <ClientSideEvents  EndCallback="function(s, e){EndCallBackGv(s, e); }" />
                                                                    <SettingsBehavior AllowDragDrop="False" AllowFocusedRow="True" AllowSelectByRowClick="True"
                                                                        AllowSelectSingleRowOnly="True" ColumnResizeMode="Control" ConfirmDelete="True" />
                                                                    <SettingsPager Mode="ShowAllRecords">
                                                                    </SettingsPager>
                                                                    <Settings ShowFooter="true" ShowVerticalScrollBar="true" VerticalScrollableHeight="300"
                                                                        ShowHorizontalScrollBar="true" ShowStatusBar="Visible" />
                                                                    <Columns>
                                                                        <dx:GridViewDataColumn FieldName="operacion" VisibleIndex="1" Caption="Operación"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="orden_compra" VisibleIndex="2" Caption="O.compra"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="id_tipo" VisibleIndex="3" Caption="id Tipo Doc."
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true"
                                                                            Visible="False">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="tipo" VisibleIndex="3" Caption="Tipo Doc." HeaderStyle-HorizontalAlign="Center"
                                                                            CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="num_docum" VisibleIndex="4" Caption="Num.Docum"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="provision" VisibleIndex="5" Caption="provision" Visible="False"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="desc_provision" VisibleIndex="5" Caption="Provisión" Visible="True"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="fecha_emision" VisibleIndex="6" Caption="Fec.Emisión"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="fecha_signature" VisibleIndex="7" Caption="Fec.Signature"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="dias_disp" VisibleIndex="8" Caption="Días Disp."
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="estado" VisibleIndex="9" Caption="Estado" HeaderStyle-HorizontalAlign="Center" Visible="False"
                                                                            CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="desc_estado_documento" VisibleIndex="9" Caption="Estado" HeaderStyle-HorizontalAlign="Center"
                                                                            CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="rut_proveedor" VisibleIndex="10" Caption="Proveedor"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true"
                                                                            Width="140">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Left">
                                                                            </CellStyle>
                                                                            <DataItemTemplate>
                                                                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                                                    <tr>
                                                                                        <td>
                                                                                            <dx:ASPxLabel runat="server" ID="lblProveedor" Text='<%# String.Format("{0}", Eval("rut_proveedor")) %>'>
                                                                                            </dx:ASPxLabel>
                                                                                        </td>
                                                                                    </tr>
                                                                                </table>
                                                                            </DataItemTemplate>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="proveedor" VisibleIndex="11" Caption="Proveedor"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="valor_neto" VisibleIndex="12" Caption="Valor Neto"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                            <DataItemTemplate>
                                                                                <dx:ASPxLabel runat="server" ID="lblNeto" Text='<%# Eval("valor_neto", "{0:N0}") %>'>
                                                                                </dx:ASPxLabel>
                                                                            </DataItemTemplate>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="valor_impuesto" VisibleIndex="13" Caption="Valor Impto."
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                            <DataItemTemplate>
                                                                                <dx:ASPxLabel runat="server" ID="lblValorImpuesto" Text='<%# Eval("valor_impuesto", "{0:N0}") %>'>
                                                                                </dx:ASPxLabel>
                                                                            </DataItemTemplate>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="valor_exento" VisibleIndex="14" Caption="Valor Exento"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                            <DataItemTemplate>
                                                                                <dx:ASPxLabel runat="server" ID="lblValorExento" Text='<%# Eval("valor_exento", "{0:N0}") %>'>
                                                                                </dx:ASPxLabel>
                                                                            </DataItemTemplate>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="valor_total" VisibleIndex="15" Caption="Valor Total."
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                            <DataItemTemplate>
                                                                                <dx:ASPxLabel runat="server" ID="lblValorTotal" Text='<%# Eval("valor_total", "{0:N0}") %>'>
                                                                                </dx:ASPxLabel>
                                                                            </DataItemTemplate>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="comentarios" VisibleIndex="16" Caption="Comentarios"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="estado_recibo" VisibleIndex="17" Caption="Estado Recibo"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="fecha_envio" VisibleIndex="18" Caption="Fecha Envío / Recibo"
                                                                            HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" ReadOnly="true">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Right">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                    </Columns>
                                                                    <SettingsBehavior ColumnResizeMode="Control" AllowFocusedRow="True" AllowDragDrop="false"
                                                                        ConfirmDelete="true" AllowSelectByRowClick="true" AllowSelectSingleRowOnly="true" />
                                                                </dx:ASPxGridView>
                                                            </td>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr style="height: 6px;">
                                                <td class="modul_bordes">
                                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="caja-datos">
                                                        <tr>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                            <td>
                                                            </td>
                                                            <td width="10" rowspan="3">
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <div class="modul_bottom">
                                                        <div class="modul_bottom_right">
                                                            <div class="modul_borde-bottom">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td width="10">
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                            <!---------------------------------fin de parámetros de consulta-------------------------------->
                        </td>
                    </tr>
                </table>
            </div>
            <%--POPUP CARGA FACTURAS--%>
            <dx:ASPxPopupControl ID="popUpFacturas" runat="server" HeaderText="Carga Facturas de Compra"
                Width="900px" ShowCloseButton="False" ClientInstanceName="popUpFacturas" Modal="True"
                PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="TopSides">
                <ContentCollection>
                    <dx:PopupControlContentControl ID="Popupcontrolcontentcontrol3" runat="server" Width="400px">
                    </dx:PopupControlContentControl>
                </ContentCollection>
            </dx:ASPxPopupControl>
            <%-- FIN POPUP CARGA FACTURAS--%>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>


________________________________________________________________________
.CS
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxClasses;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.Data;
using LeaOperBussinesLayer;
using LeaOperBussinesLayer.BussinesComponents.Compras.AdmPago;
using LeaOperBussinesLayer.BussinesComponents.Compras.CargaFacturas;
using LeaOperBussinesLayer.BussinesEntities.Compras.AdmPago;
using LeaOperBussinesLayer.DataAcessComponent.Compras.AdmPago;
using LeaOperBussinesLayer.Util;
using LeaseOperWeb.Negocio.Comun;
using LeaseOperWeb.Resources;
using LeaseOperWeb.Utils;
using Newtonsoft.Json;

namespace LeaseOperWeb.Paginas.Compras.CargaFacturasCompra
{
    public partial class Ingresados : System.Web.UI.Page
    {
        #region Page_Init
        protected void Page_Init(object sender, EventArgs e)
        {
            gvFacturasCompra.CustomCallback += gvFacturasCompra_CustomCallback;
        }

        #endregion

        #region Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Page.IsPostBack))
            {
                LlenagvFacturasCompra();

            }

        }
        #endregion

        #region Evento CallBack Grilla gvFacturasCompra
        void gvFacturasCompra_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (e.Parameters != null && e.Parameters.Trim().ToUpper() == "REFRESHGRILLA")
            {
                LlenagvFacturasCompra();
            }
        }

        #endregion

        #region Exportar

        protected void btnExportar_Click(object sender, EventArgs e)
        {
            if (gvFacturasCompra.VisibleRowCount == 0)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "openWin", "<script>alert('No hay registros a exportar')</script>");
                return;
            }
            try
            {
                gvexExportarExcel.GridViewID = "gvFacturasCompra";
                var dt = new CargaFacturasBc().SelectFacturasCompras(0);
                gvFacturasCompra.DataSource = dt;
                gvFacturasCompra.DataBind();
                var nameFile = "FacturasCompra";
                gvexExportarExcel.WriteXlsToResponse(nameFile);
            }
            catch (Exception ex)
            {

            }
        }


        #endregion

        #region custom methods

        private void LlenagvFacturasCompra()
        {
            var dt = new CargaFacturasBc().SelectFacturasCompras(0);
            gvFacturasCompra.DataSource = dt;
            gvFacturasCompra.DataBind();
        }

        [WebMethod]
        public static void CargaDatosSession(string operacion, string ordenCompra, string tipo, string numDocum, string provision, string fechaEmision, string fechaSignature, string diasDisp, string estado, string rutProveedor, string proveedor, string valorNeto, string valorImpuesto, string valorExento, string valorTotal, string comentarios, string estadoRecibo, string fechaEnvio, string idTipoDocum, string origen)
        {

            HttpContext.Current.Session["CargaFacturaOrigen"] = operacion + ";" + ordenCompra + ";" + tipo + ";" +
                                                                numDocum + ";" + provision + ";" + fechaEmision + ";" +
                                                                fechaSignature + ";" + diasDisp + ";" + estado + ";" +
                                                                rutProveedor + ";" + proveedor + ";" + valorNeto + ";" +
                                                                valorImpuesto + ";" + valorExento + ";" + valorTotal +
                                                                ";" + comentarios + ";" + estadoRecibo + ";" +
                                                                fechaEnvio + ";" + idTipoDocum + ";" + origen;
        }

        protected void btnModificar_Click(object sender, EventArgs e)
        {
            if (gvFacturasCompra.FocusedRowIndex >= 0)
            {
                var folioNumDocum = gvFacturasCompra.GetRowValues(gvFacturasCompra.FocusedRowIndex, "num_docum");
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert",
                                                    string.Format(resourcesJavaScript.jsShowPopUp,
                                                                  "PopUpDocumentosElectronicos.aspx?folioNumDocum=" +
                                                                  folioNumDocum.ToString().Trim()), true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", "<script>alert('No hay un documento seleccionado.')</script>", false);
            }
        }

        #endregion


    }
}

No hay comentarios:

Publicar un comentario