private void fillRpt() { try { dsPersonal ds = new dsPersonal(); DateTime fecha = DateTime.Today; int entero = 0; DateTime periodo_ini = new DateTime(); DateTime.TryParse(txt_fecha_ini.Text, out fecha); periodo_ini = fecha; DateTime periodo_fin = new DateTime(); DateTime.TryParse(txt_fecha_fin.Text, out fecha); periodo_fin = fecha; int.TryParse(ddl_sede.SelectedValue, out entero); int id_bodega = entero; entero = 0; switch (ddl_rpt.SelectedValue) { case "personal_empresa": CrystalReportViewer1.ReportSource = ControlRpt.PersonalEmpresaRpt(ds, HttpContext.Current.Server.MapPath("~/report/personal/personal_empresa.rpt")); break; case "119": CrystalReportViewer1.ReportSource = ControlRpt.PersonalEmpresa119(ds, HttpContext.Current.Server.MapPath("~/report/personal/personal_asistencia.rpt"), periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear, id_bodega, ddl_sede.SelectedItem.Text); break; default: break; } } catch { throw; } finally { } }
protected void clickGetRpt(object sender, EventArgs args) { try { //ReportViewer ReportViewer1 = new ReportViewer(); //ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.Visible = false; DateTime fecha = DateTime.Today; DateTime periodo_ini = new DateTime(); DateTime.TryParse(txt_fecha_ini.Text, out fecha); periodo_ini = fecha; DateTime periodo_fin = new DateTime(); DateTime.TryParse(txt_fecha_fin.Text, out fecha); periodo_fin = fecha; //ReportViewer1.Reset(); string rptSelected = ddl_reporte.SelectedValue; ReportDataSource rptSource = null; ReportParameter[] parametros; switch (ddl_reporte.SelectedValue) { case "ResProd": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.ResProd(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; case "PartNom": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.PartNom(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; case "ProdDiario": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.ProdDiarioGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; case "Fondeo": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.FondeoGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; case "Odntbj": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.odntbjGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); parametros = new ReportParameter[1]; parametros[0] = new ReportParameter("p_Periodo", "Del " + txt_fecha_ini.Text + " Al " + txt_fecha_fin.Text, false); showExcel(rptSource, parametros); break; case "Maquila": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.MaquilaGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); parametros = new ReportParameter[1]; parametros[0] = new ReportParameter("p_Periodo", "Del " + txt_fecha_ini.Text + " Al " + txt_fecha_fin.Text, false); showExcel(rptSource, parametros); break; case "Piso": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.PisoGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear, Convert.ToInt32(ddl_bodega.SelectedValue), Convert.ToInt32(ddl_cuenta.SelectedValue), Convert.ToInt32(txt_existencia.Text))); parametros = new ReportParameter[3]; parametros[0] = new ReportParameter("p_Bodega", ddl_bodega.SelectedItem.Text, false); parametros[1] = new ReportParameter("p_Cuenta", ddl_cuenta.SelectedItem.Text, false); parametros[2] = new ReportParameter("p_Periodo", "Del " + txt_fecha_ini.Text + " Al " + txt_fecha_fin.Text, false); showExcel(rptSource, parametros); break; case "Trafico": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.CitasGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear, Convert.ToInt32(ddlDestino.SelectedItem.Value), Convert.ToInt32(ddlEstatus.SelectedValue))); showPreview(rptSource); break; case "Remision": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.RemisionGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; case "Inventario": rptSource = new ReportDataSource("ds" + rptSelected, ControlRpt.InventarioGet(periodo_ini.Year, periodo_ini.DayOfYear, periodo_fin.Year, periodo_fin.DayOfYear)); showExcel(rptSource); break; default: break; } //ReportViewer1.LocalReport.DataSources.Add(rptSource); //ReportViewer1.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/report/" + rptSelected + "/") + "rpt" + rptSelected + ".rdlc"; ////ReportViewer1.LocalReport.Refresh(); //Warning[] warnings; //string[] streamIds; //string mimeType = string.Empty; //string encoding = string.Empty; //string extension = string.Empty; //byte[] bytes = ReportViewer1.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings); ////ReportViewer1.LocalReport.Refresh(); //Response.Buffer = true; //Response.Clear(); //Response.ContentType = mimeType; //Response.AddHeader("content-disposition", "attachment; filename=" + ddl_reporte.SelectedValue + ".xls"); //Response.BinaryWrite(bytes); // create the file //Response.Flush(); // send it to the client to download } catch (Exception e) { throw e; } }