Beispiel #1
0
        void RefreshDataBindingTienGio()
        {
            tienGio = new DataTable();
            tienGio.Columns.Add(new DataColumn("Ngay"));
            tienGio.Columns.Add(new DataColumn("KhoangThoiGian"));
            tienGio.Columns.Add(new DataColumn("DonGia"));
            tienGio.Columns.Add(new DataColumn("SoLuong"));
            tienGio.Columns.Add(new DataColumn("GioBD", typeof(double)));
            tienGio.Columns.Add(new DataColumn("Phong"));
            tienGio.Columns.Add(new DataColumn("colType"));

            TongTienGio = 0;
            foreach (DTO.ThongTinThanhToanTheoNgay ngay in ThanhToanBUS.TinhTienThuePhong(thuePhong, txtGioRa.Time).listThongTin)
            {
                TongTienGio += ngay.TongThanhTien;
                foreach (LoaiPhongDTO.DonGiaTheoKhoangThoiGian dongia in ngay.listDonGiaTheoKhoangThoiGian)
                {
                    DataRow dr = tienGio.NewRow();

                    dr["Ngay"]           = ngay.ngay.Thu + " (" + ngay.ngay.date.ToString("dd-MM-yyyy") + ")";
                    dr["KhoangThoiGian"] = dongia.GioBatDau + " - " + dongia.GioKetThuc;
                    dr["GioBD"]          = dongia.GioBatDau.hour * 3600 + dongia.GioBatDau.minute * 60 + dongia.GioBatDau.second;
                    dr["DonGia"]         = dongia.DonGia;
                    dr["SoLuong"]        = Math.Round(ThongTinThanhToanTheoNgay.Gio.CalcTimeSpan(dongia.GioBatDau, dongia.GioKetThuc).TotalHours, 2);
                    dr["Phong"]          = PhongBUS.LayThongTinPhong(thuePhong.MaPhong).TenPhong;

                    tienGio.Rows.Add(dr);
                }
            }

            txtTienGio.Properties.DataSource = tienGio;
            txtTienGio.Properties.NullText   = TongTienGio.ToString("###,###,###,##0 VNĐ");
        }
Beispiel #2
0
        public void RefreshDataBinding(ThuePhongDTO thuePhongDTO, KhachHangDTO khachHangDTO)
        {
            txtTienGio.ReadOnly = false;
            gridView1.OptionsBehavior.ReadOnly = false;

            this.thuePhong = thuePhongDTO;

            txtGioVao.Time = thuePhong.GioThuePhong;
            txtGioRa.Time  = (thuePhong.GioTraPhong == DateTime.MinValue) ?DateTime.Now : thuePhong.GioTraPhong;

            thuePhong.GioTraPhong = txtGioRa.Time;

            listKhuyenMai = new Dictionary <int, DichVuPhongDTO>();

            RefreshDataBindingTienGio();


            loaiKhachHang = LoaiKhachHangBUS.LayLoaiKhachHang(khachHangDTO);


            DichVuPhongDTO dichVuPhongDTO;

            //Kiểm tra các ngày đặt biệt
            foreach (DTO.ThongTinThanhToanTheoNgay ngay in ThanhToanBUS.TinhTienThuePhong(thuePhong, DateTime.Now).listThongTin)
            {
                //Sinh nhật
                if (ngay.ngay.date.Day == khachHangDTO.NgaySinh.Day && ngay.ngay.date.Month == khachHangDTO.NgaySinh.Month && khachHangDTO.MaKH != 0)
                {
                    if (TongTienGio * loaiKhachHang.PhanTramGiamGiaSinhNhat > loaiKhachHang.SoTienGiamGiaSinhNhat_Max)
                    {
                        dichVuPhongDTO = new DichVuPhongDTO(-1, thuePhong.MaThuePhong, 1, DateTime.Now, 1.0, -loaiKhachHang.SoTienGiamGiaSinhNhat_Max);
                    }
                    else if ((TongTienGio * loaiKhachHang.PhanTramGiamGiaSinhNhat < loaiKhachHang.SoTienGiamGiaSinhNhat_Min))
                    {
                        dichVuPhongDTO = new DichVuPhongDTO(-1, thuePhong.MaThuePhong, 1, DateTime.Now, 1.0, -loaiKhachHang.SoTienGiamGiaSinhNhat_Min);
                    }
                    else
                    {
                        dichVuPhongDTO = new DichVuPhongDTO(-1, thuePhong.MaThuePhong, 1, DateTime.Now, 1.0, -(TongTienGio * loaiKhachHang.PhanTramGiamGiaSinhNhat));
                    }

                    if (dichVuPhongDTO.DonGia != 0)
                    {
                        listKhuyenMai.Add(dichVuPhongDTO.MaDVP, dichVuPhongDTO);
                    }
                }
            }

            //KM Loại KH
            if (TongTienGio * loaiKhachHang.PhanTramGiamGia > loaiKhachHang.SoTienGiamGia_Max)
            {
                dichVuPhongDTO = new DichVuPhongDTO(-(listKhuyenMai.Count + 1), thuePhong.MaThuePhong, 2, DateTime.Now, 1.0, -loaiKhachHang.SoTienGiamGia_Max);
            }
            else if ((TongTienGio * loaiKhachHang.PhanTramGiamGia < loaiKhachHang.SoTienGiamGia_Min))
            {
                dichVuPhongDTO = new DichVuPhongDTO(-(listKhuyenMai.Count + 1), thuePhong.MaThuePhong, 2, DateTime.Now, 1.0, -loaiKhachHang.SoTienGiamGia_Min);
            }
            else
            {
                dichVuPhongDTO = new DichVuPhongDTO(-(listKhuyenMai.Count + 1), thuePhong.MaThuePhong, 2, DateTime.Now, 1.0, -(TongTienGio * loaiKhachHang.PhanTramGiamGia));
            }

            if (dichVuPhongDTO.DonGia != 0 && khachHangDTO.MaKH != 0)
            {
                listKhuyenMai.Add(dichVuPhongDTO.MaDVP, dichVuPhongDTO);
            }

            RefreshDataBindingDichVuPhong();
        }