Пример #1
0
        static void Menu(ref Flight[] arrival, ref Flight[] depature, ref Passenger[] people, ref List <FlightClass> f_class_list)
        {
            Console.Clear();
            do
            {
                Console.WriteLine("work with: \n1) flights \n2) flight classes \n3) exit");
                ConsoleKeyInfo case_switch = Console.ReadKey();
                switch (case_switch.Key.ToString())
                {
                case "D1":                                             //arrival
                    menu_flight(ref arrival, ref people, ref f_class_list);
                    break;

                //case "D2":
                //    menu_flight(ref depature, ref people, ref f_class_list);
                //    break;
                case "D2":
                    Console.WriteLine("\ninput the name of the flight class");
                    string name_f_class = Console.ReadLine();
                    int    cost         = 0;
                    do
                    {
                        Console.WriteLine("input the cost");
                        string cost_string  = Console.ReadLine();
                        bool   check_number = int.TryParse(cost_string, out cost);
                        if (cost == 0)
                        {
                            Console.WriteLine("input a number");
                        }
                    }while (cost == 0);
                    FlightClass f_class = new FlightClass(name_f_class, cost);
                    using (var ctx = new AirplaneContext())
                    {
                        ctx.FlightClasses.Add(f_class);
                        ctx.SaveChanges();
                    }
                    f_class_list.Add(f_class);
                    break;

                case "D3":
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("wrong input");
                    break;
                }
            } while (true);
        }
Пример #2
0
        public void Delete_flight()
        {
            FlightEventArgs args = new FlightEventArgs();

            args.flight_number = this.flight_num;
            //FlightDeleteHandler(this, args);

            using (var ctx = new AirplaneContext())
            {
                ctx.Entry(this).State = EntityState.Deleted;
                ctx.SaveChanges();
            }
            this.Flight_num = string.Empty;
            this.City       = string.Empty;
            this.Airline    = string.Empty;
            this.Terminal   = string.Empty;
            this.Status     = string.Empty;
            this.Gate       = 0;
            this.arr_date   = DateTime.MinValue;
        }
Пример #3
0
        public void Add_flight()
        {
            Console.SetCursorPosition(0, Console.CursorTop);
            do
            {
                Console.WriteLine("input the flight number, can not be empty");
                this.Flight_num = Console.ReadLine();
            } while (this.Flight_num == null);
            Console.WriteLine("input the city/port");
            this.City = Console.ReadLine();
            Console.WriteLine("input the airline");
            this.Airline = Console.ReadLine();
            Console.WriteLine("input the terminal");
            this.Terminal = Console.ReadLine();
            Console.WriteLine("choose the status");
            this.Status = Status_Choice();
            Console.ReadKey();
            int i = 0;

            do
            {
                Console.WriteLine("input the gate");
                string gate = Console.ReadLine();
                bool   s    = int.TryParse(gate, out i);
                this.Gate = i;
                if (i == 0)
                {
                    Console.WriteLine("gate must be a number");
                }
            }while (i == 0);
            this.arr_date = DateAndTime();
            using (var ctx = new AirplaneContext())
            {
                ctx.Flights.Add(this);
                ctx.SaveChanges();
            }
        }