Exemple #1
0
        public void ThueXe(Manager manager)
        {
            Console.Clear();
            MotorBL mtbl = new MotorBL();
            bool    a    = false;
            bool    b    = false;

            Console.WriteLine("---------------------------------------------------");
            Console.WriteLine("--------------Thue xe----------");
            Console.WriteLine("--------------------------------------------------");
            ContractBL contractBL = new ContractBL();

            Contract contract = new Contract();

            Customers customer = new Customers();
            Motor     motor    = new Motor();

            customer = InputCustomerInfo();
            motor    = InputMotor();


            Menus menu = new Menus();


            List <Motor> listmotor = null;
            string       choice;

            while (b == false)
            {
                Console.WriteLine("Nhap bien so xe: ");
                contract.motor.LicensePlate = Console.ReadLine();
                try
                {
                    listmotor = mtbl.GetMotorByLicensePlates(contract.motor.LicensePlate);

                    foreach (var item in listmotor)
                    {
                        if (item.Motor_Status != "CHO THUE")
                        {
                            b = true;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    b = false;
                }
                if (b == false)
                {
                    Console.WriteLine("Xe da duoc thue hoac khong ton tai.Ban co muon nhap lai (Y/N):");
                    while (true)
                    {
                        choice = Console.ReadLine().ToUpper();
                        if ((choice != "Y") && (choice != "N"))
                        {
                            Console.WriteLine("Ban chi duoc nhap Y/N. Moi nhap lai: ");
                            choice = Console.ReadLine().ToUpper();
                            continue;
                        }
                        break;
                    }
                    switch (choice)
                    {
                    case "Y":

                        continue;

                    case "y":
                        continue;

                    case "N":
                        menu.MenuManager(manager);
                        break;

                    case "n":
                        menu.MenuManager(manager);
                        break;

                    default:
                        continue;
                    }
                }
            }
            while (a == false)
            {
                Console.WriteLine("nhap ngay thue: ");
                contract.DateRental = Console.ReadLine();

                Console.WriteLine("Nhap ngay tra: ");
                contract.DateReturn = Console.ReadLine();

                Console.WriteLine("Kieu giao dich: ");
                while (true)
                {
                    contract.Type_Transaction = Console.ReadLine().ToUpper();
                    if (contract.Type_Transaction != "CHO THUE")
                    {
                        Console.WriteLine("Ban chi duoc nhap CHO THUE .Ban co muon nhap lai: (Y/N)?");

                        while (true)
                        {
                            choice = Console.ReadLine().ToUpper();
                            if ((choice != "Y") && (choice != "N"))
                            {
                                Console.WriteLine("Ban chi duoc nhap Y/N");
                                choice = Console.ReadLine().ToUpper();
                                continue;
                            }
                            break;
                        }
                        switch (choice)
                        {
                        case "Y":
                            continue;

                        case "y":
                            continue;

                        case "N":
                            menu.MenuManager(manager);
                            break;

                        case "n":
                            menu.MenuManager(manager);
                            break;

                        default:
                            continue;
                        }
                    }
                    break;
                }



                Console.WriteLine("Trang thai hop dong: ");
                contract.Contract_Status = Console.ReadLine().ToUpper();



                try
                {
                    contractBL.CreateContract(contract, customer);
                    a = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                if (a == true)
                {
                    Console.WriteLine("THUE XE THANH CONG .");
                }
            }
        }