Documente Academic
Documente Profesional
Documente Cultură
Pagina Catalogo.aspx
Pagina listacomprados.aspx
COMPONENTEDATOS
CLASE Conexion
Public Class Conexion
Private Shared ReadOnly _instancia As Conexion = New Conexion
Private Sub New()
End Sub
Public Shared ReadOnly Property Instancia() As Conexion
Get
Return _instancia
End Get
End Property
Public Function cadenaconexion() As String
Return "Data Source=SERVER;Initial Catalog=BDClases;Integrated
Security=True"
End Function
End Class
CLASE ProductosDA
Imports System.Data
Imports System.Data.SqlClient
Imports ComponenteEntidad
Public Class ProductosDA
Private Shared ReadOnly _instancia As New ProductosDA
Public Shared ReadOnly Property Instancia() As ProductosDA
Get
Return _instancia
End Get
End Property
Public Function ListarTodos() As List(Of Productos)
Dim cnn As New SqlConnection(Conexion.Instancia.cadenaconexion)
cnn.Open()
Dim sqlcmd As New SqlCommand("pa_productos_Listar", cnn)
sqlcmd.CommandType = CommandType.StoredProcedure
Dim PaTable As SqlDataReader = sqlcmd.ExecuteReader
Dim Coleccion As New List(Of Productos)
While PaTable.Read
Coleccion.Add(New Productos(PaTable.Item(0), PaTable.Item(1),
PaTable.Item(2), PaTable.Item(3), PaTable.Item(4)))
End While
cnn.Close()
cnn.Dispose()
Return Coleccion
End Function
COMPONENTEENTIDAD
Public Class Productos
Private _codproducto As String
Private _descripcion As String
Private _precio As Double
Private _cantidad As Integer
Private _foto As String
Public Property codproducto() As String
Get
Return _codproducto
End Get
Set(ByVal value As String)
_codproducto = value
End Set
End Property
COMPONENTENEGOCIO
Imports ComponenteEntidad
Imports ComponenteDatos
Public Class ProductosCN
Public Sub New()
End Sub
Private Shared ReadOnly _instancia As New ProductosCN
Public Shared ReadOnly Property Instancia() As ProductosCN
Get
Return _instancia
End Get
End Property
Public Function ListarTodos() As List(Of Productos)
Return ProductosDA.Instancia.ListarTodos
End Function
Public Function ListarporCodigo(ByVal cod As String) As List(Of
Productos)
Return ProductosDA.Instancia.ListarporCodigo(cod)
End Function
Public Function Insertar(ByVal Productos As Productos) As Boolean
ProductosDA.Instancia.Insertar(Productos)
End Function
Public Function Editar(ByVal Productos As Productos) As Boolean
ProductosDA.Instancia.Editar(Productos)
End Function
Public Function Eliminar(ByVal codproducto As String) As Boolean
ProductosDA.Instancia.Eliminar(codproducto)
End Function
End Class
CREAR CANASTADS
EN LA PAGINA CATALOGOS
EDIT TEMPLATES
PROPIEDADES DE PRECIOLABEL
EN LA PAGINA LISTACOMPRADOS
<table class="style1">
<tr>
<td bgcolor="#006699">
<asp:Label ID="Label2" runat="server" Font-Bold="True"
ForeColor="White"
Text="Mi Carrito de Compras"></asp:Label>
</td>
</tr>
<tr>
<td class="style2">
<asp:GridView ID="GvwCarrito" runat="server"
AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px"
CellPadding="3" Width="444px">
<RowStyle ForeColor="#000066" />
<Columns>
<asp:TemplateField HeaderText="Quitar">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server"
CommandArgument='<%#
Eval("codproducto") %>' CommandName='Borrar'
ImageUrl="~/Imagenes/Eliminar.png" HeaderText="Quitar"
onclick="ImageButton1_Click"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="codproducto"
HeaderText="Codigo" />
<asp:BoundField DataField="desproducto"
HeaderText="Producto" />
<asp:BoundField DataField="preproducto"
HeaderText="Precio" />
<asp:TemplateField HeaderText="Cantidad" >
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("canproducto") %>'
ontextchanged="TextBox1_TextChanged"
Width="80px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="subtotal"
HeaderText="Subtotal" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True"
ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True"
ForeColor="White" />
</asp:GridView>
</td>
</tr>
<tr>
<td align="right" class="style2">
<asp:Label ID="Label1" runat="server" Text="Subtotal S/." FontBold="True"></asp:Label>
&
nbsp;
<asp:Label ID="Lblsubtotal" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td align="center" class="style2">
<asp:Button ID="Button1" runat="server" Text="Actualizar Datos"
style="height: 26px" />
<asp:Button ID="Button2" runat="server" Text="Continuar Comprando" />
</td>
</tr>
</table>