This document contains code for searching for existing data and saving new data in a database table. The search code loops through the rows of a data table, comparing search values to column values to check for matches. If a match is found, it enables editing of the found record. If no match is found, it adds a new row for data entry. The save code validates the data, saves any changes to the database via a TableAdapter, and disables the fields after saving.
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Código para Grabar datos
1. COLEGIO DE EDUCACION PROFESIONAL
TECNICA DEL ESTADO DE TLAXCALA
Alumna:
ESPINOSA SANCHEZ MIRIAM
Docente:
ING. AGUSTÌN HERNÀNDEZ DELGADO
PROYECTO:
CONTROL DE PARAESCOLAR
MODULO:
ELABORACIÒN Y MANTENIMIENTO DE SISTEMAS DE INFORMACIÒN
ESPECIALIDAD:
INFORMÀTICA
GRADO: 6º SEMESTREGRUPO: 603
03-Mayo-2014
2. Código para búsqueda de datos existentes.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim mitabla As DataTable = ParaescolarDataSet.altas
Dim cfilas As DataRowCollection = mitabla.Rows
Dim nuevafila As DataRow
Dim i As Integer
Dim bandera As Boolean
bandera = True
Dim tamano As Integer
AltasBindingSource.MoveFirst()
tamano = AltasBindingSource.Count()
Dim res As Boolean
Dim a As String
Dim b As String
a = UCase(Trim(MatriculaTextBox.Text))
b = UCase(Trim(TextBox1.Text))
If (tamaño = 0) Then
MsgBox("Tabla Vacia")
Else
AltasBindingSource.MoveFirst()
a = UCase(Trim(MatriculaTextBox.Text))
Do
res = a Like b
If (res = True) Then
bandera = False
Else
AltasBindingSource.MoveNext()
a = UCase(Trim(MatriculaTextBox.Text))
i = i + 1
End If
Loop While (bandera = True And i <= tamaño)
End If
If (bandera = False) Then
IdTextBox.Visible = True
MatriculaTextBox.Visible = True
Nombre_compTextBox1.Visible = True
GrupoTextBox.Visible = True
EspecialidadTextBox.Visible = True
Nom_paraescolarTextBox.Visible = True
4. End If
End Sub
Código para el botón grabar
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If (ParaescolarDataSet.HasChanges) Then
Me.Validate()
Me.AltasBindingSource.EndEdit()
Me.AltasTableAdapter.Update(Me.ParaescolarDataSet.altas)
MsgBox("Grabando")
IdTextBox.Enabled = False
MatriculaTextBox.Enabled = False
Nombre_compTextBox1.Enabled = False
GrupoTextBox.Enabled = False
EspecialidadTextBox.Enabled = False
Nom_paraescolarTextBox.Enabled = False
Nom_profTextBox.Enabled = False
Fech_inicioDateTimePicker.Enabled = False
End If
End Sub