public void ShowGenericRpt() { try { bool isValid = true; string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString(); // Setting ReportName if (string.IsNullOrEmpty(strReportName)) { isValid = false; } if (isValid) { ReportDocument rd = new ReportDocument(); string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Report//" + strReportName; rd.Load(strRptPath); rd.VerifyDatabase(); rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport"); // Clear all sessions value Session["ReportName"] = null; } else { Response.Write("<H2>Nothing Found; No Report name found</H2>"); } } catch (Exception ex) { Response.Write(ex.ToString()); } }
public void LoadReport(ReportDocument crReportDocument, string nombre_reporte, string impresion) { string server = System.Configuration.ConfigurationManager.AppSettings["servidor_crystal"]; string base_crystal = System.Configuration.ConfigurationManager.AppSettings["base_crystal"]; string usuario_crystal = System.Configuration.ConfigurationManager.AppSettings["usuario_crystal"]; string pasword_crystal = System.Configuration.ConfigurationManager.AppSettings["pasword_crystal"]; crReportDocument.DataSourceConnections[0].SetConnection(server, base_crystal, false); crReportDocument.DataSourceConnections[0].SetLogon(usuario_crystal, pasword_crystal); if (impresion == "S") { crReportDocument.Load(HttpContext.Current.Server.MapPath(nombre_reporte)); crReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); } else { crReportDocument.Load(HttpContext.Current.Server.MapPath(nombre_reporte)); crReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); } Session["impresion"] = ""; }
private void LoadRpt() { string districtcode = GetDistrictCode(); string Receiptno = txtReceiptno.Text.Trim(); string Paymentcode = cboPaymentType.SelectedValue.ToString(); string Paymode = cboPaymode.SelectedValue.ToString(); DateTime fromdate = bll.ReturnDate(txtfromDate.Text.Trim(), 1); DateTime todate = bll.ReturnDate(txttoDate.Text.Trim(), 2); string teller = cboCashier.SelectedValue.ToString(); dataTable = datapay.GetPayments(districtcode, Receiptno, Paymentcode, Paymode, teller, fromdate, todate); dataTable = formatTable(dataTable); string appPath, physicalPath, rptName; appPath = HttpContext.Current.Request.ApplicationPath; physicalPath = HttpContext.Current.Request.MapPath(appPath); rptName = physicalPath + "\\bin\\reports\\Payments.rpt"; Rptdoc.Load(rptName); Rptdoc.SetDataSource(dataTable); CrystalReportViewer1.ReportSource = Rptdoc; Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); if (rdPdf.Checked.Equals(true)) { Rptdoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "PAYMENTS"); } else { Rptdoc.ExportToHttpResponse(ExportFormatType.ExcelRecord, Response, true, "PAYMENTS"); } }
private void GenerarReporteComisionesSupervisores(string RutaReporte, string NombreArchivo) { decimal IdUsuario = Session["IdUsuario"] != null ? (decimal)Session["IdUsuario"] : 0; ReportDocument Reporte = new ReportDocument(); Reporte.Load(RutaReporte); Reporte.Refresh(); Reporte.SetParameterValue("@IdUsuario", IdUsuario); Reporte.SetDatabaseLogon("sa", "Pa$$W0rd"); if (rbGenerarReportePDF.Checked == true) { Reporte.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, NombreArchivo); } else if (rbGenerarReporteExcel.Checked == true) { Reporte.ExportToHttpResponse(ExportFormatType.Excel, Response, true, NombreArchivo); } else if (rbGenerarReporteWord.Checked == true) { Reporte.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, true, NombreArchivo); } }
//GenerarInformacionCheque #endregion #region GENERAR CHEQUE private void GenerarCheque(decimal NumeroCheque, string RutaCheque, string NombreCheque) { decimal Idusuario = Session["IdUsuario"] != null?Convert.ToDecimal(Session["IdUsuario"]) : 0; ReportDocument Cheque = new ReportDocument(); Cheque.Load(RutaCheque); Cheque.Refresh(); Cheque.SetParameterValue("@IdUsuario", Idusuario); Cheque.SetParameterValue("@NumeroCheque", NumeroCheque); Cheque.SetDatabaseLogon("sa", "Pa$$W0rd"); if (rbPDF.Checked == true) { Cheque.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, NombreCheque); } else if (rbExcel.Checked == true) { Cheque.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, NombreCheque); } else if (rbWord.Checked == true) { Cheque.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, NombreCheque); } }
protected void Button2_Click(object sender, EventArgs e) { MyClass my = new MyClass(); DataTable dt = new DataTable(); string fld = DropDownList1.SelectedValue.ToString(); string txt = TextBox1.Text; if (Session["College_id"] != null) { cid = int.Parse(Session["College_id"].ToString()); sql = "select * from " + Tbl_Name + " where College_id=" + cid + " and " + fld + " like '" + txt + "%' "; Label1.Text = cid.ToString(); Label2.Text = my.Get_College(cid); } else { Label1.Visible = false; Label2.Visible = false; sql = "select * from " + Tbl_Name + " where " + fld + " like '" + txt + "%' "; } dt = my.GetTable(sql); report1.SetDataSource(dt); CrystalReportViewer1.ReportSource = report1; CrystalReportViewer1.RefreshReport(); report1.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Report"); }
protected void btnExportar_Click(object sender, EventArgs e) { userName = User.Identity.Name; nit = homeCtrl.obtenerNit(userName); reporte = (List <KilometrajeRptDetOptimizado>)ViewState["RptKilometrajes"]; if (reporte.Count > 0) { var empresa = "NO DEFINIDO"; if (SitePrincipal.ExisteActiva()) { empresa = homeCtrl.nombreEmpresa(nit); } var fechaInicio = Request["datepicker1"].ToString() + " " + cbohorai.Text; var fechaFin = Request["datepicker2"].ToString() + " " + cbohoraf.Text; var placa = "Todos"; //var cboPlacaCheckedItems = cboplaca.CheckedItems.ToList(); //if (cboPlacaCheckedItems[0].Value != "0") //{ // placa = cboPlacaCheckedItems[0].Value; // for (int i = 1; i < cboPlacaCheckedItems.Count; i++) // placa = placa + ", " + cboPlacaCheckedItems[i].Value; //} rptDocument = new ReportDocument(); rptDocument.Load(Server.MapPath("~/Reporte/reporteKilometraje.rpt")); rptDocument.SetDataSource(reporte); rptDocument.SetParameterValue("Empresa", empresa); rptDocument.SetParameterValue("FechaInicio", fechaInicio); rptDocument.SetParameterValue("FechaFin", fechaFin); rptDocument.SetParameterValue("Placa", placa); Response.Buffer = false; Response.Clear(); var formato = rcbFormato.SelectedValue; if (formato == "0") { rptDocument.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporteKilometraje_v" + DateTime.Now.ToString("yyyyMMddHHMMss")); } else if (formato == "1") { rptDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "reporteKilometraje_v" + DateTime.Now.ToString("yyyyMMddHHMMss")); } } else { MensajeAlerta("Favor, Primero visualizar los datos antes de exportar."); } }
//ausdnoadnoidasx protected void CoordiReportSubmit_Click1(object sender, EventArgs e) { rprt.Load(Server.MapPath("~/AdminPortal/CoordiReport.rpt")); //bringing data string CS = ConfigurationManager.ConnectionStrings["DB"].ConnectionString; SqlConnection con = new SqlConnection(CS); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select department_details.dname,usertnp.id,coordinator.cname,usertnp.email from usertnp,department_details,coordinator where coordinator.id = usertnp.id and department_details.deptno = coordinator.deptno"; //cmd.Parameters.AddWithValue("@uid", uid); cmd.Connection = con; con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds, "Coordireport"); rprt.SetDataSource(ds); con.Close(); rprt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Coordinator List"); ErrorLabel.Text = ""; SuccessLabel.Text = "Report Generated"; }
protected void btnExportar_Click(object sender, EventArgs e) { userName = User.Identity.Name; nit = homeCtrl.obtenerNit(userName); reporte = (List <DetencionRptDet>)ViewState["RptDetenciones"]; if (reporte.Count > 0) { var empresa = "Todas"; if (SitePrincipal.ExisteActiva()) { empresa = homeCtrl.nombreEmpresa(nit); } var fechaInicio = Request["datepicker1"].ToString() + " " + cbohorai.Text; var fechaFin = Request["datepicker2"].ToString() + " " + cbohoraf.Text; var placa = "Todas"; var cboPlacaCheckedItems = cboplaca.CheckedItems.ToList(); if (cboPlacaCheckedItems[0].Value != "0") { placa = cboPlacaCheckedItems[0].Value; for (int i = 1; i < cboPlacaCheckedItems.Count; i++) { placa = placa + ", " + cboPlacaCheckedItems[i].Value; } } rptDocument = new ReportDocument(); rptDocument.Load(Server.MapPath("~/Reporte/reporteDetencion.rpt")); rptDocument.SetDataSource(reporte); rptDocument.SetParameterValue("Empresa", empresa); rptDocument.SetParameterValue("FechaInicio", fechaInicio); rptDocument.SetParameterValue("FechaFin", fechaFin); rptDocument.SetParameterValue("Placa", placa); Response.Buffer = false; Response.Clear(); var formato = rcbFormato.SelectedValue; if (formato == "0") { rptDocument.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporteDetencion.v" + DateTime.Now.ToString() + ".xlsx"); } else if (formato == "1") { rptDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "reporteDetencion.v" + DateTime.Now.ToString() + ".pdf"); } } }
protected void GenerateReportCommon_Click(object sender, EventArgs e) { ReportDocument rprt = new ReportDocument(); if (ActionType.SelectedIndex == 0) { } else if (ActionType.SelectedIndex == 1) { SuccessLabel.Text = "done"; //rprt.Load(Server.MapPath("~/CoordinatorPortal/ApplicationReport.rpt")); // rprt.SetParameterValue("compname",CompanyNameList.SelectedItem.ToString()); rprt.Load(Server.MapPath("~/CoordinatorPortal/CrystalReport1_application.rpt")); rprt.SetParameterValue("companyid_sel", Convert.ToInt32(CompanyNameList.SelectedValue.ToString())); rprt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report"); ErrorLabel.Text = ""; } else if (ActionType.SelectedIndex == 2) { if (BatchYearListList.SelectedValue.Equals("1")) { ErrorLabel.Text = "Please select year"; SuccessLabel.Text = ""; } else if (BatchYearListList.SelectedIndex == 1) { SuccessLabel.Text = "done"; rprt.Load(Server.MapPath("~/AdminPortal/PlacementReportDeptWise.rpt")); rprt.SetParameterValue("dept", dept_na_co); rprt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report"); ErrorLabel.Text = ""; } else { SuccessLabel.Text = "done"; rprt.Load(Server.MapPath("~/CoordinatorPortal/PlacementReportYearWise.rpt")); rprt.SetParameterValue("deptname", dept_na_co); rprt.SetParameterValue("year", BatchYearListList.SelectedValue); rprt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report"); ErrorLabel.Text = ""; } } else { SuccessLabel.Text = "done"; rprt.Load(Server.MapPath("~/CoordinatorPortal/CompanyReport.rpt")); rprt.SetParameterValue("compname", CompanyNameList.SelectedItem.ToString()); rprt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report"); ErrorLabel.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { // Vencimiento de sesion if (Session[Constants.NameSessionUser] == null) { Utilities.logout(Page.Session, Page.Response); } else { _user = (Users)Session[Constants.NameSessionUser]; } _noLiq = Request.Params["NoLiq"]; _empPick = Request.Params["EmpPick"]; if (!(Request.Params["excel"] == null)) { _excel = Request.Params["excel"]; } // if (!string.IsNullOrEmpty(_noLiq) && !string.IsNullOrEmpty(_empPick)) { // REPORTE GENERALIZADO DE LIQUIDACION PopulateValueCrystalReport(); // Ubicacion del reporte crystal reportPath = Server.MapPath(_nameFileCrystalReport); // Instanciar el objeto de reporte de crystal _pickObjReport = new ReportDocument(); // Enlazar el archivo del reporte y el objeto instanciado _pickObjReport.Load(reportPath); // Establecer el dataSource dirigido al reporte crystal _pickObjReport.SetDataSource(_pickValsReport); // Para cargar el reporte directamente en un pdf o mostrarlo en una nueva pagina de html if (Request.Params["ShowReportOnWeb"] == null) { string nombreArchivo = "Picking_" + _noLiq; // Abrir en pdf automaticamente /// ExportFormatType.NoFormat /// if (_excel == "1") { _pickObjReport.ExportToHttpResponse(ExportFormatType.Excel, Response, true, nombreArchivo); } else { _pickObjReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, nombreArchivo); } } // Objeto crystal reports presente en la pagina aspx crvPicking.ReportSource = _pickObjReport; } }
protected void btnPDF_Click(object sender, System.EventArgs e) { string tempFile = Session.SessionID.ToString(); LoadReport(); rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, tempFile); rd.Close(); rd.Dispose(); }
private void Export(InitializeModule.ECT_Buttons iExport) { ReportDocument myReport = new ReportDocument(); try { if (Session["rptDS"] == null) { return; } DataSet rptDS = new DataSet(); rptDS = (DataSet)Session["rptDS"]; //Prepare_Report(Retrieve(iSession)); int iSession = Convert.ToInt32(rbnSession.SelectedValue); string reportPath = Server.MapPath("Reports/CurrentTimeTable_rpt.rpt"); myReport.Load(reportPath); myReport.SetDataSource(rptDS); TextObject txt; txt = (TextObject)myReport.ReportDefinition.ReportObjects["txtTitle"]; txt.Text = GetCaption(iSession); txt = (TextObject)myReport.ReportDefinition.ReportObjects["UserTXT"]; string sUserName = Session["CurrentUserName"].ToString(); txt.Text = "/ " + sUserName; switch (iExport) { case InitializeModule.ECT_Buttons.Print: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Page.Response, true, "ECTReport"); break; case InitializeModule.ECT_Buttons.ToExcel: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Page.Response, true, "ECTReport"); break; case InitializeModule.ECT_Buttons.ToWord: myReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.WordForWindows, Page.Response, true, "ECTReport"); break; } } catch (Exception exp) { Console.WriteLine("{0} Exception caught.", exp); //divMsg.InnerText = exp.Message; } finally { myReport.Close(); myReport.Dispose(); } }
protected void lnkpdf_Click(object sender, EventArgs e) { try { rep.Load(Server.MapPath("~//Reports//TotalComplainRpt.rpt")); rep.SetDatabaseLogon("sa", "hx3b8"); rep.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, ""); } catch { } }
protected void ExportToWord_Click(object sender, EventArgs e) { try { document.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.WordForWindows, Response, true, "PersonAnswerDetails"); } catch (Exception Ex) { System.Text.StringBuilder stringBuilder = PageUtility.MessageBox("Error", Ex.Message, "error"); ClientScript.RegisterStartupScript(Page.GetType(), "alertMessageError", stringBuilder.ToString()); } }
protected void lblCursos_Click(object sender, EventArgs e) { dsCursos dsCursos = reportesLogic.GetDataCursos(); if (dsCursos.cursos.Rows.Count > 0) { crystalReport.Load(Server.MapPath("~/ReporteCursos.rpt")); crystalReport.SetDataSource(dsCursos); CrystalReportViewer1.RefreshReport(); CrystalReportViewer1.ReportSource = crystalReport; crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "PersonDetails"); } }
protected void lnkPDF_Click(object sender, EventArgs e) { try { { rep.Load(Server.MapPath("~\\Reports\\_StaticReportRpt.rpt")); rep.SetDatabaseLogon(_Rept.DatabaseUserName, _Rept.DatabasePassword); rep.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, ""); } } catch { } }
protected void btnExportar_Click(object sender, EventArgs e) { userName = User.Identity.Name; nit = homeCtrl.obtenerNit(userName); reporte = (List <EstadoPuertaRptDet>)ViewState["RptEstadosPuerta"]; if (reporte.Count > 0) { var empresa = "Todas"; if (SitePrincipal.ExisteActiva()) { empresa = homeCtrl.nombreEmpresa(nit); } var fechaInicio = Request["datepicker1"].ToString() + " " + cbohorai.Text; var fechaFin = Request["datepicker2"].ToString() + " " + cbohoraf.Text; var placa = cboplaca.Text; rptDocument = new ReportDocument(); rptDocument.Load(Server.MapPath("~/Reporte/reporteEstadoPuerta.rpt")); rptDocument.SetDataSource(reporte); rptDocument.SetParameterValue("Empresa", empresa); rptDocument.SetParameterValue("FechaInicio", fechaInicio); rptDocument.SetParameterValue("FechaFin", fechaFin); rptDocument.SetParameterValue("Placa", placa); Response.Buffer = false; Response.Clear(); var formato = rcbFormato.SelectedValue; if (formato == "0") { rptDocument.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporteEstadoPuerta.v" + DateTime.Now.ToString() + ".xlsx"); } else if (formato == "1") { rptDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "reporteEstadoPuerta.v" + DateTime.Now.ToString() + ".pdf"); } } else { MensajeAlerta("Favor, Primero visualizar los datos antes de exportar."); } }
protected void lnkPDF_Click(object sender, EventArgs e) { try { { rep.Load(Server.MapPath("~\\Reports\\_PECC_DecisionRPT.rpt")); rep.SetDatabaseLogon(_Rept.DatabaseUserName, _Rept.DatabasePassword); rep.SetParameterValue(0, drpProvince.SelectedValue); rep.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, ""); } } catch { } }
public static void ExportPdf(ReportDocument reportDocument, string reportFileName = "", bool noStampTime = false) { ExportOptions options = new ExportOptions(); options.ExportFormatType = ExportFormatType.PortableDocFormat; if (noStampTime) { reportDocument.ExportToHttpResponse(options, System.Web.HttpContext.Current.Response, false, reportFileName); } else { reportDocument.ExportToHttpResponse(options, System.Web.HttpContext.Current.Response, false, reportFileName + '_' + DateTime.Now.ToString("yyyy-MM-dd_HHmmss", CultureInfo.CreateSpecificCulture("en-US"))); } }
protected void lnkPDF_Click(object sender, EventArgs e) { try { if (drpProvince.SelectedValue != "0") { rep.Load(Server.MapPath("~\\Reports\\Complaint_Status_RPT.rpt")); rep.SetDatabaseLogon(_Rept.DatabaseUserName, _Rept.DatabasePassword); rep.SetParameterValue(0, drpProvince.SelectedValue.ToString()); rep.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, ""); } } catch { } }
public static void ExportRepFile(string DocumentName, double top, double bottom, double left, double right, params string[] nums) { ReportDocument rDoc = SetReportDoc(nums); string ExtFile = DocumentName.Substring(DocumentName.LastIndexOf(".") + 1, 3).ToLower(); string FileName = DocumentName.Substring(0, DocumentName.LastIndexOf(".")).ToLower(); if (ExtFile == "pdf") { //设置打印边距 PageMargins margins; margins = rDoc.PrintOptions.PageMargins; margins.topMargin = Convert.ToInt32(top * 567); //567 margins.leftMargin = Convert.ToInt32(left * 567); margins.rightMargin = Convert.ToInt32(right * 567); margins.bottomMargin = Convert.ToInt32(bottom * 567); rDoc.PrintOptions.ApplyPageMargins(margins); if (nums[1].ToString() == "N1") { rDoc.PrintOptions.PaperOrientation = PaperOrientation.Portrait; rDoc.PrintOptions.PaperSize = PaperSize.PaperLetter; } //else //{ // rDoc.PrintOptions.PaperOrientation = PaperOrientation.DefaultPaperOrientation; // rDoc.PrintOptions.PaperSize = PaperSize.DefaultPaperSize; //} rDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, FileName); } else if (ExtFile == "doc") { rDoc.ExportToHttpResponse(ExportFormatType.WordForWindows, HttpContext.Current.Response, true, FileName); } else if (ExtFile == "xls") { rDoc.ExportToHttpResponse(ExportFormatType.Excel, HttpContext.Current.Response, true, FileName); } else if (ExtFile == "rtf") { rDoc.ExportToHttpResponse(ExportFormatType.RichText, HttpContext.Current.Response, true, FileName); } else { rDoc.ExportToHttpResponse(ExportFormatType.WordForWindows, HttpContext.Current.Response, true, FileName); } }
protected void cmdExportarExcel_Click(object sender, EventArgs e) { String regionCodigo = txtRegionCodigo.Text; String zonaCodigo = txtZonaCodigo.Text; try { String db_databaseName = connectionBL.getDataBaseName(); String db_serverName = connectionBL.getServerName(); String db_userID = connectionBL.getUserID(); String db_password = connectionBL.getPassword(); ReportDocument rpt = new ReportDocument(); rpt.Load(Server.MapPath("../CrystalReports/crReporteSeguimiento.rpt")); rpt.SetDatabaseLogon("", "", ".", db_databaseName); rpt.SetParameterValue("@regionCodigo", regionCodigo); rpt.SetParameterValue("@zonaCodigo", zonaCodigo); rpt.SetParameterValue("@estadoVerificiado", Convert.DBNull); rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Reporte_seguimientos_" + DateFormatter.getTimestamp(DateTime.Now)); /* rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Prueba_ExcelNormal"); //rpt.ExportToHttpResponse(ExportFormatType.ExcelRecord, Response, true, "Prueba_ExcelRecord"); */ } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } }
private void ShowReport() { try { ReportDocument myReportDocument = new ReportDocument(); myReportDocument.Load(Server.MapPath("~/StoreReport/Report/rptExchangeRequestOrderReport.rpt")); myReportDocument.Refresh(); CrystalReportViewer1.ReportSource = myReportDocument; long ExchangeRequestNo = 0; if (!string.IsNullOrEmpty(txtExchangeRequestNo.Text)) { ExchangeRequestNo = long.Parse(txtExchangeRequestNo.Text); } myReportDocument.DataSourceConnections[0].SetConnection(csGetPermission.DBServerName, csGetPermission.DBName, csGetPermission.DBUser, csGetPermission.DBPassword); myReportDocument.SetParameterValue("@ExchangeRequestNo", ExchangeRequestNo); myReportDocument.SetParameterValue("@OrderType", long.Parse(ddlExchangeRequest.SelectedValue)); myReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); } catch { } }
protected void btnCrystal_Click(object sender, EventArgs e) { if (int.Parse(Session["reporteactivoCampos"].ToString()) == 1) { // Get the report document string sReporte = Session["reportdocumentCampos"].ToString(); ReportDocument repDoc = getReportDocument(sReporte); //Esta linea soluciona el problema de la excepcion que no permite guardar los archivos repDoc.SetDataSource((DataSet)Session["datasetCamposEditables"]); // Stop buffering the response Response.Buffer = false; // Clear the response content and headers Response.ClearContent(); Response.ClearHeaders(); try { // Export the Report to Response stream in Crystal Report format repDoc.ExportToHttpResponse(ExportFormatType.CrystalReport, Response, true, Session["tituloCampos"].ToString()); // There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports } catch (Exception ex) { Console.WriteLine(ex.Message); ex = null; } } }
public void GetInternalEmiInvoiceReport(int internal_requisition_master_id, int user_id) { try { var wbClient = new WebClient(); string downloadString = CoreRules.httpRequest() + "InternalEmiRequisition/GetInternalEmiInvoiceReport?internal_requisition_master_id=" + internal_requisition_master_id + "&user_id=" + user_id; var apidata = wbClient.DownloadString(downloadString); InternalEmiCombinedInvoiceReportModel oDeliAndDis = JsonConvert.DeserializeObject <InternalEmiCombinedInvoiceReportModel>(apidata); DataTable dt1 = ToDataTable(oDeliAndDis.InternalInvoiceReportModel); using (var reportDocument = new ReportDocument()) { reportDocument.Load(Server.MapPath("~/Reports/crystal_view/InternalEmiInvoiceReportData.rpt")); reportDocument.SetDataSource(oDeliAndDis.InternalInvoiceReportModel); if (oDeliAndDis.InstallmentDetailsModel.Count > 0) { reportDocument.OpenSubreport("installmentDetailsSubRpt").SetDataSource(oDeliAndDis.InstallmentDetailsModel); } else { reportDocument.OpenSubreport("installmentDetailsSubRpt").SetDataSource(dt1); //if assign list and list is empty then it showing error } reportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "Invoice_" + DateTime.Now.ToString("dd-MM-yyyy_hh-mm_tt")); } } catch (Exception ex) { throw ex; } }
public void ShowGenericRpt() { try { bool isValid = true; string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString(); // Setting ReportName var rptSource = System.Web.HttpContext.Current.Session["rptSource"]; if (string.IsNullOrEmpty(strReportName)) { isValid = false; } if (isValid) { ReportDocument rd = new ReportDocument(); string strRptPath = System.Web.HttpContext.Current.Server.MapPath("../") + "Reports/" + strReportName; rd.Load(strRptPath); if (rptSource != null && rptSource.GetType().ToString() != "System.String") { rd.SetDataSource(rptSource); } rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport"); // Clear all sessions value Session["ReportName"] = null; Session["rptSource"] = null; } else { Response.Write("<H2>Nothing Found; No Report name found</H2>"); } } catch (Exception ex) { Response.Write(ex.ToString()); } }
public void exprt() { userName = HttpContext.Current.User.Identity.Name; HomeController homeController = new HomeController(); nit = homeController.obtenerNit(userName); List <DetencionesRpt> reporte = new List <DetencionesRpt>(); reporte = (List <DetencionesRpt>)HttpContext.Current.Session["RptDetenciones"]; ReportDocument rptDocument = new ReportDocument(); var empresa = "Todas"; if (SitePrincipal.ExisteActiva()) { empresa = homeController.nombreEmpresa(nit); } string placa = "Todas"; var fechaI = Request["datepicker1"].ToString() + " " + cbohorai.Text; var fechaF = Request["datepicker2"].ToString() + " " + cbohoraf.Text; rptDocument.Load(Server.MapPath("~/Reporte/reporteDetencion.rpt")); rptDocument.SetDataSource(reporte); rptDocument.SetParameterValue("Empresa", empresa); rptDocument.SetParameterValue("FechaInicio", fechaI); rptDocument.SetParameterValue("FechaFin", fechaF); rptDocument.SetParameterValue("Placa", ""); Response.Buffer = false; Response.Clear(); rptDocument.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporteDetencion.v" + DateTime.Now.ToString("yyyyMMddHHMMss")); }
private void ShowReport() { try { ReportDocument myReportDocument = new ReportDocument(); myReportDocument.Load(Server.MapPath("~/StoreReport/Report/rptCheckAudit.rpt")); myReportDocument.Refresh(); CrystalReportViewer1.ReportSource = myReportDocument; long RecordReceiptNo = 0; long AuditNo = 0; if (!string.IsNullOrEmpty(txtRecordReceiptNo.Text)) { RecordReceiptNo = long.Parse(txtRecordReceiptNo.Text); } if (!string.IsNullOrEmpty(txtAuditNo.Text)) { AuditNo = long.Parse(txtAuditNo.Text); } //myReportDocument.SetDatabaseLogon(csGetPermission.DBUser, csGetPermission.DBPassword, csGetPermission.DBServerName, csGetPermission.DBName); myReportDocument.DataSourceConnections[0].SetConnection(csGetPermission.DBServerName, csGetPermission.DBName, csGetPermission.DBUser, csGetPermission.DBPassword); myReportDocument.SetParameterValue("@RecordReceiptNo", RecordReceiptNo); myReportDocument.SetParameterValue("@AuditNo", AuditNo); myReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); } catch { } }
private void Exibe_Certidao_Endereco(Certidao_endereco dados) { lblMsg.Text = ""; string sComplemento = dados.Li_compl; string sQuadras = string.IsNullOrWhiteSpace(dados.Li_quadras) ? "" : " Quadra: " + dados.Li_quadras.ToString().Trim(); string sLotes = string.IsNullOrWhiteSpace(dados.Li_lotes) ? "" : " Lote: " + dados.Li_lotes.ToString().Trim(); sComplemento += sQuadras + sLotes; string sEndereco = dados.Logradouro + ", " + dados.Numero.ToString() + sComplemento; ReportDocument crystalReport = new ReportDocument(); crystalReport.Load(Server.MapPath("~/Report/CertidaoEnderecoValida.rpt")); crystalReport.SetParameterValue("NUMCERTIDAO", dados.Numero.ToString("00000") + "/" + dados.Ano.ToString("0000")); crystalReport.SetParameterValue("DATAEMISSAO", dados.Data.ToString("dd/MM/yyyy") + " às " + dados.Data.ToString("HH:mm:ss")); crystalReport.SetParameterValue("CONTROLE", dados.Numero.ToString("00000") + dados.Ano.ToString("0000") + "/" + dados.Codigo.ToString() + "-EA"); crystalReport.SetParameterValue("ENDERECO", sEndereco); crystalReport.SetParameterValue("CADASTRO", dados.Codigo.ToString("000000")); crystalReport.SetParameterValue("NOME", dados.Nomecidadao); crystalReport.SetParameterValue("INSCRICAO", dados.Inscricao); crystalReport.SetParameterValue("BAIRRO", dados.descbairro); HttpContext.Current.Response.Buffer = false; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); try { crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "comp" + dados.Numero.ToString() + dados.Ano.ToString() + "_EA"); } catch { } finally { crystalReport.Close(); crystalReport.Dispose(); } }
public void PrintBillingReportS2(string IPID) { string[] splt = IPID.Split('^'); ReportDocument doc = new ReportDocument(); string pst = string.Empty; if (splt[1].ToString() == "Cash") { pst = HttpContext.Current.Server.MapPath("~/Admin/CReport/BillingReceipt.rpt"); } else { pst = HttpContext.Current.Server.MapPath("~/Admin/CReport/BillingReceipt1.rpt"); } doc.Load(pst); DataSet FetchedRecords = new DataSet(); DataTable dt = new DataTable(); FetchedRecords = SqlHelper.ExecuteDataset(GlobalPath.ConnectionString, "usp_Print_BillingSlip", splt[0].ToString()); dt = FetchedRecords.Tables[0]; if (dt != null) { if (dt.Rows.Count > 0) { doc.SetDataSource(dt); doc.Refresh(); doc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "PRINTOUT"); } } }
protected void Button1_Click(object sender, EventArgs e) { int idOrientador = (int)Session["id"]; if ((int.Parse(ddlAnio1.SelectedValue) > int.Parse(ddlAnio2.SelectedValue)) || ((int.Parse(ddlAnio1.SelectedValue) == int.Parse(ddlAnio2.SelectedValue)) && int.Parse(ddlMes1.SelectedValue) > int.Parse(ddlMes2.SelectedValue))) { Response.Write(@"<script>alert('RANGO INCORRECTO');setTimeout(function(){window.location = '" + Request.RawUrl + @"';}, 10);</script>"); } else { try { ReportDocument crystalrpt = new ReportDocument(); crystalrpt.Load(Server.MapPath(@"~/Reportes/AsistenciaRangoOrientador.rpt")); //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*"); crystalrpt.Refresh(); crystalrpt.SetParameterValue("@IdOrientador", idOrientador); crystalrpt.SetParameterValue("@Anio", ddlAnio1.SelectedValue); crystalrpt.SetParameterValue("@Mes", ddlMes1.SelectedValue); crystalrpt.SetParameterValue("@Anio2", ddlAnio2.SelectedValue); crystalrpt.SetParameterValue("@Mes2", ddlMes2.SelectedValue); crystalrpt.SetParameterValue("@IdProceso", ddlProceso.SelectedValue); crystalrpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "ReporteAsistencia"); crystalrpt.Refresh(); } catch { } } }
//Exporta a Excel el grid protected void ExportExcel(object sender, EventArgs e) { string sucursal = cmbSucursal.Value.ToString(); //1. Configurar la conexión y el tipo de comando SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString); try { SqlCommand comando = new SqlCommand("web_spS_ObtenerRItemsAdicionales", conn); SqlDataAdapter adaptador = new SqlDataAdapter(comando); DataTable dt = new DataTable(); adaptador.SelectCommand.CommandType = CommandType.StoredProcedure; adaptador.SelectCommand.Parameters.Add(@"Sucursal", SqlDbType.Char).Value = sucursal; adaptador.Fill(dt); ReportDocument reporteResumenExcel = new ReportDocument(); reporteResumenExcel.Load(Server.MapPath("reportess/ResumenOCPrecios.rpt")); reporteResumenExcel.SetDataSource(dt); reporteResumenExcel.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Resumen de OC: " + sucursal); reporteResumenExcel.Close(); reporteResumenExcel.Dispose(); } catch (Exception ex) { ex.Message.ToString(); } finally { if (conn.State != ConnectionState.Closed) conn.Close(); conn.Dispose(); } }
protected void cmdExportarExcel_Click(object sender, EventArgs e) { String regionCodigo = lblRegionCodigo.Text; String zonaCodigo = lblZonaCodigo.Text; String fechaInscripcion = txtFechaInscripcionIni.Text; String fechaInscripcionIni = txtFechaInscripcionIni.Text; String fechaInscripcionFin = txtFechaInscripcionFin.Text; String campanhaInscripcion = txtCampaniaInscripcion.Text; String documentoNumero = txtDocumentoIdentidad.Text; String consultoraCodigo = txtCodigoConsultora.Text; String apellidoPaterno = txtApellidoPaterno.Text; String apellidoMaterno = txtApellidoMaterno.Text; String nombres = txtNombres.Text; DateTime dtProjectStartDate = new DateTime(); DateTime dtFecRegIni = new DateTime(2000, 01, 01); DateTime dtFecRegFin = DateTime.Today; CultureInfo culture = new CultureInfo("en-GB"); if (fechaInscripcionIni.Length > 0) { try { dtProjectStartDate = Convert.ToDateTime(fechaInscripcion, culture); dtFecRegIni = Convert.ToDateTime(fechaInscripcionIni, culture); dtFecRegFin = Convert.ToDateTime(fechaInscripcionFin, culture); } catch (Exception ex) { dtProjectStartDate = DateTime.Now; } } try { String db_databaseName = connectionBL.getDataBaseName(); String db_serverName = connectionBL.getServerName(); String db_userID = connectionBL.getUserID(); String db_password = connectionBL.getPassword(); ReportDocument rpt = new ReportDocument(); rpt.Load(Server.MapPath("../CrystalReports/crReporteReingresoDetalle.rpt")); rpt.SetDatabaseLogon("", "", ".", db_databaseName); rpt.SetParameterValue("@regionCodigo", regionCodigo); rpt.SetParameterValue("@zonaCodigo", zonaCodigo); rpt.SetParameterValue("@fechaReingreso", Convert.DBNull); // < por ahora null rpt.SetParameterValue("@fechaReingresoini", dtFecRegIni.ToShortDateString()); // < por ahora null rpt.SetParameterValue("@fechaReingresofin", dtFecRegFin.ToShortDateString()); // < por ahora null rpt.SetParameterValue("@campanhaInscripcion", campanhaInscripcion); rpt.SetParameterValue("@campanhaFacturacion", Convert.DBNull); rpt.SetParameterValue("@documentoNumero", documentoNumero); rpt.SetParameterValue("@consultoraCodigo", consultoraCodigo); rpt.SetParameterValue("@apellidoPaterno", apellidoPaterno); rpt.SetParameterValue("@apellidoMaterno", apellidoMaterno); rpt.SetParameterValue("@nombres", nombres); if (Convert.ToInt32(ddlEstadoVerificado.SelectedValue) > 1) { rpt.SetParameterValue("@estadoVerificado", Convert.DBNull); } else { rpt.SetParameterValue("@estadoVerificado", Convert.ToBoolean(Convert.ToInt32(ddlEstadoVerificado.SelectedValue))); } rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporte_detalle_reingreso_" + DateFormatter.getTimestamp(DateTime.Now)); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } }
protected void gvReingresos_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "generatePDFView") { String reingresoID = gvReingresos.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text; String consultoraID = gvReingresos.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text; try { String db_databaseName = connectionBL.getDataBaseName(); String db_serverName = connectionBL.getServerName(); String db_userID = connectionBL.getUserID(); String db_password = connectionBL.getPassword(); ReportDocument rpt = new ReportDocument(); rpt.Load(Server.MapPath("../CrystalReports/crReingreso.rpt")); rpt.SetDatabaseLogon("", "", ".", db_databaseName); rpt.SetParameterValue("@reingresoID", Convert.ToInt32(reingresoID)); rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Reingreso_" + DateFormatter.getTimestamp(DateTime.Now)); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } } }
protected void cmdExportarExcel_Click(object sender, EventArgs e) { String regionCodigo = lblRegionCodigo.Text; String zonaCodigo = lblZonaCodigo.Text; String fechaInscripcion = txtFechaInscripcion.Text; String campanhaInscripcion = txtCampaniaInscripcion.Text; String documentoNumero = txtDocumentoIdentidad.Text; String consultoraCodigo = txtCodigoConsultora.Text; String apellidoPaterno = txtApellidoPaterno.Text; String apellidoMaterno = txtApellidoMaterno.Text; String nombres = txtNombres.Text; int intEstadoVerificado = Convert.ToInt32(ddlEstadoVerificado.SelectedValue); int intModoGrabacion = Convert.ToInt32(ddlModoGrabacion.SelectedValue); try { String db_databaseName = connectionBL.getDataBaseName(); String db_serverName = connectionBL.getServerName(); String db_userID = connectionBL.getUserID(); String db_password = connectionBL.getPassword(); ReportDocument rpt = new ReportDocument(); rpt.Load(Server.MapPath("../CrystalReports/crReporteIncorporacionDetalle.rpt")); rpt.SetDatabaseLogon("", "", ".", db_databaseName); rpt.SetParameterValue("@regionCodigo", regionCodigo); rpt.SetParameterValue("@zonaCodigo", zonaCodigo); rpt.SetParameterValue("@fechaInscripcion", Convert.DBNull); // < por ahora null rpt.SetParameterValue("@campanhaInscripcion", campanhaInscripcion); rpt.SetParameterValue("@numeroDocumento", documentoNumero); rpt.SetParameterValue("@consultoraCodigo", consultoraCodigo); rpt.SetParameterValue("@apellidoPaterno", apellidoPaterno); rpt.SetParameterValue("@apellidoMaterno", apellidoMaterno); rpt.SetParameterValue("@nombres", nombres); if (Convert.ToInt32(ddlEstadoVerificado.SelectedValue) == 2) rpt.SetParameterValue("@estadoVerificado", Convert.DBNull); else rpt.SetParameterValue("@estadoVerificado", Convert.ToBoolean(Convert.ToInt32(ddlEstadoVerificado.SelectedValue))); if (Convert.ToInt32(ddlModoGrabacion.SelectedValue) == 2) rpt.SetParameterValue("@modoGrabacion", Convert.DBNull); else rpt.SetParameterValue("@modoGrabacion", Convert.ToBoolean(Convert.ToInt32(ddlModoGrabacion.SelectedValue))); rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "reporte_detalle_incorporaciones_" + DateFormatter.getTimestamp(DateTime.Now)); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } }
private void imprimepresupuesto() { String opciones; String[] Datos; SqlConnection connection; SqlDataAdapter adapter; try { DataSet dspresupuesto= new DataSet(); opciones = Request.QueryString["op"]; Datos = opciones.Split('_'); System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselImprimeCotizacion", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("FechaDesde", Datos[0].ToString()); command.Parameters.AddWithValue("FechaHasta", Datos[1].ToString()); command.Parameters.AddWithValue("idOrigen", Datos[2].ToString()); command.Parameters.AddWithValue("IdDestino", Datos[3].ToString() ); command.Parameters.AddWithValue("Email", Datos[4].ToString()); command.Parameters.AddWithValue("edades", Datos[5].ToString()); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(dspresupuesto); conn.Close(); String archivo = ""; ReportDocument rptDoc = new ReportDocument(); rptDoc.Load(Server.MapPath("~/Reportes/presupuesto1.rpt")); rptDoc.SetDataSource(dspresupuesto.Tables[0]); dspresupuesto.Dispose(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); string targetFileName = "C:/Data/Tusegurodeviaje/Reports/TempReports/presupuesto_" + (new Random()).Next() + ".pdf"; //string targetFileName = Request.PhysicalApplicationPath + "C:\Data\Tusegurodeviaje\Reports\TempReports\\presupuesto" + (new Random()).Next() + ".pdf"; rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; diskOpts.DiskFileName = targetFileName; //archivo = Server.MapPath(targetFileName); rptDoc.ExportOptions.DestinationOptions = diskOpts; // Export report ... Server-Side. rptDoc.Export(); CrystalReportViewer1.ReportSource = rptDoc; rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "presupuesto"); } catch (Exception ex) { Response.Write(ex.Message); } finally { } }
public void PrintReport(Page _Page, string _ReportName, string _FileName, DataTable[] dts, string[] _DSTableName, string[] paramNames = null, string[] paramValues = null) { paramNames = paramNames == null ? new string[] { } : paramNames; paramValues = paramValues == null ? new string[] { } : paramValues; dts = dts == null ? new DataTable[] { } : dts; _DSTableName = _DSTableName == null ? new string[] { } : _DSTableName; ReportDocument rptDoc = new ReportDocument(); try { rptDoc.Load(_Page.Server.MapPath("~/Reports/" + _ReportName)); dsPSMS ds = new dsPSMS(); for (int i = 0; i < dts.Length; i++) { ds.Tables[_DSTableName[i]].Merge(dts[i]); } if (dts.Length > 0) rptDoc.SetDataSource(ds); if (paramNames.Length == paramValues.Length) { for (int i = 0; i < paramNames.Length; i++) rptDoc.SetParameterValue(paramNames[i], paramValues[i]); } rptDoc.SetDatabaseLogon(dbINFO._UID, dbINFO._PWD, dbINFO._SRV, dbINFO._CAT); _Page.Response.Buffer = false; _Page.Response.ClearContent(); _Page.Response.ClearHeaders(); //Export the Report to Response stream in PDF format and file name Customers rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, _Page.Response, true, _FileName); _Page.Response.ClearContent(); _Page.Response.ClearHeaders(); _Page.Response.Clear(); _Page.Response.Close(); } catch (Exception ex) { //DO NOTHING } finally { rptDoc.Close(); rptDoc.Dispose(); } }
//dbINFO._SRV, dbINFO._CAT, dbINFO._UID, dbINFO._PWD public void PrintReport(Page _Page, string _ReportName, string _FileName, DataTable dt) { ReportDocument rptDoc = new ReportDocument(); try { rptDoc.Load(_Page.Server.MapPath("~/Reports/" + _ReportName)); rptDoc.SetDataSource(dt); rptDoc.SetDatabaseLogon(dbINFO._UID, dbINFO._PWD, dbINFO._SRV, dbINFO._CAT); _Page.Response.Buffer = false; _Page.Response.ClearContent(); _Page.Response.ClearHeaders(); //Export the Report to Response stream in PDF format and file name Customers rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, _Page.Response, true, _FileName); } catch (Exception ex) { Utility.ShowHTMLMessage(_Page, "100", ex.Message); } finally { rptDoc.Close(); rptDoc.Dispose(); } }
public void ShowRptData() { try { string strReportName = System.Web.HttpContext.Current.Session["ReportName"].ToString(); string cardCode = System.Web.HttpContext.Current.Session["CardCode"].ToString(); string cardName = System.Web.HttpContext.Current.Session["CardName"].ToString(); string startDate = System.Web.HttpContext.Current.Session["StartDate"].ToString(); string endDate = System.Web.HttpContext.Current.Session["EndDate"].ToString(); ReportDocument rd = new ReportDocument(); string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Report//" + strReportName; ExceptionLog.Write(string.Format("the report path is {0}", strRptPath)); rd.Load(strRptPath); TableLogOnInfo logInfo = new TableLogOnInfo(); logInfo.ConnectionInfo.ServerName = "."; logInfo.ConnectionInfo.DatabaseName = "SBO_GS_TEST"; logInfo.ConnectionInfo.UserID = "sa"; logInfo.ConnectionInfo.Password = "******"; rd.Database.Tables[0].ApplyLogOnInfo(logInfo); if (!string.IsNullOrEmpty(cardName)) rd.SetParameterValue("cardname", cardName); if (!string.IsNullOrEmpty(startDate)) rd.SetParameterValue("Sdate", Convert.ToDateTime(startDate)); if (!string.IsNullOrEmpty(startDate)) rd.SetParameterValue("Edate", Convert.ToDateTime(endDate)); rd.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport"); Session["ReportName"] = null; Session["CardCode"] = null; Session["CardName"] = null; Session["StartDate"] = null; Session["EndDate"] = null; } catch (Exception ex) { Response.Write(ex.ToString()); } }
protected void gvIncorporaciones_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "generatePDFView") { String incorporacionID = gvIncorporaciones.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text; String consultoraID = gvIncorporaciones.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text; String db_databaseName = connectionBL.getDataBaseName(); String db_serverName = connectionBL.getServerName(); String db_userID = connectionBL.getUserID(); String db_password = connectionBL.getPassword(); ReportDocument rpt = new ReportDocument(); rpt.Load(Server.MapPath("../CrystalReports/rcSolicitudCredito.rpt")); rpt.SetDatabaseLogon("", "", ".", db_databaseName); rpt.SetParameterValue("@incorporacionID", Convert.ToInt32(incorporacionID)); rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "solicitud_de_credito_" + DateFormatter.getTimestamp(DateTime.Now)); } }
public void GH() { customerReport = new ReportDocument(); customerReport.Load(Server.MapPath("Print_Invoice.rpt"));//Print_Invoice DataSet dssql = new DataSet(); DataTable dtsql2 = new DataTable(); dtsql2.TableName = "Invoice"; dtsql2.Columns.Add("ProdDesc"); dtsql2.Columns.Add("Qty"); dtsql2.Columns.Add("UnitPrice"); dtsql2.Columns.Add("SubTotal"); dssql.Tables.Add(dtsql2); using(inikierpEntities ent=new inikierpEntities()) { //var v = from eo in ent.eorder // join cus in ent.customercode on eo.cusID equals cus.cusID // where eo.odID == 62636 // select new // { // eo.orderNo,eo.invNo // }; //foreach(var h in v) //{ //} var yy = from ei in ent.eorderitem join pd in ent.productcode on ei.prodID equals pd.prodID where ei.odID == 62632 select new { pd.prodDesc, ei.qty, ei.unitPrice }; int j = 0; foreach(var f in yy) { dssql.Tables["Invoice"].Rows.Add(); dssql.Tables["Invoice"].Rows[j]["ProdDesc"] = f.prodDesc; dssql.Tables["Invoice"].Rows[j]["Qty"] = f.qty; dssql.Tables["Invoice"].Rows[j]["UnitPrice"] = f.unitPrice; dssql.Tables["Invoice"].Rows[j]["SubTotal"] = f.qty * f.unitPrice; j++; } } DataView dv = new DataView(); dv = dssql.Tables["Invoice"].DefaultView; customerReport.SetDataSource(dv); this.CrystalReportViewer1.ReportSource = customerReport; customerReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); }
public void GH() { customerReport = new ReportDocument(); customerReport.Load(Server.MapPath("Print_Eorder.rpt")); DataSet dssql = new DataSet(); //DataTable dtsql = new DataTable(); //dtsql.TableName = "Eorder"; //dtsql.Columns.Add("CustomerName"); //dtsql.Columns.Add("CompanyNo"); //dtsql.Columns.Add("CustomerNo"); //dtsql.Columns.Add("EorderNo"); //dtsql.Columns.Add("InvoiceNo"); //dtsql.Columns.Add("Sendway"); //dtsql.Columns.Add("InvoiceTtile"); //dtsql.Columns.Add("Payway"); //dtsql.Columns.Add("Phone"); //dtsql.Columns.Add("CustomerAddress"); //dtsql.Columns.Add("EorderMemo"); //dtsql.Columns.Add("EorderTotal"); //dssql.Tables.Add(dtsql); DataTable dtsql2 = new DataTable(); dtsql2.TableName = "Eorderitem"; dtsql2.Columns.Add("ProdSeq"); dtsql2.Columns.Add("ProdDesc"); dtsql2.Columns.Add("Qty"); //dtsql2.Columns.Add("ProdSellPrice"); dtsql2.Columns.Add("UnitPrice"); dtsql2.Columns.Add("SubTotal"); dtsql2.Columns.Add("pStorageSpaces"); dssql.Tables.Add(dtsql2); using (inikierpEntities ent = new inikierpEntities()) { var v = from eo in ent.eorder join cus in ent.customercode on eo.cusID equals cus.cusID join send in ent.sendcode on eo.sendID equals send.sendID join payway in ent.paywaycode on eo.payID equals payway.payID //join invtitle in ent.invtitlecode on eo.invTitleCode equals invtitle.invTitleCode1 where eo.odID == 62636 //&& invtitle.invTitleCode1!=0 select new { eo.eoDate, eo.total, eo.orderNo, eo.eoMemo, eo.invTitleCode, eo.odID, cus.contactName, cus.sendAddress, cus.contactMobile, cus.cusID, payway.payDesc, send.sendName }; int i = 0; foreach (var h in v) { TextObject contactName = (TextObject)customerReport.ReportDefinition.ReportObjects["Text10"]; contactName.Text = h.contactName; var g = from a in ent.invtitlecode join e in ent.eorder on a.invTitleCode1 equals e.invTitleCode where e.orderNo == h.orderNo && a.invTitleCode1 == h.invTitleCode select new { a.invTitleDesc, a.invCode }; //int jj=g.ToList().Count(); foreach (var gg in g) { TextObject invCode = (TextObject)customerReport.ReportDefinition.ReportObjects["Text11"]; invCode.Text = gg.invCode; TextObject invTitleDesc = (TextObject)customerReport.ReportDefinition.ReportObjects["Text16"]; invTitleDesc.Text = gg.invTitleDesc; } TextObject cusID = (TextObject)customerReport.ReportDefinition.ReportObjects["Text12"]; cusID.Text = h.cusID.ToString(); TextObject orderNo = (TextObject)customerReport.ReportDefinition.ReportObjects["Text13"]; orderNo.Text = h.orderNo; TextObject Invoice = (TextObject)customerReport.ReportDefinition.ReportObjects["Text14"]; Invoice.Text = "發票號碼"; TextObject sendName = (TextObject)customerReport.ReportDefinition.ReportObjects["Text15"]; sendName.Text = h.sendName; TextObject payDesc = (TextObject)customerReport.ReportDefinition.ReportObjects["Text17"]; payDesc.Text = h.payDesc; TextObject contactMobile = (TextObject)customerReport.ReportDefinition.ReportObjects["Text25"]; contactMobile.Text = h.contactMobile; TextObject eoDate = (TextObject)customerReport.ReportDefinition.ReportObjects["Text18"]; eoDate.Text = h.eoDate.Value.ToString("yyyy-MM-dd"); TextObject sendAddress = (TextObject)customerReport.ReportDefinition.ReportObjects["Text19"]; sendAddress.Text = h.sendAddress; TextObject eoMemo = (TextObject)customerReport.ReportDefinition.ReportObjects["Text20"]; eoMemo.Text = h.eoMemo; TextObject total = (TextObject)customerReport.ReportDefinition.ReportObjects["Text21"]; total.Text = h.total.ToString(); int j = 0; var yy = from ei in ent.eorderitem join pd in ent.productcode on ei.prodID equals pd.prodID where ei.odID == h.odID select new { pd.prodSeq, pd.prodDesc, ei.qty, ei.unitPrice, pd.pStorageSpaces }; foreach (var f in yy) { dssql.Tables["Eorderitem"].Rows.Add(); dssql.Tables["Eorderitem"].Rows[j]["ProdSeq"] = f.prodSeq; dssql.Tables["Eorderitem"].Rows[j]["ProdDesc"] = f.prodDesc; dssql.Tables["Eorderitem"].Rows[j]["Qty"] = f.qty; dssql.Tables["Eorderitem"].Rows[j]["UnitPrice"] = f.unitPrice; dssql.Tables["Eorderitem"].Rows[j]["SubTotal"] = f.qty * f.unitPrice; dssql.Tables["Eorderitem"].Rows[j]["pStorageSpaces"] = f.pStorageSpaces; j++; } i++; } } DataView dv = new DataView(); dv = dssql.Tables["Eorderitem"].DefaultView; customerReport.SetDataSource(dv); this.CrystalReportViewer1.ReportSource = customerReport; customerReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, ""); }
//Exporta a Excel el grid protected void ExportEt(object sender, EventArgs e) { string nombreReporte = cmbCuadrillas.Text; //1. Configurar la conexión y el tipo de comando SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString); try { SqlCommand comando = new SqlCommand("web_spS_ObtenerReportePorCuadrilla", conn); SqlDataAdapter adaptador = new SqlDataAdapter(comando); DataTable dt = new DataTable(); adaptador.SelectCommand.CommandType = CommandType.StoredProcedure; adaptador.SelectCommand.Parameters.Add(@"CUADRILLA", SqlDbType.Char).Value = nombreReporte; adaptador.Fill(dt); ReportDocument reporteCuadrila = new ReportDocument(); reporteCuadrila.Load(Server.MapPath("reportess/rReportesCuadrillas.rpt")); reporteCuadrila.SetDataSource(dt); reporteCuadrila.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Reportes Cuadrilla " + nombreReporte); } catch (Exception ex) { ex.Message.ToString(); } finally { if (conn.State != ConnectionState.Closed) conn.Close(); conn.Dispose(); } }
/// <summary> /// /// </summary> private void ShowReportAll() { ReportDocument crystalReport = new ReportDocument(); crystalReport.Load(Server.MapPath(@"Reports\Report\\" + _reportName)); Session["ReportDocument"] = crystalReport; crystalReport.Database.Tables["BillMaster"].SetDataSource(_ds.Tables[0]); crystalReport.Database.Tables["Company"].SetDataSource(_ds.Tables[1]); //crystalReport.SetDataSource(_ds); rptViewer.PrintMode = PrintMode.Pdf; //rptViewer. crystalReport.PrintOptions.PaperOrientation = PaperOrientation.Landscape; rptViewer.ReportSource = (ReportDocument)Session["ReportDocument"]; rptViewer.RefreshReport(); rptViewer.DataBind(); // Stop buffering the response Response.Buffer = false; // Clear the response content and headers Response.ClearContent(); Response.ClearHeaders(); ExportFormatType format = ExportFormatType.PortableDocFormat; string ext = ".pdf"; string reportName = "myreport"; try { crystalReport.ExportToHttpResponse(format, Response, false, ""); } catch (System.Threading.ThreadAbortException) { //ThreadException can happen for internale Response implementation } catch (Exception ex) { //other exeptions will be managed throw; } }
private void muestrareporte() { SqlDataAdapter adapter; DataSet ds = new DataSet(); String archivo = ""; String IdOperacion = ""; IdOperacion = Session["SesionIdOperacionRetorno"].ToString(); Session.Remove("SesionIdOperacionRetorno"); DataTable dtVoucher = new DataTable(); DataSet dsVoucher = new DataSet(); dtVoucher.Columns.Add("IdOperacion"); dtVoucher.Columns.Add("FechaEmision"); dtVoucher.Columns.Add("NroVoucher"); dtVoucher.Columns.Add("Pasajero_Nombre"); dtVoucher.Columns.Add("Pasajero_Apellido"); dtVoucher.Columns.Add("Pasajero_Documento"); dtVoucher.Columns.Add("Pasajero_FechaNac"); dtVoucher.Columns.Add("Pasajero_TipoTelefono"); dtVoucher.Columns.Add("Pasajero_Telefono"); dtVoucher.Columns.Add("Pasajero_Celular"); dtVoucher.Columns.Add("Pasajero_Email"); dtVoucher.Columns.Add("ContactoEmergencia_Apellido"); dtVoucher.Columns.Add("ContactoEmergencia_Nombre"); dtVoucher.Columns.Add("ContactoEmergencia_Email"); dtVoucher.Columns.Add("ProductoDescripcion"); dtVoucher.Columns.Add("OrigenDescripcion"); dtVoucher.Columns.Add("DestinoDescripcion"); dtVoucher.Columns.Add("FechaPartida"); dtVoucher.Columns.Add("FechaRegreso"); dtVoucher.Columns.Add("ImporteTarifaPesos"); dtVoucher.Columns.Add("ImporteTarifaDolar"); dtVoucher.Columns.Add("IdCobertura"); dtVoucher.Columns.Add("DescripcionCobertura"); dtVoucher.Columns.Add("ValorCobertura"); dtVoucher.Columns.Add("MonedaDescripcion"); dtVoucher.Columns.Add("SimboloMoneda"); dtVoucher.Columns.Add("IdCobertura2"); dtVoucher.Columns.Add("DescripcionCobertura2"); dtVoucher.Columns.Add("ValorCobertura2"); dtVoucher.Columns.Add("MonedaDescripcion2"); dtVoucher.Columns.Add("SimboloMoneda2"); try { System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselImprimeVoucher", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("Id_Operacion", Convert.ToInt32(IdOperacion)); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(ds); conn.Close(); ds.Dispose(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = dtVoucher.NewRow(); row["IdOperacion"] = ds.Tables[0].Rows[i]["IdOperacion"].ToString(); row["FechaEmision"] = ds.Tables[0].Rows[i]["FechaEmision"].ToString(); ; row["NroVoucher"] = ds.Tables[0].Rows[i]["NroVoucher"].ToString(); row["Pasajero_Nombre"] = ds.Tables[0].Rows[i]["Pasajero_Nombre"].ToString(); row["Pasajero_Apellido"] = ds.Tables[0].Rows[i]["Pasajero_Apellido"].ToString(); row["Pasajero_Documento"] = ds.Tables[0].Rows[i]["Pasajero_Documento"].ToString(); row["Pasajero_FechaNac"] = ds.Tables[0].Rows[i]["Pasajero_FechaNac"].ToString(); row["Pasajero_TipoTelefono"] = ds.Tables[0].Rows[i]["Pasajero_TipoTelefono"].ToString(); row["Pasajero_Telefono"] = ds.Tables[0].Rows[i]["Pasajero_Telefono"].ToString(); row["Pasajero_Celular"] = ds.Tables[0].Rows[i]["Pasajero_Celular"].ToString(); row["Pasajero_Email"] = ds.Tables[0].Rows[i]["Pasajero_Email"].ToString(); row["ContactoEmergencia_Apellido"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Apellido"].ToString(); row["ContactoEmergencia_Nombre"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Nombre"].ToString(); row["ContactoEmergencia_Email"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Email"].ToString(); row["ProductoDescripcion"] = ds.Tables[0].Rows[i]["ProductoDescripcion"].ToString(); row["OrigenDescripcion"] = ds.Tables[0].Rows[i]["OrigenDescripcion"].ToString(); row["DestinoDescripcion"] = ds.Tables[0].Rows[i]["DestinoDescripcion"].ToString(); row["FechaPartida"] = ds.Tables[0].Rows[i]["FechaPartida"].ToString(); row["FechaRegreso"] = ds.Tables[0].Rows[i]["FechaRegreso"].ToString(); row["ImporteTarifaPesos"] = ds.Tables[0].Rows[i]["ImporteTarifaPesos"].ToString(); row["ImporteTarifaDolar"] = ds.Tables[0].Rows[i]["ImporteTarifaDolar"].ToString(); row["IdCobertura"] = ds.Tables[0].Rows[i]["IdCobertura"].ToString(); row["DescripcionCobertura"] = ds.Tables[0].Rows[i]["DescripcionCobertura"].ToString(); row["ValorCobertura"] = ds.Tables[0].Rows[i]["ValorCobertura"].ToString(); row["MonedaDescripcion"] = ds.Tables[0].Rows[i]["MonedaDescripcion"].ToString(); row["SimboloMoneda"] = ds.Tables[0].Rows[i]["SimboloMoneda"].ToString(); row["IdCobertura2"] = ds.Tables[0].Rows[i]["IdCobertura2"].ToString(); row["DescripcionCobertura2"] = ds.Tables[0].Rows[i]["DescripcionCobertura2"].ToString(); row["ValorCobertura2"] = ds.Tables[0].Rows[i]["ValorCobertura2"].ToString(); row["MonedaDescripcion2"] = ds.Tables[0].Rows[i]["MonedaDescripcion2"].ToString(); row["SimboloMoneda2"] = ds.Tables[0].Rows[i]["SimboloMoneda2"].ToString(); dtVoucher.Rows.Add(row); } ds.Dispose(); dsVoucher.Tables.Add(dtVoucher); ReportDocument reporte = new ReportDocument(); // creating object of crystal report reporte.Load(Server.MapPath("pagoconfirmado.rpt")); // path of report reporte.SetDataSource(dsVoucher.Tables[0]); CrystalReportViewer1.ReportSource = reporte; reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "pagoconfirmado" + IdOperacion); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; //archivo = Server.MapPath("TempReports/pagoconfirmado" + IdOperacion + ".pdf"); archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/pagoconfirmado" + IdOperacion + ".pdf"; diskOpts.DiskFileName = archivo; reporte.ExportOptions.DestinationOptions = diskOpts; reporte.Export(); MailMessage mail = new MailMessage(); //set the addresses string emailAddressList = System.Configuration.ConfigurationManager.AppSettings["emailsToSend"]; string displayName = System.Configuration.ConfigurationManager.AppSettings["displayNameEmailAddressToSendAuthorizationDocs"]; mail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["fromEmailAddressToSendAuthorizationDocs"], displayName); mail.To.Add(emailAddressList); mail.IsBodyHtml = true; //set the content mail.Subject = "Pago Pendiente"; //set the body mail.Body += "Muchas gracias.<br />"; //MailAttachment objArchivo = new MailAttachment("E:\\Email\\pedido.pdf"); mail.Attachments.Add(new Attachment(archivo)); //mail.Attachments.Add(archivo); string SMTPServer = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]; SmtpClient smtp = new SmtpClient(SMTPServer); //specify the mail server address smtp.Send(mail); dsVoucher.Dispose(); } catch (Exception ex) { lblError.Text = "Error " + ex.Message; } finally { } }
//Exporta a Excel el grid protected void ExportEstimacionCostos(object sender, EventArgs e) { string parametro = cmbClasificacion.Value.ToString(); //1. Configurar la conexión y el tipo de comando SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString); try { SqlCommand comando = new SqlCommand("web_spS_ObtenerConceptosRevisados", conn); SqlDataAdapter adaptador = new SqlDataAdapter(comando); DataTable dt = new DataTable(); adaptador.SelectCommand.CommandType = CommandType.StoredProcedure; adaptador.SelectCommand.Parameters.Add(@"CLASIFICACION", SqlDbType.VarChar).Value = parametro; adaptador.Fill(dt); ReportDocument rCaratulaEstimacionCostos = new ReportDocument(); rCaratulaEstimacionCostos.Load(Server.MapPath("reportess/rCaratulaEstimacionDeCostos.rpt")); rCaratulaEstimacionCostos.SetDataSource(dt); rCaratulaEstimacionCostos.SetParameterValue("pProveedor", "A & R Construcciones S.A de C.V"); rCaratulaEstimacionCostos.SetParameterValue("pathlogo", Server.MapPath(" ") + "\\images\\clientes\\"); ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions(); excelFormatOpts.ExcelUseConstantColumnWidth = false; rCaratulaEstimacionCostos.ExportOptions.FormatOptions = excelFormatOpts; rCaratulaEstimacionCostos.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Reportes Mantenimiento " + parametro); } catch (Exception ex) { ex.Message.ToString(); }finally{ if (conn.State != ConnectionState.Closed) conn.Close(); conn.Dispose(); } }
private void imprimecomparativa() { String opciones = ""; String[] Datos; String[] DatosViaje; DataSet ds = new DataSet(); DataSet dsCompara = new DataSet(); SqlDataAdapter adapter; int planes = 0; String edades = ""; DataTable dtComparativa = new DataTable(); DataSet dsComparativa = new DataSet(); String email = ""; dtComparativa.Columns.Add("Producto"); dtComparativa.Columns.Add("Cobertura"); dtComparativa.Columns.Add("Importe"); opciones = Request.QueryString["op"]; Datos = opciones.Split('*'); planes = (Datos.Count() - 1); try { DataTable dtPresu = new DataTable(); DataSet dsPresu = new DataSet(); opciones = Request.QueryString["op"]; DatosViaje = opciones.Split('_'); email = DatosViaje[6].ToString(); if (DatosViaje[7].ToString()!= "" ) edades = DatosViaje[7].ToString(); if (DatosViaje[8].ToString() != "") edades = edades + "/" + DatosViaje[8].ToString(); if (DatosViaje[9].ToString() != "") edades = edades + "/" + DatosViaje[9].ToString(); if (DatosViaje[10].ToString() != "") edades = edades + "/" + DatosViaje[10].ToString(); if (DatosViaje[11].ToString() != "") edades = edades + "/" + DatosViaje[11].ToString(); if (DatosViaje[12].ToString() != "") edades = edades + "/" + DatosViaje[12].ToString(); System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselImprimeCotizacion", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("FechaDesde", DatosViaje[3].ToString()); command.Parameters.AddWithValue("FechaHasta", DatosViaje[4].ToString()); command.Parameters.AddWithValue("idOrigen", DatosViaje[1].ToString()); command.Parameters.AddWithValue("IdDestino", DatosViaje[2].ToString()); command.Parameters.AddWithValue("Email", DatosViaje[6].ToString()); command.Parameters.AddWithValue("edades", edades); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(dsPresu); conn.Close(); DataSet dsPresuCompara = new DataSet(); DataTable dtPresuCompara = new DataTable(); dtPresuCompara.Columns.Add("Producto"); dtPresuCompara.Columns.Add("Producto2"); dtPresuCompara.Columns.Add("Producto3"); dtPresuCompara.Columns.Add("Producto4"); dtPresuCompara.Columns.Add("Cobertura1"); dtPresuCompara.Columns.Add("Cobertura2"); dtPresuCompara.Columns.Add("Cobertura3"); dtPresuCompara.Columns.Add("Cobertura4"); dtPresuCompara.Columns.Add("Cobertura5"); dtPresuCompara.Columns.Add("Cobertura6"); dtPresuCompara.Columns.Add("ValorCobertura_1"); dtPresuCompara.Columns.Add("ValorCobertura_1_2"); dtPresuCompara.Columns.Add("ValorCobertura_1_3"); dtPresuCompara.Columns.Add("ValorCobertura_1_4"); dtPresuCompara.Columns.Add("ValorCobertura_1_5"); dtPresuCompara.Columns.Add("ValorCobertura_1_6"); dtPresuCompara.Columns.Add("ValorCobertura_2"); dtPresuCompara.Columns.Add("ValorCobertura_2_2"); dtPresuCompara.Columns.Add("ValorCobertura_2_3"); dtPresuCompara.Columns.Add("ValorCobertura_2_4"); dtPresuCompara.Columns.Add("ValorCobertura_2_5"); dtPresuCompara.Columns.Add("ValorCobertura_2_6"); dtPresuCompara.Columns.Add("ValorCobertura_3"); dtPresuCompara.Columns.Add("ValorCobertura_3_2"); dtPresuCompara.Columns.Add("ValorCobertura_3_3"); dtPresuCompara.Columns.Add("ValorCobertura_3_4"); dtPresuCompara.Columns.Add("ValorCobertura_3_5"); dtPresuCompara.Columns.Add("ValorCobertura_3_6"); dtPresuCompara.Columns.Add("ValorCobertura_4"); dtPresuCompara.Columns.Add("ValorCobertura_4_2"); dtPresuCompara.Columns.Add("ValorCobertura_4_3"); dtPresuCompara.Columns.Add("ValorCobertura_4_4"); dtPresuCompara.Columns.Add("ValorCobertura_4_5"); dtPresuCompara.Columns.Add("ValorCobertura_4_6"); dtPresuCompara.Columns.Add("Pasajero"); dtPresuCompara.Columns.Add("Inicio"); dtPresuCompara.Columns.Add("Fin"); dtPresuCompara.Columns.Add("Origen"); dtPresuCompara.Columns.Add("Destino"); dtPresuCompara.Columns.Add("cantdias"); dtPresuCompara.Columns.Add("cantpasajeros"); dtPresuCompara.Columns.Add("edades"); dtPresuCompara.Columns.Add("tarifa1"); dtPresuCompara.Columns.Add("promo1"); dtPresuCompara.Columns.Add("comision1"); dtPresuCompara.Columns.Add("Neto1"); dtPresuCompara.Columns.Add("tarifa2"); dtPresuCompara.Columns.Add("promo2"); dtPresuCompara.Columns.Add("comision2"); dtPresuCompara.Columns.Add("Neto2"); dtPresuCompara.Columns.Add("tarifa3"); dtPresuCompara.Columns.Add("promo3"); dtPresuCompara.Columns.Add("comision3"); dtPresuCompara.Columns.Add("Neto3"); dtPresuCompara.Columns.Add("tarifa4"); dtPresuCompara.Columns.Add("promo4"); dtPresuCompara.Columns.Add("comision4"); dtPresuCompara.Columns.Add("Neto4"); dtPresuCompara.Columns.Add("IdProducto"); dtPresuCompara.Columns.Add("IdProducto2"); dtPresuCompara.Columns.Add("IdProducto3"); dtPresuCompara.Columns.Add("IdProducto4"); DataRow rowComp = dtPresuCompara.NewRow(); int columnas = 4; for (int p = 0; p < dsPresu.Tables[0].Rows.Count; p++){ for (int j = 0; j < Datos.Count() - 1; j++){ if ((Datos[j].ToString() == dsPresu.Tables[0].Rows[p]["IdProducto"].ToString())||(Datos[j].ToString() == dsPresu.Tables[0].Rows[p]["IdProducto2"].ToString())||(Datos[j].ToString() == dsPresu.Tables[0].Rows[p]["IdProducto3"].ToString())||(Datos[j].ToString() == dsPresu.Tables[0].Rows[p]["IdProducto4"].ToString())){ if (columnas == 4){ rowComp["Producto"] = dsPresu.Tables[0].Rows[p]["Producto"].ToString(); rowComp["IdProducto"] = dsPresu.Tables[0].Rows[p]["IdProducto"].ToString(); rowComp["Cobertura1"] = "Asistencia Médica por Enfermedad"; rowComp["Cobertura2"] = "Asistencia Médica por Accidente"; rowComp["Cobertura3"] = "Asistencia Médica por preexistencias"; rowComp["Cobertura4"] = "Compensacion por cancelación de viaje"; rowComp["Cobertura5"] = "Compensacion por pérdida de equipaje (línea aérea)"; rowComp["Cobertura6"] = "Compensacion por vuelo demorado o cacelado"; rowComp["ValorCobertura_1"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1"].ToString(); rowComp["ValorCobertura_1_2"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1_2"].ToString(); rowComp["ValorCobertura_1_3"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1_3"].ToString(); rowComp["ValorCobertura_1_4"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1_4"].ToString(); rowComp["ValorCobertura_1_5"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1_5"].ToString(); rowComp["ValorCobertura_1_6"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_1_6"].ToString(); rowComp["Pasajero"] = dsPresu.Tables[0].Rows[p]["Pasajero"].ToString(); rowComp["Inicio"] = dsPresu.Tables[0].Rows[p]["Inicio"].ToString(); rowComp["Fin"] = dsPresu.Tables[0].Rows[p]["Fin"].ToString(); rowComp["Origen"] = dsPresu.Tables[0].Rows[p]["Origen"].ToString(); rowComp["Destino"] = dsPresu.Tables[0].Rows[p]["Destino"].ToString(); rowComp["cantdias"] = dsPresu.Tables[0].Rows[p]["cantdias"].ToString(); rowComp["cantpasajeros"] = dsPresu.Tables[0].Rows[p]["cantpasajeros"].ToString(); rowComp["edades"] = dsPresu.Tables[0].Rows[p]["edades"].ToString(); rowComp["tarifa1"] = dsPresu.Tables[0].Rows[p]["tarifa1"].ToString(); rowComp["promo1"] = dsPresu.Tables[0].Rows[p]["promo1"].ToString(); rowComp["comision1"] = dsPresu.Tables[0].Rows[p]["comision1"].ToString(); rowComp["Neto1"] = dsPresu.Tables[0].Rows[p]["Neto1"].ToString(); } if (columnas == 3){ rowComp["Producto2"] = dsPresu.Tables[0].Rows[p]["Producto2"].ToString(); rowComp["IdProducto2"] = dsPresu.Tables[0].Rows[p]["IdProducto2"].ToString(); rowComp["ValorCobertura_2"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2"].ToString(); rowComp["ValorCobertura_2_2"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2_2"].ToString(); rowComp["ValorCobertura_2_3"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2_3"].ToString(); rowComp["ValorCobertura_2_4"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2_4"].ToString(); rowComp["ValorCobertura_2_5"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2_5"].ToString(); rowComp["ValorCobertura_2_6"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_2_6"].ToString(); rowComp["tarifa2"] = dsPresu.Tables[0].Rows[p]["tarifa2"].ToString(); rowComp["promo2"] = dsPresu.Tables[0].Rows[p]["promo2"].ToString(); rowComp["comision2"] = dsPresu.Tables[0].Rows[p]["comision2"].ToString(); rowComp["Neto2"] = dsPresu.Tables[0].Rows[p]["Neto2"].ToString(); } if (columnas == 2){ rowComp["Producto3"] = dsPresu.Tables[0].Rows[p]["Producto3"].ToString(); rowComp["IdProducto3"] = dsPresu.Tables[0].Rows[p]["IdProducto3"].ToString(); rowComp["ValorCobertura_3"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3"].ToString(); rowComp["ValorCobertura_3_2"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3_2"].ToString(); rowComp["ValorCobertura_3_3"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3_3"].ToString(); rowComp["ValorCobertura_3_4"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3_4"].ToString(); rowComp["ValorCobertura_3_5"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3_5"].ToString(); rowComp["ValorCobertura_3_6"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_3_6"].ToString(); rowComp["tarifa3"] = dsPresu.Tables[0].Rows[p]["tarifa3"].ToString(); rowComp["promo3"] = dsPresu.Tables[0].Rows[p]["promo3"].ToString(); rowComp["comision3"] = dsPresu.Tables[0].Rows[p]["comision3"].ToString(); rowComp["Neto3"] = dsPresu.Tables[0].Rows[p]["Neto3"].ToString(); } if (columnas == 1){ rowComp["Producto4"] = dsPresu.Tables[0].Rows[p]["Producto4"].ToString(); rowComp["IdProducto4"] = dsPresu.Tables[0].Rows[p]["IdProducto4"].ToString(); rowComp["ValorCobertura_4"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4"].ToString(); rowComp["ValorCobertura_4_2"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4_2"].ToString(); rowComp["ValorCobertura_4_3"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4_3"].ToString(); rowComp["ValorCobertura_4_4"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4_4"].ToString(); rowComp["ValorCobertura_4_5"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4_5"].ToString(); rowComp["ValorCobertura_4_6"] = dsPresu.Tables[0].Rows[p]["ValorCobertura_4_6"].ToString(); rowComp["tarifa4"] = dsPresu.Tables[0].Rows[p]["tarifa4"].ToString(); rowComp["promo4"] = dsPresu.Tables[0].Rows[p]["promo4"].ToString(); rowComp["comision4"] = dsPresu.Tables[0].Rows[p]["comision4"].ToString(); rowComp["Neto4"] = dsPresu.Tables[0].Rows[p]["Neto4"].ToString(); } if ((columnas > 1) && (j+1 < Datos.Count() - 1)){ columnas = columnas - 1; } else{ columnas = 4; dtPresuCompara.Rows.Add(rowComp); rowComp = dtPresuCompara.NewRow(); } } } } dsPresuCompara.Tables.Add(dtPresuCompara); ReportDocument rptDoc = new ReportDocument(); rptDoc.Load(Server.MapPath("~/Reportes/presupuesto1.rpt")); rptDoc.SetDataSource(dsPresuCompara.Tables[0]); dsPresuCompara.Dispose(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); string targetFileName = "C:/Data/Tusegurodeviaje/Reports/TempReports/compara_" + (new Random()).Next() + ".pdf"; rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; diskOpts.DiskFileName = targetFileName; //archivo = Server.MapPath(targetFileName); rptDoc.ExportOptions.DestinationOptions = diskOpts; //Export report ... Server-Side. rptDoc.Export(); enviamensaje(targetFileName, email); CrystalReportViewer1.ReportSource = rptDoc; rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "comparativa"); } catch (Exception ex){ lblError.Text = "Error enviando correo electrónico: " + ex.Message; } finally{ } }
private void muestrareporte() { SqlDataAdapter adapter; DataSet ds = new DataSet(); String archivo = ""; String IdOperacion = ""; DataTable dtVoucher = new DataTable(); DataSet dsVoucher = new DataSet(); String emailenviavoucher = ""; IdOperacion=Request.QueryString["op"].ToString(); dtVoucher.Columns.Add("IdOperacion"); dtVoucher.Columns.Add("FechaEmision"); dtVoucher.Columns.Add("NroVoucher"); dtVoucher.Columns.Add("Pasajero_Nombre"); dtVoucher.Columns.Add("Pasajero_Apellido"); dtVoucher.Columns.Add("Pasajero_Documento"); dtVoucher.Columns.Add("Pasajero_FechaNac"); dtVoucher.Columns.Add("Pasajero_TipoTelefono"); dtVoucher.Columns.Add("Pasajero_Telefono"); dtVoucher.Columns.Add("Pasajero_Celular"); dtVoucher.Columns.Add("Pasajero_Email"); dtVoucher.Columns.Add("ContactoEmergencia_Apellido"); dtVoucher.Columns.Add("ContactoEmergencia_Nombre"); dtVoucher.Columns.Add("ContactoEmergencia_Email"); dtVoucher.Columns.Add("ProductoDescripcion"); dtVoucher.Columns.Add("OrigenDescripcion"); dtVoucher.Columns.Add("DestinoDescripcion"); dtVoucher.Columns.Add("FechaPartida"); dtVoucher.Columns.Add("FechaRegreso"); dtVoucher.Columns.Add("ImporteTarifaPesos"); dtVoucher.Columns.Add("ImporteTarifaDolar"); dtVoucher.Columns.Add("IdCobertura"); dtVoucher.Columns.Add("DescripcionCobertura"); dtVoucher.Columns.Add("ValorCobertura"); dtVoucher.Columns.Add("MonedaDescripcion"); dtVoucher.Columns.Add("SimboloMoneda"); dtVoucher.Columns.Add("IdCobertura2"); dtVoucher.Columns.Add("DescripcionCobertura2"); dtVoucher.Columns.Add("ValorCobertura2"); dtVoucher.Columns.Add("MonedaDescripcion2"); dtVoucher.Columns.Add("SimboloMoneda2"); dtVoucher.Columns.Add("EmailEnviaVoucher"); try { System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselImprimeVoucher", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("Id_Operacion", Convert.ToInt32(IdOperacion)); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(ds); conn.Close(); ds.Dispose(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = dtVoucher.NewRow(); row["IdOperacion"] = ds.Tables[0].Rows[i]["IdOperacion"].ToString(); row["FechaEmision"] = ds.Tables[0].Rows[i]["FechaEmision"].ToString(); ; row["NroVoucher"] = ds.Tables[0].Rows[i]["NroVoucher"].ToString(); row["Pasajero_Nombre"] = ds.Tables[0].Rows[i]["Pasajero_Nombre"].ToString(); row["Pasajero_Apellido"] = ds.Tables[0].Rows[i]["Pasajero_Apellido"].ToString(); row["Pasajero_Documento"] = ds.Tables[0].Rows[i]["Pasajero_Documento"].ToString(); row["Pasajero_FechaNac"] = ds.Tables[0].Rows[i]["Pasajero_FechaNac"].ToString(); row["Pasajero_TipoTelefono"] = ds.Tables[0].Rows[i]["Pasajero_TipoTelefono"].ToString(); row["Pasajero_Telefono"] = ds.Tables[0].Rows[i]["Pasajero_Telefono"].ToString(); row["Pasajero_Celular"] = ds.Tables[0].Rows[i]["Pasajero_Celular"].ToString(); row["Pasajero_Email"] = ds.Tables[0].Rows[i]["Pasajero_Email"].ToString(); row["ContactoEmergencia_Apellido"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Apellido"].ToString(); row["ContactoEmergencia_Nombre"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Nombre"].ToString(); row["ContactoEmergencia_Email"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Email"].ToString(); row["ProductoDescripcion"] = ds.Tables[0].Rows[i]["ProductoDescripcion"].ToString(); row["OrigenDescripcion"] = ds.Tables[0].Rows[i]["OrigenDescripcion"].ToString(); row["DestinoDescripcion"] = ds.Tables[0].Rows[i]["DestinoDescripcion"].ToString(); row["FechaPartida"] = ds.Tables[0].Rows[i]["FechaPartida"].ToString(); row["FechaRegreso"] = ds.Tables[0].Rows[i]["FechaRegreso"].ToString(); row["ImporteTarifaPesos"] = ds.Tables[0].Rows[i]["ImporteTarifaPesos"].ToString(); row["ImporteTarifaDolar"] = ds.Tables[0].Rows[i]["ImporteTarifaDolar"].ToString(); row["IdCobertura"] = ds.Tables[0].Rows[i]["IdCobertura"].ToString(); row["DescripcionCobertura"] = ds.Tables[0].Rows[i]["DescripcionCobertura"].ToString(); row["ValorCobertura"] = ds.Tables[0].Rows[i]["ValorCobertura"].ToString(); row["MonedaDescripcion"] = ds.Tables[0].Rows[i]["MonedaDescripcion"].ToString(); row["SimboloMoneda"] = ds.Tables[0].Rows[i]["SimboloMoneda"].ToString(); row["IdCobertura2"] = ds.Tables[0].Rows[i]["IdCobertura2"].ToString(); row["DescripcionCobertura2"] = ds.Tables[0].Rows[i]["DescripcionCobertura2"].ToString(); row["ValorCobertura2"] = ds.Tables[0].Rows[i]["ValorCobertura2"].ToString(); row["MonedaDescripcion2"] = ds.Tables[0].Rows[i]["MonedaDescripcion2"].ToString(); row["SimboloMoneda2"] = ds.Tables[0].Rows[i]["SimboloMoneda2"].ToString(); row["EmailEnviaVoucher"] = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString(); emailenviavoucher = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString(); dtVoucher.Rows.Add(row); } ds.Dispose(); dsVoucher.Tables.Add(dtVoucher); ReportDocument reporte = new ReportDocument(); // creating object of crystal report reporte.Load(Server.MapPath("~/Reportes/pagoconfirmado.rpt")); // path of report reporte.SetDataSource(dsVoucher.Tables[0]); dsVoucher.Dispose(); DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions(); reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/pagoconfirmado_" + IdOperacion + ".pdf"; diskOpts.DiskFileName = archivo; reporte.ExportOptions.DestinationOptions = diskOpts; reporte.Export(); CrystalReportViewer1.ReportSource = reporte; reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "pagoconfirmado" + IdOperacion); } catch (Exception ex) { Response.Write(ex.Message); } finally { } }