示例#1
0
        public static List <Palestra> GetAllPalestrasSimposio(int id)
        {
            using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
            {
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand("Select * from palestras_simposio_view WHERE idSimposio = @id order by dataEvento DESC", conn))
                {
                    cmd.Parameters.AddWithValue("@id", id);

                    List <Palestra> palestras = new List <Palestra>();
                    MySqlDataReader reader    = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        palestras.Add(Palestra.FromDB(reader));
                    }


                    return(palestras);
                }
            }
        }
示例#2
0
        public static bool CreatePalestraSimposio(Palestra palestra)
        {
            try
            {
                using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
                {
                    conn.Open();
                    using (MySqlCommand sqlCommand = new MySqlCommand("INSERT INTO palestrasimposio VALUES(@id1,@id2)", conn))
                    {
                        sqlCommand.Parameters.AddWithValue("@id2", palestra.idSimposio);
                        sqlCommand.Parameters.AddWithValue("@id1", palestra.idPalestra);
                        sqlCommand.ExecuteNonQuery();
                    }


                    conn.Close();
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }