Ejemplo n.º 1
0
        private static void NhapSach(List <Sach> dsSach, Dictionary <string, int> sl, List <OChua> dsOChua, int n)
        {
            int   soluong = 0;
            OChua ochua   = new OChua();
            Sach  sach1   = new Sach();

            sach1.showLayout();
            if (soluong == 0)
            {
                soluong++;
            }
            Console.WriteLine("Kiem tra ten sach :");
            string tensach = Console.ReadLine();

            if (sach1.TimTenSach(dsSach, tensach) != null)
            {
                sach1 = sach1.getSachbyMa(dsSach, sach1.getMaSachbyTen(dsSach, tensach));
                Console.WriteLine("Sach da ton tai! Ma sach: " + sach1.MaSach);
                sl[sach1.getMaSachbyTen(dsSach, tensach)]++;
            }
            else
            {
                //khong thay ten sach => sinh ma cho sach
                sach1.MaSach = sach1.genKey();
                Console.WriteLine("Nhap ten sach : ");
                sach1.TenSach = Console.ReadLine();
                Console.WriteLine("Nhap ten nha xuat ban : ");
                sach1.NhaXuatBan = Console.ReadLine();
                Console.WriteLine("Nhap nam xuat ban : ");
                sach1.NamXuatBan = int.Parse(Console.ReadLine());
                dsSach.Add(sach1);
                sl.Add(sach1.MaSach, 1);
            }
            ochua.XepSach(dsOChua, sach1, n);

            Console.Clear();
            throw new NotImplementedException();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Sach                     sach        = new Sach();
            OChua                    ochua       = new OChua();
            PhieuMuon                phieuMuon   = new PhieuMuon();
            Program                  program     = new Program();
            int                      n           = 0;
            List <Sach>              dsSach      = new List <Sach>();
            List <OChua>             dsOChua     = new List <OChua>();
            List <PhieuMuon>         dsPhieuMuon = new List <PhieuMuon>();
            Dictionary <string, int> sl          = new Dictionary <string, int>();


            sach.showLayout();
            Console.WriteLine("Nhap so o chua :");
            n = int.Parse(Console.ReadLine());


            while (true)
            {
                sach.showLayout();
                int    chon    = 0;
                String luachon = "\nNhap lua chon :" +
                                 "\n1.Nhap sach " +
                                 "\n2.Lap phieu muon " +
                                 "\n3.Tim kiem theo ma sach " +
                                 "\n4.In danh sach sach ";
                Console.WriteLine(luachon);
                program.showFoot();
                chon = int.Parse(Console.ReadLine());
                switch (chon)
                {
                case 1:
                {
                    NhapSach(dsSach, sl, dsOChua, n);
                    break;
                }

                case 2:
                {
                    TaoPhieuMuon(dsOChua, dsPhieuMuon, sl);
                    break;
                }

                case 3:
                {
                    sach.showLayout();
                    Console.WriteLine("Nhap ma sach :");
                    string ms = Console.ReadLine();
                    program.TimKiem(dsSach, sl, dsOChua, ms);
                    break;
                }

                case 4:
                {
                    sach.showLayout();
                    program.DanhSachSach(dsSach, sl, dsOChua);
                    program.DanhSachOChua(dsOChua);
                    Console.ReadLine();
                    Console.Clear();
                    break;
                }

                case 0:
                    break;
                }
            }
            Console.ReadLine();
        }