コード例 #1
0
ファイル: GestorPrueba.cs プロジェクト: pablobar23/RRHH
 public void registrarPrueba(String pnombre, int pidTecnologia, int ppuntajeTotal, String pdescripcion, String pnivelDificultad, int pcantidadPreguntas)
 {
     Prueba prueba = new Prueba(pnombre, pidTecnologia, ppuntajeTotal, pdescripcion, pnivelDificultad, pcantidadPreguntas);
     UoW.PruebaRepository.Insert(prueba);
 }
コード例 #2
0
ファイル: GestorPrueba.cs プロジェクト: pablobar23/RRHH
 public void eliminarPrueba(int pidPrueba)
 {
     Prueba prueba = new Prueba { Id = pidPrueba };
     UoW.PruebaRepository.Delete(prueba);
 }
コード例 #3
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
        private void UpdatePrueba(Prueba Prueba)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();

                DataSet ds = DBAccess.ExecuteSPWithDS(cmd, "USP_Prueba_Update");

            }
            catch (SqlException ex)
            {
                if (ex.Number == 2601) // Cannot insert duplicate key row in object error
                {
                    throw new DataAccessException("Hubo un error al modificar la Prueba. El nombre de la Prueba ya existe.", ex);
                }
                else
                {
                    //logear la excepcion a la bd con un Exception
                    throw new DataAccessException("Ha ocurrido un error al modificar una Prueba", ex);
                }
            }
            catch (Exception ex)
            {
                //logear la excepcion a la bd con un Exception
                throw new DataAccessException("Ha ocurrido un error al modificar una Prueba", ex);
            }
        }
コード例 #4
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
 public void Delete(Prueba entity)
 {
     _deleteItems.Add(entity);
 }
コード例 #5
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
        private void InsertPrueba(Prueba prueba)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.Add(new SqlParameter("@nombre",prueba.Nombre));
                cmd.Parameters.Add(new SqlParameter("@id_tecnologia", prueba.IdTecnologia));
                cmd.Parameters.Add(new SqlParameter("@puntaje_total", prueba.PuntajeTotal));
                cmd.Parameters.Add(new SqlParameter("@descripcion", prueba.Descripcion));
                cmd.Parameters.Add(new SqlParameter("@nivel_dificultad", prueba.NivelDificultad));
                cmd.Parameters.Add(new SqlParameter("@cantidad_preguntas", prueba.CantidadPreguntas));
                cmd.Parameters.Add(new SqlParameter("@instrucciones", prueba.Instrucciones));

                DBAccess.ExecuteSPNonQuery(cmd, "USP_Prueba_Insert");

            }
            catch (SqlException ex)
            {
                if (ex.Number == 2601) // Cannot insert duplicate key row in object error
                {
                    throw new DataAccessException("Hubo un error al registrar la Prueba. El nombre de la Prueba ya existe.", ex);
                }
                else
                {
                    //logear la excepcion a la bd con un Exceptionv
                    throw new DataAccessException("Ha ocurrido un error al registrar un Prueba", ex);
                }

            }
            catch (Exception ex)
            {
                //logear la excepcion a la bd con un Exception
                throw new DataAccessException("Ha ocurrido un error al registrar una Prueba", ex);
            }
        }
コード例 #6
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
        private void DeletePrueba(Prueba Prueba)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.Add(new SqlParameter("@id_prueba", Prueba.Id));
                DataSet ds = DBAccess.ExecuteSPWithDS(cmd, "USP_Prueba_Delete");

            }
            catch (SqlException ex)
            {
                //logear la excepcion a la bd con un Exception
                throw new DataAccessException("Ha ocurrido un error al eliminar una Prueba", ex);

            }
            catch (Exception ex)
            {
                //logear la excepcion a la bd con un Exception
                throw new DataAccessException("Ha ocurrido un error al eliminar una Prueba", ex);
            }
        }
コード例 #7
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
 public void Update(Prueba entity)
 {
     _updateItems.Add(entity);
 }
コード例 #8
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
 public void Insert(Prueba entity)
 {
     _insertItems.Add(entity);
 }
コード例 #9
0
ファイル: PruebaRepository.cs プロジェクト: pablobar23/RRHH
 public Prueba GetById(int pid)
 {
     Prueba prueba = null;
     var sqlQuery = "SELECT [id_prueba],[nombre_prueba],[id_tecnologia],[puntaje_total],[descripcion],[nivel_dificultad],[cantidad_preguntas],[instrucciones] "+
                    "FROM [DyORRHH].[dbo].[Pruebas]"+
                    "WHERE [id_prueba] = @idPrueba";
     SqlCommand cmd = new SqlCommand();
     cmd.Parameters.AddWithValue("@idPrueba", pid);
     var ds = DBAccess.ExecuteSQLWithDS(cmd, sqlQuery);
     if (ds.Tables[0].Rows.Count > 0)
     {
         var dr = ds.Tables[0].Rows[0];
         prueba = new Prueba
         {
             Id = Convert.ToInt32(dr["id_prueba"]),
             Nombre = dr["nombre_prueba"].ToString(),
             IdTecnologia = Convert.ToInt32(dr["id_tecnologia"]),
             PuntajeTotal = Convert.ToInt32(dr["puntaje_total"]),
             Descripcion = dr["descripcion"].ToString(),
             NivelDificultad = dr["nivel_dificultad"].ToString(),
             CantidadPreguntas = Convert.ToInt32(dr["cantidad_preguntas"]),
             Instrucciones = dr["instrucciones"].ToString()
         };
     }
     return prueba;
 }