Exemplo n.º 1
0
 private void gridView2_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
 {
     if (e.Column.FieldName == "colSoLuong")
     {
         if (e.IsGetData)
         {
             e.Value = dichVuPhong.Rows[e.ListSourceRowIndex]["SoLuong"];
         }
         if (e.IsSetData)
         {
             DichVuDatPhongBUS.UpdateDichVuDatPhong(new DichVuDatPhongDTO((int)dichVuPhong.Rows[e.ListSourceRowIndex]["MaDichVuDatPhong"], (int)dichVuPhong.Rows[e.ListSourceRowIndex]["MaDichVu"], Convert.ToDouble(e.Value), (double)dichVuPhong.Rows[e.ListSourceRowIndex]["Gia"], chiTietDatPhong.MaChiTietDatPhong));
             RefreshDataBindingDichVuPhong();
         }
     }
     else if (e.Column.FieldName == "colDonGia")
     {
         if (e.IsGetData)
         {
             e.Value = Convert.ToInt32(dichVuPhong.Rows[e.ListSourceRowIndex]["Gia"]);
         }
         if (e.IsSetData)
         {
             DichVuDatPhongBUS.UpdateDichVuDatPhong(new DichVuDatPhongDTO((int)dichVuPhong.Rows[e.ListSourceRowIndex]["MaDichVuDatPhong"], (int)dichVuPhong.Rows[e.ListSourceRowIndex]["MaDichVu"], (double)dichVuPhong.Rows[e.ListSourceRowIndex]["SoLuong"], Convert.ToDouble(e.Value), chiTietDatPhong.MaChiTietDatPhong));
             RefreshDataBindingDichVuPhong();
         }
     }
     else if (e.Column.FieldName == "colThanhTien")
     {
         if (e.IsGetData)
         {
             e.Value = Convert.ToInt32(dichVuPhong.Rows[e.ListSourceRowIndex]["SoLuong"]) * (double)dichVuPhong.Rows[e.ListSourceRowIndex]["Gia"];
         }
     }
 }
Exemplo n.º 2
0
        void RefreshDataBindingDichVuPhong()
        {
            dichVuPhong             = DichVuDatPhongBUS.LayTatCaDichVuDatPhong_DichVu_LoaiDV(chiTietDatPhong);
            gridControl1.DataSource = dichVuPhong;

            if (wbntQuanlyphong.Buttons.Count != 0)
            {
                if (gridView1.RowCount == 0)
                {
                    wbntQuanlyphong.Buttons["Xóa Dịch Vụ"].Properties.Visible = false;
                }
                else
                {
                    wbntQuanlyphong.Buttons["Xóa Dịch Vụ"].Properties.Visible = true;
                }
            }
        }
