コード例 #1
0
        public void EditRecord()
        {
            Info();
            //DateTime dateArrival, dateDeparture;
            //string flightNumber, cityOfArrivval, cityOfDeparture, airline, terminal, portofArrival, portofDeparture;
            //int flightStatus;
            Console.WriteLine("Enter number index");
            int indx = int.Parse(Console.ReadLine());

            dateArrival     = airoport[indx].DateArrival;
            dateDeparture   = airoport[indx].DateDeparture;
            flightNumber    = airoport[indx].FlightNumber;
            cityOfArrivval  = airoport[indx].CityOfArrival;
            cityOfDeparture = airoport[indx].CityOfDeparture;
            airline         = airoport[indx].Airline;
            terminal        = airoport[indx].Terminal;
            portofArrival   = airoport[indx].PortOfArrival;
            portofDeparture = airoport[indx].PortOfDeparture;
            flightStatus    = (int)airoport[indx].Status;

            //var delim = new string('-', 233);
            string[] columns = { "Index".PadLeft(10),           "Flight number".PadLeft(18),     "Date and time of departure".PadLeft(31), "Date and time of arrival".PadLeft(31), "City of departure".PadLeft(20),
                                 "City of arrival".PadLeft(20), "Port of departure".PadLeft(20), "Port of arrival".PadLeft(20),            "Airline".PadLeft(16),                  "Terminal".PadLeft(18), "Flight status".PadLeft(18) };
Repeat:
            Console.Clear();
            Console.WriteLine(string.Join("|", columns));
            for (var info = indx; info <= indx; info++)
            {
                Scoop(info);
                //Console.WriteLine(delim);
                //Console.Write(string.Join('|', info).PadLeft(8));
                //Console.Write(string.Join('|', airoport[info].FlightNumber).PadLeft(20));
                //Console.Write(string.Join('|', airoport[info].DateDeparture).PadLeft(30));
                //Console.Write(string.Join('|', airoport[info].DateArrival).PadLeft(30));
                //Console.Write(string.Join('|', airoport[info].CityOfDeparture).PadLeft(20));
                //Console.Write(string.Join('|', airoport[info].CityOfArrival).PadLeft(20));
                //Console.Write(string.Join('|', airoport[info].PortOfDeparture).PadLeft(18));
                //Console.Write(string.Join('|', airoport[info].PortOfArrival).PadLeft(18));
                //Console.Write(string.Join('|', airoport[info].Airline).PadLeft(28));
                //Console.Write(string.Join('|', airoport[info].Terminal).PadLeft(12));
                //Console.Write(string.Join('|', airoport[info].Status).PadLeft(17));
                //Console.WriteLine();
            }
            for (int a = 0; a <= 3; a++)
            {
                Console.WriteLine();
            }


            Console.WriteLine("Enter number to edit column\n1)Edit date of arrival airplane\n2)Edit date of departure airplane\n3)Edit flight number\n4)Edit city of arrivval" +
                              "\n5)Edit city of departure\n6)Edit airline\n7)Edit terminal\n8)Edit port of arrival\n9)Edit port of departure\n10)Edit flight status\n11)Edit all columns\n12)Nothing");
            int editChoice = Convert.ToInt32(Console.ReadLine());

            //var editChoiceChar = editChoice.ToCharArray();
            switch (editChoice)
            {
            case 1:
                //AirportEditor airportEditor = new AirportEditor(EditDateArrival);
                //dateArrival = Convert.ToDateTime(airportEditor);
                Console.WriteLine("Enter date of arrival airplane\n Date format - {0} ", format);
                string arrivalDate = Console.ReadLine();
                dateArrival = DateTime.ParseExact(arrivalDate, format, CultureInfo.InvariantCulture, DateTimeStyles.None);
                EditAirport();
                goto Repeat;

            case 2:
                Console.WriteLine("Enter date of departure airplane\n Date format - {0} ", format);
                string departureDate = Console.ReadLine();
                dateDeparture = DateTime.ParseExact(departureDate, format, CultureInfo.InvariantCulture, DateTimeStyles.None);
                EditAirport();
                goto Repeat;

            case 3:
                Console.WriteLine("Enter flight number ");
                flightNumber = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 4:
                Console.WriteLine("Enter city of arrivval ");
                cityOfArrivval = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 5:
                Console.WriteLine("Enter city of departure ");
                cityOfDeparture = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 6:
                Console.WriteLine("Enter airline ");
                airline = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 7:
                Console.WriteLine("Enter terminal ");
                terminal = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 8:
                Console.WriteLine("Enter port of arrival ");
                portofArrival = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 9:
                Console.WriteLine("Enter port of departure");
                portofDeparture = Console.ReadLine();
                EditAirport();
                goto Repeat;

            case 10:
                Console.WriteLine("Enter flight status:\n1)check in\n2)gate closed\n3)arrived\n4)departed at\n5)unknown\n6)canceled" +
                                  "\n7)expected at\n8)delayed\n9)in flight");
                flightStatus = Convert.ToInt32(Console.ReadLine());
                EditAirport();
                goto Repeat;

            case 11:
                Add();
                EditAirport();
                View();
                break;

            case 12:
                View();
                break;
            }
            void EditAirport()
            {
                airoport[indx] = new Airport
                                 (
                    dateArrival,
                    dateDeparture,
                    flightNumber,
                    cityOfArrivval,
                    cityOfDeparture,
                    airline,
                    terminal,
                    portofArrival,
                    portofDeparture,
                    flightStatus
                                 );
            }
        }
