Base de Datos Visual Studio
-
Upload
mario-alexis-sanchez -
Category
Documents
-
view
224 -
download
0
Transcript of Base de Datos Visual Studio
7/24/2019 Base de Datos Visual Studio
http://slidepdf.com/reader/full/base-de-datos-visual-studio 1/5
MICROSOFT VISUAL BASIC .NET
Prof. Miguel Cherres [email protected]
- 1 -
7/24/2019 Base de Datos Visual Studio
http://slidepdf.com/reader/full/base-de-datos-visual-studio 2/5
MICROSOFT VISUAL BASIC .NET
Prof. Miguel Cherres [email protected]
- 2 -
7/24/2019 Base de Datos Visual Studio
http://slidepdf.com/reader/full/base-de-datos-visual-studio 3/5
MICROSOFT VISUAL BASIC .NET
Prof. Miguel Cherres [email protected]
- 3 -
7/24/2019 Base de Datos Visual Studio
http://slidepdf.com/reader/full/base-de-datos-visual-studio 4/5
MICROSOFT VISUAL BASIC .NET
Prof. Miguel Cherres [email protected]
Imports System.DataImports System.Data.SqlClientPublic Class form1
Public cn As New SqlConnection Public da1 As SqlDataAdapter Public ds1 As New DataSet Public dv1 As New DataView Public obcm As SqlCommand!uilder Public "la As Data#ow Dim indice As Inte$er Dim totr As Inte$er Dim nr As Inte$er Private Sub %orm1&'oad(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles y!ase.'oad cn / New SqlConnection(0data source /.initial catalo$/bdventasinte$rated Security/true0, 2cn / New SqlConnection(0server/(local,uid/sadatabase/bdventas0,2 cn.)pen(,
da1 / New SqlDataAdapter(0select codi$o*nombre*edad*sueldo from vendedor 0* cn, obcm / New SqlCommand!uilder(da1, da1.%ill(ds1* 0vendedor 0, dv1 / ds1.3ables(0vendedor0,.DefaultView dv1.AllowNew / 3rue dv1.Allow+dit / 3rue dv1.AllowDelete / 3rue Data4ridView1.DataSource / dv1
nr / ds1.3ables(5,.DefaultView.Count indice / 5 If nr 6 5 37en selecciona(btnprimero, +nd If
+nd Sub Sub selecciona(!yVal btn As !utton, 2mostrar nro de re$istro Dim totr As Inte$er / nr 8 1 If btn Is btnprimero 37en indice / 5 +lseIf btn Is btnanterior 37en indice 8/ 1 If indice 6 totr 37en indice / totr +lseIf btn Is btnsi$uiente 37en indice 9/ 1 If indice 6 totr 37en indice / 5 +lse indice / totr +nd If muestradatos(indice, 3e:t!o:;.3e:t / (indice 9 1,.3oStrin$ < 0=0 < nr +nd Sub Sub muestradatos(!yVal nro As Inte$er, 2mostrar re$istro
"la / ds1.3ables(0vendedor0,.#ows(nro, 3e:t!o:1.3e:t / "la.Item(5, 3e:t!o:>.3e:t / "la.Item(1, 3e:t!o:?.3e:t / "la.Item(>, 3e:t!o:@.3e:t / "la.Item(?, +nd Sub Sub asi$na(,
2asinar intems"la.Item(5, / 3e:t!o:1.3e:t
"la.Item(1, / 3e:t!o:>.3e:t "la.Item(>, / 3e:t!o:?.3e:t "la.Item(?, / 3e:t!o:@.3e:t
- 4 -
7/24/2019 Base de Datos Visual Studio
http://slidepdf.com/reader/full/base-de-datos-visual-studio 5/5
MICROSOFT VISUAL BASIC .NET
Prof. Miguel Cherres [email protected] +nd Sub
Private Sub btnnuevo&Clic(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles btnnuevo.Clic Dim : As Control Dim :cod As Strin$
%or +ac7 : In e.Controls If 3ype)f : Is 3e:t!o: 37en :.3e:t / 00 Ne:t totr / ds1.3ables(5,.DefaultView.Count If totr 6 5 37en :cod / ds1.3ables(5,.#ows(nr 8 1,.Item(5, :cod / 0v0 9 %ormat(Val(:cod.Substrin$(1* ?,, 9 1* 05550, +lse :cod / 0v5510 +nd If 3e:t!o:1.3e:t / :cod 3e:t!o:>.%ocus(, +nd Sub
Private Sub btn$uardar&Clic(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles btn$uardar.Clic 2$uardar re$istro
"la / ds1.3ables(5,.New#ow asi$na(, ds1.3ables(5,.#ows.Add("la, da1.Bpdate(ds1.3ables(0vendedor0,, nr / ds1.3ables(5,.DefaultView.Count selecciona(btnultimon, +nd Sub Private Sub btncancelar&Clic(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles btncancelar.Clic Dim : As Control
%or +ac7 : In e.Controls If 3ype)f : Is 3e:t!o: 37en :.3e:t / 00 Ne:t +nd Sub
Private Sub btneliminar&Clic(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles btneliminar.Clic If indice 6 5 37en dv1.Delete(indice, da1.Bpdate(ds1.3ables(0vendedor0,, nr / ds1.3ables(5,.DefaultView.Count(, selecciona(btnultimon, +nd If
+nd Sub Private Sub 7andlesclic(!yVal sender As System.)bect* !yVal e As System.+ventAr$s, -andles btnprimero.Clic* btnanterior.Clic* btnsi$uiente.Clic* btnultimon.Clic selecciona(C3ype(sender* !utton,, +nd Sub+nd Class
- 5 -