Exemplo n.º 3
0
        private void wbntQuanlyphong_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            switch (e.Button.Properties.Tag.ToString())
            {
            case "Thêm Dịch Vụ":
                folderDichVu.ChonDichVu chonDichVu = new folderDichVu.ChonDichVu(false);

                XtraDialogArgs args = new XtraDialogArgs(caption: "Chọn dịch vụ", content: chonDichVu, buttons: new DialogResult[] { DialogResult.OK, DialogResult.Cancel });
                args.Showing += Args_Showing;


                if (XtraDialog.Show(args) == DialogResult.OK)
                {
                    foreach (int dichVu_Key in chonDichVu.GetSelectedDichVu().Keys)
                    {
                        DichVuDatPhongBUS.LuuThongTinDichVuDatPhong(new DichVuDatPhongDTO(DichVuDatPhongBUS.PhatSinhMaDichVuPhong(), dichVu_Key, chonDichVu.GetSelectedDichVu()[dichVu_Key], DichVuBUS.LayThongTinDichVu(dichVu_Key).DonGia, chiTietDatPhong.MaChiTietDatPhong));
                        //DichVuBUS.LayThongTinDichVu(dichVu_Key);
                    }

                    RefreshDataBindingDichVuPhong();
                }
                break;

            case "Chuyển Phòng":
                ChuyenPhong formChuyenPhong = new ChuyenPhong(chiTietDatPhong);


                if (FlyoutDialog.Show(this.FindForm(), formChuyenPhong) == DialogResult.OK)
                {
                    XtraMessageBox.Show("Chuyển phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).RefreshData();
                }

                break;

            case "Xóa Dịch Vụ":
                if (XtraMessageBox.Show("Bạn có chắc muốn xóa dịch vụ '" + dichVuPhong.Rows[gridView1.GetFocusedDataSourceRowIndex()]["TenDV"] + "' ?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    DichVuDatPhongBUS.XoaDichVuDatPhong((int)dichVuPhong.Rows[gridView1.GetFocusedDataSourceRowIndex()]["MaDichVuDatPhong"]);


                    RefreshDataBindingDichVuPhong();
                }

                break;

            case "Nhận Phòng":

                //Thông báo xác nhận
                if (XtraMessageBox.Show("Xác nhận nhận đặt phòng?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).NhanPhong();
                break;

            case "Hủy Phòng":

                //Thông báo xác nhận
                if (XtraMessageBox.Show("Bạn có chắc hủy phòng đã đặt này ?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }


                Dictionary <int, DatPhongDTO> tempSapDat_1 = BUS.DatPhongBUS.LayCacDatPhongDangSapDuocDatVaDangDuocDat(ThamSoBUS.LayKhoangThoiGianChoDatPhong());
                //Hủy đặt phòng
                if (DatPhongBUS.DemSoLuongChiTietDatPhong(chiTietDatPhong.MaDatPhong) == 1)
                {
                    foreach (ChiTietDatPhongDTO dp in DatPhongBUS.LayTatCaCacChiTietDatPhong(chiTietDatPhong.MaDatPhong))
                    {
                        if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 4 && tempSapDat_1.ContainsKey(dp.MaDatPhong))
                        {
                            PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 0);
                        }
                        else if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 6 && tempSapDat_1.ContainsKey(dp.MaDatPhong))
                        {
                            PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 5);
                        }
                        else if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 7 && tempSapDat_1.ContainsKey(dp.MaDatPhong))
                        {
                            PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 1);
                        }
                    }

                    DatPhongBUS.CapNhatTinhTrangDatPhong(3, chiTietDatPhong.MaDatPhong);
                    (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).RefreshData();
                    break;
                }

                //Hủy phòng
                if (PhongBUS.LayThongTinPhong(chiTietDatPhong.MaPhong).MaTinhTrangPhong == 4 && tempSapDat_1.ContainsKey(chiTietDatPhong.MaDatPhong))
                {
                    PhongBUS.CapNhatTinhTrangPhong(chiTietDatPhong.MaPhong, 0);
                }
                else if (PhongBUS.LayThongTinPhong(chiTietDatPhong.MaPhong).MaTinhTrangPhong == 6 && tempSapDat_1.ContainsKey(chiTietDatPhong.MaDatPhong))
                {
                    PhongBUS.CapNhatTinhTrangPhong(chiTietDatPhong.MaPhong, 5);
                }
                else if (PhongBUS.LayThongTinPhong(chiTietDatPhong.MaPhong).MaTinhTrangPhong == 7 && tempSapDat_1.ContainsKey(chiTietDatPhong.MaDatPhong))
                {
                    PhongBUS.CapNhatTinhTrangPhong(chiTietDatPhong.MaPhong, 1);
                }

                DatPhongBUS.XoaCacDichVuDatPhong(chiTietDatPhong);
                DatPhongBUS.XoaDatChiTietDatPhong(chiTietDatPhong);
                //if (DatPhongBUS.DemSoLuongChiTietDatPhong(chiTietDatPhong.MaDatPhong) == 0)
                //{
                //    DatPhongBUS.XoaDatPhong(chiTietDatPhong.MaDatPhong);
                //}
                XtraMessageBox.Show("Xóa đặt phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).RefreshData();

                //ThuePhongBUS.XoaThuePhong(thuePhong);
                //PhongBUS.CapNhatTinhTrangPhong(thuePhong.MaPhong, 0);
                //if (HoaDonBUS.DemSoLuongThuePhong(hoaDon.MaHoaDon) == 0)
                //{
                //    HoaDonBUS.XoaHoaDon(hoaDon);
                //}

                //((ThongTinChiTietNhieuPhong)Parent.Parent.Parent).OnXoaPhong();

                break;

            case "Hủy Đặt Phòng":

                //Thông báo xác nhận
                if (XtraMessageBox.Show("Bạn có chắc hủy đặt phòng này ?", "Xác nhận", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                //BUS.PhongBUS.CapNhatTinhTrangPhong(chiTiet.MaPhong, 0);



                Dictionary <int, DatPhongDTO> tempSapDat = BUS.DatPhongBUS.LayCacDatPhongDangSapDuocDatVaDangDuocDat(ThamSoBUS.LayKhoangThoiGianChoDatPhong());

                foreach (ChiTietDatPhongDTO dp in DatPhongBUS.LayTatCaCacChiTietDatPhong(chiTietDatPhong.MaDatPhong))
                {
                    if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 4 && tempSapDat.ContainsKey(dp.MaDatPhong))
                    {
                        PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 0);
                    }
                    else if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 6 && tempSapDat.ContainsKey(dp.MaDatPhong))
                    {
                        PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 5);
                    }
                    else if (PhongBUS.LayThongTinPhong(dp.MaPhong).MaTinhTrangPhong == 7 && tempSapDat.ContainsKey(dp.MaDatPhong))
                    {
                        PhongBUS.CapNhatTinhTrangPhong(dp.MaPhong, 1);
                    }
                }

                DatPhongBUS.CapNhatTinhTrangDatPhong(3, chiTietDatPhong.MaDatPhong);
                (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).RefreshData();
                break;

            case "In phiếu đặt":
            {
                (Parent.Parent.Parent as ThongTinChiTietDatNhieuPhong).InPhieuDat();
                break;
            }
            }
        }
