client/Actualizadores/FrmCanales.vb

354 lines
14 KiB
VB.net
Raw Normal View History

Public Class FrmCanales
Private Sub FrmCanales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Classcom As New clsComplejo
Dim ClassCatalogos As New ClassCatalogos
Dim SQL As String
Dim FILA As DataRow
Panel.Visible = False
Me.Text = "Canales"
Me.Panel.Visible = True
'LLENA GRID Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
'SQL = "SELECT IdCanal CLAVE,Canal NOMBRE,ACTIVO,Aliasid ALIAS FROM CAT_Canal ORDER BY Canal"
SQL = "sp_ConsultarCanal 0"
ClassCatalogos.LlenaGrid(SQL, Me.GridMaster)
txtNombre.Enabled = False
chkActivo.Enabled = False
txtClave.Focus()
ClassCatalogos.CambiaColorbloque2(BtnConsulta, BtnEditar, BtnOk, Button1)
End Sub
Private Sub tlbCorteCaja_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)
Dim classcom As New clsComplejo
Dim strSQLComodin As String
Select Case e.Button.Text
Case "Agregar"
txtClave.Enabled = True
txtClave.ReadOnly = False
txtClave.Text = ""
txtNombre.Text = ""
clsVaribles.varProceso = "Agregar"
txtClave.Focus()
txtClave.Visible = True
txtNombre.Enabled = True
Me.chkActivo.Enabled = True
Case "Actualizar"
clsVaribles.varProceso = "Actualizar"
txtClave.Enabled = False
txtNombre.Enabled = True
Me.chkActivo.Enabled = True
Case "Desactivar"
clsVaribles.varProceso = "Eliminar"
txtClave.Enabled = False
txtNombre.Enabled = False
Case "Salir"
Me.Close()
End Select
End Sub
Private Sub GridMaster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridMaster.Click
End Sub
Private Sub GridMaster_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridMaster.DoubleClick
'Recupero Datos del gird
Me.txtClave.Text = Me.GridMaster.Columns("CLAVE").Value
Me.txtNombre.Text = Me.GridMaster.Columns("Nombre").Value
Me.chkActivo.Checked = Me.GridMaster.Columns("ACTIVO").Value
' Me.TXTAlias.Text = Me.GridMaster.Columns("alias").Value
txtClave.Visible = True
txtClave.Enabled = False
txtNombre.Enabled = False
TXTAlias.Enabled = False
Me.chkActivo.Enabled = False
Dim SQL As String = ""
txtClave.Enabled = False
BtnEditar.Enabled = True
ClassCatalogos.CambiaColorbloque2(BtnConsulta, BtnEditar, BtnOk, Button1)
End Sub
Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim classcom As New clsComplejo
Dim strSQLComodin As String
Dim ClassAud As New ClassMyUtils
Dim varUser As Long
Dim ClassComodin As New clsComplejo
Select Case UCase(clsVaribles.varProceso)
Case Is = "AGREGAR"
txtClave.Enabled = True
'VALIDACION DE CAMPOS
If txtClave.Text = "" Then
MessageBox.Show("Es Necesario Introducir Clave del Canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If txtNombre.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Nombre del Canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "SELECT IdCanal FROM Cat_Canal WHERE IdCanal = " & txtClave.Text
If classcom.BuscaDatos(strSQLComodin) Then
MessageBox.Show("La clave del Canal ya existe en el catalogo ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "INSERT INTO Cat_Canal(IdCanal,Canal,AliasId,Activo) VALUES ("
strSQLComodin = strSQLComodin & txtClave.Text & ",'" & txtNombre.Text & "','" & TXTAlias.Text & "'," & Me.chkActivo.CheckState & ")"
classcom.sbInserta(strSQLComodin)
'AUDITORIA
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 5, 1, txtNombre.Text)
MessageBox.Show("Operación Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Case Is = "ACTUALIZAR"
'VALIDACION DE CAMPOS
If txtClave.Text = "" Then
MessageBox.Show("Es Necesario Introducir la Clave del canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If txtNombre.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Nombre del Canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "UPDATE Cat_Canal SET "
strSQLComodin = strSQLComodin & " Canal = '" & txtNombre.Text & "',Activo = " & Me.chkActivo.CheckState
strSQLComodin = strSQLComodin & " where IdCanal = " & txtClave.Text
classcom.sbInserta(strSQLComodin)
'AUDITORIA
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 15, 1, txtNombre.Text)
MessageBox.Show("Operación Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
classcom = New clsComplejo
Case Is = "ELIMINAR"
If txtClave.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Número del Canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
'pnlBotones.Visible = False
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "UPDATE Cat_Canal SET ACTIVO = 0 where IdCanal = " & txtClave.Text
classcom.sbInserta(strSQLComodin)
''AUDITORIA
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 15, 1, txtNombre.Text)
MessageBox.Show("Operación Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
BtnOk.Enabled = False
Dim SQL As String
Dim CLASSCATALOGOS As New ClassCatalogos
GridMaster.DataSource = Nothing
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
SQL = "SELECT IdCanal CLAVE, Canal NOMBRE,ACTIVO FROM Cat_Canal ORDER BY Canal"
CLASSCATALOGOS.LlenaGrid(SQL, Me.GridMaster)
CLASSCATALOGOS.sbLimpiaControlesEsp(Panel)
End Sub
Private Sub txtClave_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtClave.KeyPress
Dim classCom As New clsComplejo
e.KeyChar = classCom.ValidaCampos("numeros", e.KeyChar)
End Sub
Private Sub txtClave_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtClave.TextChanged
End Sub
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
Dim classcom As New clsComplejo
Dim strSQLComodin As String
Dim ClassAud As New ClassMyUtils
Dim varUser As Long
Dim ClassComodin As New clsComplejo
Select Case UCase(clsVaribles.varProceso)
Case Is = "AGREGAR"
txtClave.Enabled = True
'VALIDACION DE CAMPOS
'If txtClave.Text = "" Then
' MessageBox.Show("Es Necesario Introducir la Clave del canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
' Exit Sub
'End If
If txtNombre.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Nombre ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtNombre.Focus()
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "SELECT CANAL FROM Cat_Canal WHERE CANAL = '" & txtNombre.Text & "'"
If classcom.BuscaDatos(strSQLComodin) Then
MessageBox.Show("La clave del canal ya Existe en el Catalogo ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtNombre.Focus()
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
'strSQLComodin = "INSERT INTO Cat_Canal (IdCanal, Canal, aliasid,Activo) VALUES ("
'strSQLComodin = strSQLComodin & "'" & txtClave.Text & "','" & txtNombre.Text & "','" & Me.txtalias.text & "'," & Me.chkActivo.CheckState & ")"
strSQLComodin = "sp_CargarCanal NULL,'" & txtNombre.Text & "'," & chkActivo.CheckState
classcom.sbInserta(strSQLComodin)
Case Is = "ACTUALIZAR"
'If txtClave.Text = "" Then
' MessageBox.Show("Es Necesario Introducir el Número del canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
' Exit Sub
'End If
If txtNombre.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Nombre del canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtNombre.Focus()
Exit Sub
End If
'clsVaribles.lsValAnt = ClassAud.FnObtenValAnterior("SpConValoresAnteriores 19," & txtClave.Text)
' ''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
'strSQLComodin = "UPDATE Cat_Canal SET "
'strSQLComodin = strSQLComodin & " Canal = '" & txtNombre.Text & "',Activo = " & Me.chkActivo.CheckState & ",aliasid = '" & Me.TXTAlias.Text & "'"
'strSQLComodin = strSQLComodin & " where IdCanal = '" & txtClave.Text & "'"
strSQLComodin = "sp_CargarCanal " & txtClave.Text & ",'" & txtNombre.Text & "'," & chkActivo.CheckState
classcom.sbInserta(strSQLComodin)
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 15, 1, clsVaribles.lsValAnt & " | Valores Nuevos: IdCanal: " & txtClave.Text & ", Canal = " & txtNombre.Text & ",Activo = " & Me.chkActivo.CheckState & ",aliasid = " & Me.TXTAlias.Text)
MessageBox.Show("Operación Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
classcom = New clsComplejo
Case Is = "ELIMINAR"
If txtClave.Text = "" Then
MessageBox.Show("Es Necesario Introducir el Numero del Canal ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
strSQLComodin = "UPDATE Cat_Canal SET ACTIVO = 0 where IdCanal = '" & txtClave.Text & "'"
classcom.sbInserta(strSQLComodin)
MessageBox.Show("Operación Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
BtnOk.Enabled = False
Dim SQL As String
Dim CLASSCATALOGOS As New ClassCatalogos
GridMaster.DataSource = Nothing
''Tabla: Cat_Canal, Campos IdCanal, Canal, AliasId, Activo
'SQL = "SELECT IdCanal CLAVE,Canal NOMBRE,ACTIVO,aliasid ALIAS FROM Cat_Canal ORDER BY Canal"
SQL = "sp_ConsultarCanal 0"
CLASSCATALOGOS.LlenaGrid(SQL, Me.GridMaster)
txtNombre.Text = ""
chkActivo.Checked = False
chkActivo.Enabled = False
txtNombre.Enabled = False
txtClave.Text = ""
ClassCatalogos.CambiaColorbloque2(BtnConsulta, BtnEditar, BtnOk, Button1)
'CLASSCATALOGOS.sbLimpiaControlesEsp(Panel)
'TXTAlias.Clear()
End Sub
Private Sub BtnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEditar.Click
clsVaribles.varProceso = "Actualizar"
txtClave.Enabled = False
txtNombre.Enabled = True
Me.chkActivo.Enabled = True
Me.TXTAlias.Enabled = True
BtnOk.Enabled = True
BtnEditar.Enabled = False
txtNombre.Focus()
ClassCatalogos.CambiaColorbloque2(BtnConsulta, BtnEditar, BtnOk, Button1)
End Sub
Private Sub BtnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnConsulta.Click
txtClave.Enabled = True
txtClave.ReadOnly = True
txtClave.Text = ""
txtNombre.Text = ""
clsVaribles.varProceso = "Agregar"
'txtClave.Focus()
BtnOk.Enabled = True
txtClave.Visible = True
txtNombre.Enabled = True
Me.chkActivo.Enabled = True
Me.chkActivo.Checked = False
TXTAlias.Enabled = True
TXTAlias.Clear()
BtnEditar.Enabled = False
txtNombre.Focus()
ClassCatalogos.CambiaColorbloque2(BtnConsulta, BtnEditar, BtnOk, Button1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class