示例#1
0
        /// <summary>
        /// holt alle Durchgänge des Legs mit der übergebenen id aus der Datenbank, erstellt die Objekte und fügt sie zu einer List hinzu, welche dann übergeben wird
        /// </summary>
        /// <param name="id">id des Legs aus welchem alle Durchgänge geholt werden sollen</param>
        /// <returns>List mit allen geholten Durchgängen</returns>
        public static List <Durchgang> GetDurchgängeOfLeg(int id)
        {
            List <Durchgang> durchgänge = new List <Durchgang>();

            List <string>[] list = DBConnect.SelectDurchgangLegID(id);
            for (int y = 0; y < list[0].Count && y < list[2].Count && y < list[3].Count && y < list[4].Count; y++)
            {
                Durchgang d = new Durchgang(int.Parse(list[0].ElementAt(y)), int.Parse(list[2].ElementAt(y)), int.Parse(list[3].ElementAt(y)), int.Parse(list[4].ElementAt(y)));
                d.SetWürfe(GetWürfeOfDurchgang(d.GetId()));
                durchgänge.Add(d);
            }
            return(durchgänge);
        }
示例#2
0
        public static void InsertDurchgang(Durchgang durchgang, Leg leg)
        {
            int finishBereich = 0;

            if (durchgang.IsFinishBereich())
            {
                finishBereich = 1;
            }

            string query = "INSERT INTO durchgang (`id_durchgang`, `id_leg`, `durchgangNummer`, `anzahlWurfe`, `finishBereich`) VALUES ('" + durchgang.GetId() + "', '" + leg.GetId() + "', '" + durchgang.GetDurchgangNummer() + "', '" + durchgang.GetAnzahlWürfe() + "', '" + finishBereich + "')";

            //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("Durchgang: " + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }
示例#3
0
        public static void InsertWurf(Wurf w, Durchgang durchgang)
        {
            string query = "INSERT INTO wurf (`id_wurf`, `id_durchgang`, `wurfNummer`, `multiplikator`, `wert`, `multiZiel`, `wertZiel`) VALUES ('" + w.GetId() + "', '" + durchgang.GetId() + "', '" + w.GetWurfNummer() + "', '" + w.GetMulti() + "', '" + w.GetWert() + "', '" + w.GetMultiZiel() + "', '" + w.GetWertZiel() + "')";

            //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("Wurf:" + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
            else
            {
                Console.WriteLine("NO");
                Console.ReadLine();
            }
        }