Exemplo n.º 4
0
        public void BindingData(DatPhongDTO datPhong, KhachHangDTO khachHang)
        {
            lbNgaylapphieu.Text = datPhong.NgayLapPhieuDat.ToString("dd/MM/yyyy HH:mm:ss");
            lbMaphieudat.Text   = datPhong.MaDatPhong.ToString();
            lbGiovao.Text       = datPhong.ThoiGianDatPhong.ToString("dd/MM/yyyy HH:mm:ss");
            lbTienCoc.Text      = datPhong.SoTienDatTruoc.ToString("###,###,##0 VNĐ");;

            DataSet dsDatphong;

            dsDatphong = new DataSet();
            dsDatphong.Tables.Add(DatPhongBUS.LayThongTinDatPhong_table(datPhong.MaDatPhong));
            dsDatphong.Tables.Add(ChiTietDatPhongBUS.LayTatCaChiTietDatPhong_DataTable(datPhong.MaDatPhong));
            dsDatphong.Tables.Add(DichVuDatPhongBUS.LayTatCaDichVuDatPhong_DichVu_LoaiDV(datPhong.MaDatPhong));

            dsDatphong.Relations.Add("DanhSachPhong", dsDatphong.Tables[0].Columns["MaDatPhong"], dsDatphong.Tables[1].Columns["MaDatPhong"]);
            dsDatphong.Relations.Add("DanhSachDichVu", dsDatphong.Tables[1].Columns["MaChiTietDatPhong"], dsDatphong.Tables[2].Columns["MaChiTietDatPhong"]);



            DataSource = dsDatphong;
            DataMember = "DsPhongDat";



            GroupHeader4.GroupFields.Clear();


            GroupHeader4.GroupUnion = GroupUnion.WithFirstDetail;
            GroupHeader4.GroupFields.Add(new GroupField("MaChiTietDatPhong"));



            //Group Header 4

            lbTenPhong.DataBindings.Add("Text", null, "DsPhongDat.TenPhong");
            lbMaPhong.DataBindings.Add("Text", null, "DsPhongDat.MaPhong");
            lbLoaiPhong.DataBindings.Add("Text", null, "DsPhongDat.TenLoaiPhong");
            lbSucchua.DataBindings.Add("Text", null, "DsPhongDat.SucChua");


            // //Group Header 2
            // lbLoaiDichVu.DataBindings.Add("Text", null, "colType");


            // //Detail


            string detailDataMember = string.Format("{0}.{1}", dsDatphong.Tables[1].TableName, dsDatphong.Relations[1].RelationName);

            DetailReport.DataSource = dsDatphong;
            DetailReport.DataMember = detailDataMember;

            // GroupHeader3.GroupFields.Clear();
            // GroupHeader3.GroupFields.Add(new GroupField("colType"));

            // lbLoaiDichVu.DataBindings.Add("Text", null, detailDataMember + ".colType");

            Tendichvu.DataBindings.Add("Text", null, detailDataMember + ".TenDV");
            donvitinh.DataBindings.Add("Text", null, detailDataMember + ".DonVi");
            soluong.DataBindings.Add("Text", null, detailDataMember + ".SoLuong");
            gia.DataBindings.Add("Text", null, detailDataMember + ".Gia");

            // //lbTenDV.DataBindings.Add("Text", null, detailDataMember+".TenDV");
            // //lbDonViTinh.DataBindings.Add("Text", null, "dichvuphong.DonVi");
            // //lbSoLuong.DataBindings.Add("Text", null, "dichvuphong.SoLuong");
            // //lbDonGia.DataBindings.Add("Text", null, "dichvuphong.Gia");
            tongmotDV.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", detailDataMember + ".SoLuong * " + detailDataMember + ".Gia"));


            // //Group Footer 2
            lbTongTienDV.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "sumSum( " + detailDataMember + ".SoLuong * " + detailDataMember + ".Gia)"));

            double TongTienDichVu = 0;

            foreach (DataRow r in dsDatphong.Tables[2].Rows)
            {
                TongTienDichVu += (double)r["SoLuong"] * (double)r["Gia"];
            }

            lbTienHoaDon.Text = TongTienDichVu.ToString("###,###,##0 VNĐ");;
            //lbTienHoaDon.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "sumSum( " + dsDatphong.Tables[2].TableName + ".SoLuong * " + dsDatphong.Tables[2].TableName + ".Gia)"));
            // //Group Footer 1
            // lbTongTienDV.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "sumSum( " + detailDataMember + ".SoLuong * " + detailDataMember + ".Gia)"));
            // //lbTongTienDV.DataBindings.Add("Text", null, "Sum(SoLuong)");

            // // lbTienDV.DataBindings.Add("Text", null, (Convert.ToInt32(lbDonGia.Text)* Convert.ToInt32(lbSoLuong.Text)).ToString() );

            // lbMaphieudat.Text = "#" + datphongDTO.MadatphongDTO.ToString();
            // //lbNgayThanhToan.Text = dsDatphong.Rows[0]["ThoiGian"].ToString();


            lbTenKH.Text       = khachHang.TenKH;
            lbLoaiKH.Text      = BUS.LoaiKhachHangBUS.LayLoaiKhachHang(khachHang.MaKH).TenLoaiKH;
            lbDiemTichLuy.Text = BUS.KhachHangBUS.LayKhachHang(khachHang.MaKH).DiemTichLuy.ToString("###,###,##0");

            Ghichu.Text = datPhong.GhiChu;
        }