client/frmParametrosMR.vb

159 lines
5.0 KiB
VB.net
Raw Normal View History

Public Class frmParametrosMR
Private opcion As Boolean
Private idPondera As Integer
Private idTipoPersona As Integer
Private Function llenarGrid() As Boolean
llenarGrid = False
Try
Dim ClassCatalogos As New ClassCatalogos
gridDatos.AllowUpdate = False
ClassCatalogos.LlenaGrid("SPMOSTRARPARAMMR NULL", gridDatos)
gridDatos.Splits(0).DisplayColumns(0).AutoSize()
gridDatos.Splits(0).DisplayColumns(1).AutoSize()
gridDatos.Splits(0).DisplayColumns(2).AutoSize()
gridDatos.Splits(0).DisplayColumns(3).AutoSize()
gridDatos.Splits(0).DisplayColumns(4).AutoSize()
gridDatos.Splits(0).DisplayColumns(5).AutoSize()
gridDatos.Splits(0).DisplayColumns(0).Visible = False
gridDatos.Splits(0).DisplayColumns(1).Visible = False
gridDatos.Splits(0).DisplayColumns(5).Style.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Far
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
llenarGrid = True
End Function
Private Sub frmParametrosMR_Load(sender As Object, e As EventArgs) Handles MyBase.Load
llenarGrid()
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
End Sub
Private Sub btnEditar_Click(sender As Object, e As EventArgs) Handles btnEditar.Click
opcion = False
habilitar()
txtPorcentaje.Focus()
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
End Sub
Private Function habilitar() As Boolean
habilitar = False
Try
txtPorcentaje.Enabled = true
btnGuardar.Enabled = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
habilitar = True
End Function
Private Sub gridDatos_DoubleClick(sender As Object, e As EventArgs) Handles gridDatos.DoubleClick
llenarDatos()
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
End Sub
Private Function llenarDatos() As Boolean
llenarDatos = False
Try
idPondera = gridDatos.Columns(0).Value
idTipoPersona = gridDatos.Columns(1).Value
txtTipoPersona.Text = gridDatos.Columns(2).Value
txtCriterio.Text = gridDatos.Columns(3).Value
txtSubCriterio.Text = gridDatos.Columns(4).Value
txtPorcentaje.Text = gridDatos.Columns(5).Value
btnEditar.Enabled = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
llenarDatos = True
End Function
Private Function Limpiar() As Boolean
Try
txtTipoPersona.Text = ""
txtCriterio.Text = ""
txtSubCriterio.Text = ""
txtPorcentaje.Text = ""
btnGuardar.Enabled = False
btnEditar.Enabled = False
txtPorcentaje.Enabled = False
idPondera = 0
idTipoPersona = 0
opcion = False
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
Private Sub btnCerrar_Click(sender As Object, e As EventArgs) Handles btnCerrar.Click
Me.Close()
End Sub
Private Sub txtPorcentaje_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPorcentaje.KeyPress
If Char.IsDigit(e.KeyChar) Or Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 46 Or Asc(e.KeyChar) = 8 Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtPorcentaje_KeyUp(sender As Object, e As KeyEventArgs) Handles txtPorcentaje.KeyUp
End Sub
Private Sub txtPorcentaje_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPorcentaje.KeyDown
If e.KeyCode = Keys.Back Or e.KeyCode = Keys.Right Or e.KeyCode = Keys.Left Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
Dim cls As New clsComplejo
Dim ssql As String
If ValidarDatos() Then
Try
ssql = "SPCATUALIZAPONDERAMR " & idPondera & "," & idTipoPersona & "," & txtPorcentaje.Text
cls.sbGuardaModifica(ssql)
llenarGrid()
MsgBox("Datos guardados correctamente.")
Catch ex As Exception
End Try
Limpiar()
ClassCatalogos.CambiaColorbloque2(btnAgregar, btnEditar, btnGuardar, btnCerrar)
End If
End Sub
Private Function ValidarDatos() As Boolean
ValidarDatos = False
Try
If Not IsNumeric(txtPorcentaje.Text) Then
MessageBox.Show("Se requiere valor numerico.", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Function
End If
ValidarDatos = True
Catch ex As Exception
End Try
End Function
End Class