SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
Public Class menuprin
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
'Se compara si el control esta seleccionado
If RadioButton1.Checked Then
registro.Show()
Me.Hide()
End If
'Se compara si el control esta seleccionado
If RadioButton2.Checked Then
modificar.Show()
Me.Hide()
End If
'Se compara si la propiedad del control es verdadera
If RadioButton3.Checked = True Then
eliminar.Show()
Me.Hide()
End If
End Sub
End Class
Imports System.Data.SqlClient
Public Class registro
Private Sub VolverToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles VolverToolStripMenuItem.Click
menuprin.Show()
Me.Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial
Catalog=prueba;Integrated Security=True")
Dim command As New SqlCommand("insertarusuario", conexion)
Dim adapter As New SqlDataAdapter("mostrarusuarios", conexion)
Dim datase As New DataSet
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.AddWithValue("@id", TextBox1.Text)
command.Parameters.AddWithValue("@nom", TextBox2.Text)
command.Parameters.AddWithValue("@ape", TextBox3.Text)
command.Parameters.AddWithValue("@telefo", TextBox4.Text)
Try
conexion.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MsgBox("Usuario Registrado", vbInformation, "Sistema")
TextBox1.Text = ""
TextBox1.Enabled = "false"
TextBox2.Text = ""
TextBox2.Enabled = "false"
TextBox3.Text = ""
TextBox3.Enabled = "false"
TextBox4.Text = ""
TextBox4.Enabled = "false"
Button1.Enabled = "false"
Button2.Enabled = "true"
adapter.Fill(datase)
DataGridView1.DataSource = datase.Tables(0)
conexion.Close()
End Try
End Sub
Private Sub registro_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Button2.Enabled = "false"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = ""
TextBox1.Enabled = "true"
TextBox2.Text = ""
TextBox2.Enabled = "true"
TextBox3.Text = ""
TextBox3.Enabled = "true"
TextBox4.Text = ""
TextBox4.Enabled = "true"
Button1.Enabled = "true"
Button2.Enabled = "false"
End Sub
End Class
Imports System.Data.SqlClient
Public Class modificar
Dim Dato1, Dato2, Dato3, Dato4 As String
Private Sub VolverInicioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles VolverInicioToolStripMenuItem.Click
menuprin.Show()
Me.Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial
Catalog=prueba;Integrated Security=True")
Dim command As New SqlCommand("buscausuario", conexion)
Dim adapter As New SqlDataAdapter(command)
Dim datase As New DataSet
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.AddWithValue("@id", TextBox1.Text)
Try
conexion.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
TextBox1.Text = ""
Button2.Enabled = "true"
Button3.Enabled = "true"
adapter.Fill(datase)
DataGridView1.DataSource = datase.Tables(0)
conexion.Close()
End Try
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox5.Enabled = "false"
TextBox4.Enabled = "true"
TextBox3.Enabled = "true"
TextBox2.Enabled = "true"
TextBox5.Text = Dato1
TextBox2.Text = Dato2
TextBox3.Text = Dato3
TextBox4.Text = Dato4
End Sub
Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
Dato1 = DataGridView1.CurrentRow.Cells(0).EditedFormattedValue.ToString
Dato2 = DataGridView1.CurrentRow.Cells(1).EditedFormattedValue.ToString
Dato3 = DataGridView1.CurrentRow.Cells(2).EditedFormattedValue.ToString
Dato4 = DataGridView1.CurrentRow.Cells(3).EditedFormattedValue.ToString
End Sub
Private Sub modificar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
TextBox5.Enabled = "false"
TextBox4.Enabled = "false"
TextBox3.Enabled = "false"
TextBox2.Enabled = "false"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial
Catalog=prueba;Integrated Security=True")
Dim command As New SqlCommand("modificarusuario", conexion)
Dim adapter As New SqlDataAdapter(command)
Dim datase As New DataSet
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.AddWithValue("@id", TextBox5.Text)
command.Parameters.AddWithValue("@nom", TextBox2.Text)
command.Parameters.AddWithValue("@ape", TextBox3.Text)
command.Parameters.AddWithValue("@telefo", TextBox4.Text)
Try
conexion.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MsgBox("Usuario Actualizado", vbInformation, "Sistema")
TextBox2.Text = ""
TextBox2.Enabled = "false"
TextBox3.Text = ""
TextBox3.Enabled = "false"
TextBox4.Text = ""
TextBox4.Enabled = "false"
TextBox5.Text = ""
TextBox5.Enabled = "false"
Button3.Enabled = "false"
Button2.Enabled = "false"
adapter.Fill(datase)
DataGridView1.Columns.Clear()
conexion.Close()
End Try
End Sub
End Class
Imports System.Data.SqlClient
Public Class eliminar
Dim Dato1, Dato2, Dato3, Dato4 As String
Private Sub VolverInicioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles VolverInicioToolStripMenuItem.Click
menuprin.Show()
Me.Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial
Catalog=prueba;Integrated Security=True")
Dim command As New SqlCommand("buscausuario", conexion)
Dim adapter As New SqlDataAdapter(command)
Dim datase As New DataSet
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.AddWithValue("@id", TextBox1.Text)
Try
conexion.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
TextBox1.Text = ""
Button2.Enabled = "true"
Button3.Enabled = "true"
adapter.Fill(datase)
DataGridView1.DataSource = datase.Tables(0)
conexion.Close()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox5.Enabled = "false"
TextBox4.Enabled = "true"
TextBox3.Enabled = "true"
TextBox2.Enabled = "true"
TextBox5.Text = Dato1
TextBox2.Text = Dato2
TextBox3.Text = Dato3
TextBox4.Text = Dato4
End Sub
Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick
Dato1 = DataGridView1.CurrentRow.Cells(0).EditedFormattedValue.ToString
Dato2 = DataGridView1.CurrentRow.Cells(1).EditedFormattedValue.ToString
Dato3 = DataGridView1.CurrentRow.Cells(2).EditedFormattedValue.ToString
Dato4 = DataGridView1.CurrentRow.Cells(3).EditedFormattedValue.ToString
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial
Catalog=prueba;Integrated Security=True")
Dim command As New SqlCommand("borrarusuario", conexion)
Dim adapter As New SqlDataAdapter(command)
Dim datase As New DataSet
command.CommandType = Data.CommandType.StoredProcedure
command.Parameters.AddWithValue("@id", TextBox5.Text)
command.Parameters.AddWithValue("@nom", TextBox2.Text)
command.Parameters.AddWithValue("@ape", TextBox3.Text)
command.Parameters.AddWithValue("@telefo", TextBox4.Text)
Try
conexion.Open()
command.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MsgBox("Usuario Eliminado", vbInformation, "Sistema")
TextBox2.Text = ""
TextBox2.Enabled = "false"
TextBox3.Text = ""
TextBox3.Enabled = "false"
TextBox4.Text = ""
TextBox4.Enabled = "false"
TextBox5.Text = ""
TextBox5.Enabled = "false"
Button3.Enabled = "false"
Button2.Enabled = "false"
adapter.Fill(datase)
DataGridView1.Columns.Clear()
conexion.Close()
End Try
End Sub
End Class
ALTER PROCEDURE [dbo].[borrarusuario]
-- Add the parameters for the stored procedure here
(
@id nvarchar(3),
@nom nvarchar (50),
@ape nvarchar (50),
@telefo nvarchar(12)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DELETE FROM usuario WHERE ide=@id and nombre=@nom and apellido=@ape and tel=@telefo
END
ALTER PROCEDURE [dbo].[buscausuario]
(
@id nvarchar(3)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT * FROM usuario WHERE ide=@id
ALTER PROCEDURE [dbo].[insertarusuario]
(
@id nvarchar(3),
@nom nvarchar(50),
@ape nvarchar(70),
@telefo nvarchar(15)
)
AS SET NOCOUNT ON
INSERT INTO usuario(ide, nombre, apellido, tel) VALUES (@id,@nom ,@ape,@telefo)
ALTER PROCEDURE [dbo].[modificarusuario]
(
@id nvarchar(3),
@nom nvarchar(50),
@ape nvarchar(50),
@telefo nvarchar(12)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
UPDATE usuario SET nombre=@nom, apellido=@ape, tel=@telefo WHERE ide=@id
ALTER PROCEDURE [dbo].[mostrarusuarios]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT * FROM usuario

Mais conteúdo relacionado

Mais procurados

Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3sunmitraeducation
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5sotlsoc
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3sunmitraeducation
 
PROGRAMA DE EJEMPLO
PROGRAMA DE EJEMPLOPROGRAMA DE EJEMPLO
PROGRAMA DE EJEMPLOmhormech
 
How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)Giuseppe Filograno
 
Parra maxi IF THEN ELSE
Parra maxi IF THEN ELSEParra maxi IF THEN ELSE
Parra maxi IF THEN ELSEgabo2200
 
Csphtp1 12
Csphtp1 12Csphtp1 12
Csphtp1 12HUST
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarPractica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarYosselin Marquez
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intentDiego Grancini
 

Mais procurados (19)

Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3Visual Web Developer and Web Controls CS set 3
Visual Web Developer and Web Controls CS set 3
 
Coding java.txt
Coding java.txtCoding java.txt
Coding java.txt
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
regedit
regeditregedit
regedit
 
Android App Dev Manual-1.doc
Android App Dev Manual-1.docAndroid App Dev Manual-1.doc
Android App Dev Manual-1.doc
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3Visual Web Developer and Web Controls VB set 3
Visual Web Developer and Web Controls VB set 3
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Punto fijo multivariante
Punto fijo multivariantePunto fijo multivariante
Punto fijo multivariante
 
PROGRAMA DE EJEMPLO
PROGRAMA DE EJEMPLOPROGRAMA DE EJEMPLO
PROGRAMA DE EJEMPLO
 
How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)
 
Action Bar in Android
Action Bar in AndroidAction Bar in Android
Action Bar in Android
 
Parra maxi IF THEN ELSE
Parra maxi IF THEN ELSEParra maxi IF THEN ELSE
Parra maxi IF THEN ELSE
 
Radgrid
RadgridRadgrid
Radgrid
 
Csphtp1 12
Csphtp1 12Csphtp1 12
Csphtp1 12
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarPractica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intent
 
New features in 3.0
New features in 3.0New features in 3.0
New features in 3.0
 

Destaque

What's Next in Growth? 2016
What's Next in Growth? 2016What's Next in Growth? 2016
What's Next in Growth? 2016Andrew Chen
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsBarry Feldman
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome EconomyHelge Tennø
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your BusinessBarry Feldman
 

Destaque (6)

Error palabra.java
Error palabra.javaError palabra.java
Error palabra.java
 
Android
AndroidAndroid
Android
 
What's Next in Growth? 2016
What's Next in Growth? 2016What's Next in Growth? 2016
What's Next in Growth? 2016
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
 

Semelhante a Ejercicio sql server vs visual .net

Ejercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSEEjercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSERicardoGuti50
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Netcymbron
 
Elementos del lenguaje
Elementos del lenguajeElementos del lenguaje
Elementos del lenguajeguest6473b8
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerDarwin Durand
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Netcymbron
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01mafv1976
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventasDAYANA RETO
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
 
Latihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganLatihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganNurul Arhaiyyu
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERDarwin Durand
 
Christian rodriguez then else
Christian rodriguez then   elseChristian rodriguez then   else
Christian rodriguez then elsegabo2200
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docxgabo2200
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docxgabo2200
 
Guevara rene if then., else
Guevara rene  if then., elseGuevara rene  if then., else
Guevara rene if then., elsegabo2200
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docxgabo2200
 
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdfapnashop1
 

Semelhante a Ejercicio sql server vs visual .net (20)

Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
Ejercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSEEjercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSE
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Net
 
Elementos del lenguaje
Elementos del lenguajeElementos del lenguaje
Elementos del lenguaje
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
Latihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganLatihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/Perulangan
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
Christian rodriguez then else
Christian rodriguez then   elseChristian rodriguez then   else
Christian rodriguez then else
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Guevara rene if then., else
Guevara rene  if then., elseGuevara rene  if then., else
Guevara rene if then., else
 
Federico landinez docx
Federico landinez docxFederico landinez docx
Federico landinez docx
 
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
 
Formulario mdi
Formulario mdiFormulario mdi
Formulario mdi
 

Último

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesSanjay Willie
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Último (20)

Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

Ejercicio sql server vs visual .net

  • 1. Public Class menuprin Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Se compara si el control esta seleccionado If RadioButton1.Checked Then registro.Show() Me.Hide() End If 'Se compara si el control esta seleccionado If RadioButton2.Checked Then modificar.Show() Me.Hide() End If 'Se compara si la propiedad del control es verdadera If RadioButton3.Checked = True Then eliminar.Show() Me.Hide() End If End Sub End Class Imports System.Data.SqlClient Public Class registro Private Sub VolverToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VolverToolStripMenuItem.Click menuprin.Show() Me.Hide() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial Catalog=prueba;Integrated Security=True") Dim command As New SqlCommand("insertarusuario", conexion) Dim adapter As New SqlDataAdapter("mostrarusuarios", conexion) Dim datase As New DataSet command.CommandType = Data.CommandType.StoredProcedure command.Parameters.AddWithValue("@id", TextBox1.Text) command.Parameters.AddWithValue("@nom", TextBox2.Text) command.Parameters.AddWithValue("@ape", TextBox3.Text) command.Parameters.AddWithValue("@telefo", TextBox4.Text) Try conexion.Open() command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) Finally MsgBox("Usuario Registrado", vbInformation, "Sistema") TextBox1.Text = "" TextBox1.Enabled = "false" TextBox2.Text = "" TextBox2.Enabled = "false" TextBox3.Text = "" TextBox3.Enabled = "false" TextBox4.Text = "" TextBox4.Enabled = "false" Button1.Enabled = "false" Button2.Enabled = "true" adapter.Fill(datase)
  • 2. DataGridView1.DataSource = datase.Tables(0) conexion.Close() End Try End Sub Private Sub registro_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Button2.Enabled = "false" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox1.Enabled = "true" TextBox2.Text = "" TextBox2.Enabled = "true" TextBox3.Text = "" TextBox3.Enabled = "true" TextBox4.Text = "" TextBox4.Enabled = "true" Button1.Enabled = "true" Button2.Enabled = "false" End Sub End Class Imports System.Data.SqlClient Public Class modificar Dim Dato1, Dato2, Dato3, Dato4 As String Private Sub VolverInicioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VolverInicioToolStripMenuItem.Click menuprin.Show() Me.Hide() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial Catalog=prueba;Integrated Security=True") Dim command As New SqlCommand("buscausuario", conexion) Dim adapter As New SqlDataAdapter(command) Dim datase As New DataSet command.CommandType = Data.CommandType.StoredProcedure command.Parameters.AddWithValue("@id", TextBox1.Text) Try conexion.Open() command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) Finally TextBox1.Text = "" Button2.Enabled = "true" Button3.Enabled = "true" adapter.Fill(datase) DataGridView1.DataSource = datase.Tables(0) conexion.Close() End Try End Sub Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox5.Enabled = "false" TextBox4.Enabled = "true"
  • 3. TextBox3.Enabled = "true" TextBox2.Enabled = "true" TextBox5.Text = Dato1 TextBox2.Text = Dato2 TextBox3.Text = Dato3 TextBox4.Text = Dato4 End Sub Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick Dato1 = DataGridView1.CurrentRow.Cells(0).EditedFormattedValue.ToString Dato2 = DataGridView1.CurrentRow.Cells(1).EditedFormattedValue.ToString Dato3 = DataGridView1.CurrentRow.Cells(2).EditedFormattedValue.ToString Dato4 = DataGridView1.CurrentRow.Cells(3).EditedFormattedValue.ToString End Sub Private Sub modificar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox5.Enabled = "false" TextBox4.Enabled = "false" TextBox3.Enabled = "false" TextBox2.Enabled = "false" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial Catalog=prueba;Integrated Security=True") Dim command As New SqlCommand("modificarusuario", conexion) Dim adapter As New SqlDataAdapter(command) Dim datase As New DataSet command.CommandType = Data.CommandType.StoredProcedure command.Parameters.AddWithValue("@id", TextBox5.Text) command.Parameters.AddWithValue("@nom", TextBox2.Text) command.Parameters.AddWithValue("@ape", TextBox3.Text) command.Parameters.AddWithValue("@telefo", TextBox4.Text) Try conexion.Open() command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) Finally MsgBox("Usuario Actualizado", vbInformation, "Sistema") TextBox2.Text = "" TextBox2.Enabled = "false" TextBox3.Text = "" TextBox3.Enabled = "false" TextBox4.Text = "" TextBox4.Enabled = "false" TextBox5.Text = "" TextBox5.Enabled = "false" Button3.Enabled = "false" Button2.Enabled = "false" adapter.Fill(datase) DataGridView1.Columns.Clear() conexion.Close() End Try End Sub End Class Imports System.Data.SqlClient Public Class eliminar
  • 4. Dim Dato1, Dato2, Dato3, Dato4 As String Private Sub VolverInicioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VolverInicioToolStripMenuItem.Click menuprin.Show() Me.Hide() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial Catalog=prueba;Integrated Security=True") Dim command As New SqlCommand("buscausuario", conexion) Dim adapter As New SqlDataAdapter(command) Dim datase As New DataSet command.CommandType = Data.CommandType.StoredProcedure command.Parameters.AddWithValue("@id", TextBox1.Text) Try conexion.Open() command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) Finally TextBox1.Text = "" Button2.Enabled = "true" Button3.Enabled = "true" adapter.Fill(datase) DataGridView1.DataSource = datase.Tables(0) conexion.Close() End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox5.Enabled = "false" TextBox4.Enabled = "true" TextBox3.Enabled = "true" TextBox2.Enabled = "true" TextBox5.Text = Dato1 TextBox2.Text = Dato2 TextBox3.Text = Dato3 TextBox4.Text = Dato4 End Sub Private Sub DataGridView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseClick Dato1 = DataGridView1.CurrentRow.Cells(0).EditedFormattedValue.ToString Dato2 = DataGridView1.CurrentRow.Cells(1).EditedFormattedValue.ToString Dato3 = DataGridView1.CurrentRow.Cells(2).EditedFormattedValue.ToString Dato4 = DataGridView1.CurrentRow.Cells(3).EditedFormattedValue.ToString End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim conexion As New SqlConnection("Data Source=CASTROSQLEXPRESS;Initial Catalog=prueba;Integrated Security=True") Dim command As New SqlCommand("borrarusuario", conexion) Dim adapter As New SqlDataAdapter(command) Dim datase As New DataSet command.CommandType = Data.CommandType.StoredProcedure
  • 5. command.Parameters.AddWithValue("@id", TextBox5.Text) command.Parameters.AddWithValue("@nom", TextBox2.Text) command.Parameters.AddWithValue("@ape", TextBox3.Text) command.Parameters.AddWithValue("@telefo", TextBox4.Text) Try conexion.Open() command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) Finally MsgBox("Usuario Eliminado", vbInformation, "Sistema") TextBox2.Text = "" TextBox2.Enabled = "false" TextBox3.Text = "" TextBox3.Enabled = "false" TextBox4.Text = "" TextBox4.Enabled = "false" TextBox5.Text = "" TextBox5.Enabled = "false" Button3.Enabled = "false" Button2.Enabled = "false" adapter.Fill(datase) DataGridView1.Columns.Clear() conexion.Close() End Try End Sub End Class ALTER PROCEDURE [dbo].[borrarusuario] -- Add the parameters for the stored procedure here ( @id nvarchar(3), @nom nvarchar (50), @ape nvarchar (50), @telefo nvarchar(12) ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here DELETE FROM usuario WHERE ide=@id and nombre=@nom and apellido=@ape and tel=@telefo END ALTER PROCEDURE [dbo].[buscausuario] ( @id nvarchar(3) ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT * FROM usuario WHERE ide=@id ALTER PROCEDURE [dbo].[insertarusuario] ( @id nvarchar(3), @nom nvarchar(50), @ape nvarchar(70), @telefo nvarchar(15) ) AS SET NOCOUNT ON
  • 6. INSERT INTO usuario(ide, nombre, apellido, tel) VALUES (@id,@nom ,@ape,@telefo) ALTER PROCEDURE [dbo].[modificarusuario] ( @id nvarchar(3), @nom nvarchar(50), @ape nvarchar(50), @telefo nvarchar(12) ) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here UPDATE usuario SET nombre=@nom, apellido=@ape, tel=@telefo WHERE ide=@id ALTER PROCEDURE [dbo].[mostrarusuarios] AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; SELECT * FROM usuario