private void LoadReport() { string key = Request.QueryString["key"]; CacheReportData data = new SystemCache().GetCache(key) as CacheReportData; if (data == null) { //加载一个默认的报表,提示当前报表打开失败 } else { BaseReport report = ReadReport(data.ReportID); XtraReport xtraReport = XtraReport.FromStream(report.getReportStream(), true); foreach (DefineSqlParameter par in report.DataSource.DbParameterCollection) { if (par.ParameterName.ToUpper() == "ID".ToUpper()) { par.Value = data.QueryKey; } } report.DataSource.Fill(); xtraReport.DataSource = report.DataSource; this.ReportViewer1.Report = xtraReport; //xtraReport.CreateDocument(); } }
protected new void Page_Load(object sender, EventArgs e) { //header info int vpm = Request.QueryString["vpm"].ToInt32(0); int modelId = Request.QueryString["model"].ToInt32(0); int rictype = Request.QueryString["rictype"].ToInt32(0); int ricId = Request.QueryString["id"].ToInt32(0); using (AppDb ctx = new AppDb()) { if (ricId > 0) { ric = ctx.RICs.Where(x => x.Id == ricId).FirstOrDefault(); } else { ric = ctx.RICs.Where(x => x.CatalogModelId == modelId && x.RICTypeId == rictype && x.PackingMonth == vpm.ToString()).FirstOrDefault(); } } if (ric == null) { var panel1 = new System.Web.UI.WebControls.Panel(); panel1.CssClass = "mainContent"; panel1.Controls.Clear(); panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Model/Variant/PackingMonth for RIC</h2>"))); masterPage.MainContent.Controls.Add(panel1); masterPage.PageTitle.Controls.Add(new LiteralControl("Record Implementation Control")); return; } byte[] reportb = ReportRepository.GetReportBinary("Ric"); if (reportb != null) { using (var stream = new MemoryStream(reportb)) { XtraReport report = XtraReport.FromStream(stream, true); report.Parameters["parameter1"].Value = ric.Id; report.Parameters["parameter1"].Visible = false; ASPxDocumentViewer1.Report = report; ASPxDocumentViewer1.DataBind(); } } else { string filePath = HttpContext.Current.ApplicationInstance.Server.MapPath("~/App_Data/rptRic.repx"); DevExpress.XtraReports.UI.XtraReport report = DevExpress.XtraReports.UI.XtraReport.FromFile(filePath, true); report.Parameters["parameter1"].Value = ric.Id; report.Parameters["parameter1"].Visible = false; ASPxDocumentViewer1.Report = report; ASPxDocumentViewer1.DataBind(); } }
public JsonResult SaveReport() { //string usuario,string tipodocumento,string tiporeport,string tipoprivacidad,string nombre var jsonSerializer = new JavaScriptSerializer(); dynamic parametros = jsonSerializer.DeserializeObject(Request.Params["args"]); var reportByteVector = ReportDesignerExtension.GetReportXml("Reportdesigner"); var service = new DocumentosUsuarioService(MarfilEntities.ConnectToSqlServer(ContextService.BaseDatos)); var tipoDocumento = (TipoDocumentoImpresion)Enum.Parse(typeof(TipoDocumentoImpresion), parametros["tipodocumento"]); var tipoprivacidad = (TipoPrivacidadDocumento)Enum.Parse(typeof(TipoPrivacidadDocumento), parametros["tipoprivacidad"]); var tiporeport = (TipoReport)Enum.Parse(typeof(TipoReport), parametros["tiporeport"]); var defecto = Funciones.Qbool(parametros["defecto"]); // Write a report to the storage under the specified URL. using (var stream = new MemoryStream(reportByteVector)) { using (var streamReportToSave = new MemoryStream()) { var url = DocumentosUsuarioService.CreateCustomId(tipoDocumento, new Guid(parametros["usuario"]), parametros["nombre"]); var report = XtraReport.FromStream(stream, true); report.Name = url; report.DisplayName = parametros["nombre"]; report.SaveLayout(streamReportToSave); service.SetPreferencia(tipoDocumento, new Guid(parametros["usuario"]), tipoprivacidad, tiporeport, parametros["nombre"], streamReportToSave.ToArray(), defecto); } } return(Json(new { success = true, error = "none", Result = string.Format("{0}", DocumentosUsuarioService.CreateCustomId(tipoDocumento, new Guid(parametros["usuario"]), parametros["nombre"])) })); }
private void REPORTDesigner_Load(object sender, EventArgs e) { if (collectionViewModel.Entities.Count > 0) { currentPROJECT_REPORT = collectionViewModel.Entities.First(); if (currentPROJECT_REPORT != null) { using (StreamWriter sw = new StreamWriter(new MemoryStream())) { sw.Write(currentPROJECT_REPORT.REPORT); sw.Flush(); currentREPORT = XtraReport.FromStream(sw.BaseStream, true); reportDesigner1.OpenReport(currentREPORT); return; } } } if (currentReportType == ReportType.Progress_Report) { currentREPORT = new XtraReportPROGRESS_ITEMS(); reportDesigner1.OpenReport(currentREPORT); } else if (currentReportType == ReportType.Baseline_Report) { currentREPORT = new XtraReportBASELINE_ITEMS(); reportDesigner1.OpenReport(currentREPORT); } }
/// <summary> /// 从流中创建报表,若不能创建新的报表,不绑定数据集 /// </summary> /// <param name="rp"></param> /// <returns></returns> private bool SetStreamReport(out XtraReport rp) { bool runDesign; if (_reportStream == null) { runDesign = true; rp = new XtraReport(); try { rp.LoadLayout(ReportStream); } catch { throw; } } else { try { rp = XtraReport.FromStream(_reportStream, true); runDesign = false; } catch { rp = new XtraReport(); runDesign = true; } } return(runDesign); }
public XtraReport Load(string reportID, IReportSerializer designerReportSerializer) { StorageDataSet.ReportStorageRow row = FindRow(reportID); using (MemoryStream ms = new MemoryStream(row.Buffer)) { return(XtraReport.FromStream(ms, true)); } }
static XtraReport CloneReportLayout(XtraReport report) { using (var stream = new MemoryStream()) { report.SaveLayoutToXml(stream); stream.Position = 0; return(XtraReport.FromStream(stream, true)); } }
public static XtraReport Clone(this XtraReport report) { using (var ms = new MemoryStream()) { report.SaveLayoutToXml(ms); ms.Position = 0; return(XtraReport.FromStream(ms, true)); } }
public ActionResult ExportDocumentViewer() { var model = Session["ReportViewer"] as DesignModel; var report = XtraReport.FromStream(new MemoryStream(model.Report), true); report.DataSource = model.DataSource; return(DocumentViewerExtension.ExportTo(report)); }
public static XtraReport RecargaFormato(string listado, string localizacion) { if (localizacion == "R") { var res = Program.ProxyAuxiliar.CargarInforme(listado, null, ""); var x = XtraReport.FromStream(res, true); return(x); } return(CargarInformeLocal(listado)); }
private void OpenReport(BaseReport report) { if (report == null) { return; } xtraReport = XtraReport.FromStream(report.getReportStream(), true); this.xtraReport.DataSource = report.DataSource; this.ReportViewer1.Report = this.xtraReport; }
//send parameters to report public IActionResult test() { var assembly = typeof(MyApp.ReportStorageWebExtension1).Assembly; Stream resource = assembly.GetManifestResourceStream("MyApp.Reports.XtraReport1.repx"); XtraReport report = XtraReport.FromStream(resource); report.RequestParameters = true; report.Parameters["parameter1"].Value = 654456; report.Parameters["parameter1"].Visible = false; report.CreateDocument(); return(View(report)); }
public static TReport RunThroughSerializer <TReport>(TReport report) where TReport : XtraReport { var stream = new MemoryStream(); report.SaveLayout(stream); stream.Position = 0; var report2 = XtraReport.FromStream(stream, true); return((TReport)report2); }
XtraReport GetSelectedReport() { // Return a report by a URL selected in the ListBox. string url = GetSelectedUrl(); if (string.IsNullOrEmpty(url)) { return(null); } using (MemoryStream stream = new MemoryStream(Program.ReportStorage.GetData(url))) { return(XtraReport.FromStream(stream, true)); } }
public XtraReport RaporTasarimGetir(RaporTasarimlari rpt = null, int DesignID = 0) { var rapor = new XtraReport(); if (rpt == null) { rpt = raporDal.GetByFilter(context, x => x.Id == DesignID); } rapor = XtraReport.FromStream(new MemoryStream(rpt.Dizayn)); return(rapor); }
public override byte[] GetData(string url) { if (url == "Invoice") { return(SerializeReport(new InvoiceReport())); } url += url.EndsWith(".repx") ? "" : ".repx"; using (var fileStream = File.OpenRead(Path.Combine(workingDirectory, url))) { var report = XtraReport.FromStream(fileStream, true); return(SerializeReport(report)); } }
public async Task <IActionResult> Products() { companyId = await services.GetCurrentCompanyId(); var assembly = typeof(MyApp.ReportStorageWebExtension1).Assembly; Stream resource = assembly.GetManifestResourceStream("MyApp.Reports.Products.repx"); XtraReport report = XtraReport.FromStream(resource); report.RequestParameters = true; report.Parameters["prmCompanyId"].Value = companyId; report.Parameters["prmCompanyId"].Visible = false; report.CreateDocument(); return(View("MainViewer", report)); }
public void Should_Load_From_Relative_Base_Path() { report1.Name = "TestLoad"; // Save Report (using Full Path) report1.SaveLayout(report1FullPath); Assert.IsTrue(File.Exists(report1FullPath)); // Open Report - using Report Storage var bytes = storage.GetData(report1RelativePath); var stream = new MemoryStream(bytes); var openedReport = XtraReport.FromStream(stream, true); // Assert Opened Properly Assert.AreEqual(report1.Name, openedReport.Name); }
public void LoadReport(Report report) { XtraReport newReport; using (StreamWriter sw = new StreamWriter(new MemoryStream())) { sw.Write(report.Report1); sw.Flush(); newReport = XtraReport.FromStream(sw.BaseStream, true); newReport.ShowRibbonDesignerDialog(); //ReportPrintTool pt = new ReportPrintTool(newReport); //pt.ShowPreviewDialog(); } }
private void btnLoad_Click(object sender, EventArgs e) { // Declare a base report variable. XtraReport newReport; // Retrieve a string which contains the report. string s = dataSet1.Tables["Reports"].Rows[0]["Report"].ToString(); // Obtain the report from the string. using (StreamWriter sw = new StreamWriter(new MemoryStream())) { sw.Write(s); sw.Flush(); newReport = XtraReport.FromStream(sw.BaseStream, true); } // Preview the report. newReport.ShowPreview(); }
public async Task <IActionResult> Today() { //bugun satilan urunler count(procuctId) order by count desc companyId = await services.GetCurrentCompanyId(); var assembly = typeof(MyApp.ReportStorageWebExtension1).Assembly; Stream resource = assembly.GetManifestResourceStream("MyApp.Reports.Invoices.repx"); XtraReport report = XtraReport.FromStream(resource); report.RequestParameters = true; report.Parameters["prmCompanyId"].Value = companyId; report.Parameters["prmCompanyId"].Visible = false; report.Parameters["prmFromDate"].Value = DateTime.Today.AddDays(-1); report.Parameters["prmFromDate"].Visible = false; report.Parameters["prmToDate"].Value = DateTime.Today.AddDays(+1); report.Parameters["prmToDate"].Visible = false; report.CreateDocument(); return(View("MainViewer", report)); }
public ActionResult Save(string templateId, string templateName, string returnUrl) { var xmlContent = ReportDesignerExtension.GetReportXml("reportDesigner"); var xtraReport = XtraReport.FromStream(new MemoryStream(xmlContent), true); var old = TemplateMgr.GetTemplate(templateId); var model = TemplateMgr.SaveTemplate(new TemplateModel { TemplateID = templateId, TemplateName = templateName, TemplateCode = old != null ? old.TemplateCode : null, CategoryID = old != null ? old.CategoryID : null, CreationTime = old != null ? old.CreationTime : DateTime.UtcNow, LastUpdateTime = old != null ? DateTime.UtcNow : new Nullable <DateTime>(), XtraReport = xtraReport }); return(Content(Url.Action("Index", "Design", new { Area = ReportingGlobal.AreaName, TemplateID = model.TemplateID, ReturnUrl = returnUrl }))); }
/// <summary> /// 产生Dev报表格式 /// </summary> /// <param name="rpt_control">报表控件对象</param> /// <param name="script">格式脚本</param> /// <returns>是否成功</returns> public static bool CreateXtraReport(ref XtraReport rpt_control, byte[] script) { bool ok = false; try { // 形成报表格式 MemoryStream ms = new MemoryStream(script); rpt_control = XtraReport.FromStream(ms, true); if (rpt_control != null) { rpt_control.ShowPrintMarginsWarning = false; } ok = true; } catch (Exception ex) { MessageHelper.ShowError("格式脚本不正确!\r\n" + ex.Message); } return(ok); }
/// <summary> /// 产生报表 /// </summary> /// <param name="script">报表格式脚本</param> /// <returns></returns> public bool CreateReport(byte[] script) { bool ok = true; try { // 形成报表格式 MemoryStream ms = new MemoryStream(script); this._Report = XtraReport.FromStream(ms, true); if (this._Report != null) { this._Report.ShowPrintMarginsWarning = false; } ok = true; } catch (Exception ex) { MessageHelper.ShowError("格式脚本不正确!\r\n" + ex.Message); } return(ok); }
private void simpleButton2_Click(object sender, EventArgs e) { string sql = "select * from sysFormReport where ReportFile='SumaryRFM'"; DataTable tbRep = dbStruct.GetDataTable(sql); if (tbRep == null) { return; } if (tbRep.Rows.Count == 0) { return; } DevExpress.XtraReports.UI.XtraReport rptTmp = null; if (tbRep.Rows[0]["FileName"] != DBNull.Value) { System.IO.MemoryStream ms = new System.IO.MemoryStream(tbRep.Rows[0]["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); rptTmp.Tag = tbRep.Rows[0]; rptTmp.DataSource = tbResult; SetVariables(rptTmp); rptTmp.ShowPreviewDialog(); } }
private void PrintOrPreview(int isPrint) { DevExpress.XtraReports.UI.XtraReport rptTmp = null; //gridLookUpEdit1_EditValueChanged(gridLookUpEdit1, new EventArgs()); string path = ""; if (tbMau.Rows.Count == 0)// Không có dòng trong bảng dữ liệu file mẫu { if (_reportFile == string.Empty) { //Thông báo không có tìm thấy tên file mẫu, yêu cầu thêm vào biểu mẫu MessageBox.Show(Config.GetValue("Language").ToString() == "0" ? "Không tìm thấy file mẫu" : "Don't find template file"); } else { if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } else { if (!System.IO.File.Exists(path)) { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } } if (System.IO.File.Exists(path)) // tồn tại file mẫu rồi { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); System.IO.Stream stream = System.IO.File.OpenRead(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(path).Length; drMau = tbMau.NewRow(); drMau["systableID"] = _data.DrTable["sysTableID"]; drMau["RDes"] = _data.DrTable["DienGiai"]; drMau["RFile"] = _reportFile; drMau["RecordCount"] = 0; drMau["FileName"] = br.ReadBytes((int)numBytes); _data.InsertPrintFile(drMau); tbMau.Rows.Add(drMau); gridLookUpEdit1.Properties.DataSource = tbMau; gridLookUpEdit1.EditValue = drMau["RFile"].ToString(); layoutControlItem1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; layoutControlItem8.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; // Thêm 1 dòng vào bảng sysReportFile //hiện Showreview for (int i = 0; i < _arrIndex.Length; i++) { int index = _arrIndex[i]; if (index == -1) { continue; } for (int j = 1; j <= Int32.Parse(textEditSoLien.Text); j++) { this.PrintPreview(rptTmp, string.Empty, index, isPrint, j); } if (!simpleButtonChapNhan.Enabled) { (_data as DataMasterDetail).UpdateLanIn(index); } } } else { MessageBox.Show(Config.GetValue("Language").ToString() == "0" ? "Không tìm thấy file mẫu " + _reportFile : "Don't find template file " + _reportFile); } } } else //Có dòng file mẫu in { //Bảng ko chứa cột Printindex if (!_data.DsData.Tables[0].Columns.Contains("PrintIndex") || !ChkAutochoose.Checked) { if (drMau["FileName"] == DBNull.Value) { _reportFile = drMau["RFile"].ToString(); path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; if (!System.IO.File.Exists(path)) { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } if (System.IO.File.Exists(path)) // tồn tại file mẫu rồi { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); System.IO.Stream stream = System.IO.File.OpenRead(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(path).Length; drMau["FileName"] = br.ReadBytes((int)numBytes); _data.updatePrintFile(drMau); //drMau["FileName"]=stream. //Upload file biểu mẫu vào //hiện Showreview for (int i = 0; i < _arrIndex.Length; i++) { int index = _arrIndex[i]; if (index == -1) { continue; } for (int j = 1; j <= Int32.Parse(textEditSoLien.Text); j++) { this.PrintPreview(rptTmp, drMau["Script"].ToString(), index, isPrint, j); } if (!simpleButtonChapNhan.Enabled) { (_data as DataMasterDetail).UpdateLanIn(index); } } } } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(drMau["FileName"] as byte[]); for (int i = 0; i < _arrIndex.Length; i++) { int index = _arrIndex[i]; if (index == -1) { continue; } rptTmp = XtraReport.FromStream(ms, true); for (int j = 1; j <= Int32.Parse(textEditSoLien.Text); j++) { this.PrintPreview(rptTmp, drMau["Script"].ToString(), index, isPrint, j); } if (!simpleButtonChapNhan.Enabled) { (_data as DataMasterDetail).UpdateLanIn(index); } } } // if(drMau["Script"] != DBNull.Value) } else if (_data.DsData.Tables[0].Columns.Contains("PrintIndex") && ChkAutochoose.Checked)// In lan luot theo mau { for (int i = 0; i < _arrIndex.Length; i++) { try { int index = _arrIndex[i]; if (index == -1) { continue; } int printIndex = int.Parse(_data.DsData.Tables[0].Rows[index]["PrintIndex"].ToString()); drMau = tbMau.Rows[printIndex]; _reportFile = drMau["RFile"].ToString(); _title = drMau["RDes"].ToString(); _Script = drMau["SCript"].ToString(); System.IO.MemoryStream ms = new System.IO.MemoryStream(drMau["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); for (int j = 1; j <= Int32.Parse(textEditSoLien.Text); j++) { this.PrintPreview(rptTmp, _Script, index, isPrint, j); } if (!simpleButtonChapNhan.Enabled) { (_data as DataMasterDetail).UpdateLanIn(index); } } catch { } } } } }
private void simpleButtonSuaMau_Click(object sender, EventArgs e) { if (!bool.Parse(Config.GetValue("Admin").ToString())) { return; } int index = _arrIndex[0]; DataTable dtReport = new DataTable(); try { if (_Script == string.Empty) { dtReport = _data.GetDataForPrint(index); } else { dtReport = _data.GetDataForPrint(index, _Script); } } catch { } if (dtReport == null) { return; } dtReport = AddRecordToData(dtReport); DevExpress.XtraReports.UI.XtraReport rptTmp = null; string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } if (drMau == null || (drMau != null && drMau["FileName"] == DBNull.Value)) { string pathTmp; if (Config.GetValue("DuongDanBaoCao") != null) { pathTmp = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("DbName").ToString() + "\\" + _reportFile + ".repx"; } else { pathTmp = Application.StartupPath + "\\" + Config.GetValue("DbName").ToString() + "\\Reports\\template.repx"; } if (System.IO.File.Exists(path)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); } else if (System.IO.File.Exists(pathTmp)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(pathTmp, true); } else { rptTmp = new DevExpress.XtraReports.UI.XtraReport(); } } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(drMau["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); } if (rptTmp != null) { rptTmp.DataSource = dtReport; if (drMau != null) { rptTmp.Tag = drMau; } XRDesignFormEx designForm = new XRDesignFormEx(); designForm.OpenReport(rptTmp); designForm.Tag = drMau; if (System.IO.File.Exists(path)) { designForm.FileName = path; } designForm.KeyPreview = true; designForm.KeyDown += new KeyEventHandler(designForm_KeyDown); designForm.FormClosed += designForm_FormClosed; designForm.Show(); } }
private void simplePrint_Click(object sender, EventArgs e) { if (Config.GetValue("isDemo").ToString() == "1") { return; } DevExpress.XtraReports.UI.XtraReport rptTmp = null; string reportFile, title; if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable; DataRow dr = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex]; reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString(); if (dr["FileName"] != DBNull.Value) { System.IO.MemoryStream ms = new System.IO.MemoryStream(dr["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); } } else { reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString(); } string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } if (rptTmp != null) { //rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); //rptTmp.DataSource = gridViewReport.DataSource; //if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) // (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; //XRControl xrcTitle = rptTmp.FindControl("title", true); //if (xrcTitle != null) // xrcTitle.Text = title; //SetVariables(rptTmp); //rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; ////rptTmp.Print("\\\\vytc\\Canon LBP2900"); //rptTmp.Print(Config.GetValue("PrinterName").ToString()); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; CDTControl.Printing re = new CDTControl.Printing(gridViewReport.DataSource, rptTmp); re.Print(); } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; if (System.IO.File.Exists(path)) { CDTControl.Printing re = new CDTControl.Printing(gridViewReport.DataSource, path); re.Print(); } else { if (Config.Variables.Contains("PrinterName")) { string pName = Config.GetValue("PrinterName").ToString(); rptTmp.Print(pName); } else { rptTmp.Print(); } } } if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { gridViewReport.ActiveFilterString = ""; } }
private void simpleButtonPreview_Click(object sender, EventArgs e) { // if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) // gridViewReport.ActiveFilterString = "InBaoCao = 1"; DevExpress.XtraReports.UI.XtraReport rptTmp = null; string reportFile, title; DataRow dr = null; if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable; dr = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex]; reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString(); if (dr["FileName"] != DBNull.Value) { System.IO.MemoryStream ms = new System.IO.MemoryStream(dr["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); } } else { reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString(); } string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } else { if (!System.IO.File.Exists(path)) { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } } if (rptTmp == null) { if (System.IO.File.Exists(path)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); //update vào fileName trên database if (dr != null) { System.IO.Stream stream = System.IO.File.OpenRead(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(path).Length; dr["FileName"] = br.ReadBytes((int)numBytes); _data.UpdateReportFile(dr); } rptTmp.DataSource = gridViewReport.DataSource; if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; } XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.ShowPreviewDialog(); } else { ShowDefaultReport(this.gridControlReport, false); } } else { rptTmp.DataSource = gridViewReport.DataSource; if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; } XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.ShowPreviewDialog(); } //gridControlReport.ShowPrintPreview(); if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { gridViewReport.ActiveFilterString = ""; } }
public static XtraReport ToXtraReport(this Stream report) { return(XtraReport.FromStream((MemoryStream)report, true)); }