예제 #1
0
        // Patikrinimas ar ivestas isnuomoto dviracio ID sutampa
        public Tuple <bool, int> MatchingBikeIDWithClient()
        {
            List <Bicycle> bikes = SqlQueries.SelectBikesWithClient();

            Console.Clear();
            Console.CursorVisible = true;
            Console.WriteLine("Ivesk dviracio ID");
            while (!int.TryParse(Console.ReadLine(), out bikeID))
            {
                Console.WriteLine("\nDviracio ID sudaro tik skaitmenys! Ivesk dviracio ID");
            }

            var checkResult = bikes.Select(b => b.BikeID).Contains(bikeID);

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

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

            return(new Tuple <bool, int>(isDataCorrect, bikeID));
        }
예제 #2
0
        // Isnuomoto dviracio ir nuomininko paieska pagal dviracio ID
        public void SearchByBikeID(bool bikeIDExist, int bikeID)
        {
            if (bikeIDExist)
            {
                List <Bicycle> bikes   = SqlQueries.SelectBikesWithClient();
                List <Client>  clients = SqlQueries.SelectClients();

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

                var result = (from b in bikes
                              join cl in clients on b.ClientNumber equals cl.PersonalNumber
                              select new
                {
                    b.BikeID,
                    b.Brand,
                    b.Model,
                    cl.PersonalNumber,
                    cl.Name,
                    cl.Surename
                }).Where(b => b.BikeID == bikeID);
                foreach (var bike in result)
                {
                    Console.WriteLine($"Dviratis: {bike.Brand} {bike.Model}\nNuomininkas: {bike.Name} {bike.Surename} " +
                                      $"(a.k. {bike.PersonalNumber})");
                }
                Console.ReadKey();
            }
        }
예제 #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();
            }
        }