You are on page 1of 5

CLASE

Public Class Producto


Public nombre As String
Public precio As Double
Public codigo As String
Public marca As String
Public cantidad As Integer
Public pesoneto As Double
Public activo As Boolean

End Class

CLIENTES

Public Class clientes


Dim arreglo(10) As Object
Dim c, bandera As Integer

End Class

GUARDAR

Private Sub btnguardar_Click(sender As Object, e As EventArgs) Handles btnguardar.Click


Dim p As New cliente22
p.nombre = tbnombre.Text
p.apellido = tbapellido.Text
p.nit = tbnit.Text
p.cui = tbcui.Text
p.direccion = tbdireccion.Text
p.fecha = dtpfecha.Value
p.sexo = rbfemenino.Checked
p.sexo = rbmascullino.Checked

limpiar()
If bandera = -1 Then
arreglo(c) = p
c += 1
Else
arreglo(bandera) = p
bandera = -1
End If
cargardatagrid()

End Sub

ELIMINAR

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click


arreglo(bandera) = Nothing
cargardatagrid()
End Sub

LIMPIAR()
Sub limpiar()
tbnombre.Clear()
tbapellido.Clear()
tbnit.Clear()
tbcui.Clear()
tbdireccion.Clear()
dtpfecha.Checked = False
rbfemenino.Checked = False
rbmascullino.Checked = False
End Sub
CARGAR DATA GRID
Sub cargardatagrid()
DataGridView1.ColumnCount = 7
DataGridView1.Rows.Clear()
With DataGridView1
.Columns(0).Name = "Nombre"
.Columns(1).Name = "Apellido"
.Columns(2).Name = "NIT"
.Columns(3).Name = "CUI"
.Columns(4).Name = "Dirección"
.Columns(5).Name = "Fecha de Nacimiento"
.Columns(6).Name = "Sexo"
End With
For fila As Integer = 0 To arreglo.Length - 1
If arreglo(fila) IsNot Nothing Then
Dim p1 As Object
p1 = arreglo(fila)
DataGridView1.Rows.Add(p1.nombre, p1.apellido, p1.nit, p1.cui, p1.direccion,
p1.fecha.ToString(), p1.sexo)
End If
Next
DataGridView1.Refresh()
End Sub

DATA GRID
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles
DataGridView1.CellClick
Dim fila As Integer
fila = DataGridView1.CurrentRow.Index
Dim p As Object
p = arreglo(fila)
tbnombre.Text = p.nombre
tbapellido.Text = p.apellido
tbnit = p.nit
tbcui.Text = p.cui
tbdireccion.Text = p.direccion
dtpfecha.Text = p.fecha
rbfemenino.Text = p.femenino
rbmascullino.Text = p.mascullino
bandera = fila
End Sub

FORM
Private Sub clientes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
bandera = -1
End Sub

ESTAMPITAS
AGREGAR FOTO
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim es As New Estampita
es.nombre = TextBox1.Text
es.pais = ComboBox1.SelectedItem
es.debut = Convert.ToInt32(DateTimePicker1.Value.Year)
es.nacimiento = DateTimePicker2.Value.Date
es.altura = TextBox4.Text
es.peso = TextBox3.Text
es.posicion = TextBox5.Text
es.foto = linkfoto
arreglo(cont) = es
cont += 1
pos = 0
girar()
limpiar()

End Sub

BUSCAR FOTO

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


OpenFileDialog1.ShowDialog()
linkfoto = OpenFileDialog1.FileName
PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
End Sub
BUSCAR

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


For i = 0 To cont - 1 Step 1
Dim et As New Estampita
et = arreglo(i)

If et.nombre = TextBox6.Text Or et.pais = TextBox6.Text Then


MessageBox.Show("Nombre: " & et.nombre & vbCrLf & " Selección: " & et.pais & vbCrLf & "
Año de Debut: " & et.debut & " " & et.calculartiempo() & " años." & vbCrLf & " Mide: " & et.altura &
"m. y Pesa: " & et.peso & "Kg. Su IMC es de: " & et.calcularIMC() & vbCrLf & " Nacimiento: " &
et.nacimiento & vbCrLf & "Juega de: " & et.posicion, "Jugador/es Encontrados")
End If

Next

End Sub

BOTÓN SIGUIENTE

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


If pos + 1 > cont - 1 Then
Button4.Enabled = True
Button5.Enabled = False
Else
Button5.Enabled = True
Button4.Enabled = True
pos += 1
girar()
End If

End Sub

BOTÓN ANTERIOR

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


If pos - 1 < 0 Then
Button4.Enabled = False
Button5.Enabled = True
Else
Button4.Enabled = True
Button5.Enabled = True
pos -= 1
girar()
End If

End Sub

LIMPIAR

Sub limpiar()
ComboBox1.SelectedIndex = -1
TextBox1.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
DateTimePicker1.Value = Today
DateTimePicker2.Value = Today
PictureBox1.Dispose()
End Sub
https://chat.openai.com/chat

You might also like