Пример #1
0
        public void DeleteAircraft()
        {
            if (SelectedAircraft != null)
            {
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandText = $"delete flights where aircraft = @aircraft";
                sqlCommand.Connection  = DBConnection.DBConnection.SqlConnection;

                SqlParameter aircraftParam = new SqlParameter("@aircraft", SelectedAircraft.name_aircraft);
                sqlCommand.Parameters.Add(aircraftParam);
                sqlCommand.ExecuteNonQuery();

                sqlCommand.CommandText = $"delete aircrafts where name_aircraft = @nameAircraft";
                SqlParameter nameParam = new SqlParameter("@nameAircraft", SelectedAircraft.name_aircraft);
                sqlCommand.Parameters.Add(nameParam);

                sqlCommand.ExecuteNonQuery();

                Aircrafts.Remove(SelectedAircraft);
                MessageBox.Show("Самолет успешно удален");
            }
            else
            {
                MessageBox.Show("Выберите самолет!");
            }
        }
Пример #2
0
        internal void RemoveAircraft(Aircraft aircraft)
        {
            var squadron = aircraft.Squadron;

            if (squadron != null)
            {
                squadron.RemoveAircraft(aircraft);
                if (squadron.Leader == null)
                {
                    RemoveSquadron(squadron);
                }
            }
            Aircrafts.Remove(aircraft);
            ActiveAircrafts.Remove(aircraft);
            aircraft.VertexZ = 0f;  // reset vertexZ
            if (PlayerAircrafts.Contains(aircraft))
            {
                PlayerAircrafts.Remove(aircraft);
                // check if the player now has lost all his aircrafts
                if (!PlayerAircrafts.Any())
                {
                    // and if true stop the PlayLayer and enter the WreckageLayer
                    EnterWreckageLayer();
                }
            }
            RemoveChild(aircraft);
        }
Пример #3
0
 private async void BtnDelete_OnClick(object sender, RoutedEventArgs e)
 {
     Canvas.Visibility = Visibility.Visible;
     try
     {
         await Service.Delete(_selectedAircraft.Id);
     }
     catch
     {
         Info.Text = "Server error!";
     }
     Aircrafts.Remove(_selectedAircraft);
 }