Sistemas informaticos

Solo disponible en BuenasTareas
  • Páginas : 2 (432 palabras )
  • Descarga(s) : 0
  • Publicado : 29 de noviembre de 2011
Leer documento completo
Vista previa del texto
IDAT CHICLAYO ASP .NET CARRITO DE COMPRAS

Código Fuente:
Imports System.Data Imports System.Data.SqlClient Partial Class Default10 Inherits System.Web.UI.Page Dim con As New SqlConnection("userid=sa;data source=(local);Initial catalog=ventas") Dim cmd As SqlCommand Dim dtb As New DataTable("Carrito") Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand Dim f As GridViewRow = Me.GridView1.Rows(e.CommandArgument) 'Response.Write(f.Cells(0).Text) 'Obtiene el valor del campo clave Dim cod AsInteger = Me.GridView1.DataKeys(e.CommandArgument).Value 'Obtiene el valor del cuadro de texto TextBox1 Dim t As TextBox = f.Cells(4).FindControl("textBox1") If con.State = ConnectionState.Closed Thencon.Open()

Ing. Juan Zevallos V.

1

IDAT CHICLAYO
cmd = New SqlCommand("select stock from productos where codpro=" & cod & "", con) Dim s As Integer = cmd.ExecuteScalar If CInt(t.Text) > sThen Me.Label2.Text = "Stock insuficiente" Else Dim pro As String = f.Cells(1).Text Dim pre As String = CDbl(f.Cells(2).Text) Dim tot As Double = pre * CDbl(t.Text) Dim car As New DataTable car =Session("aux") Dim fi As DataRow = car.NewRow fi(0) = cod fi(1) = pro fi(2) = pre fi(3) = CInt(t.Text) fi(4) = tot car.Rows.Add(fi) 'Response.Write(car.Rows.Count) Session("aux") = car End If End SubProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim col1 As New DataColumn("Codigo", GetType(Integer)) Dim col2 As NewDataColumn("Producto", GetType(String)) Dim col3 As New DataColumn("Precio", GetType(Double)) Dim col4 As New DataColumn("Cantidad", GetType(Integer)) Dim col5 As New DataColumn("Total", GetType(Double))dtb.Columns.Add(col1) dtb.Columns.Add(col2) dtb.Columns.Add(col3) dtb.Columns.Add(col4) dtb.Columns.Add(col5) Session("aux") = dtb End If End Sub Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e...
tracking img