Esempio n. 1
0
        public List <Confeccion> GetList()
        {
            conexion.Open();
            List <Confeccion> confecciones = new List <Confeccion>();

            query = new SqlCommand("Select * From Confeccion", conexion);
            using (SqlDataReader reader = query.ExecuteReader())
            {
                while (reader.Read())
                {
                    confecciones.Add(new Confeccion(reader.GetInt32(0),
                                                    reader.GetString(1),
                                                    reader.GetInt32(2),
                                                    reader.GetInt32(3),
                                                    reader.GetDateTime(4),
                                                    new Prenda(reader.GetInt32(5))));
                }
            }
            conexion.Close();
            DALPrenda dalPrenda = new DALPrenda();

            foreach (var confeccion in confecciones)
            {
                confeccion.Prenda = dalPrenda.Get(confeccion.Prenda);
            }
            return(confecciones);
        }
Esempio n. 2
0
        public Confeccion Get(Confeccion get)
        {
            conexion.Open();
            Confeccion confeccion = new Confeccion();

            query = new SqlCommand("SELECT * FROM Confeccion WHERE Id = @Id", conexion);
            query.Parameters.AddWithValue("Id", get.Id);
            using (SqlDataReader reader = query.ExecuteReader())
            {
                while (reader.Read())
                {
                    confeccion.Id        = reader.GetInt32(0);
                    confeccion.Codigo    = reader.GetString(1);
                    confeccion.Cantidad  = reader.GetInt32(2);
                    confeccion.Tiempo    = reader.GetInt32(3);
                    confeccion.Fecha     = reader.GetDateTime(4);
                    confeccion.Prenda.Id = reader.GetInt32(5);
                }
            }
            conexion.Close();
            DALPrenda dalPrenda = new DALPrenda();

            confeccion.Prenda = dalPrenda.Get(confeccion.Prenda);
            return(confeccion);
        }