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 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; }