Пример #1
0
        public void RefreshDataBinding()
        {
            dataSet           = new DataSet();
            dtLoaiPhong       = LoaiPhongBUS.LayTatCaLoaiPhong_DataTable();
            dtDonGiaPhong     = DonGia_LoaiPhongBUS.LayTatCaDonGia_DataTable();
            dtPhong           = PhongBUS.LayTatCaPhong_TinhTrangPhong_LoaiPhong();
            dtPhong.TableName = "phong";

            dataSet.Tables.Add(dtLoaiPhong);
            dataSet.Tables.Add(dtDonGiaPhong);
            dataSet.Tables.Add(dtPhong);

            dataSet.Relations.Add("Đơn giá phòng", dataSet.Tables["loaiphong"].Columns["MaLP"], dataSet.Tables["dongia_loaiphong"].Columns["MaLoaiPhong"]);
            dataSet.Relations.Add("Thông tin phòng", dataSet.Tables["loaiphong"].Columns["MaLP"], dataSet.Tables["phong"].Columns["MaLoaiPhong"]);

            gridControl1.DataSource = dataSet.Tables["loaiphong"];
            gridControl1.LevelTree.Nodes.Add("Đơn giá phòng", gridViewDonGiaPhong);
            gridControl1.LevelTree.Nodes.Add("Thông tin phòng", gridViewPhong);

            if (gridViewLoaiPhong.RowCount == 0)
            {
                wbntLoaiphong.Buttons[1].Properties.Visible = false;
                wbntLoaiphong.Buttons[2].Properties.Visible = false;
            }
        }
Пример #2
0
        public void RefreshDataBinding(LoaiPhongDTO loaiPhongDTO)
        {
            loaiPhong = loaiPhongDTO;



            Dictionary <string, LoaiPhongDTO.DonGiaTheoNgay> donGia = DonGia_LoaiPhongBUS.LayDonGia(loaiPhongDTO);

            for (int i = 0; i < donGia.Keys.Count; i++)
            {
                foreach (LoaiPhongDTO.DonGiaTheoKhoangThoiGian donGiaNgay in donGia.Values.ToList()[i].listDonGiaTheoKhoangThoiGian)
                {
                    for (int k = donGiaNgay.GioBatDau.hour; k < donGiaNgay.GioKetThuc.hour; k++)
                    {
                        spreadsheetControl1.Document.Worksheets[0].Cells[k, i].Value = donGiaNgay.DonGia;
                    }
                }
            }

            txtTenLoaiPhong.Text = loaiPhongDTO.TenLoaiPhong;
            txtMaLoaiPhong.Text  = loaiPhongDTO.MaLoaiPhong.ToString();
        }
Пример #3
0
        private void wbntThemphong_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            switch (e.Button.Properties.Tag.ToString())
            {
            case "Lưu":
                if (txtTenLoaiPhong.Text == "")
                {
                    txtTenLoaiPhong.ErrorText = "Tên loại phòng không được để trống";
                    return;
                }
                if (txtTenLoaiPhong.Text != loaiPhong.TenLoaiPhong)
                {
                    LoaiPhongBUS.CapNhatLoaiPhong(new LoaiPhongDTO(loaiPhong.MaLoaiPhong, txtTenLoaiPhong.Text));
                }

                DonGia_LoaiPhongBUS.XoaCacDonGiaPhong(loaiPhong);

                DonGiaTheoTuan giaTheoTuan = new DonGiaTheoTuan();
                giaTheoTuan.MaLoaiPhong = Convert.ToInt32(loaiPhong.MaLoaiPhong);

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 24; j++)
                    {
                        if (spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString() == "")
                        {
                            //Thông báo có cell trống
                            XtraMessageBox.Show("Không thể thêm được do có đơn giá trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            return;
                        }
                    }
                }

                for (int i = 0; i < 8; i++)
                {
                    DonGiaTheoNgay donGiaNgay = new DonGiaTheoNgay();
                    donGiaNgay.SetNgayTrongTuan(i);

                    DonGiaTheoKhoangThoiGian donGia = new DonGiaTheoKhoangThoiGian(new DTO.ThongTinThanhToanTheoNgay.Gio(0, 0, 0), new DTO.ThongTinThanhToanTheoNgay.Gio(1, 0, 0), Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[0, i].Value.ToString()));

                    for (int j = 1; j < 24; j++)
                    {
                        if (donGia.DonGia == Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString()))
                        {
                            donGia.GioKetThuc.AddHour(1);
                        }
                        else
                        {
                            donGiaNgay.listDonGiaTheoKhoangThoiGian.Add(donGia);

                            donGia = new DonGiaTheoKhoangThoiGian(new DTO.ThongTinThanhToanTheoNgay.Gio(j, 0, 0), new DTO.ThongTinThanhToanTheoNgay.Gio(j + 1, 0, 0), Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[0, i].Value.ToString()));


                            donGia.DonGia = Convert.ToInt32(spreadsheetControl1.Document.Worksheets[0].Cells[j, i].Value.ToString());
                        }
                        //spreadsheetControl1.Document.Worksheets[0].Cells[j, i].NumberFormat = "##.000";
                    }

                    donGiaNgay.listDonGiaTheoKhoangThoiGian.Add(donGia);

                    giaTheoTuan.listDonGiaTheoNgay.Add(donGiaNgay);
                }
                BUS.DonGia_LoaiPhongBUS.ThemDonGiaTheoKhoangThoiGian(giaTheoTuan);

                //Thông báo thành công
                XtraMessageBox.Show("Sửa loại phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                goToHomeLoaiPhong();
                break;

            case "Hủy":
                if (XtraMessageBox.Show("Bạn có muốn thoát khỏi sửa loại phòng (Mọi thông tin chưa được lưu sẽ mất) ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    goToHomeLoaiPhong();
                }
                break;
            }
        }