client/LR/frmListaRSPID.vb

146 lines
4.6 KiB
VB.net
Raw Permalink Normal View History

Public Class frmListaRSPID
Private idName As Integer
Private Sub frmListaRSPID_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
Iniciar()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function Iniciar() As Boolean
Iniciar = False
Try
Limpiar()
llenarGrid()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Iniciar = True
End Function
Private Function Limpiar() As Boolean
Try
txtNombre.Enabled = False
txtNombre.Text = ""
txtMotivo.Enabled = False
txtMotivo.Text = ""
chkActivo.Enabled = False
chkActivo.Checked = False
BtnOk.Enabled = 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("spCRU_ListaRestringidaSPID 2", Me.GridMaster)
GridMaster.Splits(0).DisplayColumns(0).AutoSize()
GridMaster.Splits(0).DisplayColumns(1).Visible = False
GridMaster.Splits(0).DisplayColumns(2).AutoSize()
GridMaster.Splits(0).DisplayColumns(3).AutoSize()
GridMaster.Splits(0).DisplayColumns(4).AutoSize()
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 Button1.Click
Me.Close()
End Sub
Private Function habilitar() As Boolean
habilitar = False
Try
txtNombre.Enabled = True
chkActivo.Enabled = True
BtnOk.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()
End Sub
Private Function llenarDatos() As Boolean
llenarDatos = False
Try
habilitar()
idName = GridMaster.Columns("ID").Value
txtNombre.Text = GridMaster.Columns("NOMBRE").Value
txtMotivo.Text = IIf(IsDBNull(GridMaster.Columns("RAZON").Value), "", GridMaster.Columns("RAZON").Value)
chkActivo.Checked = GridMaster.Columns("BLOQUEADO").Value
Activo()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
llenarDatos = True
End Function
Private Sub BtnOk_Click(sender As System.Object, e As System.EventArgs) Handles BtnOk.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
Try
If ValidarDatos() Then
nombre = txtMotivo.Text.Trim()
chk = chkActivo.CheckState
ssql = "spCRU_ListaRestringidaSPID 3," & idName & "," & chk & ",'" & nombre & "'"
cls.sbGuardaModifica(ssql)
MessageBox.Show("Operacion Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Limpiar()
llenarGrid()
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 txtMotivo.Text.Trim = "" Then
MessageBox.Show("El Motivo Debe Contener Mínimo 200 Caracteres", "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 Button2_Click(sender As System.Object, e As System.EventArgs) Handles btnLimpiar.Click
Limpiar()
End Sub
Private Sub chkActivo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkActivo.CheckedChanged
Activo()
End Sub
Private Sub Activo()
If Not chkActivo.Checked Then
txtMotivo.Enabled = True
Else
txtMotivo.Enabled = False
End If
End Sub
End Class