0% found this document useful (0 votes)
53 views2 pages

FRM Mant Maquina

This document contains code for a form in Visual Basic that allows users to manage machine data stored in a database table. The form contains controls to search for, add, update, and delete machine records. When the form loads, it retrieves all machine data and locks/unlocks buttons based on the current edit state. Users can search by description, add a new record, update an existing one, delete a selected record, and close the form.

Uploaded by

Walter Santos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views2 pages

FRM Mant Maquina

This document contains code for a form in Visual Basic that allows users to manage machine data stored in a database table. The form contains controls to search for, add, update, and delete machine records. When the form loads, it retrieves all machine data and locks/unlocks buttons based on the current edit state. Users can search by description, add a new record, update an existing one, delete a selected record, and close the form.

Uploaded by

Walter Santos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

FrmMantMaquina

Imports System.Data.SqlClient
Public Class FrmMantMaquina

Sub BloquearControles(ByVal Estado As Boolean)


Button1.Enabled = Estado
Button2.Enabled = Not Estado
Button3.Enabled = Not Estado
Button4.Enabled = Estado
Button5.Enabled = Estado
Button6.Enabled = Estado
End Sub
Private Sub FrmMantMaquina_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
buscarmaquina()
ubicacion = 0
posicionar(ubicacion)
BloquearControles(False)
End Sub

Sub buscarmaquina()
DataGridView1.DataSource = Ejecutar_Consulta("select * from maquina
where descripcion like '" & TextBox4.Text & "%'")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Dim resultado As Integer = Ejecutar_Insertar("maquina", Valores)
If resultado = 0 Then
MsgBox("Error Registrado", MsgBoxStyle.Critical, "error")
Else
MsgBox("Maquina Registrado correctamente",
MsgBoxStyle.Information, "aviso")
buscarmaquina()
End If
BloquearControles(True)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Dim resultado As Integer = Ejecutar_Actualizar("maquina", Valores)
If resultado = 0 Then
MsgBox("Error Registrado", MsgBoxStyle.Critical, "error")
Else
MsgBox("Maquina Registrado correctamente",
MsgBoxStyle.Information, "aviso")
buscarmaquina()
End If
End Sub
Function Valores() As Parametros()
Dim param(2) As Parametros
param(0) = New Parametros With {.Campo = "cod_maqui", .Parametro =
"@codmaqui", .Valor = TextBox1.Text}
param(1) = New Parametros With {.Campo = "Descripcion", .Parametro =
"@descripcion", .Valor = TextBox2.Text}
param(2) = New Parametros With {.Campo = "Tipo", .Parametro = "@tipo",
.Valor = TextBox3.Text}
Return param
End Function
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If MsgBox("Deseas Eliminar este Registro", MsgBoxStyle.Question +
MsgBoxStyle.YesNo, "Aviso") = MsgBoxResult.Yes Then
Dim resultado As Integer = Ejecutar_Eliminar("maquina", Valores)
If resultado = 0 Then
MsgBox("Error Eliminado", MsgBoxStyle.Critical, "error")
Else
MsgBox("Distrito Eliminado correctamente",
MsgBoxStyle.Information, "aviso")
buscarmaquina()
End If
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Me.Close()
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button10.Click
DataGridView1.DataSource = Ejecutar_Consulta("select * from Maquina
where descripcion like '" & TextBox4.Text & "%'")
End Sub

You might also like