Upload
gundfriendss
View
45
Download
2
Embed Size (px)
Citation preview
INSTITUTO DE EDUCACION SUPERIOR
“SAN EDUARDO”
INSTITUTO DE EDUCACION SUPERIOR
“SAN EDUARDO”
CARRERACOMPUTACIÓN E INFORMÁTICA
CARRERACOMPUTACIÓN E INFORMÁTICA
INFORME DE“INSTITUTO PABLO CASALS”
INFORME DE“INSTITUTO PABLO CASALS”
DOCENTEGUSTAVO BLAS
DOCENTEGUSTAVO BLAS
VI CICLO
TURNO MAÑANA
VI CICLO
TURNO MAÑANA
ALUMNOALZA QUITO AGUSTINCONTRERAS CASTRO FLORCOTRINA HUARANCA JHONCUEVA PEREDA RONALDGRACIA LEYVA MARIOINCA DIESTRA CINDY
ALUMNOALZA QUITO AGUSTINCONTRERAS CASTRO FLORCOTRINA HUARANCA JHONCUEVA PEREDA RONALDGRACIA LEYVA MARIOINCA DIESTRA CINDY
Grupo de Alumnos VI CICLO
INDICEINDICE
INDICE……………………………………………………………………..2INDICE……………………………………………………………………..2PRESENTACIÓN ……………………………………………............3DEDICATORIA...................................................................…............4
CAPITULO ICAPITULO I
RESEÑA HISTÓRICA………………………………………....5 DESCRIPCION DE LA EMPRESA……………………….......5AREAS DE LA EMPRESA……………………………………..................5SUB AREAS DEL AREA SELECCIONADO: “BIBLIOTECA”……........6ADQUISIÓN DE MATERIAL BIBLIOGRAFICO………………….…....6ALMACEN DE MATERIAL BIBLIOGRAFICO………………….……...6DISTRIBUCIÓN DE MATERIAL BIBLIOGRAFICO A LOS USUARIOS………………………………………………………...6
CAPITULO IICAPITULO II
EL ESCRIP………………………………………………………7-10
B/D Y RELACION DELSISTEMA DE BIBLIOTECA…………………11AÑEXOS
FORMULARIOS........................................................................................12
BIENVENIDOS AL SISTEMA BIBLIOTECA……………………................20
FORMULARIO 1……………………………………….……………......25
FORMULARIO 2…………………………………….…………..............30
FORMULARIO 3..…………………………………………………….....35
FORMULARIO 4..…………………………………………………….....40
FORMULARIO 5..…………………………………………………….....45
FORMULARIO 6..………………………………………………….…....46
FORMULARIO7………………………………………………………...47
- 2 -
Grupo de Alumnos VI CICLO
PRESENTACION
Los alumnos de instituto de educacion superior “SAN EDUARDO” estamos
Presentando en esta oportunidad el proyecto encomendado informe del
“SISTEMA DE BIBLIOTECA”.
Que esta dirigido principalmente a los alumnos en general y
consiguientemente al docente del área de taller y todo lo referente al
proyecto. Y a sí siguiendo con las normas de la institución en la que nos
encontramos.
Este sistema nos enseña que tan importante es registrar cada uno de los
libros, y a la vez llevar un orden de cuantos libros salen e ingresan por día.
Con este informe, hemos cumplido con claridad, precisión y sencillez,
seleccionado datos y material informativo con un criterio sintético que tiende a
actualizar.
Finalmente espero que el informe realizado sea de su agrado y sea esta obra
útil para cualquier tipo de lector, pero muy especialmente a los jovenes
estudiantes.
Todo ello con el fin de contribuir con el mejoramiento y aprendizaje del país.
A continuación presentamos el siguiente informe que lo dejamos a su
disposición nuestra investigación y datos brindados por la misma empresa.
GRACIAS
- 3 -
Grupo de Alumnos VI CICLO
DEDICATORIA
El proyecto encomendado por el grupo de alumnos es dedicado a
sus seres queridos, principalmente al docente del área.
Esperamos que el proyecto realizado sea de su gran utilidad para el
estudiante y sobre todo el desarrollo intelectual del educando
CAPITULO ICAPITULO I
1.1 RESEÑA HISTÓRICA
- 4 -
Grupo de Alumnos VI CICLO
Fue creado el 21 de marzo del 2008 por un grupo de alumnos del instituto de educacion superior “SAN EDUARDO”. Como informe de investigación del curso de taller, este proyecto trae consigo el desarrollo de este sistema que fue realizado en el lenguaje de programación “Visual Basic 6.0 ”y la Base de Datos en “SQL”El beneficio de este proyecto es simplificar la búsqueda de datos en la Base de Datos.
1.2 DESCRIPCION DE LA EMPRESA.
Con fecha de 18 de Mayo del 2000, se expide la Resolución Ministerial 362- 2000-ED, que resuelve denominar “INSTITUTO SUPERIOR TECNOLOGICO PARTICULAR PABLO CASALS”, ubicado en Av. Roma Nº 462 – Trujillo, desde entonces la Institución brinda un servicio educativo en 4 especialidades técnico en farmacia, técnico en enfermería, técnico en contabilidad y secretariado y ejecutivo. Actualmente las carreras que se dictan son Farmacia y Enfermería. Posteriormente se apertura las carreras de secretariado, y conputación e informática, actualmente acoge 700 alumnos en las especialidad de enfermería y Farmacia, en la carrera de farmacia acoge un 77%, así mismo el 23% de la carrera de enfermería.El instituto pablo casals tiene plenamente identificado sus áreas administrativas que conforma.
GERENTE DIRECTORSECRETARIACOORDINADORA ACADEMICADEPARTAMENTO DE FARMACIADEPARTAMENTO DE ENFERMERIADEPARTAMENTO DE HUMANIDADES
A. AREAS DE LA EMPRESA
AREA MATRICULAAREA PAGOSAREA REGISTRO ACADEMICOAREA PRINCIPAL: BIBLIOTECA
SUB AREAS DEL AREA SELECCIONADO: “BIBLIOTECA”
1. ADQUISIÓN DE MATERIAL BIBLIOGRAFICO a. FUNCIONES
i. Verifica cotización de Material Bibliográfico a Proveedores
- 5 -
Grupo de Alumnos VI CICLO
ii. Realiza pedidos a proveedoresb. PROBLEMAS
i. Tardanza de realización de pedidos
2. ALMACEN DE MATERIAL BIBLIOGRAFICO a. FUNCIONES
i. Recepciona pedidos de proveedoresii. Verifica Material Bibliográfico
iii. Ordena por Tipo de Material de pedidosiv. Registra en inventario (Documento).
b. PROBLEMASi. No existe un reporte inmediato.
ii. No se lleva un control adecuado en el ingreso de material
iii. Perdida de documentos o inventarios
3. DISTRIBUCIÓN DE MATERIAL BIBLIOGRAFICO A LOS USUARIOSc. FUNCIONES
i. Realiza catálogos de Material Bibliográficoii. Recepciona pedido de usuario
iii. Verifica que tipo entrega de material(sala o domicilio)
iv. Recepciona documentosv. Registra datos de usuarios en caso de entrega a
domicilio estableciendo requisitos de documentos de usuarios
vi. Recepciona Material de préstamo.vii. Verifica material.
viii. Ingresa a Almacén.d. PROBLEMAS
i. No se cuenta con reportes inmediatos referente material bibliográfico
ii. Se lleva manualmente el control de préstamos de libros.
iii. Pérdida de fichas de préstamos.
El problema de esta área radica básicamente en la distribución de material bibliográfico a los usuarios, por consiguiente la problemática se mencione anteriormente.
CAPITULO ICAPITULO I
EL ESCRIP
USE MASTER
- 6 -
Grupo de Alumnos VI CICLO
IF EXISTS (SELECT NAME FROM SYSDATABASES WHERE NAME = 'BIBLIOTECA')
DROP DATABASE BIBLIOTECA
CREATE DATABASE BIBLIOTECA
GO
USE BIBLIOTECA
CREATE TABLE AUTOR
(IDAUTOR INTEGER PRIMARY KEY,
NOMBRE VARCHAR (50) NOT NULL,
IDDOCUMENTO VARCHAR (5) NOT NULL
)
GO
CREATE TABLE DETALLEPRESTAMO
(IDPRESTAMO INTEGER PRIMARY KEY,
IDDOCUMENTO VARCHAR (5) NOT NULL,
ENTREGO VARCHAR (50),
OBSERVACION VARCHAR (50) NOT NULL
)
GO
CREATE TABLE DETALLEVALE
(IDVALE INTEGER PRIMARY KEY,
IDDOCUMENTO VARCHAR (5) NOT NULL,
CANTIDAD DECIMAL
)
GO
CREATE TABLE DOCUMENTO
(IDDOCUMENTO INTEGER PRIMARY KEY,
IDTIPODOCUMENTO VARCHAR (5) NOT NULL,
TITULO VARCHAR (50) NOT NULL,
- 7 -
Grupo de Alumnos VI CICLO
EDITORIAL VARCHAR (50) NOT NULL,
FECHAEDICION DATETIME,
PAIS VARCHAR (50) NOT NULL,
EDICION VARCHAR (50) NOT NULL,
DESCRIPCION VARCHAR (50) NOT NULL
)
GO
CREATE TABLE LECTOR
(IDLECTOR INTEGER PRIMARY KEY,
IDTIPOLECTOR VARCHAR (5) NOT NULL,
NOMBRE VARCHAR (50) NOT NULL,
DIRECCION VARCHAR (50) NOT NULL,
TELEFONO VARCHAR (50) NOT NULL
)
GO
CREATE TABLE LIBROSFALLADOS
(IDFALLADOS INTEGER PRIMARY KEY,
IDDOCUMENTO VARCHAR (5) NOT NULL,
MOTIVO VARCHAR (50) NOT NULL,
DESCRIPCION VARCHAR (50) NOT NULL,
IDPRESTAMO VARCHAR (5) NOT NULL
)
GO
CREATE TABLE PRESTAMO
(IDPRESTAMO INTEGER PRIMARY KEY,
IDLECTOR VARCHAR (5) NOT NULL,
FECHASISTEMA DATETIME NOT NULL,
FECHAENTREGA DATETIME,
- 8 -
Grupo de Alumnos VI CICLO
DIAS VARCHAR (50)
)
GO
CREATE TABLE PROVEEDOR
(IDPROVEEDOR INTEGER PRIMARY KEY,
PROVEEDOR VARCHAR (50) NOT NULL,
DIRECCION VARCHAR (50) NOT NULL,
CIUDAD VARCHAR (50) NOT NULL,
TELEFONO VARCHAR (50) NOT NULL
)
GO
CREATE TABLE REQUISITOS
(IDTIPOREQUISITO INTEGER PRIMARY KEY,
IDPRESTAMO VARCHAR (5) NOT NULL
)
GO
CREATE TABLE TIPODOCUMENTO
(IDTIPODOCUMENTO INTEGER PRIMARY KEY,
DOCUMENTO VARCHAR (50) NOT NULL
)
GO
CREATE TABLE TIPOLECTOR
(IDTIPOLECTOR INTEGER PRIMARY KEY,
DESCRIPCION VARCHAR (50) NOT NULL
)
GO
CREATE TABLE TIPOREQUISITO
(IDTIPOREQUISITO INTEGER PRIMARY KEY,
- 9 -
Grupo de Alumnos VI CICLO
IDTIPOLECTOR VARCHAR (50) NOT NULL,
REQUISITO VARCHAR (50) NOT NULL,
MOTIVO VARCHAR (50) NOT NULL
)
GO
CREATE TABLE USUARIO
(IDUSUARIO INTEGER PRIMARY KEY,
NOMBRE VARCHAR (40) NOT NULL,
CLAVE VARCHAR (8) NOT NULL,
RETIRADO VARCHAR (50) NOT NULL,
US VARCHAR (50) NOT NULL,
RECORDAR VARCHAR (50) NOT NULL
)
GO
CREATE TABLE VALEINGRESODOCUMENTOS
(IDVALE INTEGER PRIMARY KEY,
IDPROVEEDOR VARCHAR (5) NOT NULL,
FECHARECEPCION DATETIME,
MODALIDAD VARCHAR (50) NOT NULL,
NUMERODOCUMENTO VARCHAR (50) NOT NULL,
DOCUMENTO VARCHAR (50) NOT NULL,
OBSERVACION VARCHAR (50) NOT NULL
)
GO
- 10 -
B/D Y RELACION DELSISTEMA DE BIBLIOTECA
Grupo de Alumnos VI CICLO
- 12 -
Grupo de Alumnos VI CICLO
- 13 -
AÑEXOS
PASOS PARA PODER INGRESAR AL SISTEMA FAMILIAR
Esta pantalla nos dará la bienvenida al sistema de biblioteca, por defecto
tiene dos comandos, ingresar y salir
Ingresar: Permite ingresar hacia la otra pantalla.
Salir: Permite por defecto salir de la aplicación.
Después de ingresar nos arrojara una pantalla llamada SEGURIDAD, como
observamos esta pantalla tiene otros dos comandos muy importantes,
nombre del usuario y contraseña
Por defecto nombre del usuario es un comando que nos permitirá
ingresar el administrador que corresponde.
Contraseña, es otro comando que nos permitirá automáticamente
ingresar la contraseña, aceptamos para que posteriormente nos lleve a otra
pantalla.
Grupo de Alumnos VI CICLO
Este es el menú principal del sistema biblioteca, con ello podemos llevar
un buen mantenimiento de todos los libros que salen e ingresan durante el
día.
Como se puede observar este menú contiene el lector y tipo de lector y
registrar lector
Tipo de lector: es donde se registrara si es alumno, externo o
administrativo y entre otros.
Esta
Como
- 15 -
Grupo de Alumnos VI CICLO
Como podemos observar este mantenedor tiene distintos comandos muy
importantes.
Eliminar: Nos permitirá eliminar cualquier tipo de usuario.
Modificar: Nos permitirá modificar el tipo de usuario.
Nuevo: Nos permitirá registrar a un nuevo usuario.
Salir: Nos permitirá cerrar la sesión.
Código:
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo () As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
Vsql = "SELECT count (*) FROM TipoLector;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields (0) > 0 Then
Rscarrera.Close
Vsql = "SELECT IdTipoLector FROM TipoLector;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
Cod = Trim (CStr (CInt (Rscarrera.Fields (0)) + 1))
Cod = Right (cod, 5)
- 16 -
Grupo de Alumnos VI CICLO
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from TipoLector where IdTipoLector= '" & lvwData.SelectedItem.Text & "' "
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
If vtipo = True Then
'Consulta de nuevo
vsql = " INSERT INTO TipoLector (IdTipoLector,Descripcion)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + " '" & txtnombre.Text & "')"
Else
'Consulta de Actualizaciòn
vsql = " update TipoLector set "
vsql = vsql & " Descripcion = '" & txtnombre.Text & "'"
vsql = vsql & " where IdTipoLector= '" & lvwData.SelectedItem.Text & "' "
End If
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
- 17 -
Grupo de Alumnos VI CICLO
manipularerror:
Debug.Print Err, Err.Description
Select Case Err
Case Is = -2147467259
MsgBox "el codigo ya existe, cambielo ", vbExclamation, "Error de datos"
txtcodigo.SetFocus
End Select
End Sub
Private Sub cmdModificar_Click()
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select * from TipoLector where IdTipoLector='" & lvwData.SelectedItem.Text & "'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!IdTipoLector
txtnombre.Text = Rscarrera!Descripcion
Rscarrera.Close
Set Rscarrera = Nothing
End Sub
Private Sub cmdNuevo_Click()
vtipo = True
franuevo.ZOrder 0
txtcodigo.Text = ""
txtnombre.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select * from TipoLector"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!IdTipoLector)
iReg.ListSubItems.Add Text:=rsDatos!Descripcion
rsDatos.MoveNext
Loop
- 18 -
Grupo de Alumnos VI CICLO
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub Form_Load()
Mostrardatos
End Sub
Private Sub lvwData_BeforeLabelEdit (Cancel As Integer)
Cancel = True
End Sub
Private Sub lvwData_ColumnClick (ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvwData.SortKey = ColumnHeader.Index - 1
lvwData.Sorted = True
End Sub
Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtjefe_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
- 19 -
Grupo de Alumnos VI CICLO
Private Sub txtnombre_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM Lector;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
- 20 -
Grupo de Alumnos VI CICLO
vsql = "SELECT IDLector FROM Lector;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cbotipo_Click()
verIDtipo
End Sub
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from Lector where IdLector= '" & lvwData.SelectedItem.Text & "' "
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
If vtipo = True Then
'Consulta de nuevo
vsql = " INSERT INTO Lector (IdLector,IdTipoLector,Nombre,Direccion,Telefono)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + "'" & txtidtipo.Text & "',"
vsql = vsql + "'" & txtnombre.Text & "',"
vsql = vsql + "'" & txtdireccion.Text & "',"
vsql = vsql + " '" & txttelefono.Text & "')"
- 21 -
Grupo de Alumnos VI CICLO
Else
'Consulta de Actualizaciòn
vsql = " update Lector set "
vsql = vsql & " Nombre = '" & txtnombre.Text & "',"
vsql = vsql & " Direccion= '" & txtdireccion.Text & "',"
vsql = vsql & " Telefono= '" & txttelefono.Text & "'"
vsql = vsql & " where IdLector= '" & lvwData.SelectedItem.Text & "' "
End If
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
manipularerror:
Debug.Print Err, Err.Description
Select Case Err
Case Is = -2147467259
MsgBox "el codigo ya existe, cambielo ", vbExclamation, "Error de datos"
txtcodigo.SetFocus
End Select
End Sub
Private Sub cmdModificar_Click()
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select l.idlector,l.nombre,l.direccion,l.telefono,t.descripcion from TipoLector t,Lector l
where t.IdTipoLector=l.IdTipoLector and l.IdLector='" & lvwData.SelectedItem.Text & "'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!IdLector
cbotipo.Text = Rscarrera!Descripcion
txtnombre.Text = Rscarrera!nombre
txtdireccion.Text = IIf(IsNull(Rscarrera!direccion), "", Rscarrera!direccion)
txttelefono.Text = IIf(IsNull(Rscarrera!Telefono), "", Rscarrera!Telefono)
Rscarrera.Close
Set Rscarrera = Nothing
End Sub
Private Sub cmdNuevo_Click()
vtipo = True
franuevo.ZOrder 0
- 22 -
Grupo de Alumnos VI CICLO
txtcodigo.Text = ""
txtnombre.Text = ""
txttelefono.Text = ""
txtdireccion.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select l.idlector,t.descripcion,l.nombre from Lector l , TipoLector T Where
t.IdTipoLector=l.IdTipoLector "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!IdLector)
iReg.ListSubItems.Add Text:=rsDatos!Descripcion
iReg.ListSubItems.Add Text:=rsDatos!nombre
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click ()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click ()
Unload Me
End Sub
Private Sub lvwData_BeforeLabelEdit (Cancel As Integer)
Cancel = True
End Sub
Private Sub lvwData_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvwData.SortKey = ColumnHeader.Index - 1
lvwData.Sorted = True
End Sub
Private Sub txtCodigo_KeyPress (KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
- 23 -
Grupo de Alumnos VI CICLO
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub vertipos ()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select descripcion from TipoLector "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
cbotipo.Clear
Do While Not rsDatos.EOF
cbotipo.AddItem rsDatos! Descripcion
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub verIDtipo()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select IdTipoLector from TipoLector where descripcion='" & cbotipo.Text & "'"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
Do While Not rsDatos.EOF
txtidtipo.Text = rsDatos!IdTipoLector
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
- 24 -
Grupo de Alumnos VI CICLO
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM TipoRequisito;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
vsql = "SELECT IdTipoRequisito FROM TipoRequisito;"
- 25 -
Grupo de Alumnos VI CICLO
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cbotipolector_Click()
Mostrardatostipocodigo
End Sub
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from TipoRequisito where IdTipoRequisito= '" & lvwData.SelectedItem.Text & "'
and IdTipoLector= '" & lvwData.SelectedItem.ListSubItems(1).Text & "'"
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
If vtipo = True Then
'Consulta de nuevo
vsql = " INSERT INTO TipoRequisito (IdTipoRequisito,IdTipoLector,MOTIVO,requisito)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + " '" & txtidtipolector.Text & "',"
vsql = vsql + " '" & cbomodalidad.Text & "',"
vsql = vsql + " '" & txtnombre.Text & "')"
Else
- 26 -
Grupo de Alumnos VI CICLO
'Consulta de Actualizaciòn
vsql = " update TipoRequisito set "
vsql = vsql & " IdTipoLector = '" & txtidtipolector.Text & "',"
vsql = vsql & " Motivo= '" & cbomodalidad.Text & "',"
vsql = vsql & " Requisito = '" & txtnombre.Text & "'"
vsql = vsql & " where IdTipoRequisito= '" & lvwData.SelectedItem.Text & "' and
IdTipoLector= '" & lvwData.SelectedItem.ListSubItems(1).Text & "'"
End If
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
manipularerror:
Debug.Print Err, Err.Description
Select Case Err
Case Is = -2147467259
MsgBox "el codigo ya existe, cambielo ", vbExclamation, "Error de datos"
txtcodigo.SetFocus
End Select
End Sub
Private Sub cmdModificar_Click()
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select t.idtiporequisito,t.idtipolector,t.requisito,tl.descripcion from TipoRequisito
t,TipoLEctor tl where t.IdTipoLector=tl.IdTipoLector and t.IdTipoRequisito='" &
lvwData.SelectedItem.Text & "' and t.IdTipoLector='" &
lvwData.SelectedItem.ListSubItems(1).Text & "'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!IdTipoLector
txtnombre.Text = Rscarrera!Requisito
txtidtipolector = Rscarrera!IdTipoLector
cbotipolector.Text = Rscarrera!Descripcion
Rscarrera.Close
Set Rscarrera = Nothing
End Sub
Private Sub cmdNuevo_Click()
- 27 -
Grupo de Alumnos VI CICLO
vtipo = True
franuevo.ZOrder 0
txtcodigo.Text = ""
txtnombre.Text = ""
txtidtipolector.Text = ""
cbotipolector.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select t.IDTipoRequisito,t.idtipolector,TL.Descripcion,t.requisito from TipoRequisito
t,TipoLEctor TL where t.IdTipoLector=TL.IdTipoLector"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!IdTipoLector)
iReg.ListSubItems.Add Text:=rsDatos!IdTipoLector
iReg.ListSubItems.Add Text:=rsDatos!Descripcion
iReg.ListSubItems.Add Text:=rsDatos!Requisito
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub Form_Load()
mostrardatos
mostrardatostipo
End Sub
Private Sub lvwData_BeforeLabelEdit(Cancel As Integer)
Cancel = True
End Sub
Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
- 28 -
Grupo de Alumnos VI CICLO
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtnombre_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Private Sub mostrardatostipo()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select descripcion from TipoLEctor "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
cbotipolector.Clear
Do While Not rsDatos.EOF
cbotipolector.AddItem rsDatos!Descripcion
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub mostrardatostipocodigo()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select IdTipolector from TipoLEctor where descripcion='" & cbotipolector.Text & "'"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
Do While Not rsDatos.EOF
txtidtipolector.Text = rsDatos!IdTipoLector
rsDatos.MoveNext
- 29 -
Grupo de Alumnos VI CICLO
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
- 30 -
Grupo de Alumnos VI CICLO
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM proveedor;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
vsql = "SELECT idproveedor FROM proveedor;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cbotipo_Click()
verIDtipo
End Sub
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from proveedor where idproveedor= '" & lvwData.SelectedItem.Text & "' "
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
- 31 -
Grupo de Alumnos VI CICLO
On Error GoTo e
If vtipo = True Then
'Consulta de nuevo
vsql = " INSERT INTO proveedor(idproveedor,proveedor,direccion,ciudad,telefono)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + "'" & txtnombre.Text & "',"
vsql = vsql + "'" & txtdireccion.Text & "',"
vsql = vsql + "'" & txtciudad.Text & "',"
vsql = vsql + " '" & txttelefono.Text & "')"
Else
'Consulta de Actualizaciòn
vsql = " update proveedor set "
vsql = vsql & " Nombre = '" & txtnombre.Text & "',"
vsql = vsql & " Direccion= '" & txtdireccion.Text & "',"
vsql = vsql & " ciudad= '" & txtciudad.Text & "',"
vsql = vsql & " Telefono= '" & txttelefono.Text & "'"
vsql = vsql & " where idproveedor= '" & lvwData.SelectedItem.Text & "' "
End If
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
e:
MsgBox Err.Description, vbInformation
End Sub
Private Sub cmdModificar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select * from proveedor where idproveedor='" & lvwData.SelectedItem.Text & "'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!idproveedor
txtnombre.Text = Rscarrera!proveedor
txtdireccion.Text = IIf(IsNull(Rscarrera!direccion), "", Rscarrera!direccion)
txttelefono.Text = IIf(IsNull(Rscarrera!Telefono), "", Rscarrera!Telefono)
txttelefono.Text = IIf(IsNull(Rscarrera!ciudad), "", Rscarrera!ciudad)
Rscarrera.Close
Set Rscarrera = Nothing
- 32 -
Grupo de Alumnos VI CICLO
End Sub
Private Sub cmdNuevo_Click()
vtipo = True
franuevo.ZOrder 0
txtcodigo.Text = ""
txtnombre.Text = ""
txttelefono.Text = ""
txtdireccion.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select idproveedor,proveedor,direccion from proveedor "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!idproveedor)
iReg.ListSubItems.Add Text:=rsDatos!proveedor
iReg.ListSubItems.Add Text:=rsDatos!direccion
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub Form_Load()
mostrardatos
End Sub
Private Sub lvwData_BeforeLabelEdit(Cancel As Integer)
Cancel = True
End Sub
Private Sub lvwData_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvwData.SortKey = ColumnHeader.Index - 1
- 33 -
Grupo de Alumnos VI CICLO
lvwData.Sorted = True
End Sub
Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtjefe_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Private Sub txtnombre_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
- 34 -
Grupo de Alumnos VI CICLO
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM TipoDocumento;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
- 35 -
Grupo de Alumnos VI CICLO
vsql = "SELECT IdTipoDocumento FROM TipoDocumento;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from TipoDocumento where IdTipodocumento= '" &
lvwData.SelectedItem.Text & "' "
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
If vtipo = True Then
'Consulta de nuevo
vsql = " INSERT INTO TipoDocumento (IdTipodocumento,Documento)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + " '" & txtnombre.Text & "')"
Else
'Consulta de Actualizaciòn
vsql = " update TipoDocumento set "
vsql = vsql & " Descripcion = '" & txtnombre.Text & "'"
vsql = vsql & " where IdTipoDocumento= '" & lvwData.SelectedItem.Text & "' "
- 36 -
Grupo de Alumnos VI CICLO
End If
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
manipularerror:
Debug.Print Err, Err.Description
Select Case Err
Case Is = -2147467259
MsgBox "el codigo ya existe, cambielo ", vbExclamation, "Error de datos"
txtcodigo.SetFocus
End Select
End Sub
Private Sub cmdModificar_Click()
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select * from TipoDocumento where IdTipoDocumento='" &
lvwData.SelectedItem.Text & "'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!IdTipoDocumento
txtnombre.Text = Rscarrera!documento
Rscarrera.Close
Set Rscarrera = Nothing
End Sub
Private Sub cmdNuevo_Click()
vtipo = True
franuevo.ZOrder 0
txtcodigo.Text = ""
txtnombre.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select * from Tipodocumento"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
- 37 -
Grupo de Alumnos VI CICLO
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!IdTipoDocumento)
iReg.ListSubItems.Add Text:=rsDatos!documento
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub Form_Load()
mostrardatos
End Sub
Private Sub lvwData_BeforeLabelEdit(Cancel As Integer)
Cancel = True
End Sub
Private Sub lvwData_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvwData.SortKey = ColumnHeader.Index - 1
lvwData.Sorted = True
End Sub
Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtjefe_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
- 38 -
Grupo de Alumnos VI CICLO
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Private Sub txtnombre_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Dim vsql As String
'vTipo true a nuevo
'vTipo false a modificar
Dim vtipo As Boolean
Public Function GeneraCodigo() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM documento;"
- 39 -
Grupo de Alumnos VI CICLO
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
vsql = "SELECT iddocumento FROM documento;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigo = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigo = ""
Exit Function
End Function
Private Sub cbotipo_Click()
verIDtipo
End Sub
Private Sub cmdEliminar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
vsql = "delete from documento where IdDocumento= '" & lvwData.SelectedItem.Text & "' "
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatos
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub cmdGrabar_Click()
On Error GoTo e
If vtipo = True Then
- 40 -
Grupo de Alumnos VI CICLO
'Consulta de nuevo
vsql = " INSERT INTO documento
(IdDocumento,IdTipoDocumento,Titulo,Editorial,FechaEdicion,Pais,edicion,Descripcion)"
vsql = vsql + " VALUES ('" & txtcodigo.Text & "',"
vsql = vsql + "'" & txtidtipo.Text & "',"
vsql = vsql + "'" & txtnombre.Text & "'," ' titutlo
vsql = vsql + "'" & txtdireccion.Text & "'," ' editorial
vsql = vsql + "'" & fecha.Value & "'," ' fecha
vsql = vsql + "'" & txtpais.Text & "'," ' pais
vsql = vsql + "'" & txtedicion.Text & "'," ' edicion
vsql = vsql + "'" & txtdescripcion.Text & "')" ' descripcion
Else
'Consulta de Actualizaciòn
vsql = " update Documento set "
vsql = vsql & " IdTipoDocumento = '" & txtidtipo.Text & "',"
vsql = vsql & " Titulo= '" & txtnombre.Text & "',"
vsql = vsql & " Editorial= '" & txtdireccion.Text & "',"
vsql = vsql & " Fechaedicion= '" & fecha.Value & "',"
vsql = vsql & " pais= '" & txtpais.Text & "',"
vsql = vsql & " edicion= '" & txtedicion.Text & "',"
vsql = vsql & " descripcion= '" & txtdescripcion.Text & "'"
vsql = vsql & " where IdDocumento= '" & lvwData.SelectedItem.Text & "' "
End If
cn.Execute vsql
mostrardatos
fraMantenedor.ZOrder 0
Exit Sub
e:
MsgBox Err.Description
End Sub
Private Sub cmdImprimir_Click()
End Sub
Private Sub cmdModificar_Click()
If lvwData.ListItems.Count = 0 Then Exit Sub
Dim Rscarrera As New ADODB.Recordset
vtipo = False
franuevo.ZOrder 0
vsql = "select
l.IdTipoDocumento,l.iddocumento,l.titulo,l.editorial,l.fechaedicion,l.pais,l.edicion,l.descripcion,l.
idtipodocumento,t.documento from TipoDocumento t,Documento l where
- 41 -
Grupo de Alumnos VI CICLO
t.IdTipoDocumento=l.IdTipoDocumento and l.IdDocumento='" & lvwData.SelectedItem.Text &
"'"
Rscarrera.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
If Rscarrera.BOF And Rscarrera.EOF Then
Exit Sub
End If
txtcodigo.Text = Rscarrera!iddocumento
cbotipo.Text = Rscarrera!documento
txtnombre.Text = Rscarrera!Titulo
txtdireccion.Text = IIf(IsNull(Rscarrera!editorial), "", Rscarrera!editorial)
txtpais.Text = IIf(IsNull(Rscarrera!pais), "", Rscarrera!pais)
txtedicion.Text = IIf(IsNull(Rscarrera!edicion), "", Rscarrera!edicion)
txtdescripcion.Text = IIf(IsNull(Rscarrera!Descripcion), "", Rscarrera!Descripcion)
fecha.Value = IIf(IsNull(Rscarrera!fechaedicion), "", Rscarrera!fechaedicion)
txtidtipo.Text = IIf(IsNull(Rscarrera!IdTipoDocumento), "", Rscarrera!IdTipoDocumento)
Rscarrera.Close
Set Rscarrera = Nothing
End Sub
Private Sub cmdNuevo_Click()
vtipo = True
franuevo.ZOrder 0
txtcodigo.Text = ""
txtnombre.Text = ""
txtedicion.Text = ""
txtpais.Text = ""
txtdescripcion.Text = ""
txtdireccion.Text = ""
txtcodigo = GeneraCodigo
txtnombre.SetFocus
End Sub
Private Sub mostrardatos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select idDocumento,Titulo,editorial from Documento "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
lvwData.ListItems.Clear
Do While Not rsDatos.EOF
Set iReg = lvwData.ListItems.Add(Text:=rsDatos!iddocumento)
iReg.ListSubItems.Add Text:=rsDatos!Titulo
iReg.ListSubItems.Add Text:=rsDatos!editorial
rsDatos.MoveNext
- 42 -
Grupo de Alumnos VI CICLO
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub cmdRegresar_Click()
fraMantenedor.ZOrder 0
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub Command1_Click()
frmautor.txtnombre.Text = ""
frmautor.txtcodigo.Text = GeneraCodigoautor
frmautor.Show
End Sub
Private Sub Command2_Click()
If lvwautor.ListItems.Count = 0 Then Exit Sub
vsql = "delete from Autor where idautor= '" & lvwautor.SelectedItem.Text & "' and
IdDocumento= '" & lvwautor.SelectedItem.ListSubItems(1).Text & "'"
If MsgBox("Desea eliminar realmnte el registro", vbQuestion + vbYesNo, "Confirmacion") =
vbYes Then
On Error GoTo manipularerror
cn.Execute vsql
mostrardatosautor
End If
Exit Sub
manipularerror:
MsgBox "El registros tiene detalle"
On Error GoTo 0
End Sub
Private Sub Command3_Click()
frmautor.Command1.Visible = True
frmautor.cmdGrabar.Visible = False
frmautor.Show
End Sub
Private Sub Form_Load()
mostrardatos
vertipos
End Sub
Private Sub lvwautor_BeforeLabelEdit(Cancel As Integer)
Cancel = True
- 43 -
Grupo de Alumnos VI CICLO
End Sub
Private Sub lvwData_BeforeLabelEdit(Cancel As Integer)
Cancel = True
End Sub
Private Sub lvwData_Click()
mostrardatosautor
End Sub
Private Sub lvwData_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
lvwData.SortKey = ColumnHeader.Index - 1
lvwData.Sorted = True
End Sub
Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
' ingresamos numeros y letras pero no puntos,etc
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If (KeyAscii >= 48) Or KeyAscii = 8 Or Chr(KeyAscii) = ".." Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtjefe_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Private Sub txtnombre_KeyPress(KeyAscii As Integer)
'convertir a mayuscula cada tecla pulsada
KeyAscii = Asc(UCase(Chr(KeyAscii)))
'limitar el ingreso a caracteres: letras, espacio y backspace o retroceso
Dim c As String
c = Chr(KeyAscii)
If Not ((c >= "A" And c <= "Z") Or c = "Ñ" Or c = Chr(32) Or c = Chr(8)) Then
' no mostrar caracter
- 44 -
Grupo de Alumnos VI CICLO
KeyAscii = 0
Beep ' emitir sonido
End If
End Sub
Private Sub vertipos()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select Documento from TipoDocumento "
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
cbotipo.Clear
Do While Not rsDatos.EOF
cbotipo.AddItem rsDatos!documento
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Private Sub verIDtipo()
Dim rsDatos As New ADODB.Recordset
Dim iReg As ListItem
vsql = "select IdTipoDocumento from TipoDocumento where documento='" & cbotipo.Text &
"'"
rsDatos.Open vsql, cn, adOpenForwardOnly, adLockOptimistic
Do While Not rsDatos.EOF
txtidtipo.Text = rsDatos!IdTipoDocumento
rsDatos.MoveNext
Loop
rsDatos.Close
Set rsDatos = Nothing
End Sub
Public Function GeneraCodigoautor() As String
On Error GoTo AddErr
Dim vsql As String, cod As String
Dim Rscarrera As New ADODB.Recordset
vsql = "SELECT count(*) FROM autor;"
If Rscarrera.State = adStateOpen Then
Rscarrera.Close
End If
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
If Rscarrera.Fields(0) > 0 Then
Rscarrera.Close
- 45 -
Grupo de Alumnos VI CICLO
vsql = "SELECT idautor FROM autor;"
Rscarrera.Open vsql, cn, adOpenStatic, adLockOptimistic
Rscarrera.MoveLast
cod = Trim(CStr(CInt(Rscarrera.Fields(0)) + 1))
cod = Right(cod, 5)
Else
cod = "100"
End If
GeneraCodigoautor = cod
Exit Function
AddErr:
MsgBox Err.Description
GeneraCodigoautor = ""
Exit Function
- 46 -