Пример #1
0
        public void Button_egebniss_speichern_Click(object sender, RoutedEventArgs e)
        {
            int    Tore      = Convert.ToInt32(Tb_tore.Text);
            int    Gegentore = Convert.ToInt32(Tb_gegentore.Text);
            object o         = Datagrid_Mannschaft.SelectedItem;
            object u         = Formation_Datagrid.SelectedItem;

            Spielergebnisse neuesspiel = new Spielergebnisse();

            neuesspiel.Tore      = Tore;
            neuesspiel.Gegentore = Gegentore;

            if (o != null)
            {
                Mannschaften mannschaften  = (Mannschaften)o;
                int          MannschaftsID = mannschaften.MannschaftsID;
                neuesspiel.MannschaftsID = MannschaftsID;
            }

            if (u != null)
            {
                Formationen formationen  = (Formationen)u;
                int         FormationsID = formationen.FormationsID;
                neuesspiel.FormationsID = FormationsID;
            }


            FifaStatsEntities.Spielergebnisse.Add(neuesspiel);
            FifaStatsEntities.SaveChanges();

            Tb_tore.Clear();
            Tb_gegentore.Clear();
        }
Пример #2
0
        public void Formationen_Statistiken_Datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            object      p            = Formationen_Statistiken_Datagrid.SelectedItem;
            Formationen formationp   = (Formationen)p;
            int         FormationsID = formationp.FormationsID;

            object t = Datagrid_Mannschaft_Statistiken.SelectedItem;

            if (t is Mannschaften)
            {
                Mannschaften mannschaftP = (Mannschaften)t;

                int MannschaftsID_P = mannschaftP.MannschaftsID;;

                var list = collectionView3;
                list.Filter = (x => ((Spielergebnisse)x).MannschaftsID.Equals(MannschaftsID_P) && ((Spielergebnisse)x).FormationsID.Equals(FormationsID));

                if (list != null)
                {
                    decimal Toregesamt      = 0;
                    decimal Spielanzahl     = 0;
                    decimal Gegentoregesamt = 0;
                    decimal Gewonnen        = 0;
                    decimal Verloren        = 0;
                    foreach (Spielergebnisse item in list)
                    {
                        Toregesamt      = (decimal)item.Tore + Toregesamt;
                        Gegentoregesamt = (decimal)item.Gegentore + Gegentoregesamt;
                        Spielanzahl++;
                        if (item.Tore > item.Gegentore)
                        {
                            Gewonnen = Gewonnen + 1;
                        }
                        else if (item.Gegentore > item.Tore)
                        {
                            Verloren = Verloren + 1;
                        }

                        decimal ToreproSpieldurschnitt = Toregesamt / Spielanzahl;
                        ToreproSpieldurschnitt = Math.Round(ToreproSpieldurschnitt, 3);
                        decimal GegentoreproSpieldurschnitt = Gegentoregesamt / Spielanzahl;
                        GegentoreproSpieldurschnitt     = Math.Round(GegentoreproSpieldurschnitt, 3);
                        Formationen_Tore_pro_Spiel.Text = Convert.ToString(ToreproSpieldurschnitt);
                        if (Verloren == 0)
                        {
                            Verloren = 1;
                        }
                        decimal SN_Verhältnis = Gewonnen / Verloren;
                        SN_Verhältnis = Math.Round(SN_Verhältnis, 3);
                        TB_SN_Verhältnis_Formationen.Text    = Convert.ToString(SN_Verhältnis);
                        Formationen_Gegentore_pro_Spiel.Text = Convert.ToString(GegentoreproSpieldurschnitt);
                    }
                }
                if (list == null)
                {
                    TB_SN_Verhältnis_Formationen.Text    = "Keine Daten";
                    Formationen_Gegentore_pro_Spiel.Text = "Keine Daten";
                    Formationen_Tore_pro_Spiel.Text      = "Keine Daten";
                }
            }
        }