Example #1
0
        public FormacoesVO Get(int idFormacao)
        {
            FormacoesVO formacoesVO = null;

            DbCommand command = db.GetStoredProcCommand("dbo.DW_FormacoesSelect");
            db.AddInParameter(command, "@IdFormacao", DbType.Int32, idFormacao);
            using (IDataReader reader = db.ExecuteReader(command))
            {
                if (reader.Read())
                {
                    formacoesVO = new FormacoesVO();
                    formacoesVO.IsPersisted = true;
                    if (!reader.IsDBNull(reader.GetOrdinal("IdFormacao")))
                        formacoesVO.IdFormacao = reader.GetInt32(reader.GetOrdinal("IdFormacao"));
                    if (!reader.IsDBNull(reader.GetOrdinal("Curso")))
                        formacoesVO.Curso = reader.GetString(reader.GetOrdinal("Curso")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Descricao")))
                        formacoesVO.Descricao = reader.GetString(reader.GetOrdinal("Descricao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Instituicao")))
                        formacoesVO.Instituicao = reader.GetString(reader.GetOrdinal("Instituicao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("PeridoDe")))
                        formacoesVO.PeridoDe = reader.GetDateTime(reader.GetOrdinal("PeridoDe"));
                    if (!reader.IsDBNull(reader.GetOrdinal("PeriodoAte")))
                        formacoesVO.PeriodoAte = reader.GetDateTime(reader.GetOrdinal("PeriodoAte"));
                }
            }

            return formacoesVO;
        }
Example #2
0
        public FormacoesVOCollection GetAll()
        {
            FormacoesVOCollection listaFormacoesVO = new FormacoesVOCollection();
            FormacoesVO formacoesVO = null;

            DbCommand command = db.GetStoredProcCommand("dbo.DW_FormacoesSelectAll");

            using (IDataReader reader = db.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    formacoesVO = new FormacoesVO();
                    formacoesVO.IsPersisted = true;
                    if (!reader.IsDBNull(reader.GetOrdinal("IdFormacao")))
                        formacoesVO.IdFormacao = reader.GetInt32(reader.GetOrdinal("IdFormacao"));
                    if (!reader.IsDBNull(reader.GetOrdinal("Curso")))
                        formacoesVO.Curso = reader.GetString(reader.GetOrdinal("Curso")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Descricao")))
                        formacoesVO.Descricao = reader.GetString(reader.GetOrdinal("Descricao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Instituicao")))
                        formacoesVO.Instituicao = reader.GetString(reader.GetOrdinal("Instituicao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("PeridoDe")))
                        formacoesVO.PeridoDe = reader.GetDateTime(reader.GetOrdinal("PeridoDe"));
                    if (!reader.IsDBNull(reader.GetOrdinal("PeriodoAte")))
                        formacoesVO.PeriodoAte = reader.GetDateTime(reader.GetOrdinal("PeriodoAte"));
                    listaFormacoesVO.Add(formacoesVO);
                }
            }

            return listaFormacoesVO;
        }
Example #3
0
 public void Update(FormacoesVO formacoesVO)
 {
     ValidateRequiredAttributes(formacoesVO, true);
     DbCommand command = db.GetStoredProcCommand("dbo.DW_FormacoesUpdate");
     db.AddInParameter(command, "@IdFormacao", DbType.Int32, formacoesVO.IdFormacao);
     db.AddInParameter(command, "@Curso", DbType.AnsiString, formacoesVO.Curso);
     db.AddInParameter(command, "@Descricao", DbType.AnsiString, formacoesVO.Descricao);
     db.AddInParameter(command, "@Instituicao", DbType.AnsiString, formacoesVO.Instituicao);
     db.AddInParameter(command, "@PeridoDe", DbType.DateTime, formacoesVO.PeridoDe);
     db.AddInParameter(command, "@PeriodoAte", DbType.DateTime, formacoesVO.PeriodoAte);
     db.ExecuteNonQuery(command);
 }
Example #4
0
 private void ValidateRequiredAttributes(FormacoesVO formacoesVO, bool validateGuidOnPK)
 {
     if (formacoesVO.IdFormacao == null)
         RegisterCriticalMessageRequiredField("IdFormacao");
     if (string.IsNullOrEmpty(formacoesVO.Curso))
         RegisterCriticalMessageRequiredField("Curso");
     if (string.IsNullOrEmpty(formacoesVO.Descricao))
         RegisterCriticalMessageRequiredField("Descricao");
     if (string.IsNullOrEmpty(formacoesVO.Instituicao))
         RegisterCriticalMessageRequiredField("Instituicao");
     if (formacoesVO.PeridoDe == null)
         RegisterCriticalMessageRequiredField("PeridoDe");
     if (formacoesVO.PeriodoAte == null)
         RegisterCriticalMessageRequiredField("PeriodoAte");
     if (ex != null)
         throw ex;
 }
Example #5
0
        public FormacoesVOCollection GetAllPaged(long startRowIndex, int maximumRows)
        {
            FormacoesVOCollection listaFormacoesVO = new FormacoesVOCollection();
            FormacoesVO formacoesVO = null;

            DbCommand command = db.GetStoredProcCommand("dbo.DW_FormacoesSelectAllPaged");
            db.AddInParameter(command, "@startRowIndex", DbType.Int64, startRowIndex);
            db.AddInParameter(command, "@maximumRows", DbType.Int64, maximumRows);

            using (IDataReader reader = db.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    if (listaFormacoesVO.Count == 0) listaFormacoesVO.TotalRows = int.Parse(reader.GetValue(reader.GetOrdinal("TotalRows")).ToString());
                    formacoesVO = new FormacoesVO();
                    formacoesVO.IsPersisted = true;
                    if (!reader.IsDBNull(reader.GetOrdinal("IdFormacao")))
                        formacoesVO.IdFormacao = reader.GetInt32(reader.GetOrdinal("IdFormacao"));
                    if (!reader.IsDBNull(reader.GetOrdinal("Curso")))
                        formacoesVO.Curso = reader.GetString(reader.GetOrdinal("Curso")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Descricao")))
                        formacoesVO.Descricao = reader.GetString(reader.GetOrdinal("Descricao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("Instituicao")))
                        formacoesVO.Instituicao = reader.GetString(reader.GetOrdinal("Instituicao")).Trim();
                    if (!reader.IsDBNull(reader.GetOrdinal("PeridoDe")))
                        formacoesVO.PeridoDe = reader.GetDateTime(reader.GetOrdinal("PeridoDe"));
                    if (!reader.IsDBNull(reader.GetOrdinal("PeriodoAte")))
                        formacoesVO.PeriodoAte = reader.GetDateTime(reader.GetOrdinal("PeriodoAte"));
                    listaFormacoesVO.Add(formacoesVO);
                }
            }

            listaFormacoesVO.PageSize = maximumRows;

            return listaFormacoesVO;
        }