如何在Windows应用程序中使用水晶报告生成账单

问题描述:

我已经申请了

我需要以下列模式创建账单客户



FPan。公司名称。手机

公司地址。电话

客户名称



1 lx l7000 lfromdate l todate

2 lyl 3000 l fromdate l todate









总计10000



Dt1在一行中有公司和客户的详细信息。

和Dt2有多行客户服务详情

Plz亲切

帮助代码

I hv made application in which
I need to create bill customer in following pattern

FPan. Firm name. Mobile
Firm Address. Phone
customers name

1 l x l7000 lfromdate l todate
2 l y l 3000 l fromdate l todate
.
.
.

Total 10000

Dt1 has firm and customers details in one row.
and Dt2 has customer's service details multiple rows
Plz kindly
help in to code

搜索时有很多例子: https://www.google.com/webhp?q=how+to+create+a+crystal+report [ ^ ]



例如,请看:

- 创建一个简单但有用的Crystal Report [ ^ ]

- 如何使用C#和MySQL创建Crystal报告 [ ^ ]
There are a lot of examples if you search: https://www.google.com/webhp?q=how+to+create+a+crystal+report[^]

For example, have a look at:
- Creating a simple but useful Crystal Report[^]
- How to Create a Crystal Report using C# and MySQL[^]


Hello Meenakshi,
Just Refer the Below Example.

step 1:- Add New Form and Drag & Drop the CrystalReportViewer and set its Dock property to Fill.

step 2:- Now Right Click on your Project and Click on add New Item (Ctrl+shift+a), After open Popup Choose the Reporting tab from vertical tab and select the CrystalReport.
e.g. "crystalreport1.rpt"

step 3:- After that, Right Click on your Project and Click on add New Item (Ctrl+shift+a), After open Popup Choose the Data tab from vertical tab and set Dataset.
e.g. "DataSet1.xsd"

step 4:- Now Just Right Click and Add datatable then Add the Column to that Datatable.
e.g  I have use the Column name Such as "empID","empName","address","city","contactNo".

step 5:- After that Click on crystalreport1.rpt and Just go Field Explorer & Right Click on Database Fields and select Database expert and go in ProjectData and add Datatable Now expand the Database field and Datatable Your Database Field is ready to use.

step 6:- Now Drag and Drop Database Field From Datatable and put in section3(Details) of Crystal Report1.rpt.







Now Do the Following Code :-

 private void crystalReportViewer1_Load(object sender, EventArgs e)
        {
         ReportDocument rd;
            DataSet1 ds = new DataSet1(); //Dataset Name
            DataTable dt = ds.Tables["DataTable1"]; // Datatable Name
            DataRow dr;
            for (int i = 1; i <= 100; i++)
            {
                dr = dt.NewRow();
                dr["empID"] = i;
                dr["empName"] = "John Carry";
                dr["address"] = "Street 001, Rivera Green, CA";
                dr["city"] = "Tracy";
                dr["contactNo"] = "9876543210";
                dt.Rows.Add(dr);
            }
            rd = new CrystalReport1(); // ReportFile Name that CrystalReport1.rpt
            rd.SetDataSource(dt);
            crystalReportViewer1.ReportSource = rd;
            crystalReportViewer1.Refresh();
        }