Example #1
0
 internal void UpdateFoul(Foul foul)
 {
     using (MySqlConnection conn = new MySqlConnection(_connection))
     {
         try
         {
             conn.Open();
         }
         catch (Exception)
         {
         }
         using (MySqlCommand command = new MySqlCommand())
         {
             command.Connection  = conn;
             command.CommandText = $"UPDATE fouls SET datef='{foul.DtFoul.ToString("yyyy-MM-dd")}',idregistration={foul.IdRegistr},forfeit = {foul.IdTypeFoul} " +
                                   $"WHERE id = {foul.Id}";
             try
             {
                 command.ExecuteNonQuery();
             }
             catch (Exception)
             {
             }
         }
     }
 }
Example #2
0
        internal int NewFoul(Foul foul)
        {
            int result = 0;

            using (MySqlConnection conn = new MySqlConnection(_connection))
            {
                try
                {
                    conn.Open();
                }
                catch (Exception)
                {
                    return(result);
                }
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection = conn;
                    string dt = foul.DtFoul.ToString("yyyy-MM-dd");
                    command.CommandText = $"INSERT INTO fouls (idregistration,`datef`,fouls.`forfeit`) VALUES({foul.IdRegistr},'{dt}',{foul.IdTypeFoul})";
                    try
                    {
                        command.ExecuteNonQuery();
                        command.CommandText = "SELECT LAST_INSERT_ID()";
                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            reader.Read();
                            result = reader.GetInt32(0);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            return(result);
        }