- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 c#.net 桌面应用程序中根据 Crystal 报表中的查询显示数据。引起问题的是,当我更改查询时,查询正在更改并且根据临时表中的查询也显示数据,但在 Crystal 报表中它没有显示新数据它显示的是查询之后的相同数据也改变。
例如:我想打印 1 号账单,这样时间就可以了。但是当我当时想打印 2 号账单时,也在 Crystal 报表中只显示 1 号账单。所以,这就是我无法打印 2 号账单的原因。
这是我在按钮点击事件中的代码
private void btn_previewdocument_Click(object sender, EventArgs e)
{
try
{
string mtmptbl = "TmpRetailInvoicePrint";
RetailInvoicePrint frm = new RetailInvoicePrint();
Cursor = Cursors.WaitCursor;
timer1.Enabled = true;
ReportDocument cryRpt = new ReportDocument();
SqlCommand MyCommand = new SqlCommand();
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(cn.ConnectionString);
ConnectionInfo crConnectionInfo = new ConnectionInfo();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
string qryPreviewDocument = " SELECT Client.clientname as ClientName, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoice.invoiceno as InvoiceNo, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoice.pono as PoNO, RetailInvoice.issuedate as IssueDate, RetailInvoice.duedate as DueDate, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoice.discount as Discount, RetailInvoice.shipping as Shipping, RetailInvoice.tax as Tax, RetailInvoice.vat as Vat, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoice.sese as Sese, RetailInvoice.paymenttype as PaymentType, RetailInvoice.chequeno as Chequeno, RetailInvoice.totalamt as TotalAmt, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoice.description as Description, RetailInvoice.paymentpaid as PaymentPaid, RetailInvoice.subtotal as Subtotal, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoicePayment.productid as ProductName, RetailInvoicePayment.uom as Uom, " + System.Environment.NewLine;
qryPreviewDocument += " RetailInvoicePayment.quantity as Quantity, RetailInvoicePayment.price as Price" + System.Environment.NewLine;
qryPreviewDocument += " into " + mtmptbl + " " + System.Environment.NewLine;
qryPreviewDocument += " from tbl_retailinvoice RetailInvoice LEFT OUTER JOIN tbl_retailinvoicepayment RetailInvoicePayment " + System.Environment.NewLine;
qryPreviewDocument += " ON RetailInvoice.invoiceno = RetailInvoicePayment.invoiceno " + System.Environment.NewLine;
qryPreviewDocument += " LEFT OUTER JOIN tbl_clientdetail Client ON RetailInvoice.clientid = Client.clientid " + System.Environment.NewLine;
qryPreviewDocument += " where RetailInvoice.BranchID = " + lbl_branchid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and RetailInvoice.YearID = " + lbl_yearid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and RetailInvoice.invoiceno = " + txt_invoice.Text + "";
string SQL = "select upper(name) as TABLE_NAME FROM sysobjects WHERE type = 'U' and name = '" + mtmptbl + "' order by name";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(SQL, cn);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
string qrydrop = "drop table " + mtmptbl + "";
SqlCommand cmd = new SqlCommand(qrydrop, cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
MyCommand = new SqlCommand(qryPreviewDocument, cn);
MyCommand.CommandType = CommandType.Text;
cn.Open();
MyCommand.ExecuteNonQuery();
cn.Close();
string crReportPath = Application.StartupPath.Replace("bin\\Debug", "") + "\\Print";
cryRpt.Load(crReportPath + "\\RptRetailInvoice.rpt");
builder.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["con"];
string dbName = builder.InitialCatalog;
string dbDataSource = builder.DataSource;
string userID = builder.UserID;
string pass = builder.Password;
crConnectionInfo.ServerName = dbDataSource;
crConnectionInfo.DatabaseName = dbName;
crConnectionInfo.UserID = userID;
crConnectionInfo.Password = pass;
Tables Crtables;
Crtables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in Crtables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
frm.crystalReportViewer1.ReportSource = cryRpt;
frm.crystalReportViewer1.RefreshReport();
Cursor = Cursors.Arrow;
frm.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
因此,当任何人单击“预览文档”按钮时,“btn_previewdocument_Click”事件就会发生。
而我想在这个事件中根据要在 Crystal 报表中显示的查询数据来做。
提前致谢。
最佳答案
试试这个。在 frm.crystalReportViewer1.ReportSource = cryRpt;
之前添加 cryRpt.Refresh();
关于c# - 更改查询后也在 Crystal 报表中显示相同的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41972494/
是否可以创建一个 sql 语句来动态生成 3 行而无需任何表..这些将包括 value1 : 10 | value2: 10 value2 : 11 | value2: 11 value3 : 12
近日,葡萄城正式发布了SpreadJS最新版本 V17.1,为前端表格控件市场带来了一系列令人瞩目的新特性和功能增强。本次更新旨在进一步提升用户在计算引擎、报表生成和分析等方面的体验,为各行业的开发者
我正在使用 Visual Studio 的 Crystal 报告,我创建了一个需要有背景图像的报告。我找不到像 Microsoft Report Viewer Report 这样的背景图像的方法。有办
我正在开发一个使用 Crystal Reports 生成 pdf、excel 和 word 报告文件的大型 C# 项目。 项目位于 SVN 存储库下,我们有主干和一个单独的分支。 我们每周都会将主干合
我以正确的格式放置了我的 super 语句,但我唯一的错误是它指出类 java.lang.object 中的构造函数对象不能应用于这部分代码的给定类型: super (openFile
我正在使用 Visual Studio 2008 并希望在报告中显示以下 SQL 查询: select name, count(*) from mytable group by name; 我可以通过
我使用 C# 在我的 CR 上正确地导入了一个图像。现在我需要在同一页面上显示包含 4 种不同产品的报告,类似这样: | P1 | P2 | | P3 | P4 | 为此,我创建了一个报告并将选项 R
我正在使用 C#.net 2010,我想使用两个表创建发票。一个表 Order 包含客户订购的东西,如类别、数量、费率、总金额,另一个表 Details 包含最终支付金额的详细信息,如 Vat、Fin
我正在使用 C# 创建一个 Crystal Report,我必须在 320 个不同的参数中复制一个简单的公式,但始终具有相同的条件,如下所示: if ({Precios.AhorroE1}[1] =
我在 vs2010 中创建了一个项目,然后创建了一个已部署的安装项目。当我在我的 PC 上运行应用程序时,它显然运行良好,但对于客户端计算机,应用程序运行良好,除了 crystal报道。我制作了安装项
我正在使用 Visual Studio、.NET 创建一个使用 Crystal 报表的 Web 应用程序,除了手动拖放之外,有什么方法可以让我以有组织的方式格式化这些报表? 谢谢 最佳答案 是的,报告
我正在使用 Visual Studio 2010 创建一个使用 Crystal Reports 的 Web 应用程序。 我目前使用 odp.NET 连接到 oracle 数据库并且一切正常,当我通过
我在 Windows 窗体应用程序 C# 中有 mysql 数据库,我想使用 Crystal 报告进行报告,但我想在没有报告向导的情况下连接到数据库,因为我希望我的应用程序独立于数据库服务器地址,并且
我正在开发一个超过 200 个表的大项目,我使用 MySQL(Percona)、Java 和 Crystal Report JRC。我有一些报告非常大并且多个表之间有很多连接。在Java客户端中,我通
我有一份报告和一份带有法语国际化资源包的子报告。没有抛出任何错误或警告,但是当我使用此报告创建 pdf 时,出现奇怪的字符,因为编码错误(É 代表 é 是一个例子)。 我仍在调查那个问题,但我猜它与子
我在让 Crystal Reports 与我们的应用程序很好地协同工作时遇到了一些问题。而且我似乎找不到任何资源来回答我的问题。 基本上,我们有一个 Crystal 报表,在 Crystal 报表应用
我正在为 Winform 使用 VS 2008。我在元素中有 Crystal 报表,我想在 CSS 的帮助下对其进行格式化。 谁能给我指出正确的教程来开始这个? 最佳答案 Visual Studio
我是java和crysal报告的新手。两天以来,我尝试使用 java 和 jsf 创建 Crystal 报告 pdf。一切正常,但是当我在代码中包含参数传递时,出现错误 *HTTP Status 5
我是这个工具的新手,所以我不知道如何获取类的数据并显示在报告中。 我没有数据库,我的信息存储在类内的变量中。像这样(文件夹 Objetos): 我的程序执行以下操作:读取 XML、使用 XSD 验证、
我需要在只有一个独立数据集(未连接到任何类型的数据库)的应用程序中使用 Crystal Reports 生成报告。此外,我需要根据 DataTable 中的值生成报告。 你能帮我看看吗,我是新手。我有
我是一名优秀的程序员,十分优秀!