150 lines
4.7 KiB
VB.net
150 lines
4.7 KiB
VB.net
Public Class frmParamsGral
|
|
|
|
Private opcion As Boolean
|
|
Private idName As Integer
|
|
|
|
Private Sub frmParamsGral_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 = ""
|
|
txtValor.Enabled = False
|
|
txtValor.Text = ""
|
|
BtnOk.Enabled = False
|
|
BtnEditar.Enabled = False
|
|
chkActivo.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("select * from PARAMETROSGENERALES", Me.GridMaster)
|
|
GridMaster.Splits(0).DisplayColumns(0).AutoSize()
|
|
GridMaster.Splits(0).DisplayColumns(1).AutoSize()
|
|
GridMaster.Splits(0).DisplayColumns(2).AutoSize()
|
|
GridMaster.Splits(0).DisplayColumns(3).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 Button1.Click
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub BtnAgregar_Click(sender As System.Object, e As System.EventArgs) Handles BtnAgregar.Click
|
|
Limpiar()
|
|
habilitar()
|
|
opcion = True
|
|
End Sub
|
|
|
|
Private Function habilitar() As Boolean
|
|
habilitar = False
|
|
Try
|
|
txtNombre.Enabled = True
|
|
txtValor.Enabled = True
|
|
BtnOk.Enabled = True
|
|
chkActivo.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
|
|
idName = GridMaster.Columns(0).Value
|
|
txtNombre.Text = GridMaster.Columns(1).Value
|
|
txtValor.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()
|
|
End Sub
|
|
|
|
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 valor As String
|
|
Try
|
|
If ValidarDatos() Then
|
|
nombre = txtNombre.Text.Trim()
|
|
valor = txtValor.Text.Trim()
|
|
If opcion Then
|
|
ssql = "INSERT INTO PARAMETROSGENERALES(DESCRIPCION,VALOR,ACTIVO) "
|
|
ssql += " VALUES ('" & nombre & "'," & valor & "," & chkActivo.CheckState & ")"
|
|
Else
|
|
ssql = "UPDATE PARAMETROSGENERALES Set DESCRIPCION ='" & nombre & "',"
|
|
ssql += "VALOR = " & valor & ", ACTIVO = " & chkActivo.CheckState & " WHERE IDPARAMETRO =" & idName
|
|
End If
|
|
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 txtNombre.Text.Trim = "" Then
|
|
MessageBox.Show("Es Necesario Introducir el Nombre ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End If
|
|
|
|
ValidarDatos = True
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
End Class |