示例#1
0
        public static bool CreateApoio(Apoio apoio)
        {
            try
            {
                using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
                {
                    conn.Open();
                    using (MySqlCommand sqlCommand = new MySqlCommand("INSERT INTO apoio VALUES(@id,@idStaff,@idEvento,@descricao,@dataInicio,@dataFim,@pontos)", conn))
                    {
                        sqlCommand.Parameters.AddWithValue("@id", DBNull.Value);
                        sqlCommand.Parameters.AddWithValue("@idStaff", apoio.idStaff);
                        sqlCommand.Parameters.AddWithValue("@idEvento", apoio.idEvento);
                        sqlCommand.Parameters.AddWithValue("@descricao", apoio.descricao);
                        sqlCommand.Parameters.AddWithValue("@dataInicio", apoio.dataInicio);
                        sqlCommand.Parameters.AddWithValue("@dataFim", apoio.dataFim);
                        sqlCommand.Parameters.AddWithValue("@pontos", apoio.pontos);
                        sqlCommand.ExecuteNonQuery();
                    }


                    conn.Close();
                }
                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Erro ao criar Apoio: " + e.Message);
                return(false);
            }
        }
示例#2
0
        public static bool EditApoio(int id, Apoio apoio)
        {
            try
            {
                using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
                {
                    conn.Open();
                    using (MySqlCommand sqlCommand = new MySqlCommand("UPDATE `apoio` SET idStaff = @idStaff, idEvento = @idEvento, descricao =  @descricao, dataInicio = @dataInicio, dataFim = @dataFim, pontos= @pontos WHERE idApoio = @idApoio", conn))
                    {
                        sqlCommand.Parameters.AddWithValue("@idApoio", id);
                        sqlCommand.Parameters.AddWithValue("@idStaff", apoio.idStaff);
                        sqlCommand.Parameters.AddWithValue("@idEvento", apoio.idEvento);
                        sqlCommand.Parameters.AddWithValue("@descricao", apoio.descricao);
                        sqlCommand.Parameters.AddWithValue("@dataInicio", apoio.dataInicio);
                        sqlCommand.Parameters.AddWithValue("@dataFim", apoio.dataFim);
                        sqlCommand.Parameters.AddWithValue("@pontos", apoio.pontos);


                        sqlCommand.ExecuteNonQuery();
                    }


                    conn.Close();
                }
                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Erro ao editar Apoio: " + e.Message);
                return(false);
            }
        }
示例#3
0
        public static JObject GetFichaStaff(int id)
        {
            try
            {
                dynamic json = new JObject();

                List <JObject> apoios = Apoio.GetApoiosByStaff(id);
                json["apoios"]   = JToken.FromObject(apoios);
                json.totalPontos = Apoio.GetTotalPontosStaff(id);
                return(json);
            }
            catch (Exception e)
            {
                Debug.Write("F: " + e.Message);
                return(null);
            }
        }
示例#4
0
        public static List <Apoio> GetApoiosEvento(int id)
        {
            using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
            {
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM apoio where idEvento=@id", conn))
                {
                    cmd.Parameters.AddWithValue("@id", id);

                    MySqlDataReader reader = cmd.ExecuteReader();
                    List <Apoio>    apoios = new List <Apoio>();

                    while (reader.Read())
                    {
                        apoios.Add(Apoio.FromDB(reader));
                    }

                    return(apoios);
                }
            }
        }