Пример #1
0
        /// <summary>
        /// holt alle Legs des Sets 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 Sets aus welchem alle Legs geholt werden sollen</param>
        /// <returns>List mit allen geholten Legs</returns>
        public static List <Leg> GetLegsOfSet(int id)
        {
            List <Leg> legs = new List <Leg>();

            List <string>[] list = DBConnect.SelectLegSetID(id);
            for (int y = 0; y < list[0].Count; y++)
            {
                Leg l = new Leg(int.Parse(list[0].ElementAt(y)), int.Parse(list[2].ElementAt(y)), int.Parse(list[3].ElementAt(y)), int.Parse(list[4].ElementAt(y)));
                l.SetDurchgänge(GetDurchgängeOfLeg(l.GetId()));
                legs.Add(l);
            }
            return(legs);
        }
Пример #2
0
        public static void InsertLeg(Leg leg, Set set)
        {
            string query = "INSERT INTO leg (`id_leg`, `id_set`, `legNummer`, `rest`, `finish`) VALUES ('" + leg.GetId() + "', '" + set.GetId() + "', '" + leg.GetLegNummer() + "', '" + leg.GetRest() + "', '" + leg.GetFinish() + "')";

            //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("Leg:" + e.Message);
                    Console.ReadLine();
                }
                //close connection
                CloseConnection();
            }
        }
Пример #3
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();
            }
        }