Пример #1
0
 public void Edit(Passenger ob, int k)
 {
     Passenger_L.RemoveAt(k);
     Passenger_L.Insert(k, ob);
 }
Пример #2
0
 public void Delete(Passenger ob, int k)
 {
     Passenger_L.RemoveAt(k);
 }
Пример #3
0
        private Double Price;           // Цена

        // Конструкторы
        public Ticket()
        {
            Seat      = 0;
            Price     = 0.0;
            Passenger = new Passenger();
        }
Пример #4
0
 public Ticket(Int32 Seat, Double Price, Passenger Passenger)
 {
     this.Seat      = Seat;
     this.Price     = Price;
     this.Passenger = Passenger;
 }
Пример #5
0
        public void EditPassenger()
        {
            try
            {
                Console.Clear();

                FlightInfo flight = SearchByNumber();

                if (flight == null)
                {
                    return;
                }

                Console.WriteLine("Please, enter the first name of the passenger to edit");

                string firstName = Console.ReadLine();

                Console.WriteLine("Please, enter the second name of the passenger to edit");

                string secondName = Console.ReadLine();

                Passenger passenger = null;

                foreach (var item in flight.Passengers)
                {
                    if (item.FirstName == firstName && item.SecondName == secondName)
                    {
                        passenger = item;
                        break;
                    }
                }

                if (passenger == null)
                {
                    IOHelper.DrawConsoleHeader("We could not find a passenger, do you want to continue? Press any button", ConsoleColor.Red);
                    Console.ReadLine();
                    return;
                }

                Console.Clear();

                DrawPassenger(new List <Passenger> {
                    passenger
                });

                Console.WriteLine("Please enter new first name or press enter if you don't want to change");
                var pasFirstName = Console.ReadLine();
                if (!String.IsNullOrEmpty(pasFirstName))
                {
                    passenger.FirstName = pasFirstName;
                }

                Console.WriteLine("Please enter new second name or press enter if you don't want to change");
                var pasSecondName = Console.ReadLine();
                if (!String.IsNullOrEmpty(pasSecondName))
                {
                    passenger.SecondName = pasSecondName;
                }

                Console.WriteLine("Please enter new nationality or press enter if you don't want to change");
                var nationality = Console.ReadLine();
                if (!String.IsNullOrEmpty(nationality))
                {
                    passenger.Nationality = nationality;
                }

                Console.WriteLine("Please enter new pasport or press enter if you don't want to change");
                var pasport = Console.ReadLine();
                if (!String.IsNullOrEmpty(pasport))
                {
                    passenger.Pasport = pasport;
                }

                var birthday = (DateTime)IOHelper.SetDate("Please, enter the new birthday of the passenger (use this format dd.MM.yyyy)", "dd.MM.yyyy", true);
                if (birthday != null)
                {
                    passenger.Birthday = birthday;
                }

                Console.WriteLine("Please, enter the new gender (Male or Female) of the passenger");
                var gender = Console.ReadLine();
                if (!String.IsNullOrEmpty(gender))
                {
                    passenger.Gender = (Gender)Enum.Parse(typeof(Gender), gender);
                }

                Console.WriteLine("Please, enter the new flight class (Business or Economy) of the passenger");
                var flClass = Console.ReadLine();
                if (!String.IsNullOrEmpty(flClass))
                {
                    passenger.ClassType = (FlightClasses)Enum.Parse(typeof(FlightClasses), flClass);
                }

                IOHelper.DrawConsoleHeader("Changes have been made, press any key to continue", ConsoleColor.Green);
                Console.ReadLine();
            }
            catch
            {
                IOHelper.DrawConsoleHeader("Data format was incorrect to press any key to continue", ConsoleColor.Red);
                Console.ReadLine();
            }
        }