0% found this document useful (0 votes)
12 views14 pages

Report

Uploaded by

Đỗ Ngọc Mai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views14 pages

Report

Uploaded by

Đỗ Ngọc Mai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

BÀI 5: 49

BÀI 5:

5.1 M
-
báo cáo.

5.2

ra Report Data. )

project Windows Form,


Reporting (
)

Report Viewer Cho Visual Studio 2015 ( )


-
50

- Check vào Microsoft

Report Data ( file .rdlc)


BÀI 5: 51

- file.
-
.
T
52

(folder models).
- Add thêm 1 class StudentReport.cs (mã sinh
tên khoa)

- T o DataSet và lo i Object và tr t i class mu n l y d li u trong file report


data
BÀI 5: 53

Ch n Next, và ch c t o ra c 5. (N u không th y SV ph i
build l
54
- t tên cho DataSet ch a trong report file

ReportViewer

ReportViewer
BÀI 5: 55

private void frmStudentManagement_Load(object sender, EventArgs e)


{
StudentDBContext context = new StudentDBContext();
List<Student> listStudent = context.Students.ToList(); //l y t t c sv
List<StudentReport> listReport = new List<StudentReport>();
foreach (Student i in listStudent)
{
StudentReport temp = new StudentReport();
temp.StudentID = i.StudentID;
temp.FullName = i.FullName;
temp.AverageScore = i.AverageScore;
temp.FacultyName = i.Faculty.FacultyName;
listReport.Add(temp);
}
this.reportViewer1.LocalReport.ReportPath = "rptStudentReport.rdlc";
var reportDataSource = new ReportDataSource("StudentDataSet", listReport);
tên dataset trong thi t k
this.reportViewer1.LocalReport.DataSources.Clear(); //clear
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.reportViewer1.RefreshReport(); //ch y report
}
56
- Ch xem k t qu

- Object
ra các Object

5.3
Lab4, Sinh Viên thêm

ProductOrder Product, Order, Invoice


-

Product: h,
Giá Mua, Giá Bán)
BÀI 5: 57
Order:

Invoice: (
hàng, ghi chú)

Khi Load Form

-
-

-
(Invoic (Có
DropDownStyle = DropDownList)
58

báo giá)

- Visible = True)

- Order mà = Mã
(DropDownList)

- :
BÀI 5: 59
er trong Report
Data)

- (rptProduct.rdlc)

=RowNumber(nothing)
- (rptOrder.rdlc)
60

: invoiceNo,

:S

ProductOrderModel context = new ProductOrderModel();


if (optBangBaoGia.Checked == true) //TH báo giá
{
List<Product> listProduct = context.Products.ToList();
this.reportViewer1.LocalReport.ReportPath = "rptProduct.rdlc"; //nh copy report debug
var reportDataSource = new ReportDataSource("ProductDataSet", listProduct);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.reportViewer1.LocalReport.DisplayName = "B ng Báo Giá";
}
else //TH chi ti
{
Invoice invoice =context.Invoices.FirstOrDefault(p=>p.InvoiceNo == cmbInvoice.Text);
List<Order>listOrder=context.Orders.Where(p=>p.InvoiceNo==cmbInvoice.Text).ToList();
if (invoice == null || listOrder.Count() == 0)
{
MessageBox.Show("Không tìm th );
return;
}
//S d ng 2 tham s truy n vào cho report
ReportParameter[] param = new ReportParameter[2];
param[0] = new ReportParameter("InvoiceNo", invoice.InvoiceNo);
param[1] = new ReportParameter("DeliveryDateStr", string.Format("Ngày " +
invoice.DeliveryDate.ToString("dd/MM/yyyy")));
this.reportViewer1.LocalReport.ReportPath = "rptOrder.rdlc"; //nh copy report->debug
this.reportViewer1.LocalReport.SetParameters(param);
var reportDataSource = new ReportDataSource("OrderDataSet", listOrder);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource);
this.reportViewer1.LocalReport.DisplayName = "Phi u giao hàng"; //tên hi n th
}
this.reportViewer1.RefreshReport();
BÀI 5: 61
ProductOrder
.

-
Disable
- Custom) và
D
-

Th Price * Quantity).
62

y.

You might also like