Bueno me ha surgido otra duda y esta es al rellenar un DataGrid con la arquitectura anteriormente usada.
El codigo que tengo es el siguiente:
Código PHP:
Public Class DataGridEE
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
Public Sub New(ByVal pProductsID As String,
ByVal pProdcutsName As String,
ByVal pUnitPrice As Integer,
ByVal pQtyAvailable As Integer)
m_productsID = pProductsID
m_productsName = pProdcutsName
m_UnitPrice = pUnitPrice
m_QtyAvailable = pQtyAvailable
End Sub
End Class
Public Class DataGridEEList
Inherits SortableList(Of DataGridEE)
Dim LDataGridEE As New List(Of DataGridEE)
Sub add(ByVal oDataGridEE As DataGridEE)
Throw New NotImplementedException
End Sub
End Class
Código PHP:
Public Class DataGridBL
Private Shared m_current As New DataGridBL
Dim dl As New DataGridDL
Public Shared ReadOnly Property Current() As DataGridBL
Get
Return m_current
End Get
End Property
Private Sub New()
End Sub
Public Function getDataGrid(ByVal ProductoID As String) As DataGridEEList
Return Current.dl.getCapaEntidad(ProductoID)
End Function
End Class
Código PHP:
Imports System.Data.SqlClient
Imports System.Data
Friend Class DataGridDL
Dim con As New SqlConnection
Sub abrir()
con = New SqlConnection(ConfigurationManager.ConnectionStrings("CadenaConexion").ConnectionString)
con.Open()
End Sub
Public Function getCapaEntidad(ByVal productoId As String) As DataGridEEList
abrir()
Dim ret As DataGridEEList = New DataGridEEList
Dim oDataGridEE As DataGridEE
Dim oCapaEE As CapaEE
Using bd As New SqlConnection(ConfigurationManager.ConnectionStrings("cadenaConexion").ConnectionString)
Using cmd As New SqlCommand("Ver_Productos", bd)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@ProductID", productoId)
bd.Open()
Dim dr As IDataReader = cmd.ExecuteReader
With dr
While dr.Read()
oDataGridEE = New DataGridEE()
oDataGridEE.ProductsID = dr.Item(0)
oDataGridEE.ProdcutsName = dr.Item(1)
ret.add(oDataGridEE)
End While
End With
End Using
End Using
Return ret
End Function
Sub DataGridEntidad(ByVal p1 As String)
Throw New NotImplementedException
End Sub
End Class
Código PHP:
sqltext = "select c_idprueba, c_nombre from T_prueba"
dAdapter = New SqlDataAdapter(sqltext, con)
dAdapter.Fill(dSet, "Prueba")
MyDataGrid.DataSource = dSet.Tables(0)
MyDataGrid.DataSource = dSet
MyDataGrid.DataBind()
con.Close()
Dim da As New SqlDataAdapter
Dim objDs As New Data.DataSet
Dim oDataGridList As New DataGridEEList
oDataGridList = DataGridBL.Current.getDataGrid("P001")
Me.MyDataGrid2.DataSource = oDataGridList
Me.MyDataGrid2.DataBind()
Me.MyDataGrid2.Focus()
End Sub
End Class
La clase me recoge datos pero luego en me salta la siguiente exception al pasar por ret.add(oDataGridEE)
Cita: No se puede implementar el método o la operación.
¿Cual es mi error? Muchas gracias