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); }
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; }
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(); }
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!"); } }
private void btDatSan_Click(object sender, EventArgs e) { HoaDonBUS.addHoaDon(new HoaDon(0, DateTime.Now, tbTenKhachHang.Text, false)); HoaDon hoaDon = HoaDonBUS.getLastHoaDon(); SanBong sanBong = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]]; PhieuDatSanBongBUS.addPhieuDatSanBong(new PhieuDatSanBong(0, sanBong.id, dtpGioVao.Value, (int)nudSoGio.Value, (double)nudDonGia.Value, hoaDon.id)); updateListViewSan(); if (lvChiTietHoaDon.Items.Count > 0) { foreach (MatHang matHang in matHangChoList) { ChiTietHoaDonBUS.addChiTietHoaDon(new ChiTietHoaDon(0, hoaDon.id, matHang.id, matHang.soLuong, matHang.donGia)); } } btDatSan.Enabled = false; }
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(); }