Beispiel #1
0
 private async void BtnCreate_OnClick(object sender, RoutedEventArgs e)
 {
     Canvas.Visibility = Visibility.Collapsed;
     if (isCreate)
     {
         var pilot = ReadTextBoxesData();
         if (pilot != null)
         {
             try
             {
                 await Service.Create(pilot);
             }
             catch
             {
                 Info.Text = "Server error!";
             }
             lastId++;
             pilot.Id = lastId;
             Aircrafts.Add(pilot);
             isCreate = false;
             CreateInfo();
             Info.Text = "Choose new action!";
         }
     }
     else
     {
         CreateInfo();
         isCreate  = true;
         Info.Text = "Info : Input data and press 'Create' ";
     }
 }
Beispiel #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var result = await Service.GetAll();

            result.ForEach(x => Aircrafts.Add(x));
            lastId = Aircrafts.LastOrDefault().Id;
            LoadTypes();
        }
Beispiel #3
0
 public void AddAircraft(Aircraft aircraft)
 {
     if (!Aircrafts.Any(i => i.Id == aircraft.Id))
     {
         Aircrafts.Add(aircraft);
     }
     return;
 }
Beispiel #4
0
        public async Task Search()
        {
            Aircrafts.Clear();

            List <Aircraft> tempAircrafts = await AircraftService.GetAll();

            foreach (var item in tempAircrafts)
            {
                Aircrafts.Add(item);
            }
        }
Beispiel #5
0
        public void TakeAllRouts()
        {
            Classes.Clear();
            Classes.Add(new FlightsModel {
                clas = "Бизнес"
            });
            Classes.Add(new FlightsModel {
                clas = "Эконом"
            });

            Routs.Clear();
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = @"select id_route,s1.town,s2.town,length_of_route from route   inner join airport s1  on s1.nameAirport = route.id_airport_from 
                 inner join  airport s2 on s2.nameAirport = route.id_airport_to";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader = sqlCommand.ExecuteReader();

            foreach (var i in reader)
            {
                Routs.Add(new RouteModel {
                    IdRoute = reader.GetInt32(0), airport_From_To = $"{reader.GetString(1)} - {reader.GetString(2)}", length_of_route = Convert.ToString(reader.GetInt32(3))
                });
            }
            reader.Close();

            Aircrafts.Clear();
            sqlCommand.CommandText = @"select * from aircrafts";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader2 = sqlCommand.ExecuteReader();

            foreach (var i in reader2)
            {
                Aircrafts.Add(new AircraftModel {
                    name_aircraft = reader2.GetString(0), count_of_seats = reader2.GetInt32(1).ToString(), speed = reader2.GetInt32(2).ToString()
                });
            }
            reader2.Close();

            Company.Clear();
            sqlCommand.CommandText = @"select * from company";
            sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;
            SqlDataReader reader3 = sqlCommand.ExecuteReader();

            foreach (var i in reader3)
            {
                Company.Add(new CompanyModel {
                    company_name = reader3.GetString(0), cost_of_1km = reader3.GetFloat(1).ToString(), cost_of_business = reader3.GetFloat(2).ToString(), cost_of_econom = reader3.GetFloat(3).ToString()
                });
            }
            reader3.Close();
        }
Beispiel #6
0
        /// <summary>
        ///   Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse.
        /// </summary>
        public AircraftListDesignViewModel()
        {
            Aircraft aircraft = new Aircraft(new AircraftInformation()
            {
                AircraftFile = "test.acf",
                Livery       = "my/test/livery",
            }, new AircraftLauncherInformation());

            aircraft.Update(new Situation(true, new FileInfo("temp.tmp")));
            Aircraft aircraft2 = new Aircraft(new AircraftInformation()
            {
                AircraftFile = "test.acf",
                Livery       = "my/test/livery"
            }, new AircraftLauncherInformation());

            aircraft2.Update(new Situation(false, null));
            aircraft2.Update(100.42356, 42.456789);
            Aircrafts.Add(aircraft);
            Aircrafts.Add(aircraft2);
            SelectedAircraft            = aircraft;
            SelectedAircraft.IsSelected = true;
        }
        private async void LoadAircrafts()
        {
            var result = await AircraftService.GetAll();

            result.ForEach(x => Aircrafts.Add(x));
        }
Beispiel #8
0
 internal void AddAircraft(Aircraft aircraft)
 {
     Aircrafts.Add(aircraft);
     AddChild(aircraft);
 }