我有一张表 tbl_invoice。我想在这个表中显示数据的水晶报告。对于每张发票,我都有 invoiceid(主键)和账单编号。每张发票的主键都会更改,但 billno 保持不变。我正在获取 max invoiceid 的 billno 并将其传递给水晶报告。但它只显示了水晶报告中的最后一条记录。如何显示与账单号匹配的所有记录?我写了这段代码
private void button1_Click(object sender, EventArgs e)
{
SalesInvoice_Caret crt = new SalesInvoice_Caret();
crt.SetParameterValue("BillNo", txtBillNo.Text);
crystalReportViewer1.ReportSource = crt;
crystalReportViewer1.Refresh();
}
private void crt_sales_invoice_viewer_Load(object sender, EventArgs e)
{
string getBill = "Select top 1 BillNo from tbl_sales_invoice order by SalesInvoiceId desc";
SqlCommand cmd = new SqlCommand(getBill, con);
con.Open();
object obj = cmd.ExecuteScalar();
con.Close();
MessageBox.Show(obj.ToString());
txtBillNo.Text = obj.ToString();
}