예제 #1
0
        public static List<MaterialMueble> GetByIdMueble(Mueble item)
        {
            SqlDataReader reader = null;
            SqlConnection connection = null;

            connection = new SqlConnection(MuebleDAO.CONNECTION_STRING);

            string query = "SELECT m.id_material "
                + ",m.denominacion "
                + ",m.caracteristicas "
                + ",m.stock_minimo "
                + ",m.stock_real "
                + ",m.stock_asignado "
                + ",m.id_ud_medida "
                + ",mm.cantidad "
                + "From Materiales m, Materiales_Muebles mm  "
                + "WHERE mm.idMueble = @idMueble ";

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = query;
            cmd.Connection = connection;
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@idMueble", item.IdMueble);

            connection.Open();
            reader = cmd.ExecuteReader();

            List<MaterialMueble> materialMueble = new List<MaterialMueble>();

            if (reader.Read())
            {
                MaterialDAO matDao = new MaterialDAO();
                Material material = new Material();
                material.IdMaterial = (int?)reader["id_material"];
                material.Denominacion = (string)reader["denominacion"];
                material.Caracteristicas = (string)reader["caracteristicas"];
                material.StockMin = (Decimal)reader["stock_minimo"];
                material.StockReal = (Decimal)reader["stock_real"];
                material.StockAsign = (Decimal)reader["stock_asignado"];
                int? idUnidadMedida = (int?)reader["id_ud_medida"];
                if (idUnidadMedida != null)
                {
                    material.UdMedida = UnidadMedidaDAO.GetById(idUnidadMedida.Value);
                }
                MaterialMueble mm = new MaterialMueble();
                mm.Cantidad = (Int32)reader["cantidad"];
                mm.Material = material;
                materialMueble.Add(mm);
            }

            return materialMueble;
        }
예제 #2
0
 public void MaterialDAOConstructorTest()
 {
     MaterialDAO target = new MaterialDAO();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }