示例#1
0
        static void Main(string[] args)
        {
            double j = 1;

            Console.WriteLine("--------------------------------------Chuong Trinh Quan Li Sinh Vien--------------------------------------------");
            bool choice = true;

            Console.Write("Nhap so sinh vien cua lop : ");
            int n = int.Parse(Console.ReadLine());

            while (n > 10 || n < 0)
            {
                Console.WriteLine("So sinh vien toi da random hoac tu nhap la 10 hoac ban da nhap so sinh vien khong hop le.");
                Console.Write("Nhap Lai : ");
                n = int.Parse(Console.ReadLine());
            }
            ArrayList ArrSV = new ArrayList(n);

            Console.WriteLine("2 Che do : Random va tu nhap thong tin. ");
            Console.WriteLine("Ban muon random SV hay tu nhap . Neu chon random thi ghi Random neu tu nhap thi ghi gi cung duoc ");
            Console.Write("Lua chon cua ban : ");
            string c_random = Console.ReadLine();

            if (c_random != "Random")
            {
                for (int i = 0; i < n; i++)
                {
                    ArrSV.Add(new SV());
                }
                inputInfo(ArrSV, ref j);
            }
            else
            {
                for (int i = 0; i < n; i++)
                {
                    ArrSV.Add(new SV());
                }
                foreach (SV items in ArrSV)
                {
                    items.RandomSV();
                    items.getMSSV = j;
                    j++;
                }
            }
            do
            {
Menu:
                StartProgam();
                printInfo(ArrSV);
                functionProgam();
                int rule = int.Parse(Console.ReadLine());
                switch (rule)
                {
                case 1:
                    Console.Write("Ban muon sap xep mon nao ");
                    string     subject = Console.ReadLine();
                    Sort_Score sub     = new Sort_Score();
                    sub.inputChoice(subject);
                    ArrSV.Sort(sub);
                    Console.WriteLine("Sau khi sap xep theo Diem {0} :", subject);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 2:
                    Sort_Score sub_2 = new Sort_Score();
                    sub_2.inputChoice("MSSV");
                    ArrSV.Sort(sub_2);
                    Console.WriteLine("Sau khi sap xep theo MSSV :");
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 3:
                    Console.Write("Nhap so Sinh vien muon them : ");
                    int       addSV  = int.Parse(Console.ReadLine());
                    ArrayList ArrAdd = new ArrayList(addSV);
                    for (int i = 0; i < addSV; i++)
                    {
                        ArrAdd.Add(new SV());
                    }
                    inputInfo(ArrSV, ref j);
                    ArrSV.AddRange(ArrAdd);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 4:
                    Console.Write("Nhap so Sinh vien muon xoa : ");
                    string removeSV = Console.ReadLine();
                    ArrSV.Remove(removeSV);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 6:
                    Console.WriteLine("Chuong trinh dang thuc hien xoa man hinh. ");
                    Console.Clear();
                    Console.WriteLine("Man Hinh Da Xoa Xong.");
                    Console.WriteLine("Dang Cap Nhap Lai Du Lieu");
                    Console.WriteLine("Data Update......");
                    Pause();
                    Console.WriteLine("Cap Nhap Data Hoan thanh");
                    Pause();
                    Console.Clear();
                    Console.WriteLine("--------------------------------------Chuong Trinh Quan Li Sinh Vien--------------------------------------------");
                    goto Menu;

                case 7:
                    Console.WriteLine("Ban da chon ket thuc chuong trinh. Cam on vi da su dung chuong trinh");
                    Console.WriteLine("See you again in next time. Bye");
                    choice = false;
                    break;

                default:
                    Console.WriteLine("Lua chon khong hop le ");
                    Endprogam(ref choice);
                    break;
                }
            } while (choice == true);
            Console.Read();
        }
示例#2
0
        static void Main(string[] args)
        {
            double j = 1;

            Console.WriteLine("--------------------------------------Chuong Trinh Quan Li Sinh Vien--------------------------------------------");
            bool choice = true;

            Console.Write("Nhap so sinh vien cua lop : ");
            int n = int.Parse(Console.ReadLine());

            while (n > 10 || n < 0)//Xoa dong nay neu muon nhap hon 10 Sinh vien
            {
                Console.WriteLine("So sinh vien toi da random hoac tu nhap la 10 hoac ban da nhap so sinh vien khong hop le.");
                Console.Write("Nhap Lai : ");
                n = int.Parse(Console.ReadLine());
            }// Va ca dong nay nua nha :))
            List <SV> ArrSV = new List <SV>(n);

            Console.WriteLine("2 Che do : Random va tu nhap thong tin. ");
            Console.WriteLine("Ban muon random SV hay tu nhap . Neu chon random thi ghi Random neu tu nhap thi ghi gi cung duoc ");
            Console.Write("Lua chon cua ban : ");//Che do Random chi tu dong nhap duoc toi da 10 nguoi , neu nhap qua se bi crash
            string c_random = Console.ReadLine();

            if (c_random != "Random")//Tu nhap vao
            {
                for (int i = 0; i < n; i++)
                {
                    ArrSV.Add(new SV());
                }
                inputInfo(ArrSV, ref j);
            }
            else//Random SV
            {
                for (int i = 0; i < n; i++)
                {
                    ArrSV.Add(new SV());
                }
                foreach (SV items in ArrSV)
                {
                    items.RandomSV();
                    items.getMSSV = j;
                    j++;
                }
            }
            do
            {
Menu:
                StartProgam();
                printInfo(ArrSV);
                functionProgam();
                int rule = int.Parse(Console.ReadLine());
                switch (rule)
                {
                case 1:    //Sap xep theo diem
                    Console.Write("Ban muon sap xep mon nao ");
                    string     subject = Console.ReadLine();
                    Sort_Score sub     = new Sort_Score();
                    sub.inputChoice(subject);
                    ArrSV.Sort(sub);
                    Console.WriteLine("Sau khi sap xep theo Diem {0} :", subject);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 2:    //Sap xep theo MSSV
                    Sort_Score sub_2 = new Sort_Score();
                    sub_2.inputChoice("MSSV");
                    ArrSV.Sort(sub_2);
                    Console.WriteLine("Sau khi sap xep theo MSSV :");
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 3:    //Them SV
                    Console.Write("Nhap so Sinh vien muon them : ");
                    int       addSV  = int.Parse(Console.ReadLine());
                    List <SV> ArrAdd = new List <SV>(addSV);
                    for (int i = 0; i < addSV; i++)
                    {
                        ArrAdd.Add(new SV());
                    }
                    inputInfo(ArrAdd, ref j);
                    ArrSV.AddRange(ArrAdd);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 4:    //Xoa sinh vien
                    Console.Write("Nhap ten Sinh vien muon xoa : ");
                    string name_remove = Console.ReadLine();
                    SV     reSV        = ArrSV.Find(new SearchNameSV(name_remove).search);//Tim kiem vi tri SV can xoa trong list ban dau
                    ArrSV.Remove(reSV);
                    printInfo(ArrSV);
                    Endprogam(ref choice);
                    break;

                case 5:    //Sua thong tin SV( p/s : Thong tin Age neu sua o lan dau nhap vao thi duoc nhung lan 2 se bi crash ct)
StartChange:
                    string y_choice = "y";
                    string _choice = "1";
                    do
                    {
                        Console.Write("Nhap ten sinh vien muon sua : ");
                        string name_change = Console.ReadLine();
ThisSVchange:
                        int index = ArrSV.FindIndex(new SearchNameSV(name_change).search);
                        SV chSV = ArrSV.Find(new SearchNameSV(name_change).search);
                        if (_choice != "0")
                        {
                            Console.WriteLine("\rThong tin sinh vien can doi : ");
                            chSV.OutputInfo();
                        }
                        ArrSV.Remove(chSV);
                        Console.WriteLine("Ban muon doi thong tin nao cua sinh vien hay toan bo : ");
                        Console.Write("Neu toan bo nhap All khong thi nhap thong tin can sua: ");
                        string   infochange = Console.ReadLine();
                        changeSV changeInfo = new changeSV();
                        changeInfo.ChangeScoreSV(ref chSV, infochange);
                        ArrSV.Insert(index, chSV);
                        printInfo(ArrSV);
                        Continue(ref y_choice, "sua");
                        if (y_choice == "y")
                        {
                            Console.WriteLine("Ban muon tiep tuc sua sinh vien nay hay sua sinh vien khac ");
                            Console.Write("Nhap 0 de tiep tuc sua sinh vien hay nhap gi cx duoc de sua sv khac");
                            _choice = Console.ReadLine();
                            if (_choice == "0")
                            {
                                goto ThisSVchange;
                            }
                            else
                            {
                                goto StartChange;
                            }
                        }
                    } while (y_choice == "y");
                    Endprogam(ref choice);
                    break;

                case 6:    //Tim kiem sinh vien
                    Console.Write("Nhap ten Sinh vien muon tim kiem : ");
                    string name_search = Console.ReadLine();
                    SV     searchSV    = ArrSV.Find(new SearchNameSV(name_search).search);//Tim kiem vi tri SV can kiem trong list ban dau
                    Console.WriteLine("Thong tin sinh vien sau khi tim kiem la: ");
                    searchSV.OutputInfo();
                    Endprogam(ref choice);
                    break;

                case 7:    //Xoa toan bo thong tin SV
                    ArrSV.Clear();
                    printInfo(ArrSV);
                    break;

                case 8:    //Xoa man hinh
                    Console.WriteLine("Chuong trinh dang thuc hien xoa man hinh. ");
                    Console.Clear();
                    Console.WriteLine("Man Hinh Da Xoa Xong.");
                    Console.WriteLine("Dang Cap Nhap Lai Du Lieu");
                    Console.WriteLine("Data Update......");
                    Pause();
                    Console.WriteLine("Cap Nhap Data Hoan thanh");
                    Pause();
                    Console.Clear();
                    Console.WriteLine("--------------------------------------Chuong Trinh Quan Li Sinh Vien--------------------------------------------");
                    goto Menu;

                case 9:    //Ket thuc chuong trinh
                    Console.WriteLine("Ban da chon ket thuc chuong trinh. Cam on vi da su dung chuong trinh");
                    Console.WriteLine("See you again in next time. Bye");
                    choice = false;
                    break;

                default:
                    Console.WriteLine("Lua chon khong hop le ");
                    Endprogam(ref choice);
                    break;
                }
            } while (choice == true);
            Console.Read();
        }