示例#1
0
        private void btCapNhat_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            HoaDon          hoaDon          = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);
            int             pos;

            foreach (MatHang matHang in matHangChoList)
            {
                pos = kiemTraChiTietHoaDon(matHang.id);
                if (pos == -1)
                {
                    ChiTietHoaDonBUS.addChiTietHoaDon(new ChiTietHoaDon(0, hoaDon.id, matHang.id, matHang.soLuong, matHang.donGia));
                }
                else
                {
                    ((ChiTietHoaDon)chiTietHoaDonList[pos]).soLuong = matHang.soLuong;
                    ChiTietHoaDonBUS.updateChiTietHoaDon((ChiTietHoaDon)chiTietHoaDonList[pos]);
                }
            }
            hoaDon.tenKhachHang = tbTenKhachHang.Text;
            HoaDonBUS.updateHoaDon(hoaDon);
            phieuDatSanBong.thoiGianBatDau = dtpGioVao.Value;
            phieuDatSanBong.soGioDat       = (int)nudSoGio.Value;

            PhieuDatSanBongBUS.updatePhieuDatSanBong(phieuDatSanBong);
        }
示例#2
0
        private void btThuTien_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            HoaDon          hoaDon          = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);

            hoaDon.daThanhToan = true;
            HoaDonBUS.updateHoaDon(hoaDon);
            btThuTien.Enabled = false;
        }
示例#3
0
        private void btDoiSan_Click(object sender, EventArgs e)
        {
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            SanBong         sanBongDoi      = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];

            phieuDatSanBong.idSanBong = sanBongDoi.id;


            if (!PhieuDatSanBongBUS.updatePhieuDatSanBong(phieuDatSanBong))
            {
                MessageBox.Show("That Bai");
            }
            this.Close();
        }
示例#4
0
        private void btHuySan_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);

            if (HoaDonBUS.deleteHoaDon(phieuDatSanBong.idHoaDon))
            {
                statusBarAddText("Hủy sân thành công");
                updateListViewSan();
            }
            else
            {
                MessageBox.Show("Không thể hủy sân!" + lvSanBong.SelectedItems[0].Text, "Lỗi khi hủy sân",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                statusBarAddText("Lỗi khi hủy sân!");
            }
        }
示例#5
0
        private void lvSanBong_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvSanBong.SelectedItems.Count > 0)
            {
                tbTenSan.Text       = (lvSanBong.SelectedItems[0]).Text;
                nudDonGia.Value     = (decimal)((SanBong)sanBongList[lvSanBong.SelectedIndices[0]]).donGia;
                btSuaSan.Enabled    = true;
                btXoaSan.Enabled    = true;
                tabTinhTien.Enabled = true;

                SanBong sanBong = ((SanBong)sanBongList[lvSanBong.SelectedIndices[0]]);
                if (sanBong.dangThue)
                {
                    PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
                    tbTenKhachHang.Text = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon).tenKhachHang;
                    dtpGioVao.Value     = phieuDatSanBong.thoiGianBatDau;
                    nudSoGio.Value      = phieuDatSanBong.soGioDat;
                    dtpGioRa.Value      = phieuDatSanBong.thoiGianBatDau.AddHours((double)phieuDatSanBong.soGioDat);
                    btDatSan.Enabled    = false;
                    loadLvChiTietHoaDon(phieuDatSanBong.idHoaDon);
                    btDoiSan.Enabled  = true;
                    btCapNhat.Enabled = true;
                    btHuySan.Enabled  = true;
                    HoaDon hoaDon = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);
                    if (hoaDon.daThanhToan)
                    {
                        btThuTien.Enabled = false;

                        btDoiSan.Enabled          = false;
                        btCapNhat.Enabled         = false;
                        gbMatHangTinhTien.Enabled = false;

                        lbThanhToan.Text = "ĐÃ THANH TOÁN";
                    }
                    else
                    {
                        btThuTien.Enabled         = true;
                        lbThanhToan.Text          = "CHƯA THANH TOÁN";
                        btDoiSan.Enabled          = true;
                        btCapNhat.Enabled         = true;
                        gbMatHangTinhTien.Enabled = true;
                    }
                }
                else
                {
                    btDatSan.Enabled = true;
                    matHangChoList.Clear();
                    btDoiSan.Enabled  = false;
                    btCapNhat.Enabled = false;
                    btHuySan.Enabled  = false;
                    btThuTien.Enabled = false;


                    gbMatHangTinhTien.Enabled = true;
                }
                tbTenSanTT.Text = sanBong.tenSan;
            }
            else
            {
                tbTenSan.Text       = "";
                btSuaSan.Enabled    = false;
                btXoaSan.Enabled    = false;
                tabTinhTien.Enabled = false;
                tbTenSanTT.Text     = "";
                tbTenKhachHang.Text = "";
                nudSoGio.Value      = 0;
                dtpGioVao.Value     = DateTime.Now;
                dtpGioRa.Value      = DateTime.Now;
                tbTienSan.Text      = "";
                tbTienHang.Text     = "";
                nudGiamGia.Value    = 0;
                nudTienKhac.Value   = 0;
                lvChiTietHoaDon.Items.Clear();
                nudDonGia.Value  = 0;
                btDoiSan.Enabled = false;
                lbThanhToan.Text = "CHƯA THANH TOÁN";
            }
            loadTinhTien();
        }