コード例 #1
0
ファイル: PrincipalController.cs プロジェクト: KassabNova/UAG
        //public ActionResult ObtenerMascota()
        //{
        //    ViewBag.Message = "Mascotas";
        //    List<Mascota> mascota = new List<Mascota>();
        //    mascota = DALittlePets.ObtenerMascota();
        //    return View("Mascota", mascota);
        //}

        public ActionResult ObtenerMascotaDetalle(int idmascota)
        {
            MascotaDetalle mascota = new MascotaDetalle();

            mascota = DALittlePets.ObtenerMascotaDetalle(idmascota);
            return(View("MascotaDetalle", mascota));
        }
コード例 #2
0
ファイル: DALittlePets.cs プロジェクト: KassabNova/UAG
        public static MascotaDetalle ObtenerMascotaDetalle(int idmascota)
        {
            MascotaDetalle mascota = null;

            SqlConnection conexion = new SqlConnection("Data Source=(LocalDB)\\Prueba;Initial Catalog=LittlePets; Integrated Security=true");
            SqlCommand    comando  = new SqlCommand("spObtenerMascotaDetalle", conexion);


            SqlDataReader dr = comando.ExecuteReader();

            if (dr.HasRows)
            {
                mascota = new MascotaDetalle();
                if (dr.Read())
                {
                    mascota.IdMascota  = Convert.ToInt32(dr["IdMascota"]);
                    mascota.Dueño      = Convert.ToString(dr["NombreDueño"]);
                    mascota.Nombre     = Convert.ToString(dr["NombreMascota"]);
                    mascota.Especie    = Convert.ToString(dr["Especie"]);
                    mascota.Raza       = Convert.ToString(dr["Raza"]);
                    mascota.Color      = Convert.ToString(dr["Color"]);
                    mascota.Peso       = Convert.ToDecimal(dr["Peso"]);
                    mascota.Sexo       = Convert.ToString(dr["Sexo"]);
                    mascota.Nacimiento = Convert.ToDateTime(dr["Nacimiento"]);
                }
            }
            conexion.Close();
            return(mascota);
        }
コード例 #3
0
        public ActionResult ObtenerMascotaDetalle(string idmascota)
        {
            int            idMascota = Convert.ToInt32(idmascota);
            MascotaDetalle mascota   = new MascotaDetalle();

            mascota = DALittlePets.ObtenerMascotaDetalle(idMascota);
            return(View("MascotaDetalle", mascota));
        }
コード例 #4
0
ファイル: DALittlePets.cs プロジェクト: KassabNova/LittlePets
        public static MascotaDetalle ObtenerMascotaDetalle(int idmascota)
        {
            MascotaDetalle mascota = null;

            try
            {
                SqlConnection conexion = new SqlConnection(CONEXION_KASSAB);
                using (conexion)
                {
                    conexion.Open();
                    using (SqlCommand comando = new SqlCommand("spObtenerMascotaDetalle", conexion))
                    {
                        comando.CommandType = CommandType.StoredProcedure;
                        comando.Parameters.AddWithValue("@IdMascota", idmascota);
                        using (SqlDataReader lector = comando.ExecuteReader())
                        {
                            if (lector.HasRows)
                            {
                                mascota = new MascotaDetalle();
                                if (lector.Read())
                                {
                                    mascota.IdMascota = Convert.ToInt32(lector["IdMascota"]);
                                    mascota.Dueño     = Convert.ToString(lector["NombreDueño"]);
                                    mascota.Cuidador  = Convert.ToString(lector["NombreCuidador"]);
                                    mascota.Nombre    = Convert.ToString(lector["Nombre"]);
                                    mascota.Especie   = Convert.ToString(lector["Especie"]);
                                    mascota.Raza      = Convert.ToString(lector["Raza"]);
                                    mascota.Color     = Convert.ToString(lector["Color"]);
                                    mascota.Peso      = Convert.ToDecimal(lector["Peso"]);
                                    mascota.Sexo      = Convert.ToString(lector["Sexo"]);
                                    mascota.Edad      = Convert.ToInt32(lector["Edad"]);
                                }
                            }
                        }
                    }
                    conexion.Close();
                }
            }
            catch
            {
                throw;
            }
            return(mascota);
        }