Exemple #1
0
        // Automobilio grazinimas
        public bool CarGivedBack(string vehNumber)
        {
            List<Car> cars = SqlQueries.SelectCarsWithClient();

            var result = cars.Select(c => c).Where(c => c.VehNumber == vehNumber);

            foreach (var car in result)
            {
                // Skaciavimas kiek dienu buvo isnuomotas automobilis
                DateTime rentDay = Convert.ToDateTime(car.RentFromDate);
                double days = (todayDate - rentDay).TotalDays;

                if (days == 0)
                {
                    // Nuomos kaina, jei automobilis grazinamas ta pacia diena
                    totalPrice = car.RentPrice;
                }
                else
                {
                    // Kainos skaiciavimas uz visa nuomos laika
                    totalPrice = car.RentPrice * days;
                }
            }

            car.RentStatus = false;
            
            Console.Clear();
            Console.WriteLine($"Transporto priemone grazinta\nTransporto priemones kaina uz visa nuomos laikotarpi: {totalPrice} Eur");
            Console.ReadKey();

            return car.RentStatus;
        }
Exemple #2
0
        // Patikrinimas ar isnuomoto automobilio numeris sutampa
        public virtual Tuple <bool, string> MatchingCarNumberWithClient()
        {
            List <Car> cars = SqlQueries.SelectCarsWithClient();

            Console.Clear();
            Console.CursorVisible = true;
            Console.WriteLine("Ivesk automobilio valstybini numeri");
            vehNumber = Console.ReadLine().ToUpper();
            while (!lettersAndNums.IsMatch(vehNumber) || vehNumber == "")
            {
                Console.WriteLine($"\nValstybini numeri gali sudaryti tik raides ir skaitmenys!\nIvesk automobilio valstybini numeri");
                vehNumber = Console.ReadLine().ToUpper();
            }
            var checkResult = cars.Select(c => c.VehNumber).Contains(vehNumber);

            if (!checkResult)
            {
                Console.Clear();
                Console.WriteLine("Automobilis su tokiu numeriu neegzistuoja arba nera isnuomotas");
                Console.ReadKey();

                isDataCorrect = false;
            }
            else
            {
                isDataCorrect = true;
            }

            return(new Tuple <bool, string>(isDataCorrect, vehNumber));
        }
Exemple #3
0
        // Isnuomotu transporto priemoniu konkreciam klientui gavimas pagal kliento asmens koda
        public void VehiclesRentedToClient(bool personalNumExist, long personalNumber)
        {
            if (personalNumExist)
            {
                // Pradines nuomu kainu reiksmes
                double?           rentPriceForCar  = 0;
                double?           rentPriceForMoto = 0;
                double?           rentPriceForBike = 0;
                List <Client>     clients          = SqlQueries.SelectClients();
                List <Car>        cars             = SqlQueries.SelectCarsWithClient();
                List <Motorcycle> motos            = SqlQueries.SelectMotorcyclesWithClient();
                List <Bicycle>    bikes            = SqlQueries.SelectBikesWithClient();

                Console.CursorVisible = false;
                Console.Clear();

                // Kliento gavimas
                var result = clients.Select(cl => cl).Where(cl => cl.PersonalNumber == personalNumber);

                foreach (var client in result)
                {
                    Console.WriteLine($"Klientas: {client.Name} {client.Surename} (a.k.: {personalNumber})\n");
                }

                Console.WriteLine("Automobiliai\n");

                // Automobilio gavimas
                var result2 = cars.Select(c => c).Where(c => c.ClientNumber == personalNumber).OrderBy(c => c.Brand).ThenBy(c => c.Model);
                foreach (var car in result2)
                {
                    // Skaiciavimas kiek dienu isnuomotas automobilis
                    DateTime rentDay    = Convert.ToDateTime(car.RentFromDate);
                    double   daysRented = (todaysDate - rentDay).TotalDays;

                    if (daysRented == 0)
                    {
                        // Nuomos kaina, jei automobilis isnuomotas siandien
                        rentPriceForCar += car.RentPrice;
                    }
                    else
                    {
                        // Nuomos kaina, jei automobilis isnuomotas seniau nei siandien
                        rentPriceForCar += car.RentPrice * daysRented;
                    }

                    Console.WriteLine($"{car.VehNumber} {car.Brand} {car.Model}");
                }

                Console.WriteLine("\nMotociklai\n");

                // Motociklo gavimas
                var result3 = motos.Select(m => m).Where(m => m.ClientNumber == personalNumber).OrderBy(m => m.Brand).ThenBy(m => m.Model);

                foreach (var moto in result3)
                {
                    // Skaiciavimas kiek dienu isnuomotas motociklas
                    DateTime rentDay    = Convert.ToDateTime(moto.RentFromDate);
                    double   daysRented = (todaysDate - rentDay).TotalDays;

                    if (daysRented == 0)
                    {
                        // Nuomos kaina, jei motociklas isnuomotas siandien
                        rentPriceForMoto += moto.RentPrice;
                    }
                    else
                    {
                        // Nuomos kaina, jei motociklas isnuomotas seniau nei siandien
                        rentPriceForMoto += moto.RentPrice * daysRented;
                    }

                    Console.WriteLine($"{moto.VehNumber} | {moto.Brand} | {moto.Model}");
                }

                Console.WriteLine("\nDviraciai\n");

                // Dviracio gavimas
                var result4 = bikes.Select(b => b).Where(b => b.ClientNumber == personalNumber).OrderBy(b => b.Brand).ThenBy(b => b.Model);

                foreach (var bike in result4)
                {
                    // Skaiciavimas kiek dienu isnuomotas dviratis
                    DateTime rentDay    = Convert.ToDateTime(bike.RentFromDate);
                    double   daysRented = (todaysDate - rentDay).TotalDays;

                    if (daysRented == 0)
                    {
                        // Nuomos kaina, jei dviratis isnuomotas siandien
                        rentPriceForBike += bike.RentPrice;
                    }
                    else
                    {
                        // Nuomos kaina, jei dviratis isnuomotas seniau nei siandien
                        rentPriceForBike += bike.RentPrice * daysRented;
                    }

                    Console.WriteLine($"{bike.BikeID} | {bike.Brand} | {bike.Model}");
                }

                totalRentPrice = (rentPriceForCar + rentPriceForMoto + rentPriceForBike);

                Console.WriteLine($"\n\n\nSusikaupusi nuomos kaina uz issinuomotus automobilius: {rentPriceForCar} Eur.\n" +
                                  $"Susikaupusi nuomos kaina uz issinuomotus motociklus: {rentPriceForMoto} Eur.\n" +
                                  $"Susikaupusi nuomos kaina uz issinuomotus dviracius: {rentPriceForBike} Eur.\n" +
                                  $"\nSusikaupusi nuomos kaina uz visas issinuomotas transporto priemones: {totalRentPrice} Eur.");

                Console.ReadKey();
            }
        }