示例#1
0
 private void frmOderDichVu_Load(object sender, EventArgs e)
 {
     cmbMaPhong.DataSource    = OderDichVuBUS.LoadDanhSachMaPhong();
     cmbMaPhong.DisplayMember = "MaPhong";
     cmbDichVu.DataSource     = OderDichVuBUS.LoadDanhSachDichVu();
     cmbDichVu.DisplayMember  = "TenDichVu";
 }
示例#2
0
        private void btnOder_Click(object sender, EventArgs e)
        {
            List <OderDichVuDTO> lst = new List <OderDichVuDTO>();
            string tendichvu         = cmbDichVu.Text;

            lst = OderDichVuBUS.LayMaDichVuDangKi(tendichvu);
            OderDichVuDTO infor = new OderDichVuDTO();

            infor.MaPhong  = Convert.ToInt32(cmbMaPhong.Text);
            infor.SoLuong  = Convert.ToInt32(txtSoLuong.Text);
            infor.MaDichVu = lst[0].MaDichVu;
            if (OderDichVuBUS.DangKiDichVu(infor) == true)
            {
                MessageBox.Show("Đăng kí dịch vụ thành công", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Lỗi hệ thống hoặc chưa nhập số lượng", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            bool    success = true;
            BillDTO infor   = LayThongTinKhachHangThanhToan();

            if (BillBUS.LapHoaDon(infor))
            {
                for (int i = 0; i < dgvHoaDon.RowCount; i++)
                {
                    BillDTO inforHD = ThongTinHoaDonThanhToan(i);
                    if (!(BillBUS.LapChiTietHoaDon(infor, inforHD)))
                    {
                        success = false;
                        MessageBox.Show("Không lập được hóa đơn chi tiết thứ " + i + "", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                    List <CustomerDTO> lstkh = new List <CustomerDTO>();
                    int?maphieuthue          = inforHD.MaPhieuThue;
                    lstkh = CustomerBUS.LayMaKhachHangCanXoa(maphieuthue);
                    if (!(BillBUS.XoaChiTietPhieuThue(inforHD)))
                    {
                        success = false;
                        MessageBox.Show("Không xóa được chi tiết phiếu thuê ", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                    int dem = lstkh.Count();
                    for (int j = 0; j < dem; j++)
                    {
                        CustomerDTO id = new CustomerDTO();
                        id.MaKH = lstkh[j].MaKH;
                        if (!(CustomerBUS.XoaKhachHang(id)))
                        {
                            success = false;
                            MessageBox.Show("Không xóa được khách hàng ", "Lỗi", MessageBoxButtons.OK,
                                            MessageBoxIcon.Stop);
                        }
                    }
                    if (!(BillBUS.XoaPhieuThue(inforHD)))
                    {
                        success = false;
                        MessageBox.Show("Không xóa được phiếu thuê ", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                    if (!(RoomBUS.ThietLapTrangThaiPhongBanDau(inforHD)))
                    {
                        success = false;
                        MessageBox.Show("Không cập nhập được tình trạng phòng ", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                    if (!(OderDichVuBUS.XoaDichVuPhongDK(inforHD)))
                    {
                        success = false;
                        MessageBox.Show("Không xóa được dich vụ phòng đã đăng kí ", "Lỗi", MessageBoxButtons.OK,
                                        MessageBoxIcon.Stop);
                    }
                }

                if (success == true)
                {
                    success = false;
                    MessageBox.Show("Lập hóa đơn thanh toán thành công ", "Thông báo", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    for (int k = 0; k < dgvHoaDon.RowCount; k++)
                    {
                        dgvHoaDon.Rows.RemoveAt(k);
                        k      = -1;
                        numRow = 0;
                    }
                    frmTraPhong_Load(sender, e);
                    DialogResult dialog = MessageBox.Show("Bạn có muốn in hóa đơn không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialog == DialogResult.Yes)
                    {
                        ThietLapButton(false);
                    }
                    txtTenKhachHang.Text = "";
                    txtDiaChi.Text       = "";
                    txtPhiDichVu.Text    = "";
                    txtPhuThu.Text       = "";
                    txtSoNgayThue.Text   = "";
                    txtHeSo.Text         = "";
                    txtDonGia.Text       = "0";
                    txtTongTien.Text     = "0";
                    cmbMaPhong.Text      = "";
                }
            }
            else
            {
                MessageBox.Show("Không lập hóa đơn thanh toán được ", "Lỗi", MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
            }
            ThietLapButton(false);
        }
        private void cmbMaPhong_SelectedIndexChanged(object sender, EventArgs e)
        {
            BillDTO infor = new BillDTO();

            infor.MaPhong = int.Parse(cmbMaPhong.Text);
            List <BillDTO> lst = new List <BillDTO>();

            lst = BillBUS.LayThongTinPhongThue(infor);
            //txtDonGiaPhong.Text = lst[0].DonGia.ToString();
            txtDonGia.Text       = string.Format("{0:0,0}", lst[0].DonGia);
            txtTenKhachHang.Text = lst[0].TenKhachHang.ToString();
            txtDiaChi.Text       = lst[0].DiaChi.ToString();
            int maphieuthue = lst[0].MaPhieuThue.Value;

            infor.NgayBatDauThue = Convert.ToDateTime(lst[0].NgayBatDauThue.ToString());

            BillBUS.TinhSoNgayDaThue(infor);
            lst = BillBUS.LaySoNgayDaThue();
            txtSoNgayThue.Text = lst[0].SoNgayDaThue.ToString();
            if (Convert.ToInt32(txtSoNgayThue.Text) < 0)
            {
                btnThanhToan.Enabled = false;
                MessageBox.Show("Chưa thể thanh toán khách hàng này", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (txtSoNgayThue.Text == "0")
            {
                txtSoNgayThue.Text = "1";
            }
            int num = BillBUS.LaySoLuongKhach(maphieuthue);

            lst = BillBUS.LayKhachNuocNgoai();
            int kpt = lst[0].KhachPTThu.Value;
            int kng = lst[0].SLKhachNG.Value;

            if (num >= kpt)
            {
                lst            = BillBUS.TinhPhuThu(num);
                txtPhuThu.Text = lst[0].PhuThu.ToString();
            }
            else
            {
                txtPhuThu.Text = "0";
            }
            int nc = BillBUS.DemSoLuongKhachNuocNgoai(infor);

            if (nc >= kng)
            {
                lst          = BillBUS.TinhHeSo();
                txtHeSo.Text = lst[0].HeSo.ToString();
            }
            else
            {
                txtHeSo.Text = "0";
            }
            decimal phidichvu = 0;
            int     numdv     = OderDichVuBUS.LaySoLuongDichVuDK(infor.MaPhong);

            if (numdv == 0)
            {
                txtPhiDichVu.Text = "0";
            }
            else
            {
                for (int i = 0; i < numdv; i++)
                {
                    List <OderServiceDTO> lst2   = new List <OderServiceDTO>();
                    OderServiceDTO        infor2 = new OderServiceDTO();
                    lst2            = OderDichVuBUS.DanhSachDichVuDK(infor.MaPhong);
                    infor2.MaDichVu = lst2[i].MaDichVu;
                    infor2.SoLuong  = lst2[i].SoLuong;
                    List <ServiceDTO> lst3 = new List <ServiceDTO>();
                    lst3 = ServiceBUS.LayDonGia(infor2.MaDichVu);
                    ServiceDTO dongiadv = new ServiceDTO();
                    dongiadv.DonGia = lst3[0].DonGia;
                    decimal tiendv = dongiadv.DonGia;
                    phidichvu += infor2.SoLuong * tiendv;
                }
                txtPhiDichVu.Text = string.Format("{0:0,0  }", phidichvu);
            }


            bool flag = true;

            for (int i = 0; i < dgvHoaDon.RowCount; i++)
            {
                if (dgvHoaDon.Rows[i].Cells["colMaPhong"].Value.ToString() != null)
                {
                    if (dgvHoaDon.Rows[i].Cells["colMaPhong"].Value.ToString() == cmbMaPhong.Text)
                    {
                        btnThemHoaDon.Enabled = false;
                        flag = false;
                        break;
                    }
                }
            }

            if (flag == true)
            {
                btnThemHoaDon.Enabled = true;
            }
        }