You are on page 1of 27

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

Instituto Tecnolgico Superior de Lerdo

Informtica
Administracin y Organizacin de Datos

Integrantes del Equipo:


Judith Elena Saucedo Flores Viviana Montelongo Cabrales Berenicee Fabiola Medina Rosales Diana Cristina Hernndez y Cardona Rebeca Nez

Grupo: 4

Seccin: B

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO Documentacin Para el Usuario Ventana principal

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO Documentacin Para el Programador


Imports System.IO Public Class Form1 Structure Datos 'Estructura donde se guardan los datos Dim nombre As String 'Elemento de la estructura para almacenar el nombre Dim edad As Integer 'variable para edad Dim carrera As String 'variable para almacenar la carrera del estudiante Dim NumerodeControl As Integer 'variable que almacena el numero de control End Structure Dim datosTemporales(1000) As Datos 'los datos temporales cuentan con un arreglo con mil espacios para almacenar los datos Dim totalDeRegistros As Integer = 0 'Toma el valor del total de registros que tiene el archivo Dim registroActual As Integer = 0 'Toma el valor del registro actual que se esta leyendo, o se va a modificar, o guardar Dim direccionYNombre As String 'Toma el valor de la direccion donde se guarda el archivo y el nombre Dim modificado As Boolean 'la variable modificado es de tipo boleano

Private Sub mnu_crear_Click(sender As System.Object, e As System.EventArgs) Handles mnu_crear.Click Dim ventanaDeGuardar As New SaveFileDialog() 'Se crea una ventana para guardar el archivo If ventanaDeGuardar.ShowDialog() = Windows.Forms.DialogResult.OK Then 'entonces Si presionamos guardar en la ventana entonces 'Se crea un flujo de datos (como un canal para guardar la informacion) 'la variable direccion y nombre toma la direcion de la ventana donde se guardo el archivo direccionYNombre = ventanaDeGuardar.FileName 'se crea el flujo Dim flujo As New FileStream(direccionYNombre, FileMode.Create, FileAccess.Write) ' 'en la label archivo se imprime la direccion donde se guardo el archivo lbl_archivo.Text = direccionYNombre 'se habilitan los menus mnu_guardar.Enabled = True mnu_guardarComo.Enabled = True btn_guardar.Enabled = True 'se borra o se pone en blanco lo que contienen los label y se indica que no hay ningun registro aun en lbl_registroActual lbl_nombre.Text = "" lbl_carrera.Text = "" lbl_edad.Text = "" lbl_numero.Text = "" lbl_registroActual.Text = "Sin Registros" 'se le asigna el valor de cero al total de registros y al registro actual totalDeRegistros = 0 registroActual = 0 'se deshabilitan los menus mnusiguiente.Enabled = False

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


mnuanterior.Enabled = False mnuultimo.Enabled = False mnuprimero.Enabled = False mnueliminar.Enabled = False mnumodificar.Enabled = False Dim datosTemporales(1000) As Datos 'se cierra el flujo de datos flujo.Close() End If End Sub Private Sub mnu_guardar_Click(sender As System.Object, e As System.EventArgs) Handles mnu_guardar.Click If totalDeRegistros > 0 Then 'Se guardan los registros en el archivo solo si se han guardado localmente al menos 1 'Se crea un flujo (como un canal) para guardar la informacion Dim flujoParaGuardar As New FileStream(direccionYNombre, FileMode.Create, FileAccess.Write) Dim escritor As New BinaryWriter(flujoParaGuardar) 'Se crea un objeto utilizado para escribir en el archivo Dim indice As Integer 'Contador usado para recorrer el ciclo For For indice = 0 To totalDeRegistros - 1 'Ciclo que recorre todos los registros del archivo escritor.BaseStream.Seek(70 * indice, SeekOrigin.Begin) 'Se define la longitud de cada registro (70 bytes) escritor.Write(CType(datosTemporales(indice).nombre, String)) 'Se escriben los datos del nombre en el archivo escritor.Write(CType(datosTemporales(indice).edad, Integer)) 'Se escriben los datos del edad en el archivo escritor.Write(CType(datosTemporales(indice).carrera, String)) 'Se escriben los datos de la carrera en el archivo escritor.Write(CType(datosTemporales(indice).NumerodeControl, Integer)) 'Se escriben los datos del numero de control en el archivo Next 'Se cierra el escritor escritor.Close() 'Se cierra el flujo para guardar flujoParaGuardar.Close() End If End Sub Private Sub mnu_abrir_Click(sender As System.Object, e As System.EventArgs) Handles mnu_abrir.Click Dim ventanaParaAbrir As New OpenFileDialog() 'Se crea una ventana para buscar el archivo If ventanaParaAbrir.ShowDialog() = Windows.Forms.DialogResult.OK Then 'En caso de precionar el boton de abrir... direccionYNombre = ventanaParaAbrir.FileName 'Se obtiene la direccion y nombre del archivo a abrir Dim flujoParaLeer As New FileStream(direccionYNombre, FileMode.Open, FileAccess.Read) 'Flujo para leer el archivo Dim lector As New BinaryReader(flujoParaLeer) 'Se crea un objeto con el que se lee el archivo lbl_archivo.Text = direccionYNombre

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


