如何通过编程将参数传递给现有的晶体报告 [英] How can I pass parameter to existing crystal report by programming

查看:75
本文介绍了如何通过编程将参数传递给现有的晶体报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用visual studio 2010和13.0.18.2192版本的水晶报告,但是当我尝试将新参数字段传递给现有报告时我遇到了问题它不会出现,给出错误..我想通过商店名称作为报告的顶部,我通过在报告中作为textobj传递我尝试了但是我将通过打印预览正确打印但是当我在程序中运行时它打印出来像我的旧水晶报告(带有商店名称) )。



我尝试过:



 double discountP = 0; 
if(txtDis.Text.Length> 0&& txtDis.Text!=0)
discountP = double.Parse(txtDis.Text);
string path2 =;
if((InvNo.StartsWith(CAS-V)|| InvNo.StartsWith(INV-V))&& needVat&& discountP == 0)
path2 = Path.Combine(Environment.CurrentDirectory,@。\ CrystalReporInvoiceVat.rpt);
else if(discountP> 0)
path2 = Path.Combine(Environment.CurrentDirectory,@。\ CrystalReporInvoiceVat.rpt);
else
path2 = Path.Combine(Environment.CurrentDirectory,@。\ CrystalCallReportSalesInv.rpt);
rptDoc.SetDataSource(ds1);
rptDoc.DataSourceConnections.Clear();
rptDoc.SetParameterValue(ShopName,NEW SINGHE HARDWARE STORES);
//rptDoc.SetParameterValue(\"ShopAdd,29 Karalliyadda Theldeniya电话:081-2050044 081-2050040 077-3777713);
rptDoc.SetParameterValue(CusName,txtName.Text);
rptDoc.SetParameterValue(CusID,txtInvTo.Text);
rptDoc.SetParameterValue(CusAdd1,txtCusDetails1.Text);

解决方案

这个解决方案对我有用。试一试。

 var date = DateTime.Today(); 
ReportDocument report = new ReportDocument();
CrystalReportViewer crystalReportViewer1 = new CrystalReportViewer();

//在此处附加数据源等
report.SetParameterValue(@ EndDate,date);
crystalReportViewer1.RefreshReport();


I'm using visual studio 2010 and crystal report 13.0.18.2192 version, But I have a problem when I try to pass a new parameter field to existing report It won't appear, give an error.. I want to pass The Shop name as the top of the report, I tried it by passing as a textobj in the report but I will print correctly by print preview but when I run it inside the program it prints like as my old crystal report (with out shop name).

What I have tried:

double discountP = 0;
if (txtDis.Text.Length > 0 && txtDis.Text!="0")
    discountP = double.Parse(txtDis.Text);
string path2="";
if ((InvNo.StartsWith("CAS-V") || InvNo.StartsWith("INV-V")) && needVat && discountP == 0)
path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReporInvoiceVat.rpt");
else if(discountP>0)
path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReporInvoiceVat.rpt");
else
 path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReportSalesInv.rpt");
rptDoc.SetDataSource(ds1);
rptDoc.DataSourceConnections.Clear();
rptDoc.SetParameterValue("ShopName", "NEW SINGHE HARDWARE STORES");
//rptDoc.SetParameterValue("ShopAdd", "29 Karalliyadda Theldeniya Tel:081-2050044 081-2050040 077-3777713");
rptDoc.SetParameterValue("CusName", txtName.Text);
rptDoc.SetParameterValue("CusID", txtInvTo.Text);
rptDoc.SetParameterValue("CusAdd1", txtCusDetails1.Text);

解决方案

This solution was working for me. just have a try.

 var date = DateTime.Today();
 ReportDocument report = new ReportDocument();
 CrystalReportViewer crystalReportViewer1 = new CrystalReportViewer();

//Attach datasource etc. here
 report.SetParameterValue("@EndDate", date);
 crystalReportViewer1.RefreshReport();         


这篇关于如何通过编程将参数传递给现有的晶体报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