jueves, 21 de abril de 2016

C# - checkbox, marcar o desmarcar todo


--control con evento  (ASPX)
_________________________________________
  <dx:ASPxCheckBox ID="chkTodosOp" runat="server" CheckState="Unchecked" Text="Todos Seleccionados"
                                                                                            ValueChecked="1" ValueType="System.Int32" ValueUnchecked="0">
                                                                                            <ClientSideEvents CheckedChanged="function(s,e){SeleccionarTodos(s, e);}"></ClientSideEvents>
                                                                                        </dx:ASPxCheckBox>


--Llamada (Javascript)
_________________________________________
  function SeleccionarTodos(s, e) {
            CallBackMain.PerformCallback(s.GetValue() + ',CheckedAll');
        }

--Ejecución (.CS)
_________________________________________


 #region SELECCIONAR TODOS
                if (e.Parameter != null && e.Parameter.Contains(",") &&
                    e.Parameter.Split(',')[1].ToString().Trim() == "CheckedAll")
                {
                    var chkSelectAll = e.Parameter.Split(',')[0];

                    if (gvListaOperaciones.VisibleRowCount > 0)
                    {
                        for (int i = 0; i < gvListaOperaciones.VisibleRowCount; i++)
                        {
                            var dataCheckBox = gvListaOperaciones.Columns[""] as GridViewDataCheckColumn;
                            var chk = (ASPxCheckBox)gvListaOperaciones.FindRowCellTemplateControl(i, dataCheckBox, "chkDetalle");

                            if (Convert.ToInt32(chkSelectAll) == 1)
                            {
                                chk.Checked = true;
                            }
                            else
                            {
                                chk.Checked = false;
                                limpiaGrillaBienes();
                            }

                        }

                    }

                }
                #endregion



--GRILA (.ASPX)
_________________________________________

<dx:ASPxGridView ID="gvListaOperaciones" ClientInstanceName="gvListaOperaciones"
                                                                    runat="server" DataSourceID="ObjectSourceListaOperaciones" Width="100%" KeyFieldName="operacion"
                                                                    SettingsBehavior-AllowSort="False" Visible="true">
                                                                    <%--      <ClientSideEvents RowDblClick="function(s, e) { RowDblClik(s, e); }" EndCallback="function(s, e) { OnEndCallback(s, e); }">
                                                                    </ClientSideEvents>--%>
                                                                    <SettingsBehavior AllowDragDrop="false" AllowFocusedRow="True" />
                                                                    <SettingsEditing Mode="Inline" />
                                                                    <Settings ShowFooter="True" ShowHorizontalScrollBar="True" ShowVerticalScrollBar="True"
                                                                        VerticalScrollableHeight="200" />
                                                                    <SettingsLoadingPanel Text="Cargando..." />
                                                                    <ClientSideEvents RowDblClick="function(s, e) { RowDblClik(s, e); }" EndCallback="function(s, e) { OnEndCallback(s, e); }" />
                                                                    <Columns>
                                                                        <dx:GridViewDataCheckColumn FieldName="" VisibleIndex="0" Caption="" Width="55">
                                                                            <DataItemTemplate>
                                                                                <dx:ASPxCheckBox ID="chkDetalle" runat="server" ValueChecked="1" ValueType="System.Int32"
                                                                                    ValueUnchecked="0">
                                                                                    <ClientSideEvents CheckedChanged="function(s, e) {CallBackMain.PerformCallback('R');}" />
                                                                                </dx:ASPxCheckBox>
                                                                            </DataItemTemplate>
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                            <PropertiesCheckEdit ValueType="System.Int16" ValueChecked="1" ValueUnchecked="0">
                                                                            </PropertiesCheckEdit>
                                                                        </dx:GridViewDataCheckColumn>
                                                                        <dx:GridViewDataColumn FieldName="operacion" VisibleIndex="0" Width="100px" Caption="Operación"
                                                                            ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="estado" VisibleIndex="1" Caption="Estado" Width="100px"
                                                                            ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="fecha_ingreso_cont" VisibleIndex="2" Width="150px"
                                                                            Caption="Fecha Ing.Contrato" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
                                                                            CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="fecha_opc" Width="150px" VisibleIndex="3" Caption="Fecha Op.Compra"
                                                                            ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="rut_cliente"  Width="100px" VisibleIndex="4"
                                                                        Caption="Rut Cliente" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                        <dx:GridViewDataColumn FieldName="nom_cliente"  Width="200px" VisibleIndex="5" Caption="Nom. Cliente" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                         <dx:GridViewDataColumn FieldName="cod_mat"  Width="80px" Caption="Cod. Mat" ReadOnly="true" Visible="false" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>
                                                                         <dx:GridViewDataColumn FieldName=""  Width="100%" Caption="" VisibleIndex="6" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
                                                                            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                            <CellStyle HorizontalAlign="Center">
                                                                            </CellStyle>
                                                                        </dx:GridViewDataColumn>

                                                                    </Columns>
                                                                    <SettingsBehavior AllowDragDrop="False" AllowSort="False" AllowFocusedRow="True">
                                                                    </SettingsBehavior>
                                                                    <SettingsPager Visible="true" Mode="ShowPager" PageSize="1000" />
                                                                    <SettingsEditing Mode="Inline"></SettingsEditing>
                                                                    <Settings ShowFooter="True" ShowVerticalScrollBar="True" ShowHorizontalScrollBar="True">
                                                                    </Settings>
                                                                    <SettingsLoadingPanel Text="Cargando..."></SettingsLoadingPanel>
                                                                    <ImagesEditors>
                                                                        <CheckBoxChecked Height="15px" Url="../../../img/icon/accept.png" Width="15px">
                                                                        </CheckBoxChecked>
                                                                        <CheckBoxUnchecked Height="15px" Url="../../../img/icon/ico-chec.png" Width="15px">
                                                                        </CheckBoxUnchecked>
                                                                    </ImagesEditors>
                                                                </dx:ASPxGridView>