If lector.PeekChar <> -1 Then 'Se verifica que el archivo tenga texto 'Se obtienen el total de los registros del archivo totalDeRegistros = CType(Math.Ceiling(flujoParaLeer.Length / 70), Integer) If totalDeRegistros = 1 Then mnueliminar.Enabled = True ElseIf totalDeRegistros > 1 Then mnusiguiente.Enabled = True mnuultimo.Enabled = True mnuanterior.Enabled = True mnueliminar.Enabled = True mnumodificar.Enabled = True mnunuevo.Enabled = True mnuprimero.Enabled = True

End If Dim indice As Integer 'Contador para recorrer el ciclo For For indice = 0 To totalDeRegistros - 1 lector.BaseStream.Seek(70 * indice, SeekOrigin.Begin) datosTemporales(indice).nombre = lector.ReadString.ToString datosTemporales(indice).edad = lector.ReadInt32.ToString datosTemporales(indice).carrera = lector.ReadString.ToString datosTemporales(indice).NumerodeControl = lector.ReadInt32.ToString Next btn_guardar.Enabled = True mnu_guardar.Enabled = True mnu_guardarComo.Enabled = True

lector.Close() 'Se cierra el objeto para leer flujoParaLeer.Close() 'Se cierra el flujo para leer registroActual = 0 VerRegistro(0) End If btn_guardar.Enabled = True mnu_guardar.Enabled = True mnu_guardarComo.Enabled = True End If End Sub Private Sub mnu_guardarComo_Click(sender As System.Object, e As System.EventArgs) Handles mnu_guardarComo.Click Dim ventanaParaGuardar As New SaveFileDialog() 'Ventana para guardar 'En caso de precionar guardar en la ventana... If ventanaParaGuardar.ShowDialog = Windows.Forms.DialogResult.OK Then direccionYNombre = ventanaParaGuardar.FileName 'Se asigna la direccion y el nombre del archivo Dim flujoParaGuardar As New FileStream(direccionYNombre, FileMode.Create, FileAccess.Write)

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


Dim escritor As New BinaryWriter(flujoParaGuardar) 'Se crea un objeto utilizado para escribir en el archivo lbl_archivo.Text = direccionYNombre Dim indice As Integer 'Contador usado para recorrer el ciclo For For indice = 0 To totalDeRegistros - 1 'Ciclo que recorre todos los registros del archivo escritor.BaseStream.Seek(70 * indice, SeekOrigin.Begin) 'Se define la longitud de cada registro (70 bytes) escritor.Write(CType(datosTemporales(indice).nombre, String)) 'Se escriben los datos en el archivo escritor.Write(CType(datosTemporales(indice).edad, Integer)) escritor.Write(CType(datosTemporales(indice).carrera, String)) 'Se escriben los datos en el archivo escritor.Write(CType(datosTemporales(indice).NumerodeControl, Integer)) Next escritor.Close() flujoParaGuardar.Close() End If End Sub

'Funcion para mostrar los datos Public Sub VerRegistro(ByVal numeroDeRegistro) registroActual = numeroDeRegistro lbl_nombre.Text = datosTemporales(numeroDeRegistro).nombre 'Se muestra en el textbox el dato del arreglo lbl_edad.Text = datosTemporales(numeroDeRegistro).edad 'Se muestra en el textbox ls edad lbl_carrera.Text = datosTemporales(numeroDeRegistro).carrera 'Se muestra en el textbox el dato del arreglo lbl_numero.Text = datosTemporales(numeroDeRegistro).NumerodeControl lbl_registroActual.Text = "Registro: " & (registroActual + 1) 'Se indica en la etiqueta (label) el registro actual End Sub

Private Sub mnusiguiente_Click(sender As System.Object, e As System.EventArgs) Handles mnusiguiente.Click 'esta condicion permite que si el registro actual es menor que el total de registros menos 1 If registroActual < totalDeRegistros - 1 Then 'entonces registroActual += 1 'Se avanza al siguiente registro VerRegistro(registroActual) 'Se muestra el registro actual, por medio de la funcion Ver registro End If End Sub Private Sub mnuanterior_Click(sender As System.Object, e As System.EventArgs) Handles mnuanterior.Click 'esta condicion permite que si el registro actual es mayor a cero entonces se retocede al registro anterior If registroActual > 0 Then registroActual -= 1 'Se retrocede al registro anterior VerRegistro(registroActual) 'Se muestra el registro actual, por medio de la funcion VerRegistro

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


