static void Menu() { string[] mn = { " 1.Nhap danh sach hoc sinh tu tep hocsinh.txt va lop.txt", " 2.Hien thi danh sach hoc sinh theo lop", " 3.Quan Ly lop hoc", " 4.Them hoc sinh ", " 5.Sua thong tin hoc sinh ", " 6.Xoa thong tin hoc sinh ", " 7.Tim kiem hoc sinh ", " 8.Sap xep hoc sinh theo diem ", " 9.Thong Ke ", " 0.Ket thuc " }; do { Console.Clear(); foreach (string con in mn) { Console.WriteLine("\t" + con); } Console.Write("\t\tBan chon:"); int chon; chon = int.Parse(Console.ReadLine()); switch (chon) { case 1: dshs.doctep(); dsl.doctep(); Console.Write("Ban vua doc DL xong!"); Console.ReadKey(); break; case 2: dshs.hienthi(); Console.ReadKey(); break; //XL??? case 3: dsl.Insert(); Console.ReadKey(); break; case 4: dshs.Insert(); Console.ReadKey(); break; case 5: Console.ReadKey(); break; case 6: Console.ReadKey(); break; case 7: dshs.Search(); Console.ReadKey(); break; case 8: dshs.Sort(); dsl.Sortkhoi(); Console.ReadKey(); break; case 9: dshs.ThongkeTyLe(); dsl.Thongke(); Console.ReadKey(); break; case 0: Environment.Exit(0); break; } }while(true); }
public void Insert() { Nodehs tg = new Nodehs(); tg.hs = new HocSinh(); tg.link = null; //??Kiem tra ma lop da co chua? Neu chua=> bao loi; neu co: 1 ghi them SV vao tep hocsinh.txt; cap nhat siso tep Lop.txt? //TT HS hop le thi them vao DS HS va ghi vao tep Nodehs tghs = new Nodehs(); danhsachlop dsl = new danhsachlop(); dsl.doctep(); NodeL tgl = new NodeL(); int mahs; string malop; bool ok1; bool ok2;//SV có mã lớp chưa có do { ok1 = true; Console.Write("Nhap Ma hoc sinh: "); mahs = int.Parse(Console.ReadLine()); tghs = this.ds; while (tghs != null)//XL { if (tghs.hs.mahs == mahs) { ok1 = false; } tghs = tghs.link; } if (!ok1) { Console.WriteLine("DL ko hop le: Ma HS da co! Moi nhap lai"); } } while (!ok1); tg.hs.mahs = mahs; tg.hs.nhap1(); do { ok2 = false; Console.Write("Nhap ma lop: "); malop = Console.ReadLine(); tgl = dsl.ds; while (tgl != null) { if (string.Compare(tgl.L.malop, malop) == 0) { ok2 = true; break; } tgl = tgl.link; } if (!ok2) { Console.WriteLine("DL ko hop le: Ma lop chua co! Moi nhap lai"); } } while (!ok2);//XL tg.hs.malop = String.Copy(malop); ghitep(tg); //Cap nhat si so tep Lop.txt tg.link = ds; ds = tg; }