client/frmObjCuenta.vb

203 lines
6.2 KiB
VB.net
Raw Normal View History

Public Class frmObjCuenta
Private opcion As Boolean
Private id As Integer
Private Sub frmObjCuenta_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
txtObjCta.Enabled = False
txtObjCta.Text = ""
chkActivo.Enabled = False
chkActivo.Checked = False
btnGuardar.Enabled = False
btnEditar.Enabled = False
txtRiesgo.Text = ""
txtRiesgo.Enabled = False
2020-01-20 18:14:59 -06:00
id = 0
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("SPMOSTRAROBJCTA NULL", Me.GridMaster)
GridMaster.Splits(0).DisplayColumns(0).AutoSize()
GridMaster.Splits(0).DisplayColumns(1).AutoSize()
GridMaster.Splits(0).DisplayColumns(2).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 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
2020-01-20 18:14:59 -06:00
txtObjCta.Focus()
End Sub
Private Function habilitar() As Boolean
habilitar = False
Try
txtObjCta.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
txtObjCta.Text = GridMaster.Columns(1).Value
txtRiesgo.Text = GridMaster.Columns(2).Value
chkActivo.Checked = GridMaster.Columns(3).Value
2020-01-20 18:14:59 -06:00
btnEditar.Enabled = True
2020-01-20 18:14:59 -06:00
txtObjCta.Enabled = False
txtRiesgo.Enabled = False
chkActivo.Enabled = False
btnGuardar.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
2020-01-20 18:14:59 -06:00
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
llenarDatos = True
End Function
Private Sub BtnEditar_Click(sender As System.Object, e As System.EventArgs) Handles btnEditar.Click
opcion = False
habilitar()
2020-01-20 18:14:59 -06:00
btnAgregar.Enabled = True
btnEditar.Enabled = False
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
2020-01-20 18:14:59 -06:00
txtObjCta.Focus()
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
2020-01-20 18:14:59 -06:00
Dim riesgo As Single
Try
If ValidarDatos() Then
nombre = txtObjCta.Text.Trim()
chk = chkActivo.CheckState
riesgo = txtRiesgo.Text.Trim()
2020-01-20 18:14:59 -06:00
If opcion Then
ssql = "SPACTUALIZAROBJCTA " & id & ",'" & nombre & "'," & riesgo & "," & chk
Else
ssql = "SPACTUALIZAROBJCTA " & id & ",'" & nombre & "'," & riesgo & "," & chk
End If
2020-01-20 18:14:59 -06:00
cls.sbGuardaModifica(ssql)
MessageBox.Show("Operación Realizada Correctamente ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Limpiar()
llenarGrid()
2020-01-20 18:14:59 -06:00
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 txtObjCta.Text.Trim = "" Then
MessageBox.Show("Es necesario introducir el Objeto de la Cuenta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
2020-01-20 18:14:59 -06:00
txtObjCta.Focus()
Exit Function
End If
If txtRiesgo.Text.Trim = "" Then
2020-01-20 18:14:59 -06:00
MessageBox.Show("Es Necesario introducir el Riesgo ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtRiesgo.Focus()
Exit Function
End If
If Not IsNumeric(txtRiesgo.Text) Then
2020-01-20 18:14:59 -06:00
MessageBox.Show("El Riesgo debe ser númerico ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtRiesgo.Focus()
Exit Function
End If
If txtRiesgo.TextLength > 4 Then
MessageBox.Show("Riesgo no valido ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
2020-01-20 18:14:59 -06:00
txtRiesgo.Focus()
Exit Function
End If
ValidarDatos = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
End Class