191 lines
6.3 KiB
VB.net
191 lines
6.3 KiB
VB.net
|
Public Class frmNacionalidad
|
|||
|
|
|||
|
Private opcion As Boolean
|
|||
|
Private id As Integer
|
|||
|
|
|||
|
Private Sub frmNacionalidad_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|||
|
Try
|
|||
|
Iniciar()
|
|||
|
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function Iniciar() As Boolean
|
|||
|
Iniciar = False
|
|||
|
Try
|
|||
|
Limpiar()
|
|||
|
llenarGrid()
|
|||
|
DesHeader.Text = Me.Text
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
Iniciar = True
|
|||
|
End Function
|
|||
|
|
|||
|
Private Function Limpiar() As Boolean
|
|||
|
Try
|
|||
|
txtNacionalidad.Enabled = False
|
|||
|
txtNacionalidad.Text = ""
|
|||
|
chkActivo.Enabled = False
|
|||
|
chkActivo.Checked = False
|
|||
|
btnGuardar.Enabled = False
|
|||
|
btnEditar.Enabled = False
|
|||
|
|
|||
|
txtRiesgo.Text = ""
|
|||
|
txtRiesgo.Enabled = False
|
|||
|
|
|||
|
opcion = False
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
End Function
|
|||
|
|
|||
|
Private Function llenarGrid() As Boolean
|
|||
|
llenarGrid = False
|
|||
|
Try
|
|||
|
Dim ClassCatalogos As New ClassCatalogos
|
|||
|
|
|||
|
GridMaster.AllowUpdate = False
|
|||
|
ClassCatalogos.LlenaGrid("sp_NacionalidadConsultaPorId 0", Me.GridMaster)
|
|||
|
|
|||
|
GridMaster.Splits(0).DisplayColumns(0).AutoSize()
|
|||
|
GridMaster.Splits(0).DisplayColumns(1).AutoSize()
|
|||
|
GridMaster.Splits(0).DisplayColumns(2).AutoSize()
|
|||
|
|
|||
|
GridMaster.Splits(0).DisplayColumns(0).Visible = False
|
|||
|
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
llenarGrid = True
|
|||
|
End Function
|
|||
|
|
|||
|
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnCerrar.Click
|
|||
|
Me.Close()
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BtnAgregar_Click(sender As System.Object, e As System.EventArgs) Handles btnAgregar.Click
|
|||
|
Limpiar()
|
|||
|
habilitar()
|
|||
|
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
|
|||
|
opcion = True
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function habilitar() As Boolean
|
|||
|
habilitar = False
|
|||
|
Try
|
|||
|
txtNacionalidad.Enabled = True
|
|||
|
chkActivo.Enabled = True
|
|||
|
btnGuardar.Enabled = True
|
|||
|
txtRiesgo.Enabled = True
|
|||
|
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
habilitar = True
|
|||
|
End Function
|
|||
|
|
|||
|
Private Sub GridMaster_DoubleClick(sender As System.Object, e As System.EventArgs) Handles GridMaster.DoubleClick
|
|||
|
llenarDatos()
|
|||
|
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function llenarDatos() As Boolean
|
|||
|
llenarDatos = False
|
|||
|
Try
|
|||
|
id = GridMaster.Columns(0).Value
|
|||
|
txtNacionalidad.Text = GridMaster.Columns(1).Value
|
|||
|
txtRiesgo.Text = GridMaster.Columns(2).Value
|
|||
|
'chkActivo.Checked = GridMaster.Columns(3).Value
|
|||
|
|
|||
|
btnEditar.Enabled = True
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
llenarDatos = True
|
|||
|
End Function
|
|||
|
|
|||
|
Private Sub BtnEditar_Click(sender As System.Object, e As System.EventArgs) Handles btnEditar.Click
|
|||
|
opcion = False
|
|||
|
habilitar()
|
|||
|
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BtnOk_Click(sender As System.Object, e As System.EventArgs) Handles btnGuardar.Click
|
|||
|
Guardar()
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function Guardar() As Boolean
|
|||
|
Guardar = False
|
|||
|
Dim cls As New clsComplejo
|
|||
|
Dim ssql As String
|
|||
|
Dim nombre As String
|
|||
|
Dim chk As Integer
|
|||
|
Dim riesgo As Integer
|
|||
|
Try
|
|||
|
If ValidarDatos() Then
|
|||
|
nombre = txtNacionalidad.Text.Trim()
|
|||
|
chk = chkActivo.CheckState
|
|||
|
riesgo = txtRiesgo.Text.Trim()
|
|||
|
If opcion Then
|
|||
|
ssql = "SPINSERTUPDATENACIONDALIDAD 0,'" & nombre & "'," & riesgo
|
|||
|
Else
|
|||
|
'ssql = "SPACTUALIZAROBJCTA " & id & ",'" & nombre & "'," & riesgo & "," & chk
|
|||
|
ssql = "SPINSERTUPDATENACIONDALIDAD " & id & ",'" & nombre & "'," & riesgo
|
|||
|
|
|||
|
End If
|
|||
|
cls.sbGuardaModifica(ssql)
|
|||
|
MessageBox.Show("Operación Realizada Correctamente ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
Limpiar()
|
|||
|
llenarGrid()
|
|||
|
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
|
|||
|
End If
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
Guardar = True
|
|||
|
End Function
|
|||
|
|
|||
|
Private Function ValidarDatos() As Boolean
|
|||
|
ValidarDatos = False
|
|||
|
Try
|
|||
|
If txtNacionalidad.Text.Trim = "" Then
|
|||
|
MessageBox.Show("Es necesario introducir la Nacionalidad ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
|
|||
|
If txtRiesgo.Text.Trim = "" Then
|
|||
|
MessageBox.Show("Es ecesario introducir el Riesgo ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
|
|||
|
If Not IsNumeric(txtRiesgo.Text) Then
|
|||
|
MessageBox.Show("El riesgo debe ser númerico ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
|
|||
|
If txtRiesgo.TextLength > 4 Then
|
|||
|
MessageBox.Show("Riesgo no valido ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
|
|||
|
ValidarDatos = True
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
End Function
|
|||
|
|
|||
|
Private Sub txtRiesgo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRiesgo.KeyPress
|
|||
|
If Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 46 Or Asc(e.KeyChar) = 8 Or Char.IsDigit(e.KeyChar) Then
|
|||
|
e.Handled = False
|
|||
|
Else
|
|||
|
e.Handled = True
|
|||
|
End If
|
|||
|
|
|||
|
If InStr(txtRiesgo.Text, ".") <> 0 And Asc(e.KeyChar) = 46 Then
|
|||
|
e.Handled = True
|
|||
|
End If
|
|||
|
End Sub
|
|||
|
End Class
|