Esempio n. 1
0
        public Tenido Get(Tenido get)
        {
            conexion.Open();
            Tenido teñido = new Tenido();

            query = new SqlCommand("SELECT * FROM Teñido WHERE Id = @Id", conexion);
            query.Parameters.AddWithValue("Id", get.Id);
            using (SqlDataReader reader = query.ExecuteReader())
            {
                while (reader.Read())
                {
                    teñido.Id     = reader.GetInt32(0);
                    teñido.Codigo = reader.GetString(1);
                    teñido.CantidadTelaUtilizada  = reader.GetInt32(2);
                    teñido.CantidadTinteUtilizada = reader.GetInt32(3);
                    teñido.Tiempo   = reader.GetInt32(4);
                    teñido.Fecha    = reader.GetDateTime(5);
                    teñido.Tela.Id  = reader.GetInt32(6);
                    teñido.Tinte.Id = reader.GetInt32(7);
                }
            }
            conexion.Close();
            DALTela dalTela = new DALTela();

            teñido.Tela = dalTela.Get(teñido.Tela);
            DALTinte dalTinte = new DALTinte();

            teñido.Tinte = dalTinte.Get(teñido.Tinte);
            return(teñido);
        }
Esempio n. 2
0
        public List <Tenido> GetList()
        {
            conexion.Open();
            List <Tenido> teñidos = new List <Tenido>();

            query = new SqlCommand("Select * From Teñido", conexion);
            using (SqlDataReader reader = query.ExecuteReader())
            {
                while (reader.Read())
                {
                    teñidos.Add(new Tenido(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(3), reader.GetInt32(2), reader.GetInt32(4), reader.GetDateTime(5), new Tinte(reader.GetInt32(7)), new Tela(reader.GetInt32(6))));
                }
            }
            conexion.Close();
            DALTinte dalTinte = new DALTinte();
            DALTela  dalTela  = new DALTela();

            foreach (var teñido in teñidos)
            {
                teñido.Tinte = dalTinte.Get(teñido.Tinte);
                teñido.Tela  = dalTela.Get(teñido.Tela);
            }
            return(teñidos);
        }