Esempio n. 1
0
        /// <summary>
        /// Retorna todas as ocorrências de CategoriaData
        /// throws BusinessData.BusinessLogic.DataAccess.DataAccessExceptiom
        /// </summary>
        /// <returns>Lista de CategoriaData</returns>
        public List <CategoriaData> GetCategoriaData()
        {
            DbCommand            cmd = baseDados.GetStoredProcCommand("CategoriasDataSelect");
            CategoriaData        aux;
            List <CategoriaData> listaAux = new List <CategoriaData>();
            Color cor;

            try
            {
                using (IDataReader leitor = baseDados.ExecuteReader(cmd))
                {
                    while (leitor.Read())
                    {
                        cor = Color.FromName(leitor.GetString(leitor.GetOrdinal("Cor")));
                        aux = CategoriaData.GetCategoriaData(leitor.GetGuid(leitor.GetOrdinal("CategoriasDataId")),
                                                             leitor.GetString(leitor.GetOrdinal("Descricao")),
                                                             cor,
                                                             leitor.GetBoolean(leitor.GetOrdinal("DiaLetivo")));
                        listaAux.Add(aux);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new DataAccessException(ErroMessages.GetErrorMessage(ex.Number), ex);
            }

            return(listaAux);
        }
Esempio n. 2
0
        /// <summary>
        /// Retorna Categoria de Data relativa ao Id especificado
        /// throws BusinessData.BusinessLogic.DataAccess.DataAccessExceptiom
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CategoriaData GetCategoriaData(Guid id)
        {
            DbCommand cmd = baseDados.GetStoredProcCommand("CategoriasDataSelectById");

            baseDados.AddInParameter(cmd, "@CategoriasDataId", DbType.Guid, id);

            CategoriaData aux = null;
            Color         cor;

            try
            {
                using (IDataReader leitor = baseDados.ExecuteReader(cmd))
                {
                    leitor.Read();
                    cor = Color.FromName(leitor.GetString(leitor.GetOrdinal("Cor")));
                    aux = CategoriaData.GetCategoriaData(leitor.GetGuid(leitor.GetOrdinal("CategoriasDataId")),
                                                         leitor.GetString(leitor.GetOrdinal("Descricao")),
                                                         cor,
                                                         leitor.GetBoolean(leitor.GetOrdinal("DiaLetivo")));
                }
            }
            catch (SqlException ex)
            {
                throw new DataAccessException(ErroMessages.GetErrorMessage(ex.Number), ex);
            }
            catch (Exception)
            {
                return(null);
            }
            return(aux);
        }