207 lines
7.7 KiB
VB.net
207 lines
7.7 KiB
VB.net
|
Public Class frmProcedenciaRecurso
|
|||
|
|
|||
|
Private opcion As Boolean
|
|||
|
Private idName As Integer
|
|||
|
|
|||
|
Private Sub frmProcedenciaRecurso_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|||
|
Try
|
|||
|
Iniciar()
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function Iniciar() As Boolean
|
|||
|
Iniciar = False
|
|||
|
Dim sql As String
|
|||
|
Dim Classcom As New clsComplejo
|
|||
|
Try
|
|||
|
txtRiesgo.Enabled = False
|
|||
|
Limpiar()
|
|||
|
llenarGrid()
|
|||
|
DesHeader.Text = Me.Text
|
|||
|
sql = "sp_ConsultaCatalogoRiesgo"
|
|||
|
Classcom.sbLlenaCombo(sql, Me.CMBRiesgo)
|
|||
|
CMBRiesgo.SelectedIndex = -1
|
|||
|
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 = ""
|
|||
|
chkActivo.Enabled = False
|
|||
|
chkActivo.Checked = False
|
|||
|
BtnOk.Enabled = False
|
|||
|
BtnEditar.Enabled = False
|
|||
|
CMBRiesgo.Enabled = False
|
|||
|
txtRiesgo.Text = ""
|
|||
|
txtRiesgo.Enabled = False
|
|||
|
CMBRiesgo.SelectedValue = -1
|
|||
|
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 cd.IDPROCEDENCIARECURSO,cd.PROCEDENCIARECURSO,cd.ACTIVO,cd.RIESGO 'CALIFICACION RIESGO',CALRIESGO 'R',cr.RIESGO FROM CAT_PROCEDENCIARECURSO cd INNER JOIN CAT_RIESGO cr on cd.CALRIESGO = cr.IdRiesgo", Me.GridMaster)
|
|||
|
GridMaster.Splits(0).DisplayColumns(0).AutoSize()
|
|||
|
GridMaster.Splits(0).DisplayColumns(1).AutoSize()
|
|||
|
GridMaster.Splits(0).DisplayColumns(2).AutoSize()
|
|||
|
GridMaster.Splits(0).DisplayColumns(4).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()
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
opcion = True
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function habilitar() As Boolean
|
|||
|
habilitar = False
|
|||
|
Try
|
|||
|
txtNombre.Enabled = True
|
|||
|
chkActivo.Enabled = True
|
|||
|
CMBRiesgo.Enabled = True
|
|||
|
BtnOk.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, BtnOk, Button1)
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Function llenarDatos() As Boolean
|
|||
|
llenarDatos = False
|
|||
|
Try
|
|||
|
|
|||
|
idName = GridMaster.Columns(0).Value
|
|||
|
txtNombre.Text = GridMaster.Columns(1).Value
|
|||
|
chkActivo.Checked = GridMaster.Columns(2).Value
|
|||
|
CMBRiesgo.SelectedValue = Convert.ToInt32(GridMaster.Columns(4).Value)
|
|||
|
txtRiesgo.Text = Convert.ToInt32(GridMaster.Columns(3).Value)
|
|||
|
' CMBRiesgo.Enabled = True
|
|||
|
BtnEditar.Enabled = True
|
|||
|
txtRiesgo.Enabled = False
|
|||
|
txtNombre.Enabled = False
|
|||
|
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, BtnOk, Button1)
|
|||
|
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 chk As Integer
|
|||
|
Dim riesgoValor As Integer
|
|||
|
Dim nRiesgo As Integer
|
|||
|
Try
|
|||
|
If ValidarDatos() Then
|
|||
|
nombre = txtNombre.Text.Trim()
|
|||
|
chk = chkActivo.CheckState
|
|||
|
If CMBRiesgo.SelectedValue = 1 Then
|
|||
|
nRiesgo = 4
|
|||
|
ElseIf CMBRiesgo.SelectedValue = 2 Then
|
|||
|
nRiesgo = 5
|
|||
|
ElseIf CMBRiesgo.SelectedValue = 3 Then
|
|||
|
nRiesgo = 6
|
|||
|
End If
|
|||
|
riesgoValor = ObtieneRiesgoValor(nRiesgo)
|
|||
|
'CMBRiesgo.SelectedValue = 0
|
|||
|
If CMBRiesgo.SelectedValue = Nothing Then
|
|||
|
MessageBox.Show("Es necesario seleccionar un riesgo ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
If txtRiesgo.Text = "" Then
|
|||
|
MessageBox.Show("Es necesario colocar la calificación de riesgo", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Function
|
|||
|
End If
|
|||
|
|
|||
|
|
|||
|
If opcion Then
|
|||
|
ssql = "INSERT INTO CAT_PROCEDENCIARECURSO(PROCEDENCIARECURSO,ACTIVO,CALRIESGO,RIESGO) "
|
|||
|
ssql += " VALUES ('" & nombre & "', " & chk & "," & CMBRiesgo.SelectedValue & "," & txtRiesgo.Text & ")"
|
|||
|
Else
|
|||
|
ssql = "UPDATE CAT_PROCEDENCIARECURSO SET PROCEDENCIARECURSO ='" & nombre & "', CALRIESGO= " & CMBRiesgo.SelectedValue & " ,RIESGO=" & Convert.ToInt32(txtRiesgo.Text) & " ,"
|
|||
|
ssql += "ACTIVO = " & chk & " WHERE IDPROCEDENCIARECURSO =" & idName
|
|||
|
End If
|
|||
|
cls.sbGuardaModifica(ssql)
|
|||
|
MessageBox.Show("Operacion Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
Limpiar()
|
|||
|
llenarGrid()
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
End If
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message)
|
|||
|
End Try
|
|||
|
Guardar = True
|
|||
|
End Function
|
|||
|
Private Function ObtieneRiesgoValor(ByVal idParametro As Integer) As Integer
|
|||
|
Dim Classcom As New clsComplejo
|
|||
|
Dim ssql As String
|
|||
|
Dim Fila As DataRow
|
|||
|
ObtieneRiesgoValor = 0
|
|||
|
ssql = "sp_ConsultaParametroRiesgo " & idParametro & " "
|
|||
|
Classcom = New clsComplejo
|
|||
|
Classcom.fdtDataSet(ssql)
|
|||
|
If Classcom.ds.Tables(0).Rows.Count <> 0 Then
|
|||
|
Fila = Classcom.ds.Tables(0).Rows(0)
|
|||
|
ObtieneRiesgoValor = Fila("valor").ToString
|
|||
|
End If
|
|||
|
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
|
|||
|
|
|||
|
Private Sub txtRiesgo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtRiesgo.KeyPress
|
|||
|
e.Handled = Not IsNumeric(e.KeyChar) And Not Char.IsControl(e.KeyChar)
|
|||
|
End Sub
|
|||
|
End Class
|