public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CrystalReportCHITIETLAIKHACHHANG rpt = new CrystalReportCHITIETLAIKHACHHANG(); rpt.Site = this.Site; return(rpt); }
private void button1_Click(object sender, EventArgs e) { List <CCongNoKhachHang> _datasource = new List <CCongNoKhachHang>(); string note = ""; BindingSource bs = new BindingSource(); long MAKH = long.Parse(comboBox1.SelectedValue.ToString()); DateTime FROM = dateTimePickerFROM.Value.Date; DateTime TO = dateTimePickerTO.Value.Date; /* Lấy tất cả dữ liệu xuất hàng cho khách hàng này */ /* Từ ngày đến ngày */ IQueryable <CCongNoKhachHang> xuat_hang = (from _xh in DataInstance.Instance().DBContext().XUAT_HANG join _kho in DataInstance.Instance().DBContext().KHOes on _xh.MAKHO equals _kho.ID //join _hh in DataInstance.Instance().DBContext().HANG_HOA on _xh.MAHH equals _hh.ID where _xh.MAKH == MAKH where _xh.NGAY_XUAT >= FROM && _xh.NGAY_XUAT <= TO orderby _xh.NGAY_XUAT ascending select new CCongNoKhachHang { ID = (int)_xh.ID, NGAY = _xh.NGAY_XUAT.Value, KHO = _kho.NAME, HANGHOAID = _xh.MAHH, //HANGHOA = _hh.NAME, SOLUONG = _xh.SO_LUONG, DONGIABAN = _xh.DON_GIA_BAN, THANHTIEN = _xh.THANH_TIEN, TRATRUOC = _xh.TRA_TRUOC, LAISUAT = _xh.LAI_SUAT, LAI = 0, TRAGOC = 0, TRALAI = 0, CONNO = 0 }); note = "CHI TIẾT LÃI KHÁCH HÀNG"; DateTime now = dateTimePickerTO.Value.Date; /* Không sử dụng dữ liệu từ thu nợ */ foreach (CCongNoKhachHang row in xuat_hang) { //double lai = Utility.Lai(row.NGAY, now, row.LAISUAT, row.THANHTIEN - row.TRATRUOC); double lai = MXuatHang.GetLai(row.ID, now); string HangHoa = MHangHoa.GetNameByID(row.HANGHOAID); _datasource.Add(new CCongNoKhachHang() { NGAY = row.NGAY, KHO = row.KHO, HANGHOA = HangHoa, SOLUONG = row.SOLUONG, DONGIABAN = row.DONGIABAN, THANHTIEN = row.THANHTIEN, TRATRUOC = row.TRATRUOC, LAISUAT = row.LAISUAT * 100, /* Cần tính lãi */ LAI = lai, TRAGOC = 0, TRALAI = 0, CONNO = row.THANHTIEN + (long)lai - row.TRATRUOC }); } //} bs.DataSource = _datasource; CrystalReportCHITIETLAIKHACHHANG rpt = new CrystalReportCHITIETLAIKHACHHANG(); rpt.SetDataSource(bs); rpt.SetParameterValue("KH", comboBox1.Text); rpt.SetParameterValue("FROM", dateTimePickerFROM.Value); rpt.SetParameterValue("TO", dateTimePickerTO.Value); rpt.SetParameterValue("COMP", ConstClass.COMPANY_NAME); rpt.SetParameterValue("NOTE", note); crystalReportViewer1.ReportSource = rpt; crystalReportViewer1.Zoom(150); }