//Update phí trễ public void updateLateFee(int idDvd, int idOrder, int fee) { bRentOrderDetail = new bChiTietPhieuMuon(); eChiTietPhieuMuon item = new eChiTietPhieuMuon(); item.IdDvd = idDvd; item.IdPhieuMuon = idOrder; item.PhiTre = fee; item.NgayTra = DateTime.Now; item.TinhTrang = false; bRentOrderDetail.updateChiTietPhieuMuon(item); }
private void dgvListNo_DoubleClick(object sender, EventArgs e) { bRentOrderDetail = new bChiTietPhieuMuon(); eChiTietPhieuMuon item = new eChiTietPhieuMuon(); item.IdPhieuMuon = Convert.ToInt32(dgvListNo.CurrentRow.Cells[0].Value); item.IdDvd = Convert.ToInt32(dgvListNo.CurrentRow.Cells[1].Value); item.PhiTre = 0; item.NgayTra = bRentOrderDetail.getChiTietPhieuMuon(item.IdPhieuMuon, item.IdDvd).NgayTra; item.TinhTrang = true; DialogResult dialogResult1 = MessageBox.Show("Bạn muốn trả nợ đĩa" + dgvListNo.CurrentRow.Cells[0].Value.ToString() + "không? :D", "Thông báo phí trễ", MessageBoxButtons.YesNo); if (dialogResult1 == DialogResult.Yes) { bRentOrderDetail.updateChiTietPhieuMuon(item); MessageBox.Show("Bạn đã trả nợ đĩa " + item.IdDvd + "! :D"); } }
private void btnTraHet_Click(object sender, EventArgs e) { if (dgvListNo.Rows.Count == 0) { MessageBox.Show("Bạn không có nợ để trả! :D"); return; } bRentOrderDetail = new bChiTietPhieuMuon(); eChiTietPhieuMuon item = new eChiTietPhieuMuon(); foreach (DataGridViewRow dgvr in dgvListNo.Rows) { item.IdPhieuMuon = Convert.ToInt32(dgvr.Cells[0].Value); item.IdDvd = Convert.ToInt32(dgvr.Cells[1].Value); item.PhiTre = 0; item.NgayTra = DateTime.Now; item.TinhTrang = true; bRentOrderDetail.updateChiTietPhieuMuon(item); } MessageBox.Show("Bạn đã trả mọi nợ đĩa! :D"); }
private void btnTra_Click(object sender, EventArgs e) { if (dgvListTra.RowCount == 0) { MessageBox.Show("Vui lòng nhập DVD cần trả! :D"); txtIdDvdTra.Focus(); return; } bRentOrderDetail = new bChiTietPhieuMuon(); eChiTietPhieuMuon item = new eChiTietPhieuMuon(); bReserve = new bPhieuDatTruoc(); bReserveDetail = new bChiTietPhieuDatTruoc(); foreach (DataGridViewRow dgvr in dgvListTra.Rows) { item.IdPhieuMuon = Convert.ToInt32(dgvr.Cells[1].Value); item.IdDvd = Convert.ToInt32(dgvr.Cells[0].Value); item.PhiTre = bRentOrderDetail.getChiTietPhieuMuon(item.IdPhieuMuon, item.IdDvd).PhiTre - Convert.ToInt32(dgvr.Cells[3].Value); item.NgayTra = DateTime.Now; item.TinhTrang = true; bDVD.updateDvd(new eDvd(item.IdDvd, bDVD.getDvd(item.IdDvd).IdTiltle, "TrenKe", true)); bRentOrderDetail.updateChiTietPhieuMuon(item); int idTitle = bDVD.getDvd(item.IdDvd).IdTiltle; var listReserve = bReserveDetail.getAllChiTietPhieuDatTruoc().Where(n => n.IdTitle == idTitle && n.TrangThai1 == false && n.Huy == true); if (listReserve.Any()) { bDVD.updateDvd(new eDvd(item.IdDvd, bDVD.getDvd(item.IdDvd).IdTiltle, "DatTruoc", true)); int idReserve = listReserve.First().IdPhieuDatTruoc; bReserveDetail.updateChiTietPhieuDatTruoc(new eChiTietPhieuDatTruoc(idReserve, idTitle, true, true)); } } bDVD = new bDvd(); MessageBox.Show("Bạn đã trả thành công! :D"); btnTraFunction_Click(sender, e); }
//Các nút truy xuất Databse #region Các nút truy xuất Databse private void btnXacNhanThongTinThue_Click(object sender, EventArgs e) { if (txtThongTinThue.Text.Length == 0) { if (lbNhapThongTinThue.Text == "Nhập Id khách hàng: ") { MessageBox.Show("Vui lòng nhập id của khách hàng! :D"); txtThongTinThue.Focus(); } else { MessageBox.Show("Vui lòng nhập id của DVD! :D"); txtThongTinThue.Focus(); } } else { if (lbNhapThongTinThue.Text == "Nhập Id khách hàng: ") { int tongTre = 0; string idKhach = txtThongTinThue.Text; bRentOrder = new bPhieuMuon(); bRentOrderDetail = new bChiTietPhieuMuon(); var listPhieuMuon = bRentOrder.getAllPhieuMuon().Where(n => n.IdKhach == int.Parse(txtThongTinThue.Text)).ToList(); foreach (var phieumuon in listPhieuMuon) { int a = phieumuon.IdPhieuMuon; var list = bRentOrderDetail.getAllChiTietPhieuMuon().Where(n => n.IdPhieuMuon == a && n.TinhTrang == true && n.PhiTre > 0); if (list.Count() > 0) { foreach (var item in list) { tongTre += item.PhiTre; } } } if (tongTre > 0) { DialogResult dialogResult = MessageBox.Show("Bạn có phí trễ chưa thanh toán! Bạn có muốn thay toán ngay bây giờ không? :D", "Thông báo phí trễ", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { DialogResult dialogResult1 = MessageBox.Show("Bạn muốn trả hết nợ hay trả từng cái? (Chọn yes để trả hết, no để đến chi tiết! :D", "Thông báo phí trễ", MessageBoxButtons.YesNo); if (dialogResult1 == DialogResult.Yes) { foreach (var phieumuon in listPhieuMuon) { int a = phieumuon.IdPhieuMuon; var list = bRentOrderDetail.getAllChiTietPhieuMuon().Where(n => n.IdPhieuMuon == a && n.TinhTrang == true && n.PhiTre > 0); if (list.Count() > 0) { foreach (var item in list) { bRentOrderDetail.updateChiTietPhieuMuon(new eChiTietPhieuMuon(item.IdPhieuMuon, item.IdDvd, 0, item.NgayTra, item.TinhTrang)); } } } MessageBox.Show("Bạn đã hết nợ! :D"); } else { btnTraTienPhatFuncTion_Click(sender, e); txtKhachNo.Text = idKhach; btnXacNhanNo_Click(sender, e); } } } bCus = new bKhachHang(); try { eKhachHang temp = bCus.getKhachHang(int.Parse(txtThongTinThue.Text)); lbMaKhachHang.Text = temp.IdKhach.ToString(); lbTenKhach.Text = temp.TenKhach; lbDiaChiKhach.Text = temp.DiaChiKhach; lbSoKhach.Text = temp.SdtKhach; lbNhapThongTinThue.Text = "Nhập Id Dvd: "; txtThongTinThue.Clear(); txtThongTinThue.Focus(); } catch (Exception) { MessageBox.Show("Khách hàng không tồn tại! :D"); } } else { bDVD = new bDvd(); if (bDVD.getDvd(int.Parse(txtThongTinThue.Text.ToString())).TinhTrang == "Thue") { MessageBox.Show("DVD đã được thuê! Vui lòng chọn DVD khác! :D"); txtThongTinThue.Clear(); txtThongTinThue.Focus(); } else { try { bTua = new bTitle(); dgvThue.Rows.Add(txtThongTinThue.Text, bTua.getTitle(bDVD.getDvd(int.Parse(txtThongTinThue.Text)).IdTiltle).TenTitle, bTua.getTitle(bDVD.getDvd(int.Parse(txtThongTinThue.Text)).IdTiltle).GiaThue); txtThongTinThue.Clear(); txtThongTinThue.Focus(); } catch (Exception) { MessageBox.Show("Dvd không tồn tại! :D"); } } } } }