Ver Mensaje Individual
  #15 (permalink)  
Antiguo 28/07/2011, 11:11
igonfil
 
Fecha de Ingreso: junio-2008
Mensajes: 250
Antigüedad: 18 años, 4 meses
Puntos: 1
Respuesta: Arquitectura de 3 capas en vb.net

Bueno ya conseguí que funcionara de la manera anterior, pero ahora he realizado unas modificiones para poder comprender mejor esta arquitectura. Y muchísimas gracias por vuestra ayuda y espero que como a mi esto ayude a resolver estas dudas a mas gente. En esta ocasión tengo las siguientes capas:
CapaEE:
Código PHP:
Public Class CapaEE

    
Private m_productsID As String
    
Private m_productsName As String
    
Private m_UnitPrice As Integer
    
Private m_QtyAvailable As Integer
    Sub 
New()
    
End Sub
    Property ProductsID 
As String
        Get
            
Return m_productsID
        End Get
        Set
(ByVal value As String)
            
m_productsID = value
        End Set
    End Property
    Property ProdcutsName 
As String
        Get
            
Return m_productsName
        End Get
        Set
(ByVal value As String)
            
m_productsName = value
        End Set
    End Property
    Property UnitPrice 
As Integer
        Get
            
Return m_UnitPrice
        End Get
        Set
(ByVal value As Integer)
            
m_UnitPrice = value
        End Set
    End Property
    Property QtyAvailable 
As Integer
        Get
            
Return m_QtyAvailable
        End Get
        Set
(ByVal value As Integer)
            
m_QtyAvailable = value
        End Set
    End Property
  
    Sub add
(ByVal oCapaEE As CapaEE)
        Throw New 
NotImplementedException
    End Sub


End 
Class 
CapaDL:
Código PHP:
Imports System.Data.SqlClient
Imports System
.Data
Friend 
Class CapaDL
    Dim con 
As New SqlConnection
    Sub abrir
()
        
con = New SqlConnection(ConfigurationManager.ConnectionStrings("CadenaConexion").ConnectionString)
        
con.Open()
    
End Sub
    
Public Function CapaEntidad(ByVal productoId As String) As CapaEE
        abrir
()

        
Dim ret As CapaEE = New CapaEE

               Using bd 
As New SqlConnection(ConfigurationManager.ConnectionStrings("cadenaConexion").ConnectionString)
            
Using cmd As New SqlCommand("Productos", bd)
                
bd.Open()
                
Dim dr As IDataReader = cmd.ExecuteReader
                With dr
                    
While dr.Read
                        ret
.ProductsID = .Item(0).ToString.Trim

                                          End 
While
                
End With
            End Using
        End Using
        
Return ret
    End 
Function
End Class 
CapaBL:
Código PHP:
Public Class CapaBL

    
Private Shared m_current As New CapaBL
    Dim dl 
As New CapaDL
    
Public Shared ReadOnly Property Current() As CapaBL
        Get
            
Return m_current
        End Get
    End Property
    
Private Sub New()

    
End Sub
    
Public Function getCapa(ByVal ProductoID As String) As CapaEE
        
Return Current.dl.CapaEntidad(ProductoID)
    
End Function
End Class 
CapaVista
Código PHP:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim oCapa 
As New CapaEE

        oCapa 
= CapaBL.Current.getCapa("P001")
        
LblID.Text = oCapa.ProductsID

    End Sub 
y ademas tengo el siguiente procedimiento almacenado
Código PHP:
USE [Prueba]
GO
/****** Object:  StoredProcedure [dbo].[Ver_Productos]    Script Date: 07/28/2011 18:42:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE 
[dbo].[Ver_Productos]
    @
ProductID varchar    
AS
   
Select * from Products where ProductID=@ProductID order by ProductID desc; 
En esta ocasión me muestra en el dr el siguiente error (se el motivo de este error pero no se como adjuntar este parametro desde la capa correspondiente)
Cita:
Procedure or function 'Ver_Productos' expects parameter '@ProductID', which was not supplied.