Ejemplo n.º 1
0
        //Dat Phong
        private void button1_Click(object sender, EventArgs e)
        {
            //Cap nhat
            if (
                string.IsNullOrWhiteSpace(txtHoTen.Text) ||
                string.IsNullOrWhiteSpace(txtCMND.Text) ||
                string.IsNullOrWhiteSpace(txtSDT.Text) ||
                string.IsNullOrWhiteSpace(txtNgaySinh.Text)
                )
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin của dịch vụ", "Lỗi thông tin",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (!txtCMND.Text.All(char.IsDigit) || !txtSDT.Text.All(char.IsDigit))
                {
                    MessageBox.Show("SDT và CMND phải là số", "Lỗi thông tin",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    KhachHangDTO _data = new KhachHangDTO();
                    _data.IdKhachHang = Global.Instance().idKhachHang().ToString();
                    _data.HoTen       = txtHoTen.Text;
                    _data.NgaySinh    = txtNgaySinh.Text;
                    _data.Cmnd        = Int32.Parse(txtCMND.Text);
                    _data.Sdt         = Int32.Parse(txtSDT.Text);

                    if (!_khBus.ThemThongTinKhachHang(_data))
                    {
                        MessageBox.Show("Đặt phòng cho kháchh hàng thất bại", "Thất bại",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Đặt phòng thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //Luu trạng thái Phong
                        _phongDTO.TrangThai = "Đang Sử Dụng";
                        _phongBus.CapNhatThongTinPhong(_phongDTO);
                        //Luu Phong duoc dat
                        PhongDangSuDungDTO _pdsdDTO = new PhongDangSuDungDTO();
                        _pdsdDTO.IdPhong        = _phongDTO.IdPhong;
                        _pdsdDTO.ThoiGianBatDau = txtNgay.Text;
                        _pdsdDTO.IdKhachHang    = _data.IdKhachHang;
                        _pdsdDTO.DsDichVu       = "";
                        _pdsdDTO.GiaDichVu      = 0.ToString();
                        _phongBus.ThemThongTinPhongDangSuDung(_pdsdDTO);

                        this.Hide();
                        TrangChu op = new TrangChu();
                        op.Show();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void wbntSuaphong_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            switch (e.Button.Properties.Tag.ToString())
            {
            case "Lưu":
                //Kiểm tra thông tin hợp lệ
                if (txtTenPhong.Text == "")
                {
                    return;
                }



                //Lưu thông tinh
                if (PhongBUS.CapNhatThongTinPhong(new PhongDTO(int.Parse(txtMaPhong.Text), txtTenPhong.Text, (int)((GUI.MyComboBoxItem)cmbLoaiPhong.SelectedItem).Tag, cmbTang.Text, txtGhiChu.Text, (int)((GUI.MyComboBoxItem)cmbTinhTrangPhong.SelectedItem).Tag, Convert.ToInt32(spinSucChua.Value))))
                {
                    //Thông báo thành công

                    XtraMessageBox.Show("Cập nhật phòng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    actionBack();
                }
                else
                {
                    //Thông báo thất bại

                    XtraMessageBox.Show("Cập nhật phòng thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                break;

            case "Hủy":
                if (ThongBaoHuySuaPhong())
                {
                    actionBack();
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (this.state == 0)
            {
                //Cap nhat
                if (string.IsNullOrWhiteSpace(txtIdPhong.Text) ||
                    string.IsNullOrWhiteSpace(txtTenPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbLoaiPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbTrangThai.Text) ||
                    string.IsNullOrWhiteSpace(txtDonGia.Text)
                    )
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin của phòng", "Lỗi thông tin",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!txtDonGia.Text.All(char.IsDigit))
                    {
                        MessageBox.Show("Đơn giá phải là số", "Lỗi thông tin",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        PhongDTO _data = new PhongDTO();
                        _data.IdPhong   = txtIdPhong.Text;
                        _data.TenPhong  = txtTenPhong.Text;
                        _data.LoaiPhong = cbbLoaiPhong.SelectedIndex;
                        _data.TrangThai = cbbTrangThai.Text;
                        _data.Dongia    = Int32.Parse(txtDonGia.Text);


                        if (!phongBUS.CapNhatThongTinPhong(_data))
                        {
                            MessageBox.Show("Cập nhật thông tin phòng vào cơ sở dữ liệu thất bại", "Thất bại",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            DocDuLieu(phongBUS.LayDuDieu());
                            MessageBox.Show("Thông tin phòng đã được cập nhật vào cơ sở dữ liệu", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            else
            if (this.state == 1)
            {
                //Them
                if (string.IsNullOrWhiteSpace(txtIdPhong.Text) ||
                    string.IsNullOrWhiteSpace(txtTenPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbLoaiPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbTrangThai.Text) ||
                    string.IsNullOrWhiteSpace(txtDonGia.Text)
                    )
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin của phòng", "Lỗi thông tin",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!txtDonGia.Text.All(char.IsDigit))
                    {
                        MessageBox.Show("Đơn giá phải là số", "Lỗi thông tin",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        PhongDTO _data = new PhongDTO();
                        _data.IdPhong   = txtIdPhong.Text;
                        _data.TenPhong  = txtTenPhong.Text;
                        _data.LoaiPhong = cbbLoaiPhong.SelectedIndex;
                        _data.TrangThai = cbbTrangThai.Text;
                        _data.Dongia    = Int32.Parse(txtDonGia.Text);


                        if (!phongBUS.ThemThongTinPhong(_data))
                        {
                            MessageBox.Show("Thêm thông tin phòng vào cơ sở dữ liệu thất bại hoặc ID Phòng bị trùng", "Thất bại",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            DocDuLieu(phongBUS.LayDuDieu());
                            MessageBox.Show("Thông tin phòng đã được thêm vào cơ sở dữ liệu", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            btnNhapLai_Click(sender, e);
        }
Ejemplo n.º 4
0
        //Tra Phong
        private void button11_Click(object sender, EventArgs e)
        {
            if (trangThaiPhong == 1)
            {
                PhongDTO phong = _phongBUS.LayThongTinPhong(idPhongClick);

                DateTime dtNow = DateTime.Now;

                PhongDangSuDungDTO _pdsdDTO = new PhongDangSuDungDTO();
                _pdsdDTO = _phongBUS.LayThongTinPhongDangSuDung(idPhongClick);

                string[]         _array = _pdsdDTO.DsDichVu.Split(',');
                DichVuBUS        _dvBus = new DichVuBUS();
                List <DichVuDTO> _dvDTO = new List <DichVuDTO>();

                foreach (var item in _array)
                {
                    DichVuDTO _dv = _dvBus.LayThongTinDichVu(item);
                    if (_dv != null)
                    {
                        _dvDTO.Add(_dv);
                    }
                }

                string idPhong        = "\n ID Phòng: " + idPhongClick;
                string tenPhong       = "\n Tên Phòng: " + phong.TenPhong;
                string ngayDatPhong   = "\n Thời gian Đặt Phòng: " + txtThoiGianDatPhong.Text;
                string ngayTraPhong   = "\n Thời gian Trả Phòng: " + dtNow.ToString();
                string dsDV_ThanhToan = "\n Danh sách dịch vụ sử dụng:";
                int    sDichVu        = 0;
                foreach (var item in _dvDTO)
                {
                    dsDV_ThanhToan += "\n       + " + item.TenDichVu;


                    sDichVu += (int)item.Gia;
                }
                DateTime dtBatDau = DateTime.Parse(txtThoiGianDatPhong.Text);

                TimeSpan span       = dtNow - dtBatDau;
                double   TongHoaDon = (span.TotalMinutes / 60) * (phong.Dongia) + sDichVu;
                string   s          = Global.Instance().ConvertCurrency(TongHoaDon.ToString());


                string chiphi = "\n Tổng hóa đơn: " + s + " VND";

                DialogResult dialogResult = MessageBox.Show("Bạn muốn thanh toán hóa đơn với:" + idPhong + tenPhong + ngayDatPhong + ngayTraPhong + dsDV_ThanhToan + chiphi, "Thanh Toán", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    BaoBieuDTO baoBieu = new BaoBieuDTO();
                    baoBieu.IdBaoBieu       = Global.Instance().idBaoBieu();
                    baoBieu.IdPhong         = idPhongClick;
                    baoBieu.IdNhanVien      = "1";
                    baoBieu.IdKhachHang     = _pdsdDTO.IdKhachHang;
                    baoBieu.DsDichVu        = _pdsdDTO.DsDichVu;
                    baoBieu.ThoiGianBatDau  = txtThoiGianDatPhong.Text;
                    baoBieu.ThoiGianKetThuc = dtNow.ToString();
                    baoBieu.TongTien        = (float)TongHoaDon;

                    BaoBieuBUS _baobieuBUs = new BaoBieuBUS();
                    _baobieuBUs.ThemThongTinBaoBieu(baoBieu);

                    _phongBUS.XoaThongTinPhongDangSuDung(idPhongClick);

                    //Cap nhat thong tin Phong
                    PhongDTO _phongCapNhat = _phongBUS.LayThongTinPhong(idPhongClick);
                    _phongCapNhat.TrangThai = "Còn Trống";
                    _phongBUS.CapNhatThongTinPhong(_phongCapNhat);

                    LoadData(state);
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }
            else
            {
                MessageBox.Show("Phòng đang sử dụng mới được trả phòng", "Thông báo");
            }
        }