我尝试打印销售发票时出现问题 [英] problem when i try printing sales invoice

查看:131
本文介绍了我尝试打印销售发票时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button1_Click(object sender, EventArgs e)
{
    hesham2020Entities2 db = new hesham2020Entities2();
    string u;
    u = textBox1.Text.Trim();
    var y = from v in db.inv_detail
            from s in db.invoice_head 
            where s.invno==u
            select new
                {v.unit,v.qty,v.p_no,v.description,v.price,v.tot_price,s.invno,s.customer_id,s.inv_dat,s.po_no,s.total,s.currency};
    CrystalReport6 crt = new CrystalReport6();
    crt.SetDataSource(y);
    crv9.Refresh();
    crt.SetParameterValue(0, comboBox2.SelectedItem);
    crt.SetParameterValue(1, comboBox3.SelectedItem);
    //crt.SetParameterValue(2, textBox1.Text);
    crv9.ReportSource = crt;
    crv9.Refresh();
}

当我尝试打印此发票时,如果发票明细包含3行,则它打印了9行, 这意味着每行打印3次,但是当发票明细包含1行时,它将打印1行.我不知道错误的原因

when i try to print this invoice if the invoice details contain 3 rows it printed 9 rows, that mean every row printed 3 times, but when the invoice details contain 1 row it printed 1 row. i can not know the reason of the error

推荐答案

您缺少inv_detail和invoice_head之间的联接. 基本上,您正在做笛卡尔积,您应该尝试类似的事情:

You are missing the join between inv_detail and invoice_head. Basically you are doing a cartesian product, you should try something like:

from db.invoice_head 
join db.inv_detail
on [...]

这篇关于我尝试打印销售发票时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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