public static Sach.sach Themsachmoi(Sach.listsach listSach) { Console.WriteLine("Them dau sach moi vao thu vien: "); Sach.sach book = Nhapsach(listSach, "Them sach vao danh sach"); Console.WriteLine("Them sach thanh cong! \n"); return(book); }
public static Sach.sach Nhapsach(Sach.listsach a, string ghichu) { Console.WriteLine(ghichu); Sach.sach book; Console.Write("Ma sach_ISBN: "); nhapmasach: string isbn = Console.ReadLine(); if (FindBook.Tramasach(a, isbn) == -1) { book.Masach_ISBN = isbn; } else { Console.WriteLine("Sach da ton tai."); Console.Write("Nhap lai ma sach ISBN: "); goto nhapmasach; } Console.Write("Ten sach: "); book.Tensach = Console.ReadLine(); Console.Write("Tac gia: "); book.Tacgia = Console.ReadLine(); Console.Write("Nha xuat ban: "); book.Nhaxuatban = Console.ReadLine(); Console.Write("Gia sach: "); book.Giasach = int.Parse(Console.ReadLine()); nhaploaisach: Console.WriteLine("(Sach Tieng Viet - 0; Sach Ngoai van - 1)"); Console.Write("Loai sach: "); int k; k = int.Parse(Console.ReadLine()); if (k == 0) { book.Loaisach = "Sach Tieng Viet"; } else if (k == 1) { book.Loaisach = "Sach Ngoai van"; } else { Console.WriteLine("Loai sach khong ton tai moi nhap lai"); goto nhaploaisach; } Console.WriteLine(book.Loaisach); Console.Write("So luong: "); book.Tongsoluong = int.Parse(Console.ReadLine()); book.Slmuon = 0; book.Slhientai = book.Tongsoluong; return(book); }
public static Sach.sach Timsach(Sach.listsach a) { Console.WriteLine("Nhap ma sach can tra cuu: "); string MaTam = Console.ReadLine(); int vitri = Tramasach(a, MaTam); if (vitri >= 0) { return(a.dssach[vitri]); } else { Console.WriteLine("Sach khong ton tai."); return(a.dssach[0]); } }
public static int Tramasach(Sach.listsach dssach, string Masach) { if (dssach.dssach == null) { return(-1); } for (int i = 0; i < dssach.dssach.Length; i = i + 1) { string masach = dssach.dssach[i].Masach_ISBN; if (string.Compare(masach, Masach) == 1) { return(i); } else { continue; } } return(-1); }
public static void Xoasach(Sach.listsach a) { string MS; int vitri; Console.WriteLine("XOA THONG TIN SACH"); Console.Write("Nhap vao Ma so cua sach:"); MS = Console.ReadLine(); vitri = FindBook.Tramasach(a, MS); if (vitri == -1) { Console.WriteLine("Khong co ma sach nay."); } else { int n = a.dssach.Length; for (int i = vitri; i <= n; i++) { a.dssach[i] = a.dssach[i + 1]; n--; } } }
static void Main(string[] args) { Sach.listsach a = new Sach.listsach(); a = AddListBook.Nhaplistsach("Danh sach sach trong thu vien"); int n; do { chuongtrinhquanli: Console.WriteLine(" --- CHUONG TRINH QUAN LY THU VIEN --- \n"); Console.WriteLine("Danh sach cac chuc nang: \n"); Console.WriteLine("1.Them sach"); Console.WriteLine("2.Xoa sach"); Console.WriteLine("3.Sua sach"); Console.WriteLine("4.Tim kiem sach"); Console.WriteLine("5.Them doc gia"); Console.WriteLine("6.Xoa doc gia"); Console.WriteLine("7.Sua doc gia"); Console.WriteLine("8.Tim kiem doc gia"); Console.WriteLine("9.Lap phieu muon sach"); Console.WriteLine("10.Lap phieu tra sach"); Console.WriteLine("11.Liet ke danh sach muon sach tre han"); Console.WriteLine("0.Thoat"); Console.Write("Vui long chon chuc nang can thuc hien: "); n = int.Parse(Console.ReadLine()); switch (n) { case 0: System.Environment.Exit(0); break; case 1: Sach.sach NewBook = AddBook.Themsachmoi(a); Console.WriteLine(NewBook.Tacgia); a.dssach[a.dssach.GetUpperBound(0)] = NewBook; break; case 2: DelBook.Xoasach(a); break; // case 3: // Sachuasach(a, n); // break; // case 4: // Inchitietsach(a, n, MS); // break; // case 5: // Themdocgia(b, n); // break; // case 6: // Xoadocgia(b, n); // break; // case 7: // Suadocgia(b, n); // break; // case 8: // Inchitietdocgia(b, n, MDG); // break; default: Console.WriteLine("Vui long nhap lua chon phu hop!"); break; } Sach.ViewListsach(a); goto chuongtrinhquanli; }while (n >= 12); //Console.ReadKey(); }