Example #1
0
        /// <summary>
        /// holt alle Spiele aus der DB, erstellt diese als Objekte, inkl. aller Verküpfungen und Attributen und fügt diese zu einer List hinzu, welche dann übergeben wird
        /// </summary>
        /// <returns>List mit allen komplett erstellten SpielObjekten aus der DB</returns>
        public static List <Spiel> GetSpieleFromDB()
        {
            List <Spiel> spiele = new List <Spiel>();

            List <string>[] list = DBConnect.SelectSpiele();
            for (int y = 0; y < list[0].Count; y++)
            {
                Spiel s = new Spiel(int.Parse(list[0].ElementAt(y)), TimeOfStringTime(list[1].ElementAt(y)), int.Parse(list[2].ElementAt(y)), int.Parse(list[3].ElementAt(y)), int.Parse(list[4].ElementAt(y)));
                s.SetSpieler(GetSpielerInSpielFromDB(s.GetId()));
                s.SetSetsGewonnen(GetSetsGewonnenFromDB(s.GetId()));
                s.SetSets(GetSetsOfSpiel(s.GetId()));

                spiele.Add(s);
            }
            return(spiele);
        }
Example #2
0
        public static void InsertSpieltMit(Spiel s, Spieler sp, int setsGewonnen)
        {
            string query = "INSERT INTO spieltMit (`id_user`, `id_spiel`, `setsGewonnen`) VALUES ('" + sp.GetId() + "', '" + s.GetId() + "', '" + setsGewonnen + "')";

            //open connection
            if (OpenConnection() == true)
            {
                try
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, connection);

                    //Execute command
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e.Message);
                    //Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }
Example #3
0
        public static void InsertSpiel(Spiel s)
        {
            //string query = "INSERT INTO spiel (`id_spiel`, `datum`, `start`, `setsToWin`, `legsToWin`) VALUES ('" + s.GetId() + "', '" + s.GetDatum().Year + "-" + s.GetDatum().Month + "-" + s.GetDatum().Day + "', '501', '" + s.GetSetsToWin() + "', '" + s.GetLegsToWin() + "')";
            string query = "INSERT INTO spiel (`id_spiel`, `datum`, `start`, `setsToWin`, `legsToWin`) VALUES ('" + s.GetId() + "', '" + s.GetDatum().Year + "-" + s.GetDatum().Month + "-" + s.GetDatum().Day + " " + s.GetDatum().Hour + ":" + s.GetDatum().Minute + ":" + s.GetDatum().Second + "', '501', '" + s.GetSetsToWin() + "', '" + s.GetLegsToWin() + "')";

            //open connection
            if (OpenConnection() == true)
            {
                try
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, connection);

                    //Execute command
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Spiel: " + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }
Example #4
0
        public static void InsertSet(Set set, Spiel spiel)
        {
            string query = "INSERT INTO `set` (`id_set`, `id_spiel`, `setNummer`, `legsGewonnen`, `id_spieler`) VALUES ('" + set.GetId() + "', '" + spiel.GetId() + "', '" + set.GetSetNummer() + "', '" + set.GetLegsGewonnen() + "', '" + set.GetSpieler().GetId() + "');";

            //open connection
            if (OpenConnection() == true)
            {
                try
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, connection);

                    //Execute command
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Set: " + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }