public void CapNhat(ArrayList arrayList) { KhoaBanQuyen khoaBanQuyen = Find(arrayList); if (khoaBanQuyen == null) { Console.WriteLine("Không tìm thấy"); } else { Console.WriteLine("Nhập mã khóa bản quyển"); khoaBanQuyen.Makhoa = ChuanHoaKey(Console.ReadLine()); Console.WriteLine("Tên khóa bản quyền"); khoaBanQuyen.Tenkhoa = Console.ReadLine(); Console.WriteLine("Nhập số lượng khóa"); khoaBanQuyen.Soluotkichhoat = int.Parse(Console.ReadLine()); Console.WriteLine("Nhập thể loại"); khoaBanQuyen.Theloai = Console.ReadLine(); Console.WriteLine("Nhập ngày nhập"); khoaBanQuyen.Ngaynhap = Console.ReadLine(); Console.WriteLine("Nhập tình trạng"); khoaBanQuyen.Errorcode = Console.ReadLine(); Console.WriteLine("Cập nhật thành công"); } }
public void Xoa(ArrayList arrayList) { KhoaBanQuyen khoaBanQuyen = Find(arrayList); if (khoaBanQuyen == null) { Console.WriteLine("Không tìm thấy"); } else { arrayList.Remove(khoaBanQuyen); Console.WriteLine("Xóa thành công"); } }
public KhoaBanQuyen Find(ArrayList arrayList) { Hien(arrayList); Console.WriteLine("Nhập từ khóa cần tìm"); string keyword = Console.ReadLine(); KhoaBanQuyen result = null; foreach (KhoaBanQuyen khoaBanQuyen in arrayList) { if (keyword.Equals(khoaBanQuyen.Makhoa)) { result = khoaBanQuyen; } } return(result); }
public void Display(KhoaBanQuyen khoaBanQuyen, ArrayList arrayList) { Console.WriteLine("|{0,-5}|{1,-30}|{2,-15}|{3,-15}|{4,-10}|{5,-15}|{6,-10}|", arrayList.IndexOf(khoaBanQuyen), khoaBanQuyen.Makhoa, khoaBanQuyen.Tenkhoa, khoaBanQuyen.Theloai, khoaBanQuyen.Soluotkichhoat, khoaBanQuyen.Ngaynhap, khoaBanQuyen.Errorcode); }