Пример #1
0
        private static void ReturnCar(ClientClass client)
        {
            Console.Clear();
            List <RentClass> rentsOfClient = RentService.GetRentsOfClient(client);

            if (rentsOfClient.Count == 0)
            {
                Console.Clear();
                Console.WriteLine("You have no rents");
                return;
            }

            foreach (var i in RentService.GetRentsOfClient(client))
            {
                Console.WriteLine("\nCar id: " + i.CurrentCar.CarId);
                Console.WriteLine("Car type: " + i.CurrentCar.Bodywork.Type);
                Console.WriteLine("Car color: " + i.CurrentCar.Bodywork.Color);
            }
            Console.Write("\nChoose car's id you want to return: ");
            if (UserInputInt(out int chosenCarId))
            {
                Console.Clear();
                CarClass tempCar = AutoParkService.SearchCarById(chosenCarId);
                if (tempCar != null && tempCar.CurrentClient == client)
                {
                    RentService.RemoveRent(RentService.GetRentByCarId(chosenCarId));
                    Console.WriteLine($"Car with id '{chosenCarId}' was successfully returned");
                    return;
                }
            }
            Console.Clear();
            Console.WriteLine("Id not found!");
        }
        public ReturnRentedCarForm(ClientClass client)
        {
            this.client = client;
            InitializeComponent();
            int lHeight = RentService.GetRentsOfClient(client).Count * 13 + 10;

            listBox1.DataSource = RentService.GetRentsOfClient(client);
            button1.Location    = new Point(button1.Location.X, button1.Location.Y - (listBox1.Height - lHeight));
            listBox1.Height     = lHeight;
            Height = lHeight + 150;
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <RentClass> rentsOfClient = RentService.GetRentsOfClient(client);

            if (rentsOfClient.Count == 0)
            {
                MessageBox.Show("You have no rents", "Autopark");
                return;
            }
            else
            {
                this.Hide();
                ReturnRentedCarForm rrc = new ReturnRentedCarForm(client);
                rrc.Closed += (s, args) => this.Show();
                rrc.Show();
            }
        }