void XuatSachTheoNhaXuatBan() { try { string path = @"\NhaXuatBan.txt"; listSach.DataSource = null; textTotal.Clear(); NhaXuatBans = NhaXuatBan.DocDanhSachNhaXuatBanArr(path); dsChuyenMuc.DataSource = null; dsChuyenMuc.DisplayMember = "TenNhaXuatBan"; dsChuyenMuc.ValueMember = "NhaXuatBanID"; dsChuyenMuc.DataSource = NhaXuatBans.ToList(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static NhaXuatBan[] DocDanhSachNhaXuatBanArr(string path) { try { string[] arr = File.ReadAllLines(path); NhaXuatBan[] nxb = new NhaXuatBan[arr.Length]; for (int i = 0; i < arr.Length; i++) { string[] rows = arr[i].Split('|'); nxb[i] = new NhaXuatBan { NhaXuatBanID = rows[0], TenNhaXuatBan = rows[1], DiaChi = rows[2], SoDienThoai = rows[3] }; } return(nxb); } catch (Exception ex) { throw new Exception(ex.Message); } }