コード例 #2
0
        public void Working()
        {
            Records();
            AirportPropEditor airportEdit = null;

            airportEdit += EditAirline;
            airportEdit += EditCityOfArrivval;
            airportEdit += EditCityOfDeparture;
            airportEdit += EditDateArrival;
            airportEdit += EditDateDeparture;
            airportEdit += EditFlightNumber;
            airportEdit += EditFlightStatus;
            airportEdit += EditPortofArrival;
            airportEdit += EditPortofDeparture;
            airportEdit += EditTerminal;

            while (true)
            {
                Console.Clear();
                Console.WriteLine(new string('-', 50));
                UserChoice chooise = PromptWhatToDo();

                switch (chooise)
                {
                case UserChoice.Information:
                {
                    DumpAirportList(list);
                    break;
                }

                case UserChoice.CreateRecords:
                {
                    Console.WriteLine("How many airplane you want add?");
                    int numAirplane = int.Parse(Console.ReadLine());
                    for (int c = 0; c < numAirplane; c++)
                    {
                        var airport = new Airport();
                        airportEdit(airport);
                        list.Add(airport);
                    }
                    break;
                }

                case UserChoice.EditRecords:
                {
                    Airport aira = GetEditToEdit(list);
                    airportEdit(aira);
                    break;
                }

                case UserChoice.EditSpecificProp:
                {
                    Airport ai = GetEditToEdit(list);
                    Console.WriteLine("Choose what to edit (enter number):");
                    int num = 1;
                    foreach (string availableChoiseName in Enum.GetNames(typeof(SelectedAirportProp)))
                    {
                        Console.WriteLine("{0} {1}", num++, availableChoiseName);
                    }

                    SelectedAirportProp toEdit = Enum.Parse <SelectedAirportProp>(Console.ReadLine());

                    switch (toEdit)
                    {
                    case SelectedAirportProp.Airline:
                    {
                        EditAirline(ai);
                        break;
                    }

                    case SelectedAirportProp.CityOfArrivval:
                    {
                        EditCityOfArrivval(ai);
                        break;
                    }

                    case SelectedAirportProp.CityOfDeparture:
                    {
                        EditCityOfDeparture(ai);
                        break;
                    }

                    case SelectedAirportProp.DateArrival:
                    {
                        EditDateArrival(ai);
                        break;
                    }

                    case SelectedAirportProp.DateDeparture:
                    {
                        EditDateDeparture(ai);
                        break;
                    }

                    case SelectedAirportProp.FlightNumber:
                    {
                        EditFlightNumber(ai);
                        break;
                    }

                    case SelectedAirportProp.FlightStatus:
                    {
                        EditFlightStatus(ai);
                        break;
                    }

                    case SelectedAirportProp.PortofArrival:
                    {
                        EditPortofArrival(ai);
                        break;
                    }

                    case SelectedAirportProp.PortofDeparture:
                    {
                        EditPortofDeparture(ai);
                        break;
                    }

                    case SelectedAirportProp.Terminal:
                    {
                        EditTerminal(ai);
                        break;
                    }
                    }

                    break;
                }

                case UserChoice.SearchRecords:
                {
                    SearchRecord();
                    break;
                }

                case UserChoice.DeleteRecords:
                {
                    DeleteRecord();
                    break;
                }
                }
            }
        }