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