End If End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lbl_registroActual.Text = "Sin Registros" 'Se indica que aun no existen registros lbl_archivo.Text = "Sin Archivo" 'Se indica del archivo que se esta utilizando 'aqui se inhabilitan los menus con los que se operan los archivos btn_guardar.Enabled = False mnusiguiente.Enabled = False mnuprimero.Enabled = False mnumodificar.Enabled = False mnuultimo.Enabled = False mnuanterior.Enabled = False mnueliminar.Enabled = False mnu_guardar.Enabled = False mnu_guardarComo.Enabled = False

End Sub 'menu eliminar Private Sub mnueliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnueliminar.Click ' datosTemporales(registroActual) = Nothing 'Se declkara la variable contador la cual se asigna el tipo de dato entero Dim cont As Integer 'Se entra en un ciclo for el cual recorre todos los registro que se crearon For cont = registroActual To totalDeRegistros - 1 datosTemporales(cont) = datosTemporales(cont + 1) Next tbx_carrera.Text = "" tbx_edad.Text = "" tbx_nombre.Text = "" tbx_numero.Text = "" totalDeRegistros = totalDeRegistros - 1 If totalDeRegistros > 0 Then VerRegistro(0) Else mnueliminar.Enabled = False lbl_registroActual.Text = "Sin Registros" End If End Sub Private Sub salirToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles salirToolStripMenuItem1.Click

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


Application.Exit() End Sub Private Sub mnumodificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnumodificar.Click datosTemporales(registroActual).nombre = tbx_nombre.Text ' Se guarda el valor del textbox en el arreglo de datos datosTemporales(registroActual).edad = tbx_edad.Text ' Se guarda el valor del textbox en el arreglo de datos datosTemporales(registroActual).carrera = tbx_carrera.Text ' Se guarda el valor del textbox en el arreglo de datos datosTemporales(registroActual).NumerodeControl = tbx_numero.Text ' Se guarda el valor del textbox en el arreglo de datos 'Se limpian los textbox tbx_carrera.Text = "" tbx_edad.Text = "" tbx_nombre.Text = "" tbx_numero.Text = "" VerRegistro(registroActual) End Sub ' al darle click al menu primero con la funcion ver registro se imprime el registro numero 1 que se encuentra en el registr4o ceero del arreglo Private Sub mnuprimero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuprimero.Click VerRegistro(0) End Sub ' al darle click al menu ultimo con la funcion ver registro se imprime el ultimo registro creado Private Sub mnuultimo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuultimo.Click VerRegistro(totalDeRegistros - 1) End Sub 'al carle click al menu nuevo lo que contenga en el text box se borrara dejandolo vacio para agregar un nuevo registro Private Sub mnunuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnunuevo.Click tbx_carrera.Text = "" tbx_edad.Text = "" tbx_nombre.Text = "" tbx_numero.Text = "" End Sub Private Sub btn_guardar_Click_1(sender As System.Object, e As System.EventArgs) Handles btn_guardar.Click datosTemporales(totalDeRegistros).nombre = tbx_nombre.Text ' Se guarda el valor del textbox en el arreglo de datos datosTemporales(totalDeRegistros).edad = tbx_edad.Text ' Se guarda el valor del textbox en el arreglo de datos datosTemporales(totalDeRegistros).carrera = tbx_carrera.Text ' Se guarda el valor del textbox en el arreglo de datos

CD DE LERDO

28/Febrero/ 2012

INSTITUTO TECNOLOGICO SUPERIOR DE LERDO


datosTemporales(totalDeRegistros).NumerodeControl = tbx_numero.Text ' Se guarda el valor del textbox en el arreglo de datos registroActual = totalDeRegistros ' en esta condicion se especifica que si el total de registros en igual a cero entonces se habilitan los menus eliminar y modificar If totalDeRegistros = 0 Then mnueliminar.Enabled = True mnumodificar.Enabled = True ' Si no si la condicion no se ccumple es decir el total de registros es mayor a cero se habilitan los mennus con ' los que se pueden operar los registros Else mnuanterior.Enabled = True mnuprimero.Enabled = True mnusiguiente.Enabled = True mnuultimo.Enabled = True ' fin de la condicion End If totalDeRegistros += 1 'Se aumenta el total de registros lbl_registroActual.Text = "Registro: " & (registroActual + 1) tbx_carrera.Text = "" tbx_edad.Text = "" tbx_nombre.Text = "" tbx_numero.Text = "" VerRegistro(totalDeRegistros - 1) End Sub

CD DE LERDO

28/Febrero/ 2012

You might also like