C# - Ejemplo de CRUD Entity Framework

  #region Metodos CRUD Publicos

        /// <summary>
        /// Metodo Select
        /// </summary>
        /// /// <param name="numProyecto"></param>
        /// <param name="msj"></param>
        /// <returns></returns>
        public List<RequerimientoBe> Select(Int32 numProyecto,ref string msj)
        {
            var obj = new List<RequerimientoBe>();
            try
            {
                using (var context = new WorkflowComexEntities())
                {
                    var dtContex = context.REQUERIMIENTO.Where(p => p.ID_PROYECTO == numProyecto).ToList();
                    obj.AddRange(dtContex.Select(RequerimientoBe.DbToBe));
                }
            }
            catch (Exception ex)
            {
                msj = ex.Message;
            }
            return obj.ToList();
        }

        /// <summary>
        /// Metodo Insert
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="msj"></param>
        public void Insert(RequerimientoBe obj, ref string msj)
        {
            var newId = 0;
            try
            {
                using (var context = new WorkflowComexEntities())
                {
                    if (obj != null)
                    {
                        var item = RequerimientoBe.BeToDb(ref obj);
                        context.REQUERIMIENTO.AddObject(item);
                        context.SaveChanges();
                        newId = context.REQUERIMIENTO.Max(p => p.ID_REQUERIMIENTO);
                    }
                }
            }
            catch (Exception ex)
            {
                msj = ex.Message;
            }
        }

        /// <summary>
        /// Metodo Update
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="msj"></param>
        public void Update(RequerimientoBe obj, ref string msj)
        {
            try
            {
                using (var context = new WorkflowComexEntities())
                {
                    if (obj != null)
                    {
                        var item = RequerimientoBe.BeToDb(ref obj);
                        object originalObject = null;
                        var key = context.CreateEntityKey("REQUERIMIENTO", item);
                        if (!context.TryGetObjectByKey(key, out originalObject)) return;

                        context.REQUERIMIENTO.ApplyCurrentValues(item);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                msj = ex.Message;
            }

        }

        /// <summary>
        /// Metodo Delete
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="msj"></param>
        public void Delete(RequerimientoBe obj, ref string msj)
        {
            try
            {
                using (var context = new WorkflowComexEntities())
                {
                    if (obj != null)
                    {
                        var item = context.REQUERIMIENTO.FirstOrDefault(p => p.ID_REQUERIMIENTO == obj.ID_REQUERIMIENTO);
                        context.REQUERIMIENTO.DeleteObject(item);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                msj = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

            }
        }
        #endregion

C# - Esconder control (grilla) en formulario, ocultar columna de una grilla.


Ocultar CONTROL de un formulario
---------------------------------------

document.getElementById("tblNomina").style.visibility = "hidden";
document.getElementById("tblNomina").style.display = "none"


Ocultar COLUMNA de una Grilla en JQUERY
---------------------------------------

$("#grid").jqGrid('hideCol', 'nombre de la columna');

miércoles, 20 de abril de 2016

jueves, 14 de abril de 2016

C# - Toma fecha ingresada por el usuario en GRILLA

.ASPX

 <dx:GridViewDataDateColumn Caption="Fecha Pago" FieldName="fecha_pago" VisibleIndex="10"
                                                        CellStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" Visible="true"
                                                        Width="140px">
                                                        <PropertiesDateEdit DisplayFormatString="{0:dd/MM/yyyy}">
                                                        </PropertiesDateEdit>
                                                        <EditItemTemplate>
                                                            <dx:ASPxDateEdit ID="dFecha" runat="server" ClientEnabled="True" Width="135px" Text='<%# DateTime.Now.ToShortDateString() %>'>
                                                                <ClientSideEvents ValueChanged="function(s, e){ cbckPage.PerformCallback('FP,' + s.GetText()); }" />
                                                            </dx:ASPxDateEdit>
                                                        </EditItemTemplate>
                                                    </dx:GridViewDataDateColumn>

__________________________________________________________________

.CS
 var fechaPago = e.Parameter.Trim().Split(',')[1];





___________________________________________________________________

martes, 12 de abril de 2016

C# - Gatillar evento de click de boton B con botón A.

.aspx (BOTÓN A)

   <dx:ASPxButton ID="btnXlsExport" runat="server" class="boton-full" AutoPostBack="false"
                                                                                        Cursor="pointer" EnableDefaultAppearance="False" EnableTheming="False" Height="30px"
                                                                                        Text="Exportar" Width="110px" ClientIDMode="AutoID">
                                                                                        <Image Url="~/img/icon/page_white_excel.png">
                                                                                        </Image>
                                                                                       <ClientSideEvents Click="Export" />
                                                                                    </dx:ASPxButton>


____________________________________

.aspx (BOTÓN B)
  <dx:ASPxButton ID="btnExport" ClientInstanceName="btnExport" runat="server" Text=""
                ClientVisible="false" OnClick="btnExport_Click">
            </dx:ASPxButton>

____________________________________

<script>
   function Export(s, e) {
            if (gvAdmHojaRuta.GetVisibleRowsOnPage() > 0) {
                btnExport.DoClick();

            } else {
                alert('No hay datos para exportar');
            }

        }

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


    }
}