コード例 #1
0
        public Boolean InsertarResidente(entResidente Residente)
        {
            SqlCommand cmd     = null;
            Boolean    Inserta = false;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_INSERTARRESIDENTE", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmstrApellidosresidente", Residente.Apellidosresidente);
                cmd.Parameters.AddWithValue("@prmstrDireccionresidente", Residente.Direccionresidente);
                cmd.Parameters.AddWithValue("@prmstrNombresresidente", Residente.Nombresresidente);
                cmd.Parameters.AddWithValue("@prmstrTelefonoresidente", Residente.Telefonoresidente);
                cn.Open();
                int i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    Inserta = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(Inserta);
        }
コード例 #2
0
        public List <entResidente> ListarResidentesSinUsuarios()
        {
            SqlCommand          cmd   = null;
            List <entResidente> lista = new List <entResidente>();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_LISTARRESIDENTESSINUSUARIOS", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    entResidente residente = new entResidente();
                    residente.ResidenteID        = Convert.ToInt16(dr["ResidenteID"]);
                    residente.Nombresresidente   = dr["Nombresresidente"].ToString();
                    residente.Apellidosresidente = dr["Apellidosresidente"].ToString();
                    residente.Direccionresidente = dr["Direccionresidente"].ToString();
                    residente.Telefonoresidente  = dr["Telefonoresidente"].ToString();
                    lista.Add(residente);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(lista);
        }
コード例 #3
0
        public entResidente ObtenerResidente(int ResidenteID)
        {
            SqlCommand   cmd       = null;
            entResidente residente = new entResidente();

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("SP_OBTENERRESIDENTE", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmintResidenteID", ResidenteID);
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    residente.ResidenteID        = Convert.ToInt16(dr["ResidenteID"]);
                    residente.Nombresresidente   = dr["Nombresresidente"].ToString();
                    residente.Apellidosresidente = dr["Apellidosresidente"].ToString();
                    residente.Direccionresidente = dr["Direccionresidente"].ToString();
                    residente.Telefonoresidente  = dr["Telefonoresidente"].ToString();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { cmd.Connection.Close(); }
            return(residente);
        }
コード例 #4
0
        public ActionResult EditaResidente(int ResidenteID)
        {
            entResidente Residente = logResidente.Instancia.ObtenerResidente(ResidenteID);

            if (Residente == null)
            {
                return(HttpNotFound());
            }
            return(View(Residente));
        }
コード例 #5
0
 public Boolean EditarResidente(entResidente Residente)
 {
     try
     {
         return(datResidente.Instancia.EditarResidente(Residente));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #6
0
 public ActionResult NuevoResidente(entResidente Residente)
 {
     try
     {
         Boolean inserta = logResidente.Instancia.InsertarResidente(Residente);
         if (inserta)
         {
             return(RedirectToAction("ListaResidentes"));
         }
         else
         {
             return(View(Residente));
         }
     }
     catch (ApplicationException ex)
     {
         return(RedirectToAction("ListaResidentes", new { msjException = ex.Message }));
     }
 }