public CrystalReportViewer InserirDocumento(ReportClass documento, string texto) { AguardeDB.Mostrar(); // Insere documento na lista documentos.Add(documento); // Insere controles CrystalReportViewer novoViewer; TabPage novaTab; novoViewer = new CrystalReportViewer(); novaTab = new TabPage(); tabControl.TabPages.Add(novaTab); tabControl.SuspendLayout(); novaTab.SuspendLayout(); this.SuspendLayout(); // // visualizador // novoViewer.ActiveViewIndex = -1; novoViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); novoViewer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; novoViewer.EnableDrillDown = false; novoViewer.Location = new System.Drawing.Point(0, 0); novoViewer.Name = "visualizador"; novoViewer.SelectionFormula = ""; novoViewer.ShowCloseButton = false; novoViewer.ShowExportButton = false; novoViewer.ShowGotoPageButton = false; novoViewer.ShowGroupTreeButton = false; novoViewer.ShowPrintButton = false; novoViewer.ShowRefreshButton = false; novoViewer.ShowTextSearchButton = false; novoViewer.Size = new System.Drawing.Size(709, 210); novoViewer.TabIndex = 0; novoViewer.ViewTimeSelectionFormula = ""; novaTab.Controls.Add(novoViewer); novaTab.Location = new System.Drawing.Point(4, 22); novaTab.Padding = new System.Windows.Forms.Padding(3); novaTab.Size = new System.Drawing.Size(709, 210); novaTab.TabIndex = 0; novaTab.Text = texto; novaTab.UseVisualStyleBackColor = true; this.tabControl.ResumeLayout(false); novaTab.ResumeLayout(false); this.ResumeLayout(false); novoViewer.ReportSource = documento; AguardeDB.Fechar(); return novoViewer; }
/** * Funcion que crea el pdf y lo convierte a un httpresponseMessage para enviar por http * @param pbjeto de Crystal report que contiene la tabla del pdf a generar * @returns httpResponseMessage del pdf */ public HttpResponseMessage obtener_Response(ReportClass objRpt) { ExportOptions CrExportOptions; PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrExportOptions = objRpt.ExportOptions; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.FormatOptions = CrFormatTypeOptions; Stream stream = objRpt.ExportToStream(ExportFormatType.PortableDocFormat); objRpt.Export(CrExportOptions); MemoryStream ms = new MemoryStream(); stream.CopyTo(ms); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(ms.ToArray()) }; result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = "Report.pdf" }; result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); return(result); }
public override void PrintObject() { if (Client_BS.Current == null) { return; } OutputInvoiceReportMng reportMng = new OutputInvoiceReportMng(AppContext.ActiveSchema); FormatConfFacturaAlbaranReport conf = new FormatConfFacturaAlbaranReport(); ClienteInfo client = Client_BS.Current as ClienteInfo; conf.nota = (client.OidImpuesto == 1) ? Library.Invoice.Resources.Messages.NOTA_EXENTO_IGIC : string.Empty; conf.nota += (conf.nota != string.Empty) ? Environment.NewLine : string.Empty; conf.nota += EntityInfo.Nota ? Nota_TB.Text : ""; conf.cuenta_bancaria = Cuenta_TB.Text; ReportClass report = reportMng.GetDetailReport((EntityInfo.ConceptoFacturas != null) ? EntityInfo : Entity.GetInfo(true), _serie, client, _transporter, conf); if (SettingsMng.Instance.GetUseDefaultPrinter()) { int n_copias = SettingsMng.Instance.GetDefaultNCopies(); PrintReport(report, n_copias); } else { ShowReport(report); } }
protected void ExportPDF(ReportClass rpt, string output_file_name) { if (rpt != null) { ExportOptions options = new ExportOptions(); DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions(); SaveFile_SFD.InitialDirectory = SettingsMng.Instance.GetPDFPrintsFolder(); SaveFile_SFD.FileName = output_file_name; SaveFile_SFD.AddExtension = true; SaveFile_SFD.DefaultExt = "pdf"; if (SaveFile_SFD.ShowDialog() == DialogResult.OK) { PgMng.Grow(String.Format(Face.Resources.Messages.EXPORTING_PDF, SaveFile_SFD.FileName), string.Empty); diskFileDestinationOptions.DiskFileName = SaveFile_SFD.FileName; options.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; options.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile; options.ExportDestinationOptions = diskFileDestinationOptions; PgMng.Grow(); rpt.Export(options); } } else { PgMng.ShowInfoException(Resources.Messages.NO_DATA_REPORTS); } }
public ActionResult ProductIndentReports(string indent) { DataSet ds = new DataSet(); DataSet ds1 = new DataSet(); try { ds = mmsReports.GetProductIndentReport(indent); ds1 = posTransactions.companyname(); string strcompanyname = ds1.Tables[0].Rows[0]["vchcompanyname"].ToString(); string strcompanyAddress = ds1.Tables[0].Rows[0]["address"].ToString(); ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reports/ProductIndentReport.rpt"); rptH.Load(); rptH.SetDataSource(ds.Tables[0]); rptH.SetParameterValue("CompanyName", strcompanyname); rptH.SetParameterValue("Address", strcompanyAddress); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); } catch (Exception ex) { throw ex; } }
//private readonly IMasterDetailsReportService _iMasterDetailsReportService; //public MasterDetails(IMasterDetailsReportService iMasterDetailsReportService) //{ // this._iMasterDetailsReportService = iMasterDetailsReportService; //} protected void Page_Load(object sender, EventArgs e) { try { int categoryId = Convert.ToInt32(Request.QueryString["catid"]); IMasterDetailsReportService _iMasterDetailsReportService = new MasterDetailsReportService(); var masterDetailsViewModels = _iMasterDetailsReportService.GetMasterDetailsViewModelsByCategoryId(categoryId); var detailsViewModels = masterDetailsViewModels as List<MasterDetailsViewModel> ?? masterDetailsViewModels.ToList(); var reportData = detailsViewModels; ReportClass reportClass = new ReportClass(); reportClass.FileName = Server.MapPath("~/CrystalReports/MasterDetails.rpt"); reportClass.Load(); reportClass.SetDataSource(reportData); masterDetailsCrystalReportViewer.ReportSource = reportClass; } catch (Exception) { throw; } }
public void PrintDocuments(IEnumerable <tblDocumentCommon> documents) { // сортируем по фио и приоритету печати // для пациента // 2 договора на продажу // товарный чек // 2 договора на услугу var xSortedDocs = (from doc in documents let docOrdPriority = (doc is tblDocumentProduct) ? 0 : ((doc is tblDocumentSalesReceipt) ? 1 : 2) orderby doc.ShortName, docOrdPriority select doc).ToList(); List <DocumentAdapter> xSource = new List <DocumentAdapter>(1); xSource.Add(null); foreach (tblDocumentCommon doc in xSortedDocs) { DocumentAdapter xPrintAdapter = new DocumentAdapter(doc); xSource[0] = xPrintAdapter; PrinterSettings xPrintsettings = (doc is tblDocumentSalesReceipt) ? SalesReceiptPrinterSettings : DefaultDocPrinterSettings; xPrintsettings.Copies = doc.CopiesCount; ReportClass xReport = GetReport(doc, xSource); try { xReport.PrintToPrinter(xPrintsettings, xPrintsettings.DefaultPageSettings, false); doc.Printed = true; doc.IsSelected = false; } finally { xReport.Dispose(); } } }
public frm_gnt_creditor_account(stp_gnt_creditor_selResult currentCreditor) { InitializeComponent(); this.CurrentCreditor = currentCreditor; this.printReportFile = new gnt_rpt_creditor_account(); Initial_WindowBase(dbg_account, windowToolbar, grpInfo, "gnt_creditor_account", true, null); }
/// <summary> /// รายงานการเปลี่ยนยาง /// </summary> /// <returns></returns> public ActionResult TiresChanging() { List <TiresChanging> list = new List <TiresChanging>(); list.Add(new TiresChanging() { CarRegis = "61-9747 กท", Date = DateTime.Now, Mile = 36520, Position = 2, PutOnBrand = "Bridgestone", PutOnSerial = "B4L2L5559", PutOnSize = "11R22.5/16PR157", TakeOffBrand = "Bridgestone", TakeOffSerial = "L01589349", TakeOffSize = "11R22.5/16PR157" }); list.Add(new TiresChanging() { CarRegis = "81 - 6040", Date = DateTime.Now, Mile = 267017, Position = 5, PutOnBrand = "Bridgestone", PutOnSerial = "B4L2L5559", PutOnSize = "11R22.5/16PR157", TakeOffBrand = "Bridgestone", TakeOffSerial = "L01589349", TakeOffSize = "11R22.5/16PR157" }); list.Add(new TiresChanging() { CarRegis = "50-3719", Date = DateTime.Now, Mile = 267017, Position = 10, PutOnBrand = "Bridgestone", PutOnSerial = "B4L2L5559", PutOnSize = "11R22.5/16PR157", TakeOffBrand = "Bridgestone", TakeOffSerial = "L01589349", TakeOffSize = "11R22.5/16PR157" }); ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Views/Report/TiresChanging.rpt"); rptH.Load(); rptH.SetDataSource(list); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
public frmReportViewer(ReportClass rpt) { InitializeComponent(); crptViewer.ReportSource = rpt; crptViewer.Show(); }
private void Initialize(DataSet1 ds, ReportClass rpt, string p_id) { InitializeComponent(); //set app datasource DataRow row = ds.dtApp.NewRow(); var collection = MainForm.database.GetCollection <BsonDocument>("app"); var result = collection.Find(new BsonDocument()).First(); row["app_name"] = result["name"]; row["app_address"] = result["address"]; ds.dtApp.Rows.Add(row); if (p_id != null) { collection = MainForm.database.GetCollection <BsonDocument>("patients"); var filter = Builders <BsonDocument> .Filter.Eq("_id", ObjectId.Parse(p_id)); result = collection.Find(filter).First(); row = ds.dtDataSheet.NewRow(); row["firstname"] = result["firstname"]; row["middlename"] = result["middlename"]; row["lastname"] = result["lastname"]; ds.dtDataSheet.Rows.Add(row); } rpt.SetDataSource(ds); crystalReportViewer1.ReportSource = rpt; crystalReportViewer1.Refresh(); }
public ActionResult PurchasesMaster() { // var unitId = System.Web.HttpContext.Current.Session["ReportName"].ToString(); // Setting ReportName // string strFromDate = System.Web.HttpContext.Current.Session["rptFromDate"].ToString(); // Setting FromDate // string strToDate = System.Web.HttpContext.Current.Session["rptToDate"].ToString(); // Setting ToDate // var rptSource = System.Web.HttpContext.Current.Session["rptSource"]; //Rename Processed Batch // string newPath = AddSuffix(sourceFile, String.Format("({0})", parameters.IsProcessed)); //FileInfo fi = new FileInfo(sourceFile); //if (fi.Exists) //{ // fi.MoveTo(newPath); //} SqlConnection con = new SqlConnection(Helpers.Helpers.DatabaseConnect); DataTable dt = new DataTable(); try { con.Open(); SqlCommand cmd = new SqlCommand("SELECT AllocationName,ExpenseName,UnitName,VendorName,ActualAmount,Reference,CreatedOn,CurrencyAbbr,Discount FROM vw_PurchasesByCriteria ", con); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dt); } catch (Exception ex) { ExceptionLogging.SendErrorToText(ex); ViewBag.ErrorMessage = Messages.GENERAL_ERROR; return(View()); // ex.Message.ToString(); } // string OutputFileName = BatchId + "_" + monthend + ".xlsx"; ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath(("~/Reports/") + "PurchasesByCriteria.rpt"); rptH.Load(); rptH.SetDataSource(dt); // string filePath = Server.MapPath("~/BatchOut/"); // string destPath = Path.Combine(filePath, ToSafeFileName(OutputFileName)); // if (formatId == parameters.Excel) // rptH.ExportToDisk(ExportFormatType.ExcelWorkbook, destPath); // Stream stream = rptH.ExportToStream(ExportFormatType.ExcelWorkbook); //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); // else // rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
public ActionResult OutWardReports(string fromdate, string todate, string Store, string Category) { System.Data.DataSet ds = mmsReports.GetOutwardData(fromdate, todate, Store, Category); if (ds != null) { System.Data.DataSet ds1 = posTransactions.companyname(); string strcompanyname = ds1.Tables[0].Rows[0]["vchcompanyname"].ToString(); string strcompanyAddress = ds1.Tables[0].Rows[0]["address"].ToString(); ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reports/OuwardItemStatement.rpt"); rptH.Load(); rptH.SetDataSource(ds.Tables[0]); rptH.SetParameterValue("CompanyName", strcompanyname); rptH.SetParameterValue("Address", strcompanyAddress); rptH.SetParameterValue("FromDate", fromdate); rptH.SetParameterValue("ToDate", todate); rptH.SetParameterValue("Store", Store); rptH.SetParameterValue("Category", Category); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); } else { return(View("StockReport")); } }
public Stream GetReportPDF(object report, Dictionary <string, object> items) { // ReportDocument rd = new ReportDocument(); ReportClass reporte = (ReportClass)report; reporte.Load(); foreach (var item in items) { if (item.Key.Split('.')?.ToList()?.Count() > 1) { string subReport = item.Key.Split('.')[0]; string dataSource = item.Key.Split('.')[1]; reporte.Subreports[subReport].Database.Tables[dataSource].SetDataSource(item.Value); } else { reporte.Database.Tables[item.Key].SetDataSource(item.Value); } } //reporte.SetDataSource(items); Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); reporte.Close(); return(stream); }
public ActionResult DescargarReporteAsignaciones(int?id) { try { //var asignaciones = ProyectoCN.ListarAsignaciones(); var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/AsignacionReport.rpt"); rptH.Load(); if (id == null) { rptH.SetDataSource(ProyectoCN.ListarAsignaciones()); } else { rptH.SetDataSource(ProyectoCN.ListarAsignaciones(id.Value)); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //En PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception ex) { throw; } }
public async Task<ActionResult> UserStats(string _sDate, string _eDate) { //Declarations of variables DateTime _sdt = Convert.ToDateTime(_sDate); DateTime _edt = Convert.ToDateTime(_eDate).AddDays(1); List<userDTO> _list = new List<userDTO>(); string _path = ""; _path = "/CrystalReport/rptUserStats.rpt"; //string sname = Session["LName"].ToString(); //Database Query var sql =await (from a in db.TBL_WEBUSERS where a.DATE_VERIFIED >= _sdt && a.DATE_VERIFIED <= _edt select a).ToListAsync(); foreach (var r in sql) { userDTO tbl = new userDTO(); tbl._dateV = r.DATE_VERIFIED.ToString(); tbl.userName = r.USERNAME; tbl.region = getRegioName(r.REGION); _list.Add(tbl); } ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath(_path); rptH.Load(); rptH.SetDataSource(_list); rptH.SetParameterValue("Petsa", _sdt.ToShortDateString() + " - " + _edt.ToShortDateString()); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); }
public ActionResult DescargarReporteProyectos() { try { var proyectos = ProyectoCN.ListarProyectos(); var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/ProyectosListas.rpt"); rptH.Load(); rptH.SetDataSource(proyectos); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //En PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception ex) { throw; } }
public void SetHeaderInfo(ReportClass report) { controller.LoadById("1"); ReportObjects obj = report.ReportDefinition.Sections[0].ReportObjects; TextObject txtBoxHeaderTextPersonalizzato = (TextObject)obj["HeaderTextPersonalizzato"]; //txtBoxHeaderTextPersonalizzato.Text = ReportSettings.Default.ReportTitlePersonalizzato; txtBoxHeaderTextPersonalizzato.Text = controller.Sottotitolo3; ReportObjects obj1 = report.ReportDefinition.Sections[0].ReportObjects; TextObject txtBoxHeaderTextTitle = (TextObject)obj1["HeaderTextTitle"]; //txtBoxHeaderTextTitle.Text = ReportSettings.Default.ReportTitle; txtBoxHeaderTextTitle.Text = controller.Intestazione; ReportObjects obj2 = report.ReportDefinition.Sections[0].ReportObjects; TextObject txtBoxHeaderTextSubTitle = (TextObject)obj2["HeaderTextSubTitle"]; // txtBoxHeaderTextSubTitle.Text = ReportSettings.Default.ReportSubTitle; txtBoxHeaderTextSubTitle.Text = controller.Sottotitolo1; ReportObjects obj3 = report.ReportDefinition.Sections[0].ReportObjects; TextObject txtBoxHeaderTextSubTitle2 = (TextObject)obj3["HeaderTextSubTitle2"]; //txtBoxHeaderTextSubTitle2.Text = ReportSettings.Default.ReportSubTittle2; txtBoxHeaderTextSubTitle2.Text = controller.Sottotitolo2; }
public frmReport(ReportClass _rpt,DateTime _tu,DateTime _den) { rpt = _rpt; tu = _tu; den = _den; InitializeComponent(); }
public void PrepararImpressão(ReportClass relatório, IEnumerable<Entidades.Pessoa.Impressão.PessoaImpressão> pessoas, Região região) { DataSetPessoa ds = new DataSetPessoa(); DataTable tabela = ds.Tables["Pessoa"]; DataTable info = ds.Tables["Informações"]; DataRow itemInfo = info.NewRow(); if (região != null) { Representante representante = região.ObterRepresentante(); itemInfo["Representante"] = (representante == null ? "" : representante.PrimeiroNome); itemInfo["Região"] = (região.Nome); } else { itemInfo["Representante"] = ""; itemInfo["Região"] = "Todas"; } info.Rows.Add(itemInfo); foreach (Entidades.Pessoa.Impressão.PessoaImpressão p in pessoas) { DataRow linha = tabela.NewRow(); MapearItem(p, linha); tabela.Rows.Add(linha); } relatório.SetDataSource(ds); }
public void PrepararImpressão(ReportClass relatório, List<Entidades.PedidoConserto.Pedido> pedidos) { DataSetRecibo ds = new DataSetRecibo(); DataTable tabela = ds.Tables["Recibo"]; foreach (Entidades.PedidoConserto.Pedido p in pedidos) { DataRow linha = tabela.NewRow(); MapearItem(p, linha); tabela.Rows.Add(linha); } DataTable tabelaItens = ds.Tables["Itens"]; ControleImpressãoPedido.PrepararItens(pedidos, tabelaItens); DataRow linha2 = tabelaItens.NewRow(); linha2["código"] = 22; linha2["pedido"] = 33; linha2["referênciaFormatada"] = "ref. formatada"; tabelaItens.Rows.Add(linha2); relatório.SetDataSource(ds); //relatório.Subreports["Miolo.rpt"].SetDataSource(ds); }
//Begin public static void ShowRp(ReportClass rc, object objDataSource, Window parentWindow, string database, string server, string use, string pass) { try { rc.SetDataSource(objDataSource); ReportViewUI Viewer = new ReportViewUI(); //log on TableLogOnInfos logonInfos = new TableLogOnInfos(); TableLogOnInfo logonInfo = new TableLogOnInfo(); ConnectionInfo connectioninfo = new ConnectionInfo(); Tables CrTables; // tham so server connectioninfo.DatabaseName = database; connectioninfo.ServerName = server; connectioninfo.Password = pass; connectioninfo.UserID = use; CrTables = rc.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { logonInfo = CrTable.LogOnInfo; logonInfo.ConnectionInfo = connectioninfo; CrTable.ApplyLogOnInfo(logonInfo); } // Viewer.setReportSource(rc); Viewer.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
// // GET: /Report/ public ActionResult AuditDriverList() { // database call var TANK_usp_rpt_AuditDrivers_spParams = new TANK_usp_rpt_AuditDrivers_spParams() { //TODO: re-factor it later from hard coded LocationID = 1, StartDT = DateTime.Now.AddYears(-1), EndDT = DateTime.Now }; DataTable data = _utilityService.ExecStoredProcedureForDataTable("TANK_usp_rpt_AuditDrivers", TANK_usp_rpt_AuditDrivers_spParams); //# database call ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("~/Reports/crDailyDriverActivity.rpt"); rptH.Load(); rptH.SetDataSource(data); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); // return View(); }
public ActionResult ImprimirColaboradorQueryClasic(string COD_Colaborador) { String ConnStr = @"data source=.;initial catalog=IDCHECKDB;persist security info=True;user id=sa;password=12345"; SqlConnection myConnection = new SqlConnection(ConnStr); DataTable dt = new DataTable(); try { myConnection.Open(); SqlCommand cmd = new SqlCommand("SELECT COD_Colaborador, ApellidoPaterno, ApellidoMaterno, Nombres, Foto FROM Colaboradores where COD_Colaborador =" + COD_Colaborador, myConnection); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dt); myConnection.Close(); } catch (Exception e) { } ReportClass rpth = new ReportClass(); rpth.FileName = Server.MapPath("~/Reports/CrystalReportFotocheck.rpt"); rpth.Load(); rpth.SetDataSource(dt); Stream stream = rpth.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
public VentanaInforme(ReportClass reporte) { InitializeComponent(); report = reporte; cargar(); }
public ActionResult Reporte5AS() { String cnn = @"data source = TOSHIBA; initial catalog = BD_Colegio; persist security info = True; user id = sa; password = 12345;"; SqlConnection con = new SqlConnection(cnn); DataTable dt = new DataTable(); try { con.Open(); SqlCommand cmd = new SqlCommand("sp_matriculados", con); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dt); } catch (Exception e) { } ReportClass rpth = new ReportClass(); rpth.FileName = Server.MapPath("~/Reporte/Secundaria/Reporte5AS.rpt"); rpth.Load(); rpth.SetDataSource(dt); Stream stream = rpth.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
public static void exportarReporte(ReportClass pReporte, string pNombre, string pFormula, ExportFormatType pFormato) { try { PrincipalUI.cursorEnEspera(); ConnectionInfo connInfo = obtenerConexionReporte(); SetDBLogonForReport(connInfo, pReporte); SetDBLogonForSubreports(connInfo, pReporte); if (pFormula != null) { pReporte.RecordSelectionFormula = pFormula; } string ruta = System.IO.Path.GetTempPath() + pNombre + DateTime.Now.Ticks + obtenerExtensionReporte(pFormato.ToString()); pReporte.ExportToDisk(pFormato, ruta); pReporte.Load(ruta); pReporte.Close(); Process.Start(ruta); } catch (Exception ex) { Mensajes.mensajeError(ex); } PrincipalUI.cursorPredeterminado(); }
public ActionResult YearwiseReport(FormCollection FC, YearwiseModel objMW) { YearwiseModel objMWlist = new YearwiseModel(); objMWlist.YearNameList = BindYear(); if (objMW.YearID == "0") { ModelState.AddModelError("Message", "Please select Year"); } else { objMWlist.YearID = objMW.YearID; DataSet ds = objIlReports.Get_YearwisePayment_details(objMW.YearID); ds.Tables[0].TableName = "DSYear"; if (ds.Tables[0].Rows.Count > 0) { ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("~/Reports/YearwiseCollectionreport.rpt"); rptH.Load(); rptH.SetDataSource(ds.Tables[0]); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "YearwiseMaintenanceReport.pdf")); } } return(View(objMWlist)); }
protected void Page_Load(object sender, EventArgs e) { objReportClass = new ReportClass(objSqlConnClass.sqlConnection); giYearCurrent = System.DateTime.Now.Year; giMonthCurrent = System.DateTime.Now.Month; }
private void btVisualizar_Click(object sender, EventArgs e) { BIZFrete bizFrete = new BIZFrete(); ReportClass relat = new ReportClass(); DataTable dt = new DataTable(); string filtro = string.Empty; string filtroRelatorio = string.Empty; string msgRetorno = string.Empty; string periodoVencimento = string.Empty; msgRetorno = this.ValidarFiltro(); if (msgRetorno == string.Empty) { this.Cursor = Cursors.WaitCursor; filtro = this.MontarFiltroSQL(); filtroRelatorio = this.MontarFiltroRelatorio(); dt = bizFrete.GerarRelatorio(filtro, filtroRelatorio); relat = new FretesGerados(); relat.SetDataSource(dt); Relatorio relatorioFrete = new Relatorio(relat); relatorioFrete.Text = "Relatório de Fretes"; this.Cursor = Cursors.Default; relatorioFrete.ShowDialog(); } else { MessageBox.Show("Atenção: " + msgRetorno, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public ActionResult ApparelWiserpt() { ApparelWiserptEntity obj; ReportClass rptH = new ReportClass(); ArrayList al = new ArrayList(); rptH.FileName = Server.MapPath("/Reports/ApparelWiserpt.rpt"); rptH.Load(); List<ApprealInfoEntity> ItemList = (List<ApprealInfoEntity>)Session["Apparel"]; foreach (ApprealInfoEntity dr in ItemList) { obj = new ApparelWiserptEntity(); obj.PDate = dr.PDate; obj.EMPID = dr.EMPID; obj.EName = dr.EName; obj.Designation = dr.Designation; obj.DeptName = dr.DeptName; obj.Intime = dr.Intime; obj.Outtime = dr.Outtime; obj.Status = dr.Status; al.Add(obj); } rptH.SetDataSource(al); MemoryStream stream = (MemoryStream)rptH.ExportToStream(ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); }
public FrmPreviewReport(string header, ReportClass reportSource) : this() { this.Text = header; crViewer.ReportSource = reportSource; crViewer.RemoveMainTab(); }
public static void ExportPdf(string filename, ReportClass crReport) { var dest = new DiskFileDestinationOptions { DiskFileName = GetPath(filename) }; var formatOpt = new PdfFormatOptions { FirstPageNumber = 0, LastPageNumber = 0, UsePageRange = false, CreateBookmarksFromGroupTree = false }; var ex = new ExportOptions { ExportDestinationType = ExportDestinationType.DiskFile, ExportDestinationOptions = dest, ExportFormatType = ExportFormatType.PortableDocFormat, ExportFormatOptions = formatOpt }; crReport.SetDatabaseLogon("sa", "sabroso123"); crReport.Export(ex); }
public static void PrepararImpressão(ReportClass relatório, List<Entidades.Mercadoria.MercadoriaEmFaltaCliente> itens, Entidades.Pessoa.Pessoa emPosseDe) { DataSetMercadoriaEmFaltaCliente ds = new DataSetMercadoriaEmFaltaCliente(); DataTable tabelaItens = ds.Tables["Itens"]; foreach (Entidades.Mercadoria.MercadoriaEmFaltaCliente item in itens) { DataRow linha = tabelaItens.NewRow(); linha["referência"] = Entidades.Mercadoria.Mercadoria.MascararReferência(item.ReferênciaNumérica); linha["pedido"] = item.Pedido; linha["qtdPedido"] = item.QuantidadePedido; linha["qtdConsignação"] = item.QuantidadeConsignado; linha["dataPedido"] = item.DataPedido.ToShortDateString(); linha["cliente"] = item.ClienteNome; linha["descrição"] = item.Descricao; tabelaItens.Rows.Add(linha); } DataTable tabelaInformações = ds.Tables["Informações"]; DataRow linhaÚnica = tabelaInformações.NewRow(); linhaÚnica["cliente"] = emPosseDe.Nome; tabelaInformações.Rows.Add(linhaÚnica); relatório.SetDataSource(ds); }
private void btVisualizar_Click(object sender, EventArgs e) { ReportClass obra = new ReportClass(); DataTable dt = new DataTable(); string filtro = string.Empty; string filtroRelatorio = string.Empty; string msgRetorno = string.Empty; msgRetorno = this.ValidarFiltro(); if (msgRetorno == string.Empty) { filtro = this.MontarFiltroSQL(); filtroRelatorio = this.MontarFiltroRelatorio(); dt = bizObra.GerarRelatorioRealizadas(filtro, filtroRelatorio); obra = new GastosObras(); obra.SetDataSource(dt); Relatorio gastosObras = new Relatorio(obra); gastosObras.Text = "Relatório de Gastos Realizados"; gastosObras.ShowDialog(); } else { MessageBox.Show("Atenção: " + msgRetorno, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnStat_Click(object sender, EventArgs e) { try { btnStat.Enabled = false; btnPrint.Enabled = false; btnClose.Enabled = false; Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor( ); StatDateType dateType = StatDateType.统计日; foreach (object obj in Enum.GetValues(typeof(StatDateType))) { if (obj.ToString( ) == cboDateType.Text) { dateType = (StatDateType)obj; break; } } DateTime dateBegin; DateTime dateEnd; short month = Convert.ToInt16(cboMonth.Text); GetStatDate(dateType, month, out dateBegin, out dateEnd); StatType statType = StatType.门诊发票分类; foreach (object obj in Enum.GetValues(typeof(StatType))) { if (obj.ToString( ) == cboStatType.Text) { statType = (StatType)obj; break; } } int showtype = cboType.SelectedIndex; lblDate.Text = "当前统计时间范围:" + dateBegin.ToString("yyyy-MM-dd HH:mm:ss") + " — " + dateEnd.ToString("yyyy-MM-dd HH:mm:ss"); int fixcol; DataTable tbData = ReportClass.GetDeptDocIncomeData(statType, dateBegin, dateEnd, showtype, out fixcol); dgvReport.Columns.Clear( ); dgvReport.DataSource = tbData; for (int i = 0; i < fixcol; i++) { dgvReport.Columns[i].Frozen = true; } for (int i = fixcol - 1; i < dgvReport.Columns.Count; i++) { dgvReport.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } } catch (Exception err) { MessageBox.Show("统计报表时发生错误!请重试", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { btnStat.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; Cursor = Cursors.Default; } }
public ActionResult DescargarVentaProductos() { try { var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/ReportesProductos/VentaProductos.rpt"); rptH.Load(); var connInfo = CrystalReportCnn.GetConnectionInfo(); TableLogOnInfo logOnInfo = new TableLogOnInfo(); Tables tables; tables = rptH.Database.Tables; foreach (Table table in tables) { logOnInfo = table.LogOnInfo; logOnInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logOnInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception) { throw; } }
// genarate Sales report public static ReportClass Sales(DateTime?from, DateTime?To) { OdbcDataAdapter reportAdapter; DataSet reportDataSet; ReportClass currentReport = null; if (from == null || To == null) { reportAdapter = new OdbcDataAdapter("select * from salesview", DBConnection.getConnection()); } else { reportAdapter = new OdbcDataAdapter("select * from salesview where InvoiceDate between date(?) and date(?)", DBConnection.getConnection()); reportAdapter.SelectCommand.Parameters.Add("@from", OdbcType.VarChar).Value = String.Format("{0:yyyy-MM-dd}", from); reportAdapter.SelectCommand.Parameters.Add("@to", OdbcType.VarChar).Value = String.Format("{0:yyyy-MM-dd}", To); } reportDataSet = new reportDS(); reportAdapter.Fill(reportDataSet, "sales"); if (reportDataSet.Tables["sales"].Rows.Count > 0) { currentReport = new RptSales(); currentReport.SetDataSource(reportDataSet); } return(currentReport); }
//private readonly IMasterDetailsReportService _iMasterDetailsReportService; //public MasterDetails(IMasterDetailsReportService iMasterDetailsReportService) //{ // this._iMasterDetailsReportService = iMasterDetailsReportService; //} protected void Page_Load(object sender, EventArgs e) { try { int categoryId = Convert.ToInt32(Request.QueryString["catid"]); IMasterDetailsReportService _iMasterDetailsReportService = new MasterDetailsReportService(); var masterDetailsViewModels = _iMasterDetailsReportService.GetMasterDetailsViewModelsByCategoryId(categoryId); var detailsViewModels = masterDetailsViewModels as List <MasterDetailsViewModel> ?? masterDetailsViewModels.ToList(); var reportData = detailsViewModels; ReportClass reportClass = new ReportClass(); reportClass.FileName = Server.MapPath("~/CrystalReports/MasterDetails.rpt"); reportClass.Load(); reportClass.SetDataSource(reportData); masterDetailsCrystalReportViewer.ReportSource = reportClass; } catch (Exception) { throw; } }
private ReportClass GenerateUserRepost() { var cs = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; var con = new SqlConnection(cs); var dt = new DataTable(); var sql = "select * from Users order by lastName, FirstName"; try { con.Open(); var cmd = new SqlCommand(sql, con); var da = new SqlDataAdapter(cmd); da.Fill(dt); } catch (Exception ex) { ex.ToString(); } var report = new ReportClass(); report.FileName = Server.MapPath("/Reports/Users.rpt"); //cargo el reporte en memoria: report.Load(); report.SetDataSource(dt); return(report); }
public void PrepararImpressão(ReportClass relatório, List<Entidades.PedidoConserto.Pedido> pedidos, DateTime início, DateTime fim, bool apenasConsertos, bool períodoPrevisão) { DataSetPedido ds = new DataSetPedido(); DataTable tabela = ds.Tables["Pedido"]; DataTable info = ds.Tables["Informações"]; DataRow item = info.NewRow(); item["dataInicio"] = início.ToShortDateString(); item["dataFim"] = fim.ToShortDateString(); item["título"] = apenasConsertos ? "Relação de Consertos" : "Relação de Pedidos"; item["tipoPeríodo"] = períodoPrevisão ? "Previsão" : "Recebido"; info.Rows.Add(item); DataTable tabelaItens = ds.Tables["Itens"]; PrepararItens(pedidos, tabelaItens); DataTable tabelaRastro = ds.Tables["Rastro"]; Dictionary<string, List<Entidades.Mercadoria.Mercadoria.RastroConsignado>> rastreamentos = Entidades.Mercadoria.Mercadoria.ObterRastreamento(); foreach (KeyValuePair<string, List<Entidades.Mercadoria.Mercadoria.RastroConsignado>> par in rastreamentos) { foreach (Entidades.Mercadoria.Mercadoria.RastroConsignado rastro in par.Value) { DataRow linha = tabelaRastro.NewRow(); linha["referênciaNumérica"] = par.Key; linha["quantidade"] = rastro.Quantidade; linha["pessoaNome"] = Entidades.Pessoa.Pessoa.AbreviarNome(rastro.Pessoa.Nome); tabelaRastro.Rows.Add(linha); } } List<Entidades.PedidoConserto.Pedido> listaPedidos = new List<Entidades.PedidoConserto.Pedido>(); foreach (Entidades.PedidoConserto.Pedido pedido in pedidos) { /* Na apresentação, pode-se escolher entre já entregues ou não. * Porém, apenas os ainda não entregues são obtidos para impressão. * * É necessário filtrar ainda ou já concluidos. * Só é impresso a pendência, ou seja, os pedidos não concluídos. */ if (!pedido.DataConclusão.HasValue) listaPedidos.Add(pedido); } //listaPedidos.Sort(); foreach (Entidades.PedidoConserto.Pedido p in listaPedidos) { DataRow linha = tabela.NewRow(); MapearItem(p, linha); tabela.Rows.Add(linha); } relatório.SetDataSource(ds); }
public void FillDataReport(ReportClass report,string[] para, object[] value,bool mode) { report.DataSourceConnections[0].SetConnection(Services.get_GUI.serverName, Services.get_GUI.databaseName, true); for (int i = 0; i < para.Length; i++) { report.SetParameterValue(para[i], value[i].ToString()); } }
public wndReportViewer(object ds,ReportClass rpt) { InitializeComponent(); ReportClass report =rpt; report.SetDataSource(ds); this.reportViewer.ViewerCore.ReportSource = report; }
protected void Page_Load(object sender, EventArgs e) { strBaseSiteUrl = AppConfig.GetBaseSiteUrl(); objReportClass = new ReportClass(objSqlConnClass.sqlConnection); giYearCurrent = System.DateTime.Now.Year; giMonthCurrent = System.DateTime.Now.Month; }
public void PrepararImpressão(ReportClass relatório, Entidades.Pagamentos.NotaPromissória entidade) { DataSetNotaPromissória ds = new DataSetNotaPromissória(); DataTable tabela = ds.Tables["NotaPromissória"]; tabela.Rows.Add(CriarItem(entidade, tabela)); relatório.SetDataSource(ds); }
public static void PrepararImpressão(ReportClass relatório, List<Entidades.PedidoConserto.Pedido> pedidos) { DataSetPedidosParaFornecedores ds = new DataSetPedidosParaFornecedores(); PrepararFornecedores(ds); PrepararItens(pedidos, ds); PrepararObservações(pedidos, ds); relatório.SetDataSource(ds); relatório.Subreports["RelatórioPedido.rpt"].SetDataSource(ds); }
public void setReport(ReportClass report) { try { this.crystalReportViewer1.ReportSource = report; } catch (Exception ex) { MessageBox.Show(ex.Message,"Report Load Failed"); } }
public static void Print(ReportClass reportClass,string printerName) { Service.ServiceGet serviceGet = new ServiceGet(); Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName); if (!(printer == null || printer.Details == "NONE" || printer.Disable == true)) { reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true); reportClass.PrintOptions.PrinterName = printer.Details; reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0)); reportClass.PrintToPrinter(1,false,0,0); } }
public ActionResult Download(string reportname, ReportByProductBrandOption search) { ReportClass rptH = new ReportClass(); rptH.FileName = ReportPath(reportname); var data = searchProduct(search).ToList(); rptH.SetDataSource(data); rptH.SetParameterValue("datefrom", search.FromDate.ToReportFormat()); rptH.SetParameterValue("dateto", search.ToDate.ToReportFormat()); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); }
public ActionResult GetBranchDetailsCR() { DataTable dt = new DataTable(); dt = ReportsManager.GetBranchDetails(1); ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("../Content/cr_BranchDetails.rpt"); rptH.Load(); rptH.SetDataSource(dt); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); }
//Used for showing simple report public void ShowSimple() { using (ReportClass reportClass = new ReportClass()) { var productList = _db.Products.ToList().Select(x => new ProductViewModel { ProductId = x.ProductId, ProductName = x.Name, ProductPrice = x.Price }); reportClass.FileName = Server.MapPath("~/") + "//CrystalReports//simple.rpt"; reportClass.SetDataSource(productList); reportClass.Load(); reportClass.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crystalReport"); } }
public ActionResult Print() { ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("~/Content/report/demo.rpt"); List<dynamic> mock = new List<dynamic>(); for (int i=0;i<10;i++) { mock.Add( new {Id = 1,Name="test"}); } rptH.SetDataSource(mock); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); }
public Boolean initReport(ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param, String ParamName) { if(param=="" || param==null ) return false; paramField.ParameterFieldName = ParamName; discreteVal.Value = param; paramField.CurrentValues.Add (discreteVal); paramFields.Add (paramField); CrystalReportViewer1.ReportSource = crReport; CrystalReportViewer1.ParameterFieldInfo = paramFields; CrystalReportViewer1.RefreshReport(); return true; }
public void PrepararImpressão(ReportClass relatório, IEnumerable<Entidades.Mercadoria.MercadoriaImpressão> mercadoria) { DataSetMercadoria ds = new DataSetMercadoria(); DataTable tabela = ds.Tables["Mercadoria"]; foreach (Entidades.Mercadoria.MercadoriaImpressão m in mercadoria) { DataRow linha = tabela.NewRow(); MapearItem(m, linha); tabela.Rows.Add(linha); } relatório.SetDataSource(ds); }
public byte[] readRPT() { ReportClass rptH = new ReportClass(); try { ParameterDiscreteValue par; rptH.FileName = file; rptH.Load(); rptH.SetDataSource(listData["table"]); foreach (ReportDocument subreport in rptH.Subreports) { if (listData.ContainsKey(subreport.Name.Trim().ToLower())) { subreport.SetDataSource(listData[subreport.Name.Trim().ToLower()]); } } parameters = insencitiveParameter(); foreach (ParameterField field in rptH.ParameterFields) { if (parameters != null) { if (parameters.ContainsKey(field.Name.Trim().ToLower())) { par = new ParameterDiscreteValue(); par.Value = parameters[field.Name.Trim().ToLower()]; field.CurrentValues.Add(par); } } } System.IO.Stream stream = rptH.ExportToStream(this.type); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); return buffer; } finally { rptH.Close(); rptH.Dispose(); } }
public ReportingTool(int ReportType) { CrystalReport1 cr = new CrystalReport1(); Data = new RISData(); GenericDS = new DataSet(); this.ReportType = ReportType; switch (ReportType) { case 0: report = new JournalArticleDoE(); break; case 1: report = new ConferencePaperDoE(); break; case 2: report = new BookDoE(); break; default: report = new ReportClass(); break; } }
public ActionResult AssignValueinReport(int id) { DataTable dtbranchdetails = new DataTable(); DataTable dtpatientvisit = new DataTable(); using (HMSDBEntities context = new HMSDBEntities()) { var branchdetails = context.sp_BranchDetails(1); var patientvisit = context.sp_GetReceipt(id); dtbranchdetails = ExtensionMethods.ConvertToDataTable(branchdetails); dtpatientvisit = ExtensionMethods.ConvertToDataTable(patientvisit); ReportClass rptH = new ReportClass(); //rptH.FileName = Server.MapPath("~/Content/cr_RegReceipt.rpt"); rptH.FileName = @"C:/Users/tanmay/Documents/GitHub/HMSApp/HospitalManagement/HospitalManagement/Content/cr_RegReceipt.rpt"; rptH.Load(); rptH.Subreports["cr_BranchDetails.rpt"].SetDataSource(dtbranchdetails);//datasource for subreport rptH.SetDataSource(dtpatientvisit);//Mainreport datasourcc Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return File(stream, "application/pdf"); } }
// Constructor // // 1- Report Title // 2- Table Start Name // 3- Table Name // 4- Field List // 5- ID Start // 6- ID End // 7- Order // 8- Custom Qry List<> //string pRptTitle, string pFromDate, string pToDate public frmPrintViewerSubRpt4P( string pRptTitle, string p, string p_2, string p_3, string p_4, string pStoreProcName, string plstField, string plstType, string plstValue, DataSet pDs, ReportClass prpt1, string pQtyType ) { InitializeComponent(); fRptTitle = pRptTitle; fp = p; fp_2 = p_2; fp_3 = p_3; fp_4 = p_4; fStoreProcName = pStoreProcName; flstField = plstField; flstType = plstType; flstValue = plstValue; fDs = pDs; frpt1 = prpt1; fQtyType = pQtyType; // try { fRptTitle = pRptTitle; this.Text = fRptTitle; } catch (Exception ex) { MessageBox.Show("Exception-Initialize: " + ex.Message, this.Text.ToString()); } }
public static void Print(ReportClass reportClass,string printerName) { Service.ServiceGet serviceGet = new ServiceGet(); Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName); if (!(printer == null || printer.Details == "NONE" || printer.Disable == true)) { if (StaticClass.mode == "AUT") { reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true); } else if (StaticClass.mode == "SQL") { //reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, // StaticClass.userName, StaticClass.password); reportClass.SetDatabaseLogon(StaticClass.userName, StaticClass.password, StaticClass.serverName, StaticClass.databaseName,true); reportClass.DataSourceConnections[0].IntegratedSecurity = false; } else { return; } if(printerName == "Hóa đơn") { reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0)); } try { reportClass.PrintOptions.PrinterName = printer.Details; reportClass.PrintToPrinter(1, false, 0, 0); } catch (Exception) { Alert.Show("Lỗi máy in", Color.Red); } } }
public Boolean initReport(ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param1, String ParamName1, String param2, String ParamName2) { if(param1=="" || param1==null ) return false; if(param2=="" || param2==null ) return false; paramField.ParameterFieldName = ParamName1; discreteVal.Value = param1; paramField.CurrentValues.Add (discreteVal); paramFields.Add (paramField); crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal); paramField2.ParameterFieldName = ParamName2; discreteVal2.Value = param2; paramField2.CurrentValues.Add (discreteVal2); paramFields.Add (paramField2); crReport.DataDefinition.ParameterFields[1].CurrentValues.Add (discreteVal2); CrystalReportViewer1.ReportSource = crReport; CrystalReportViewer1.ParameterFieldInfo = paramFields; CrystalReportViewer1.RefreshReport(); return true; }