private void btn_timkiem_Click(object sender, EventArgs e) { Clearr(); if (nhapid.Text != "") { int id = Convert.ToInt32(nhapid.Text); eDVD dvd = dVDBUL.FindDVDById(id); if (dvd != null) { eTieuDe tieuDe = tieuDe = tieuDeBUL.Find(dvd.id_TieuDe); eTheLoai theLoai = tieuDeBUL.FindTheLoaiById(tieuDe.id_TieuDe); txt_tendia.Text = tieuDe.tenTieuDe; txtgiathue.Text = theLoai.giaThue.ToString(); txttgthue.Text = theLoai.thoiGianThue.ToString(); txt_iddia.Text = dvd.id_DVD.ToString(); txt_tragthai.Text = dvd.trangThai.ToString(); btn_timkiem.Text = " Tìm kiếm"; } else { MessageBox.Show("Không có đĩa trong danh sách"); } } else { MessageBox.Show("Nhap ma can tim"); } }
private void btnCheck_Click(object sender, EventArgs e) { if (!txtIDdia.Text.ToString().Trim().Equals("")) { eDVD dvd = dVDBUL.FindDVDById(Convert.ToInt32(txtIDdia.Text.ToString())); if (dvd != null) { this.Size = new Size(319, 137); lblTieuDe1.Visible = true; lblTrangThai1.Visible = true; lblTieuDe.Visible = true; lblTrangThai.Visible = true; lblTieuDe.Text = tieuDeBUL.Find(dvd.id_TieuDe).tenTieuDe; if (dvd.trangThai == -1) { lblTrangThai.Text = "Trên kệ"; } else if (dvd.trangThai == 0) { this.Size = new Size(319, 223); grCho.Visible = true; grThue.Visible = false; lblTrangThai.Text = "Đang giữ"; ePhieuDatTruoc phieu = phieuDatTruocBUL.GetPhieuDatTruocByID(dvd.id_DVD); lblNguoiDatTrc.Text = khachHangBUL.Find(phieu.id_KhachHang).tenKhachHang; lblNgayLay.Text = phieu.ngayDatTruoc.ToShortDateString(); } else { this.Size = new Size(319, 223); grThue.Visible = true; grCho.Visible = false; lblTrangThai.Text = "Đang thuê"; ePhieuThueTra phieu = phieuThueTraBUL.getPhieuThueTraByIdDVD(dvd.id_DVD); if (phieu != null) { lblNguoiThue.Text = khachHangBUL.Find(phieu.id_KhachHang).tenKhachHang; int tgianThue = theLoaiBUL.GetTheLoaiByID(tieuDeBUL.Find(dvd.id_TieuDe).id_TheLoai).thoiGianThue; DateTime ngayTraDuKien = phieu.ngayThue.AddDays(tgianThue); lblDenHan.Text = ngayTraDuKien.ToShortDateString(); } } } else { this.Size = new Size(319, 79); grThue.Visible = false; grCho.Visible = false; lblTieuDe1.Visible = false; lblTrangThai1.Visible = false; lblTieuDe.Visible = false; lblTrangThai.Visible = false; MessageBox.Show("Không tồn tại DVD"); return; } } }
private void UpdateDVDDatTruoc() { List <ePhieuDatTruoc> list = phieuDatTruocBUL.getPhieuDatTruocs(); foreach (ePhieuDatTruoc item in list) { foreach (eDVD dVD in listDVD) { if (item.id_TieuDe == dVD.id_TieuDe) { eKhachHang kh = khBul.Find(item.id_KhachHang); eTieuDe tieuDe = tieuDeBUL.Find(dVD.id_TieuDe); string text = "Khách hàng: " + kh.tenKhachHang + "\nSố điện thoại: " + kh.soDT + "\n Muốn tiếp tục giữ lại DVD có tiêu đề: " + tieuDe.tenTieuDe + "\n Hãy thông báo với khách hàng"; DialogResult dialogResult = MessageBox.Show(text, "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { phieuDatTruocBUL.Update(item.id_PhieuDatTruoc, dVD.id_DVD); MessageBox.Show("Đã giữ DVD lại cho khách hàng"); } else if (dialogResult == DialogResult.No) { phieuDatTruocBUL.DeletePDTByIDPhieu_IDTieuDe(item.id_PhieuDatTruoc); MessageBox.Show("Huỷ yêu cầu đặt trước dvd của khách hàng thành công"); } } } } }
private DataTable ConvertListToDataTable(List<eDVD> list) { DataTable table = new DataTable(); table.Columns.Add("id_DVD", typeof(int)); table.Columns.Add("id_TieuDe", typeof(int)); table.Columns.Add("string_TieuDe", typeof(string)); table.Columns.Add("gia", typeof(string)); table.Columns.Add("thoigian", typeof(string)); foreach (eDVD item in list) { eTheLoai theLoai = tieuDeBUL.FindTheLoaiById(tieuDeBUL.Find(item.id_TieuDe).id_TheLoai); table.Rows.Add(item.id_DVD, item.id_TieuDe, tieuDeBUL.GetTieuDeByID(item.id_TieuDe).tenTieuDe, theLoai.giaThue, theLoai.thoiGianThue); } return table; }