using System.Collections.Generic;
public delegate void OnAddressPrint(string address);
static event OnAddressPrint EventAddressPrint = null;
static List<Parent> parentList = new List<Parent>();
static List<Student> studentList = new List<Student>();
public static void Main()
choose = int.Parse(Console.ReadLine());
Console.WriteLine("Nhập số lượng phụ huynh muốn thêm:");
int N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++)
Console.WriteLine("Nhập thôngg tin phụ huynh thứ: ", parentList.Count + i + 1);
Parent parent = new Parent();
Console.WriteLine("Nhập số lượng sinh viên muốn thêm:");
int M = int.Parse(Console.ReadLine());
for (int i = 0; i < M; i++)
Console.WriteLine("Nhập thônng tin sinh viên thứ: ", studentList.Count + i + 1);
Student student = new Student();
Console.WriteLine("Nhập mã phụ huynh:");
student.parentKey = Console.ReadLine();
foreach (Parent parent in parentList)
if (parent.parentKey == student.parentKey)
if (check == 0) Console.WriteLine("Không có phụ huynh hợp lệ, yêu cầu nhập lại!!");
studentList.Add(student);
Console.WriteLine("Nhập tên phụ huynh:");
string name = Console.ReadLine();
foreach (Parent parent in parentList)
Console.WriteLine("Phụ huynh có tên {0} và mã Phụ huynh la {1}, có các sinh viên là:", parent.name, parent.parentKey);
foreach (Student student in studentList)
if (student.parentKey == parent.parentKey)
if (check == 0) Console.WriteLine("Không có sinh viên nào");
Console.WriteLine("Nhập mã sinh viên:");
string rollno = Console.ReadLine();
foreach (Student std in studentList)
if (std.rollno == rollno)
Console.WriteLine("Sinh viên có tên {0} và mã sinh viên la {1}, có phụ huynh là:", std.name, std.rollno);
foreach (Parent p in parentList)
if (std.parentKey == p.parentKey)
if (check == 0) Console.WriteLine("Khônng có phụ huynh nào");
Console.WriteLine("Địa chỉ sinh viên cần tìm:");
string address = Console.ReadLine();
EventAddressPrint = showInfo;
EventAddressPrint(address);
Console.WriteLine("Tam biệt!!");
Console.WriteLine("Nhập sai!!");
private static void showMenu()
Console.WriteLine("\nCHƯƠNG TRÌNH QUẢN LÝ SINH VIÊN C#");
Console.WriteLine("*********************************MENU************************************");
Console.WriteLine("** 1.Nhập số lượng phụ huynh **");
Console.WriteLine("** 2.Nhập số lượng sinh viên **");
Console.WriteLine("** 3.Nhập tên phụ huynh -> tìm sinh viên **");
Console.WriteLine("** 4.Nhập mã sinh viên -> tim phụ huynh **");
Console.WriteLine("** 5.In thông tin sinh viên tìm theo delegate **");
Console.WriteLine("** 6.Thóat **");
Console.WriteLine("*************************************************************************");
private static void showInfo(string address)
foreach (Student student in studentList)
if (student.address == address)
if (check == 0) Console.WriteLine("Không có sinh viên nào hợp lệ!!");
public string name { get; set; }
public string address { get; set; }
public string phoneNum { get; set; }
public string parentKey { get; set; }
public virtual void input()
Console.WriteLine("Nhập tên phụ huynh:");
name = Console.ReadLine();
Console.WriteLine("Nhập địa chỉ phụ huynh:");
address = Console.ReadLine();
Console.WriteLine("Nhập số điện thoại:");
phoneNum = Console.ReadLine();
Console.WriteLine("Nhập mã phụ huynh:");
parentKey = Console.ReadLine();
public virtual void display()
Console.WriteLine("Tên phụ huynh: {0},Địa chỉ: {1}, SDT: {2}, Mã phụ huynh: {3}", name, address, phoneNum, parentKey);
public int age { get; set; }
public string rollno { get; set; }
public string email { get; set; }
public override void input()
Console.WriteLine("Nhập tên sinh viên:");
name = Console.ReadLine();
Console.WriteLine("Tuổi:");
age = int.Parse(Console.ReadLine());
Console.WriteLine("Mã sinh viên:");
rollno = Console.ReadLine();
Console.WriteLine("Nhập địa chỉ sinh viên:");
address = Console.ReadLine();
Console.WriteLine("Nhâp email sinh viên:");
email = Console.ReadLine();
Console.WriteLine("Nhập số điện thoại:");
phoneNum = Console.ReadLine();
public override void display()
Console.WriteLine("Tên sinh viên: {0}, Tuổi: {1}, MSV: {2}, Địa chỉ: {3}, Email: {4}, SDT: {5}, Mã phụ huynh: {6}", name, age, rollno, address, email, phoneNum, parentKey);