Inherits System.Web.UI.Page Dim conexion As New SqlConnection("Data Source=TELMEX0;Initial Catalog=Verduras;Integrated Security=True")
Protected Sub Page_Load(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Me.Load Call llenagrid() End Sub Sub limpia() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" End Sub Sub llenagrid() Dim datos As New DataSet Dim adaptador As New SqlDataAdapter("select * from Verduras", conexion) adaptador.Fill(datos, "verduras") GridView1.DataSource = datos.Tables("verduras") GridView1.DataBind() End Sub Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click MultiView1.ActiveViewIndex = 0 Call limpia() End Sub
Protected Sub Button1_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strcomando As String strcomando = String.Format("insert into Verduras values({0},'{1}',{2})", CInt(TextBox1.Text), TextBox2.Text, CDbl(TextBox3.Text)) Dim comando As New SqlCommand(strcomando, conexion) Try conexion.Open() comando.ExecuteNonQuery() MsgBox("Registro dado de alta") conexion.Close() Call llenagrid() MultiView1.ActiveViewIndex = -1 Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Protected Sub Button2_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button2.Click MultiView1.ActiveViewIndex = -1 Call limpia() End Sub
Protected Sub Button4_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button4.Click MultiView1.ActiveViewIndex = -1 Call limpia() End Sub
Protected Sub Button3_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button3.Click Dim strcomando As String strcomando = String.Format("update verduras set id={0}, nombre='{1}', precio={2} where id={3}", CInt(TextBox4.Text), TextBox5.Text, CDbl(TextBox6.Text), CDbl(TextBox7.Text)) Dim comando As New SqlCommand(strcomando, conexion) Try conexion.Open() comando.ExecuteNonQuery() MsgBox("Registro Modificado") conexion.Close() Call llenagrid() MultiView1.ActiveViewIndex = -1 Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Protected Sub ImageButton2_Click(ByVal sender
As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click MultiView1.ActiveViewIndex = 1 Call limpia() Call modificar() End Sub Sub modificar() TextBox4.Text = GridView1.SelectedRow.Cells(1).Text TextBox7.Text = GridView1.SelectedRow.Cells(1).Text TextBox5.Text = GridView1.SelectedRow.Cells(2).Text TextBox6.Text = GridView1.SelectedRow.Cells(3).Text End Sub Sub Eliminar() TextBox8.Text = GridView1.SelectedRow.Cells(1).Text TextBox9.Text = GridView1.SelectedRow.Cells(2).Text TextBox10.Text = GridView1.SelectedRow.Cells(3).Text End Sub Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton3.Click MultiView1.ActiveViewIndex = 2 Call limpia() Call eliminar() End Sub
Protected Sub Button6_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button6.Click MultiView1.ActiveViewIndex = -1 Call limpia() End Sub
Protected Sub Button5_Click(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Button5.Click Dim strcomando As String strcomando = String.Format("Delete from verduras where id={0}", CInt(TextBox8.Text)) Dim comando As New SqlCommand(strcomando, conexion) Try conexion.Open() comando.ExecuteNonQuery() MsgBox("Registro dado de baja") conexion.Close() Call llenagrid() MultiView1.ActiveViewIndex = -1 Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
ChatGPT Side Hustles 2024 - Unlock the Digital Goldmine and Get AI Working for You Fast with More Than 85 Side Hustle Ideas to Boost Passive Income, Create New Cash Flow, and Get Ahead of the Curve
ChatGPT Money Machine 2024 - The Ultimate Chatbot Cheat Sheet to Go From Clueless Noob to Prompt Prodigy Fast! Complete AI Beginner’s Course to Catch the GPT Gold Rush Before It Leaves You Behind
ChatGPT Millionaire 2024 - Bot-Driven Side Hustles, Prompt Engineering Shortcut Secrets, and Automated Income Streams that Print Money While You Sleep. The Ultimate Beginner’s Guide for AI Business