Esempio n. 1
0
        private void trangThaiDaNhan(object sender, EventArgs e)
        {
            // Set trạng thái đã nhận trong ds phiếu đặt
            string dk1         = tblDatPhong.CurrentRow.Cells[8].Value.ToString();
            string ngayhientai = DateTime.Now.ToString("dd/MM/yyyy");
            bool   dk2         = tblDatPhong.CurrentRow.Cells[6].Value.ToString().Trim().Equals(ngayhientai);

            if (dk1.Equals("Đã đặt") && dk2 == true)
            {
                string maphieudat  = tblDatPhong.CurrentRow.Cells[0].Value.ToString();
                string manv        = tblDatPhong.CurrentRow.Cells[1].Value.ToString();
                string cmnd        = tblDatPhong.CurrentRow.Cells[2].Value.ToString().Trim();
                string phong       = tblDatPhong.CurrentRow.Cells[5].Value.ToString();
                string ngaydenthue = tblDatPhong.CurrentRow.Cells[6].Value.ToString().Trim();
                string ngaydi      = tblDatPhong.CurrentRow.Cells[7].Value.ToString().Trim();
                dp.doiTrangThaiPhieuDat(maphieudat, Option.PD_DA_NHAN);
                p.doiTrangThaiPhong(phong, Option.P_DANG_THUE);
                tp.themPhieuThue(cmnd, manv, phong, ngaydenthue, ngaydi);
                //Hiển thị lại table Đặt phòng
                hienThiThongTin();
            }
            else
            {
                MessageBox.Show("Không thực hiện được, phòng không thể giao trong hôm nay.", "Thông báo");
            }
        }
Esempio n. 2
0
        private void themPhieuThuePhong(object sender, EventArgs e)
        {
            string manv      = txtMaNV.Text.ToString();
            string phong     = txtPhong.Text.ToString();
            string dienthoai = txtDienThoai.Text.ToString();
            string hoten     = txtHoTen.Text.ToString();
            string cmnd      = txtCMND.Text.ToString();
            string ngaythue  = DateTime.Now.ToShortDateString();
            string ngaydi    = dateNgayTra.Text.ToString();
            string rgxSDT    = @"^[0-9]{10,11}$";
            string rgxCMND   = @"^[0-9]{9,12}$";
            string rgxTen    = @"[^\d\W_]+";
            bool   mSDT      = Regex.IsMatch(txtDienThoai.Text.ToString().Trim(), rgxSDT, RegexOptions.IgnoreCase);
            bool   mCMND     = Regex.IsMatch(txtCMND.Text.ToString().Trim(), rgxCMND, RegexOptions.IgnoreCase);
            bool   mTen      = Regex.IsMatch(txtHoTen.Text, rgxTen, RegexOptions.IgnoreCase);

            if (dateNgayTra.Value < DateTime.Now.Date)
            {
                errorNgay.SetError(dateNgayTra, "Thời gian lựa chọn không phù hợp..");
            }
            else
            {
                errorNgay.Clear();
            }
            if (!mSDT)
            {
                errorDienThoai.SetError(txtDienThoai, "Số điện thoại trống hoặc không đúng.");
            }
            else
            {
                errorDienThoai.Clear();
            }
            if (!mCMND)
            {
                errorCMND.SetError(txtCMND, "CMND trống hoặc không đúng.");
            }
            else
            {
                errorCMND.Clear();
            }
            if (!mTen)
            {
                errorHoTen.SetError(txtHoTen, "Họ tên nhập chưa đúng.");
            }
            else
            {
                errorHoTen.Clear();
            }

            if (tinhTrang.tblTinhTrang.CurrentRow.Cells[4].Value.ToString().Contains("Đã đặt") ||
                tinhTrang.tblTinhTrang.CurrentRow.Cells[4].Value.ToString().Contains("Đang thuê"))
            {
                MessageBox.Show("Phòng chọn không cho phép đặt phiếu mới.");
            }

            else if (mSDT && mCMND && mTen &&
                     (!tinhTrang.tblTinhTrang.CurrentRow.Cells[4].Value.ToString().Contains("Đã đặt") ||
                      !tinhTrang.tblTinhTrang.CurrentRow.Cells[4].Value.ToString().Contains("Đang thuê")) &&
                     dateNgayTra.Value >= DateTime.Now.Date)
            {
                bool themKhach = kh.themKhachHang(cmnd, hoten, dienthoai);
                bool themPhieu = tp.themPhieuThue(cmnd, manv, phong, ngaythue, ngaydi);
                if (themKhach && themPhieu)
                {
                    p.doiTrangThaiPhong(phong, Option.P_DANG_THUE);
                    tinhTrang.hienThiDanhSachPhong();
                    ds.hienThiThongTin();
                    MessageBox.Show("Thuê phòng thành công");
                    ds.Enabled = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Xảy ra lỗi, vui lòng kiểm tra lại...");
                }
            }
        }