示例#1
0
        private void icoBtnInphieuthue_Click(object sender, EventArgs e)
        {
            try
            {
                HOA_DON hd = context.HOA_DON.FirstOrDefault(p => p.MaThuePhong == maThuePhong);
                if (hd == null)
                {
                    throw new Exception("Phiếu thuê này chưa thanh toán");
                }

                if (maThuePhong.Equals(string.Empty))
                {
                    throw new Exception("Vui lòng chọn phiếu thuê cần xuất");
                }
                ClassReport.ReportInfo info = new ClassReport.ReportInfo();
                info.ID         = maThuePhong;
                info.pIDRoom    = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.MaPhong).FirstOrDefault();
                info.pName      = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.HoTenKhachHang).FirstOrDefault();
                info.pDateFrom  = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.NgayNhan).FirstOrDefault();
                info.pDateTo    = context.CHI_TIET_PHIEU_THUE_PHONG.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.NgayTra).FirstOrDefault();
                info.pTienPhong = double.Parse(context.HOA_DON.Where(p => p.MaThuePhong.Equals(maThuePhong)).Select(p => p.TongTien).FirstOrDefault().ToString());

                FormReport.ReportPhieuThue Frm = new FormReport.ReportPhieuThue(info);
                Frm.DataSource = context.DANH_SACH_SU_DUNG_DICH_VU.Join
                                 (
                    context.DICH_VU,
                    DS => DS.MaDichVu,
                    DV => DV.MaDichVu,
                    (DS, DV) => new { DS, DV }
                                 )
                                 .Where(p => p.DS.MaThuePhong.Equals(maThuePhong))
                                 .Select
                                 (
                    p => new
                {
                    TenDichVu = p.DV.TenDichVu,
                    SoLuong   = p.DS.SoLuong,
                    DonGia    = p.DV.DonGia,
                    ThanhTien = p.DV.DonGia * p.DS.SoLuong,
                }
                                 ).ToList();
                frmReportViewer Rpv = new frmReportViewer(Frm);
                Rpv.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
 public frmReportViewer(FormReport.ReportPhieuThue frm)
 {
     InitializeComponent();
     FormPT = frm;
     load();
 }