Codigo
Publicado por Carlos (1 intervención) el 21/03/2006 06:23:53
'********* Eliminar ****************************
Private Sub btn_eliminar_Click()
Dim conexion As ADODB.Connection
Dim rs As ADODB.recordset
Set conexion = New ADODB.Connection
Set rs = New ADODB.recordset
conexion.Open "Provider=SQLOLEDB; " & _
"Initial Catalog=modelo; " & _
"Data Source=(local); " & _
"integrated security=SSPI; persist security info=True;"
conexion.Execute ("del_personal '" & txt_rut.Text & "'")
Set rs.ActiveConnection = Nothing
'rs.Open
conexion.Close
End Sub
'************** limpiar ******************
Private Sub btn_limpiar_Click()
Me.txt_rut.Text = ""
Me.txt_nombre.Text = ""
Me.txt_edad.Text = ""
Me.txt_ciudad = ""
txt_rut.SetFocus
End Sub
'*************** Salir ***************
Private Sub btn_salir_Click()
Unload Me
End Sub
'****************** Guardar *****************************
Private Sub btn_guardar_Click()
If Trim(Me.txt_rut.Text) = Empty Then
MsgBox "debe ingresar el Rut", vbInformation, "Hola"
Me.btn_guardar.Enabled = True
Me.txt_rut.Text = ""
Me.txt_rut.SetFocus
Exit Sub
End If
If IsNumeric(txt_rut.Text) = False Then
MsgBox "Dato debe ser Numerico", vbInformation, "hola"
Me.btn_guardar.Enabled = True
Me.txt_rut.Text = ""
Me.txt_rut.SetFocus
Exit Sub
End If
' nombre
If Trim(Me.txt_nombre.Text) = Empty Then
MsgBox "Debe ingresar todos los datos", vbInformation, "Sistema "
Me.btn_guardar.Enabled = True
Me.txt_nombre.SetFocus
Exit Sub
ElseIf IsNumeric(txt_nombre_mascota) = False Then
MsgBox "Nombre no es NUMERICO", vbInformation, "Sistema"
Me.btn_guardar.Enabled = True
Me.txt_nombre.Text = ""
Me.txt_nombre.SetFocus
Exit Sub
End If
''Edad
If Trim(txt_edad) = Empty Then
MsgBox "Debe la edad", vbInformation, "Sistema "
Me.txt_edad.Text = ""
Me.txt_edad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
ElseIf IsNumeric(txt_edad) = False And Trim(txt_edad) <> Empty Then
MsgBox "La Edad es NUMERICO", vbInformation, "Sistema "
Me.txt_edad.Text = ""
Me.txt_edad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
End If
''ciudad
If Trim(txt_ciudad) = Empty Then
MsgBox "Debe la edad", vbInformation, "Sistema "
Me.txt_ciudad.Text = ""
Me.txt_ciudad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
End If
' insert
conexion.Execute ("ins_personal '" & txt_rut.Text & "','" & txt_nombre.Text & "','" & txt_edad.Text & "','" & txt_ciudad.Text & "'")
MsgBox " ingresado ''" & txt_nombre.Text & "'' ha sido Ingresada satisfactoriamente"
End Sub
**************** Procedimientos ***********************
eliminar
CREATE PROCEDURE del_ciudad
@cod_ciudad as varchar(5)
AS
Begin transaction
Delete TA_ciudad
where pkn_cod_ciudad = @cod_ciudad
commit transaction
**insertar
CREATE PROCEDURE ins_proveedor
@kx_rut_proveedor as varchar(50),
@x_nombre_proveedor as varchar(50),
@x_apellido_p as varchar(50),
@x_apellido_m as varchar(50),
@x_fono as varchar(50),
@x_direccion as varchar(50),
@kn_cod_ciudad as numeric(9)
AS
Begin transaction
insert into TA_Proveedor
(kx_rut_proveedor ,
x_nombre_proveedor ,
x_apellido_p ,
x_apellido_m ,
x_fono ,
x_direccion ,
kn_cod_ciudad)
values
(@kx_rut_proveedor ,
@x_nombre_proveedor ,
@x_apellido_p ,
@x_apellido_m ,
@x_fono ,
@x_direccion ,
@kn_cod_ciudad)
commit transaction
*** Modificar
CREATE PROCEDURE upt_cliente
@kx_rut_cliente as varchar(50),
@x_nombre_cliente as varchar(50),
@x_apellido_p as varchar(50),
@x_apellido_m as varchar(50),
@x_fono as varchar(50),
@x_direccion as varchar(50),
@kn_cod_ciudad as varchar(50)
AS
Begin transaction
update TA_cliente
set x_nombre_cliente = @x_nombre_cliente,
x_apellido_p = @x_apellido_p ,
x_apellido_m = @x_apellido_m ,
x_fono = @x_fono ,
x_direccion = @x_direccion ,
kn_cod_ciudad = @kn_cod_ciudad
where kx_rut_cliente = @kx_rut_cliente
commit transaction
*** conexion ****
Global Provider As String
Global DataSource As String
Global InitialCatalog As String
Global UID As String
Global PASS As String
Global sql As String
Global recordset As ADODB.recordset
Global conexion As ADODB.Connection
Sub Main()
Set conexion = New ADODB.Connection
conexion.Open "Provider=SQLOLEDB; " & _
"Initial Catalog=modelo; " & _
"Data Source=(local); " & _
"integrated security=SSPI; persist security info=True;"
Personal.Show
End Sub
Private Sub btn_eliminar_Click()
Dim conexion As ADODB.Connection
Dim rs As ADODB.recordset
Set conexion = New ADODB.Connection
Set rs = New ADODB.recordset
conexion.Open "Provider=SQLOLEDB; " & _
"Initial Catalog=modelo; " & _
"Data Source=(local); " & _
"integrated security=SSPI; persist security info=True;"
conexion.Execute ("del_personal '" & txt_rut.Text & "'")
Set rs.ActiveConnection = Nothing
'rs.Open
conexion.Close
End Sub
'************** limpiar ******************
Private Sub btn_limpiar_Click()
Me.txt_rut.Text = ""
Me.txt_nombre.Text = ""
Me.txt_edad.Text = ""
Me.txt_ciudad = ""
txt_rut.SetFocus
End Sub
'*************** Salir ***************
Private Sub btn_salir_Click()
Unload Me
End Sub
'****************** Guardar *****************************
Private Sub btn_guardar_Click()
If Trim(Me.txt_rut.Text) = Empty Then
MsgBox "debe ingresar el Rut", vbInformation, "Hola"
Me.btn_guardar.Enabled = True
Me.txt_rut.Text = ""
Me.txt_rut.SetFocus
Exit Sub
End If
If IsNumeric(txt_rut.Text) = False Then
MsgBox "Dato debe ser Numerico", vbInformation, "hola"
Me.btn_guardar.Enabled = True
Me.txt_rut.Text = ""
Me.txt_rut.SetFocus
Exit Sub
End If
' nombre
If Trim(Me.txt_nombre.Text) = Empty Then
MsgBox "Debe ingresar todos los datos", vbInformation, "Sistema "
Me.btn_guardar.Enabled = True
Me.txt_nombre.SetFocus
Exit Sub
ElseIf IsNumeric(txt_nombre_mascota) = False Then
MsgBox "Nombre no es NUMERICO", vbInformation, "Sistema"
Me.btn_guardar.Enabled = True
Me.txt_nombre.Text = ""
Me.txt_nombre.SetFocus
Exit Sub
End If
''Edad
If Trim(txt_edad) = Empty Then
MsgBox "Debe la edad", vbInformation, "Sistema "
Me.txt_edad.Text = ""
Me.txt_edad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
ElseIf IsNumeric(txt_edad) = False And Trim(txt_edad) <> Empty Then
MsgBox "La Edad es NUMERICO", vbInformation, "Sistema "
Me.txt_edad.Text = ""
Me.txt_edad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
End If
''ciudad
If Trim(txt_ciudad) = Empty Then
MsgBox "Debe la edad", vbInformation, "Sistema "
Me.txt_ciudad.Text = ""
Me.txt_ciudad.SetFocus
Me.btn_guardar.Enabled = True
Exit Sub
End If
' insert
conexion.Execute ("ins_personal '" & txt_rut.Text & "','" & txt_nombre.Text & "','" & txt_edad.Text & "','" & txt_ciudad.Text & "'")
MsgBox " ingresado ''" & txt_nombre.Text & "'' ha sido Ingresada satisfactoriamente"
End Sub
**************** Procedimientos ***********************
eliminar
CREATE PROCEDURE del_ciudad
@cod_ciudad as varchar(5)
AS
Begin transaction
Delete TA_ciudad
where pkn_cod_ciudad = @cod_ciudad
commit transaction
**insertar
CREATE PROCEDURE ins_proveedor
@kx_rut_proveedor as varchar(50),
@x_nombre_proveedor as varchar(50),
@x_apellido_p as varchar(50),
@x_apellido_m as varchar(50),
@x_fono as varchar(50),
@x_direccion as varchar(50),
@kn_cod_ciudad as numeric(9)
AS
Begin transaction
insert into TA_Proveedor
(kx_rut_proveedor ,
x_nombre_proveedor ,
x_apellido_p ,
x_apellido_m ,
x_fono ,
x_direccion ,
kn_cod_ciudad)
values
(@kx_rut_proveedor ,
@x_nombre_proveedor ,
@x_apellido_p ,
@x_apellido_m ,
@x_fono ,
@x_direccion ,
@kn_cod_ciudad)
commit transaction
*** Modificar
CREATE PROCEDURE upt_cliente
@kx_rut_cliente as varchar(50),
@x_nombre_cliente as varchar(50),
@x_apellido_p as varchar(50),
@x_apellido_m as varchar(50),
@x_fono as varchar(50),
@x_direccion as varchar(50),
@kn_cod_ciudad as varchar(50)
AS
Begin transaction
update TA_cliente
set x_nombre_cliente = @x_nombre_cliente,
x_apellido_p = @x_apellido_p ,
x_apellido_m = @x_apellido_m ,
x_fono = @x_fono ,
x_direccion = @x_direccion ,
kn_cod_ciudad = @kn_cod_ciudad
where kx_rut_cliente = @kx_rut_cliente
commit transaction
*** conexion ****
Global Provider As String
Global DataSource As String
Global InitialCatalog As String
Global UID As String
Global PASS As String
Global sql As String
Global recordset As ADODB.recordset
Global conexion As ADODB.Connection
Sub Main()
Set conexion = New ADODB.Connection
conexion.Open "Provider=SQLOLEDB; " & _
"Initial Catalog=modelo; " & _
"Data Source=(local); " & _
"integrated security=SSPI; persist security info=True;"
Personal.Show
End Sub
Valora esta pregunta


0