コード例 #1
0
        private void btnXem_Click(object sender, EventArgs e)
        {
            using (quanlithucungEntities1 quanli = new quanlithucungEntities1())
            {
                DataTable table = new DataTable();
                table.Columns.Add("ngaylap");
                table.Columns.Add("banhang");
                table.Columns.Add("nhaphang");
                table.Columns.Add("luongnv");
                table.Columns.Add("doanhthu");

                List <DoanhThuTheoThang_Result> ds_hoadon = quanli.DoanhThuTheoThang(dateTimePicker1.Value.Month, dateTimePicker1.Value.Year).ToList();
                foreach (var item in ds_hoadon)
                {
                    table.Rows.Add(item.ngaylap, item.banhang, item.nhaphang, item.luongnv, item.doanhthu);
                }
                RPDoanhThu1.SetDataSource(table);
                crystalReportViewer1.ReportSource = RPDoanhThu1;
                crystalReportViewer1.Show();
            }
        }