コード例 #1
0
        public List <GastosTotaisDTO> GetRelacaoPorAno(GastosTotaisDTO gastosTotais)
        {
            List <GastosTotaisDTO> list = new List <GastosTotaisDTO>();

            using (MySqlConnection conn = new DBContext(ConnectionString).GetConnection())
            {
                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.Append(@" SELECT 
                                            MES,
                                            SUM(TOTAL_REMUNERACAO) AS TOTAL_REMUNERACAO
                                        FROM gastostotais
                                        WHERE ANO = @pAno
                                        GROUP BY MES
                                        ORDER BY MES ASC; ");

                conn.Open();
                MySqlCommand cmd = new MySqlCommand(stringBuilder.ToString(), conn);

                cmd.Parameters.AddWithValue("@pAno", gastosTotais.Ano);

                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new GastosTotaisDTO()
                        {
                            Mes = reader.GetInt32("MES"),
                            TotalRemuneracao = reader.GetDouble("TOTAL_REMUNERACAO")
                        });
                    }
                }
            }

            return(list);
        }
コード例 #2
0
 public List <GastosTotaisDTO> GetRelacaoPorAno(GastosTotaisDTO gastosTotais)
 {
     return(new GastosTotaisDAO(ConnectionString).GetRelacaoPorAno(gastosTotais));
 }