コード例 #1
0
        public List <entPrograma> ListarProgramas()
        {
            SqlCommand         cmd   = null;
            List <entPrograma> lista = new List <entPrograma>();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_LISTARPROGRAMAS", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    entPrograma programa = new entPrograma();
                    programa.ProgramaID          = Convert.ToInt16(dr["ProgramaID"]);
                    programa.Nombreprograma      = dr["Nombreprograma"].ToString();
                    programa.Descripcionprograma = dr["Descripcionprograma"].ToString();
                    programa.Coordinadorprograma = dr["Coordinadorprograma"].ToString();
                    programa.Fechainicioprograma = Convert.ToDateTime(dr["Fechainicioprograma"]);
                    programa.Fechafinprograma    = Convert.ToDateTime(dr["Fechafinprograma"]);
                    programa.Obra      = datObra.Instancia.ObtenerObra(Convert.ToInt16(dr["ObraID"]));
                    programa.Residente = datResidente.Instancia.ObtenerResidente(Convert.ToInt16(dr["ResidenteID"]));
                    lista.Add(programa);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(lista);
        }
コード例 #2
0
        public Boolean EditarPrograma(entPrograma programa)
        {
            SqlCommand cmd   = null;
            Boolean    edita = false;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_EDITARPROGRAMA", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmintProgramaID", programa.ProgramaID);
                cmd.Parameters.AddWithValue("@prmstrCoordinadorprograma", programa.Coordinadorprograma);
                cmd.Parameters.AddWithValue("@prmstrDescripcionprograma", programa.Descripcionprograma);
                cmd.Parameters.AddWithValue("@prmdtFechainicioprograma", programa.Fechainicioprograma);
                cmd.Parameters.AddWithValue("@prmdtFechafinprograma", programa.Fechafinprograma);
                cmd.Parameters.AddWithValue("@prmstrNombreprograma", programa.Nombreprograma);
                cn.Open();
                int i = cmd.ExecuteNonQuery();
                if (i >= 0)
                {
                    edita = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(edita);
        }
コード例 #3
0
        public entPrograma ObtenerPrograma(int ProgramaID)
        {
            SqlCommand  cmd      = null;
            entPrograma programa = new entPrograma();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_OBTENERPROGRAMA", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmintProgramaID", ProgramaID);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    programa.ProgramaID          = Convert.ToInt16(dr["ProgramaID"]);
                    programa.Nombreprograma      = dr["Nombreprograma"].ToString();
                    programa.Descripcionprograma = dr["Descripcionprograma"].ToString();
                    programa.Coordinadorprograma = dr["Coordinadorprograma"].ToString();
                    programa.Fechainicioprograma = Convert.ToDateTime(dr["Fechainicioprograma"]);
                    programa.Fechafinprograma    = Convert.ToDateTime(dr["Fechafinprograma"]);
                    programa.Obra      = datObra.Instancia.ObtenerObra(Convert.ToInt16(dr["ObraID"]));
                    programa.Residente = datResidente.Instancia.ObtenerResidente(Convert.ToInt16(dr["ResidenteID"]));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(programa);
        }
コード例 #4
0
        public entPrograma ObtenerPrograma(int ProgramaID)
        {
            SqlCommand  cmd      = null;
            entPrograma programa = new entPrograma();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_OBTENERPROGRAMA", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmProgramaID", ProgramaID);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    programa.ProgramaID = Convert.ToInt16(dr["ProgramaID"]);
                    programa.Residente  = daoResidente.Instancia.ObtenerResidente(1);
                    programa.Obra       = daoObra.Instancia.ObtenerObra(Convert.ToInt16(dr["ObraID"]));
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(programa);
        }
コード例 #5
0
        public Boolean InsertarPrograma(entPrograma programa)
        {
            SqlCommand cmd     = null;
            Boolean    Inserta = false;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_INSERTARPROGRAMA", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmObraID", programa.Obra.ObraID);
                cmd.Parameters.AddWithValue("@prmResidenteID", programa.Residente.ResidenteID);
                cn.Open();
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    Inserta = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(Inserta);
        }
コード例 #6
0
        public List <entPrograma> ListarPrograma()
        {
            SqlCommand         cmd   = null;
            List <entPrograma> lista = new List <entPrograma>();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_LISTARPROGRAMA", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    entPrograma programa = new entPrograma();
                    programa.ProgramaID = Convert.ToInt16(dr["ProgramaID"]);
                    programa.Residente  = daoResidente.Instancia.ObtenerResidente(1);
                    programa.Obra       = daoObra.Instancia.ObtenerObra(Convert.ToInt16(dr["ObraID"]));
                    lista.Add(programa);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(lista);
        }
コード例 #7
0
        public ActionResult EditaPrograma(int ProgramaID)
        {
            entPrograma Programa = logPrograma.Instancia.ObtenerPrograma(ProgramaID);

            if (Programa == null)
            {
                return(HttpNotFound());
            }
            return(View(Programa));
        }
コード例 #8
0
 public Boolean InsertaPrograma(entPrograma programa)
 {
     try
     {
         return(daoPrograma.Instancia.InsertarPrograma(programa));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #9
0
 public Boolean EditarPrograma(entPrograma Programa)
 {
     try
     {
         return(datPrograma.Instancia.EditarPrograma(Programa));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #10
0
 public ActionResult NuevoPrograma(entPrograma Programa)
 {
     try
     {
         Programa.Obra      = logObra.Instancia.ObtenerObra(ProgramaController.ObraID);
         Programa.Residente = logResidente.Instancia.ObtenerResidente(ProgramaController.ResidenteID);
         Boolean inserta = logPrograma.Instancia.InsertarPrograma(Programa);
         if (inserta)
         {
             return(RedirectToAction("ListaProgramas", new { ObraID = Programa.Obra.ObraID }));
         }
         else
         {
             return(View(Programa));
         }
     }
     catch (ApplicationException ex)
     {
         return(RedirectToAction("ListaProgramas", new { msjException = ex.Message }));
     }
 }