Beispiel #1
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();
            }
        }
Beispiel #2
0
        // Isnuomotos transporto priemones ir nuomininko paieska pagal automobilio numeri
        public void SearchByCar(bool carNumExist, string vehNumber)
        {
            if (carNumExist)
            {
                List<Car> cars = SqlQueries.SelectCarsWithClient();
                List<Client> clients = SqlQueries.SelectClients();

                Console.Clear();

                var result = (from c in cars
                              join cl in clients on c.ClientNumber equals cl.PersonalNumber
                              select new
                              {
                                  c.VehNumber,
                                  c.Brand,
                                  c.Model,
                                  cl.PersonalNumber,
                                  cl.Name,
                                  cl.Surename
                              }).Where(c => c.VehNumber == vehNumber).OrderBy(c => c.Brand);

                foreach (var car in result)
                {
                    Console.WriteLine($"Automobilis: {car.Brand} {car.Model}\nNuomininkas: {car.Name} {car.Surename} " +
                        $"(a.k. {car.PersonalNumber})");
                }

                Console.ReadKey();
            }
        }
Beispiel #3
0
        // Isnuomoto motociklo paieska pagal motociklo numeri
        public void SearchByMoto(bool motoNumExist, string vehNumber)
        {
            if (motoNumExist)
            {
                Console.CursorVisible = false;
                List <Motorcycle> motos   = SqlQueries.SelectMotorcyclesWithClient();
                List <Client>     clients = SqlQueries.SelectClients();
                Console.Clear();

                var result = (from m in motos
                              join cl in clients on m.ClientNumber equals cl.PersonalNumber
                              select new
                {
                    m.VehNumber,
                    m.Brand,
                    m.Model,
                    cl.PersonalNumber,
                    cl.Name,
                    cl.Surename
                }).Where(m => m.VehNumber == vehNumber);
                foreach (var moto in result)
                {
                    Console.WriteLine($"Motociklas: {moto.Brand} {moto.Model}\nNuomininkas: {moto.Name} {moto.Surename} " +
                                      $"(a.k. {moto.PersonalNumber})");
                }
                Console.ReadKey();
            }
        }
Beispiel #4
0
        // Kliento duomenu isvedimas i ekrana
        public void ClientData()
        {
            List <Client> clients = SqlQueries.SelectClients();

            Console.Clear();
            Console.WriteLine("AK");
            Console.SetCursorPosition(15, 0);
            Console.WriteLine("Vardas");
            Console.SetCursorPosition(30, 0);
            Console.WriteLine("Pavarde");
            Console.SetCursorPosition(50, 0);
            Console.WriteLine("Gimimo data");
            Console.SetCursorPosition(70, 0);
            Console.WriteLine("Adresas");
            Console.SetCursorPosition(90, 0);
            Console.WriteLine("Miestas");
            Console.SetCursorPosition(110, 0);

            var result = clients.Select(cl => cl).OrderBy(cl => cl.Name).ThenBy(cl => cl.Surename);

            foreach (var client in result)
            {
                Console.SetCursorPosition(0, y);
                Console.WriteLine(client.PersonalNumber);
                Console.SetCursorPosition(15, y);
                Console.WriteLine(client.Name);
                Console.SetCursorPosition(30, y);
                Console.WriteLine(client.Surename);
                Console.SetCursorPosition(50, y);
                Console.WriteLine(client.DateOfBirth);
                Console.SetCursorPosition(70, y);
                Console.WriteLine(client.Address);
                Console.SetCursorPosition(90, y);
                Console.WriteLine(client.City);
                Console.SetCursorPosition(110, y);
                y++;
            }

            Console.ReadKey();
            // Atstatoma y reiksme
            y = 2;
        }
Beispiel #5
0
        // Patikrinimas ar automobilio numeris ir asmens kodas sutampa
        public Tuple <bool, string, long> MatchingCarNumberAndClientNumber()
        {
            List <Car>    cars    = SqlQueries.SelectCars();
            List <Client> clients = SqlQueries.SelectClients();

            Console.Clear();
            Console.CursorVisible = true;
            Console.WriteLine("Ivesk isnuomojamo 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 prepareCheckList = cars.Select(c => c).Where(c => c.VehNumber == vehNumber && c.RentStatus == false &&
                                                             Convert.ToDateTime(c.TechServiceExp) >= todaysDate && Convert.ToDateTime(c.InsuranceExp) >= todaysDate).ToList();
            var checkResult = prepareCheckList.Select(c => c.VehNumber).Contains(vehNumber);

            if (!checkResult)
            {
                Console.Clear();
                Console.WriteLine("Automobilis su tokiu numeriu neegzistuoja, yra isnuomotas arba neturi galiojanciu reikalingu dokumentu!");
                Console.ReadKey();

                isDataCorrect = false;
            }
            else
            {
                Console.WriteLine("Ivesk kliento asmens koda, kuriam isnuomojamas automobilis");
                while (!long.TryParse(Console.ReadLine(), out personalNumber))
                {
                    Console.WriteLine("\nAsmens koda sudaro tik skaitmenys! Ivesk kliento asmens koda");
                }

                var checkResult2 = clients.Select(cl => cl.PersonalNumber).Contains(personalNumber);

                if (!checkResult2)
                {
                    Console.Clear();
                    Console.WriteLine("Toks klientas neegzistuoja!\nJei nori prideti nauja klienta ivesk [Y], kitu atveju - [N]");
                    comfirmedAction = true;
                    while (comfirmedAction)
                    {
                        choise = Console.ReadLine().ToUpper();
                        if (choise == "Y")
                        {
                            sqlInsert.InsertClient(true, personalNumber);
                            isDataCorrect   = true;
                            comfirmedAction = false;
                        }
                        else if (choise == "N")
                        {
                            isDataCorrect   = false;
                            comfirmedAction = false;
                        }
                        else
                        {
                            Console.WriteLine("\nJei nori prideti nauja klienta ivesk [Y], kitu atveju - [N]");
                        }
                    }
                }
                else
                {
                    isDataCorrect = true;
                }
            }

            return(new Tuple <bool, string, long>(isDataCorrect, vehNumber, personalNumber));
        }