Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        public static void InsertUser(Spieler s)
        {
            if (!CheckSpieler(s))
            {
                String firstNameData  = "'" + s.GetFirstName() + "'";
                String lastNameData   = "'" + s.GetLastName() + "'";
                String geburtstagData = "'" + s.GetGeburtstag().Year + "-" + s.GetGeburtstag().Month + "-" + s.GetGeburtstag().Day + "'";
                String eMailData      = "'" + s.GetEMail() + "'";
                String passwdData     = "'" + s.GetPasswd() + "'";
                if (s.GetFirstName() == "")
                {
                    firstNameData = "NULL";
                }
                if (s.GetLastName() == "")
                {
                    lastNameData = "NULL";
                }
                if (s.GetEMail() == "")
                {
                    eMailData = "NULL";
                }
                if (s.GetPasswd() == "")
                {
                    passwdData = "NULL";
                }
                if (s.GetGeburtstag().Equals(new DateTime(1900, 1, 1)))
                {
                    geburtstagData = "NULL";
                }
                string query = "INSERT INTO user (`id_user`, `username`, `firstName`, `lastName`, `geburtstag`, `eMail`, `password`) VALUES('" + s.GetId() + "', '" + s.GetUsername() + "', " + firstNameData + ", " + lastNameData + ", " + geburtstagData + ", " + eMailData + ", " + passwdData + ")";
                //Console.WriteLine(query);
                //Console.ReadKey();
                //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();
                }
                else
                {
                    Console.WriteLine("HALLOI");
                    Console.ReadLine();
                }
            }
        }
Esempio n. 3
0
 public static bool CheckSpieler(Spieler s)
 {
     return(CheckID(s.GetId()));
 }