예제 #1
0
        private void Button_Click_8(object sender, RoutedEventArgs e)
        {
            if (ILocal.SelectedItem != null)
            {
                if (MessageBox.Show("Esta seguro que quiere eliminar Este Elemento?", "Confirmar eliminación", MessageBoxButton.YesNo) == MessageBoxResult.Yes)

                {
                    if (ILocal.SelectedItem.GetType() == typeof(Gol))
                    {
                        Gol g = (ILocal.SelectedItem as Gol);
                        App.GolController.Delete(g);
                        golesLocal--;
                        golesL.Content = golesLocal;
                        updateWinner();
                    }

                    if (ILocal.SelectedItem.GetType() == typeof(Tarjeta))
                    {
                        Tarjeta t = (ILocal.SelectedItem as Tarjeta);
                        App.TarjetaController.Delete(t);
                    }

                    incidenciasLocal.Remove(ILocal.SelectedItem);
                    ILocal.ItemsSource = null;
                    ILocal.ItemsSource = incidenciasLocal;
                }
            }
        }
예제 #2
0
        public void Save(Tarjeta tarjeta)
        {
            using (SQLiteCommand command = new SQLiteCommand(database))
            {
                if (tarjeta.id == 0)
                {
                    command.CommandText = "INSERT INTO tarjetas(clave_jugador, clave_partido, tipo, clave_equipo) VALUES( @clave_jugador, @clave_partido, @tipo, @clave_equipo);";
                    command.Parameters.AddWithValue("@clave_jugador", tarjeta.Jugador);
                    command.Parameters.AddWithValue("@clave_partido", tarjeta.Partido);
                    command.Parameters.AddWithValue("@tipo", tarjeta.Tipo);
                    command.Parameters.AddWithValue("@clave_equipo", tarjeta.equipo);


                    command.ExecuteNonQuery();
                    tarjeta.id = (int)database.LastInsertRowId;
                }
                else
                {
                    command.CommandText = "UPDATE tarjetas SET clave_jugador = @clave_jugador, clave_partido = @clave_partido, tipo = @tipo, clave_equipo= @clave_equipo WHERE id=@id; ";
                    command.Parameters.AddWithValue("@id", tarjeta.id);
                    command.Parameters.AddWithValue("@clave_jugador", tarjeta.Jugador);
                    command.Parameters.AddWithValue("@clave_partido", tarjeta.Partido);
                    command.Parameters.AddWithValue("@tipo", tarjeta.Tipo);
                    command.Parameters.AddWithValue("@clave_equipo", tarjeta.equipo);

                    command.ExecuteNonQuery();
                }
            }
        }
예제 #3
0
        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            Jugador    j = (jugadorVisitante_Copy.SelectedItem as Jugador);
            Calendario c = (Eventos.SelectedItem as Calendario);


            if (c != null)
            {
                if (j != null)
                {
                    if (!String.IsNullOrEmpty(tipoTVisitante.Text))
                    {
                        Tarjeta T = new Tarjeta((int)j.id, tipoTVisitante.Text, (int)c.id, IDVisitante);
                        incidenciasVisitante.Add(T);
                        IVisitante.ItemsSource = null;
                        IVisitante.ItemsSource = incidenciasVisitante;
                        App.TarjetaController.Save(T);
                    }
                    else
                    {
                        MessageBox.Show("Seleccione el tipo de tarjeta");
                    }
                }
                else
                {
                    MessageBox.Show("Seleccione un jugador para agregar una tarjeta");
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un partido para agregar incidencias");
            }
        }
예제 #4
0
 public void Delete(Tarjeta t)
 {
     using (SQLiteCommand command = new SQLiteCommand(database))
     {
         command.CommandText = "DELETE FROM tarjetas WHERE id = @id;";
         command.Parameters.AddWithValue("@id", t.id);
         command.ExecuteNonQuery();
     }
 }