Пример #1
0
        protected void btn_excel_Click(object sender, EventArgs e)
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment;filename=SOPRODI_2_" + DateTime.Now.ToShortDateString() + ".xls");

            Response.Charset = "";

            // If you want the option to open the Excel file without saving than

            // comment out the line below

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            Response.ContentType = "application/vnd.xls";

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter htmlWrite =
                new HtmlTextWriter(stringWrite);

            //G_INFORME_TOTAL_NC.Columns[0].Visible = false;

            G_INFORME_TOTAL_NC.RenderControl(htmlWrite);

            Response.Write(stringWrite.ToString());

            Response.End();
        }
Пример #2
0
        protected void btn_informe_Click(object sender, EventArgs e)

        {
            DateTime t           = DateTime.Now;
            string   fecha_ahora = t.ToShortDateString();
            string   desde       = txt_desde.Text;
            string   hasta       = txt_hasta.Text;

            if (desde != "" && hasta != "")
            {
                div_report.Visible         = true;
                G_INFORME_NC.Visible       = false;
                G_INFORME_TOTAL_NC.Visible = true;

                string where = " where  tipo_doc='CM' and fecha_trans >= CONVERT(datetime,'" + desde + "', 103)  and fecha_trans <= CONVERT(datetime,'" + hasta + "',103) ";

                string es_vend            = ReporteRNegocio.esvendedor(User.Identity.Name);
                string nomb_vend          = "";
                string grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario(User.Identity.Name.ToString()));

                if (grupos_del_usuario == "")
                {
                    grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(User.Identity.Name.ToString()));
                }
                if (es_vend == "2")
                {
                    nomb_vend = ReporteRNegocio.nombre_vendedor(User.Identity.Name);
                }

                if (nomb_vend != "")
                {
                    where += " and (select top 1 vendedor from thx_v_reporte where factura = thx_v_reporte.númfactura) = '" + nomb_vend.Trim() + "' ";
                }
                where += " and  (select top 1 user1 from THX_v_reporte where factura = THX_v_reporte.númfactura) in (" + grupos_del_usuario + ") ";

                DataTable periodos = ReporteRNegocio.listar_notas_credito(where);

                busca_columna_fac             = true;
                G_INFORME_TOTAL_NC.DataSource = periodos;
                G_INFORME_TOTAL_NC.DataBind();

                ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_INFORME_TOTAL_NC')); </script>", false);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeqee", "<script> alert('Llene fechas');</script>", false);
            }
        }