324 lines
13 KiB
VB.net
324 lines
13 KiB
VB.net
|
Public Class FRMySubproducto
|
|||
|
|
|||
|
Private Sub FRMySubproducto_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
|
|||
|
|
|||
|
PnPais.Visible = False
|
|||
|
|
|||
|
Me.Text = "Subproductos"
|
|||
|
Me.PnPais.Visible = True
|
|||
|
DesHeader.Text = Text
|
|||
|
If clsVaribles.lbDemo = True Then Exit Sub
|
|||
|
|
|||
|
''LLENA GRID
|
|||
|
'SQL = "SELECT idSUBproducto CLAVE,SubProducto NOMBRE,idproducto PRODUCTO,ACTIVO, "
|
|||
|
'SQL = SQL & "NivelCta, Alias, Plazo, TipoPlazo "
|
|||
|
'SQL = SQL & "FROM CAT_subproducto ORDER BY SubProducto"
|
|||
|
|
|||
|
SQL = "sp_ConsultarSubProducto "
|
|||
|
|
|||
|
ClassCatalogos.LlenaGrid(SQL, Me.GridMaster)
|
|||
|
|
|||
|
Classcom.sbLlenaCombo("sp_ConsultarProducto 0,1 ", Me.cmbOrganismo)
|
|||
|
|
|||
|
cmbOrganismo.SelectedIndex = -1
|
|||
|
|
|||
|
txtClave.Enabled = False
|
|||
|
txtNombre.Enabled = False
|
|||
|
txtNivelCta.Enabled = False
|
|||
|
txtAlias.Enabled = False
|
|||
|
txtPlazo.Enabled = False
|
|||
|
txtTipoPlazo.Enabled = False
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
cmbOrganismo.Enabled = False
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub GridMaster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridMaster.Click
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
|
|||
|
Private Sub BtnAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAgregar.Click
|
|||
|
|
|||
|
If clsVaribles.lbDemo = True Then Exit Sub
|
|||
|
|
|||
|
txtClaveSp.Text = ""
|
|||
|
|
|||
|
txtClave.Enabled = True
|
|||
|
txtClave.ReadOnly = True
|
|||
|
txtClave.Text = ""
|
|||
|
txtNombre.Text = ""
|
|||
|
txtNivelCta.Text = ""
|
|||
|
txtAlias.Text = ""
|
|||
|
txtPlazo.Text = ""
|
|||
|
txtTipoPlazo.Text = ""
|
|||
|
|
|||
|
clsVaribles.varProceso = "Agregar"
|
|||
|
txtClaveSp.Enabled = True
|
|||
|
|
|||
|
BtnOk.Enabled = True
|
|||
|
|
|||
|
'txtClave.Visible = False
|
|||
|
txtNombre.Enabled = True
|
|||
|
txtNivelCta.Enabled = True
|
|||
|
txtAlias.Enabled = True
|
|||
|
txtPlazo.Enabled = True
|
|||
|
txtTipoPlazo.Enabled = True
|
|||
|
|
|||
|
Me.cmbOrganismo.Enabled = True
|
|||
|
Me.chkActivo.Enabled = True
|
|||
|
|
|||
|
cmbOrganismo.SelectedIndex = -1
|
|||
|
|
|||
|
BtnEditar.Enabled = False
|
|||
|
|
|||
|
chkActivo.Checked = False
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
txtClaveSp.Focus()
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BtnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEditar.Click
|
|||
|
|
|||
|
If clsVaribles.lbDemo = True Then Exit Sub
|
|||
|
|
|||
|
clsVaribles.varProceso = "Actualizar"
|
|||
|
|
|||
|
txtClaveSp.Enabled = True
|
|||
|
txtClave.ReadOnly = True
|
|||
|
txtClave.Enabled = False
|
|||
|
txtNombre.Enabled = True
|
|||
|
Me.cmbOrganismo.Enabled = True
|
|||
|
Me.chkActivo.Enabled = True
|
|||
|
|
|||
|
txtNivelCta.Enabled = True
|
|||
|
txtAlias.Enabled = True
|
|||
|
txtPlazo.Enabled = True
|
|||
|
txtTipoPlazo.Enabled = True
|
|||
|
|
|||
|
BtnOk.Enabled = True
|
|||
|
|
|||
|
BtnEditar.Enabled = False
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
txtClaveSp.Focus()
|
|||
|
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
|
|||
|
|
|||
|
If clsVaribles.lbDemo = True Then Exit Sub
|
|||
|
|
|||
|
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 txtNombre.Text = "" Then
|
|||
|
MessageBox.Show("Es Necesario Introducir el Nombre ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
If cmbOrganismo.Text = "" Then
|
|||
|
MessageBox.Show("Es Necesario Seleccinar el Producto ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
strSQLComodin = "SELECT idsubproducto FROM CAT_subproducto WHERE NOMBRESUBPRODUCTO = '" & txtNombre.Text & "' And idproducto = " & cmbOrganismo.SelectedValue
|
|||
|
If classcom.BuscaDatos(strSQLComodin) Then
|
|||
|
MessageBox.Show("Este Nombre del Subproducto ya Existe en el Catalogo para el Mismo Producto ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
classcom.ds.Clone()
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
'strSQLComodin = "SELECT idsubproducto FROM CAT_subproducto WHERE CLAVESUBPRODUCTO = '" & txtClaveSp.Text & "' And idproducto = " & cmbOrganismo.SelectedValue
|
|||
|
strSQLComodin = "SELECT idsubproducto FROM CAT_subproducto WHERE idsubproducto = '" & txtClaveSp.Text & "'"
|
|||
|
If classcom.BuscaDatos(strSQLComodin) Then
|
|||
|
MessageBox.Show("Esta clave del Subproducto ya Existe en el Catalogo para el Mismo Producto ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
classcom.ds.Clone()
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
'If IsNumeric(txtNivelCta.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo NivelCta. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
'If IsNumeric(txtAlias.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo Alias. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
'If IsNumeric(txtPlazo.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo Plazo. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
|
|||
|
'strSQLComodin = "INSERT INTO CAT_subproducto (SubProducto,idproducto,Activo, NivelCta, Alias, Plazo, TipoPlazo) VALUES ("
|
|||
|
'strSQLComodin = strSQLComodin & "'" & txtNombre.Text & "'," & cmbOrganismo.SelectedValue & " ," & Me.chkActivo.CheckState & ", "
|
|||
|
'strSQLComodin = strSQLComodin & txtNivelCta.Text & "," & txtAlias.Text & "," & txtPlazo.Text & ", '" & txtTipoPlazo.Text & "' )"
|
|||
|
|
|||
|
strSQLComodin = "sp_CargarSubproducto NULL," & cmbOrganismo.SelectedValue & ",'" & txtNombre.Text & "','" &
|
|||
|
txtClaveSp.Text & "'," & chkActivo.CheckState
|
|||
|
|
|||
|
classcom.sbInserta(strSQLComodin)
|
|||
|
|
|||
|
'AUDITORIA
|
|||
|
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 95, 1, " | Valores Nuevos: SubProducto: " & txtNombre.Text & ", Producto: " & cmbOrganismo.Text & ",Activo = " & Me.chkActivo.CheckState)
|
|||
|
'FIN AUDITORIA
|
|||
|
|
|||
|
MessageBox.Show("Operaci<EFBFBD>n Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
|
|||
|
|
|||
|
Case Is = "ACTUALIZAR"
|
|||
|
|
|||
|
'VALIDACION DE CAMPOS
|
|||
|
|
|||
|
If txtNombre.Text = "" Then
|
|||
|
MessageBox.Show("Es Necesario Introducir el Nombre del Subproducto ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
If cmbOrganismo.Text = "" Then
|
|||
|
MessageBox.Show("Es Necesario Seleccionar el Producto ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
'If IsNumeric(txtNivelCta.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo NivelCta. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
'If IsNumeric(txtAlias.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo Alias. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
'If IsNumeric(txtPlazo.Text) = False Then
|
|||
|
' MessageBox.Show("Introduzca un n<>mero entero en el campo Plazo. ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
' Exit Sub
|
|||
|
'End If
|
|||
|
|
|||
|
'clsVaribles.lsValAnt = ClassAud.FnObtenValAnterior("SpConValoresAnteriores 15," & txtClave.Text)
|
|||
|
|
|||
|
'pnlBotones.Visible = False
|
|||
|
|
|||
|
'strSQLComodin = "UPDATE CAT_Subproducto SET "
|
|||
|
'strSQLComodin = strSQLComodin & " Subproducto = '" & txtNombre.Text & "',Activo = " & Me.chkActivo.CheckState & " , idproducto = " & cmbOrganismo.SelectedValue & ", "
|
|||
|
'strSQLComodin = strSQLComodin & " NivelCta= " & txtNivelCta.Text & ", Alias=" & txtAlias.Text & ", Plazo=" & txtPlazo.Text & ", "
|
|||
|
'strSQLComodin = strSQLComodin & " TipoPlazo= '" & txtTipoPlazo.Text & "'"
|
|||
|
'strSQLComodin = strSQLComodin & " where idsubproducto = " & txtClave.Text & " "
|
|||
|
|
|||
|
strSQLComodin = "sp_CargarSubproducto " & txtClave.Text & "," & cmbOrganismo.SelectedValue & ",'" & txtNombre.Text & "','" &
|
|||
|
txtClaveSp.Text & "'," & chkActivo.CheckState
|
|||
|
|
|||
|
classcom = New clsComplejo
|
|||
|
classcom.sbInserta(strSQLComodin)
|
|||
|
|
|||
|
'AUDITORIA
|
|||
|
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 96, 1, clsVaribles.lsValAnt & " | Valores Nuevos: idsubproducto = " & txtClave.Text & ", SubProducto: " & txtNombre.Text & ", Producto: " & cmbOrganismo.Text & ",Activo = " & Me.chkActivo.CheckState)
|
|||
|
'FIN AUDITORIA
|
|||
|
|
|||
|
MessageBox.Show("Operaci<EFBFBD>n Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
|
|||
|
classcom = New clsComplejo
|
|||
|
|
|||
|
Case Is = "ELIMINAR"
|
|||
|
|
|||
|
If txtClave.Text = "" Then
|
|||
|
MessageBox.Show("Es Necesario Introducir el Numero de la Plaza ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
Exit Sub
|
|||
|
End If
|
|||
|
|
|||
|
strSQLComodin = "UPDATE CAT_subproducto SET ACTIVO = 0 where idsubproducto = " & txtClave.Text & " AND idproducto = " & cmbOrganismo.SelectedValue
|
|||
|
classcom.sbInserta(strSQLComodin)
|
|||
|
|
|||
|
''AUDITORIA
|
|||
|
'Dim ClassAud As New ClassMyUtils
|
|||
|
'Dim varUser As Long
|
|||
|
'Dim ClassComodin As New clsComplejo
|
|||
|
''varUser = ClassComodin.BuscaValores("IdUsuario", "usuario", "usuario = '" & My.User.Name & "'")
|
|||
|
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 97, 1, txtNombre.Text)
|
|||
|
|
|||
|
' ClassAud.RT_Auditoria(clsVaribles.varUsuario, 97, My.Computer.Name, "Minds Cliente", "Baja de Subproducto CLAVE = " & txtClave.Text & " NOMBRE = " & txtNombre.Text)
|
|||
|
''FIN AUDITORIA
|
|||
|
|
|||
|
MessageBox.Show("Operaci<EFBFBD>n Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
|
|||
|
End Select
|
|||
|
|
|||
|
BtnOk.Enabled = False
|
|||
|
txtClaveSp.Enabled = False
|
|||
|
|
|||
|
Dim SQL As String
|
|||
|
Dim CLASSCATALOGOS As New ClassCatalogos
|
|||
|
|
|||
|
GridMaster.DataSource = Nothing
|
|||
|
'SQL = "SELECT idSUBproducto CLAVE,SubProducto NOMBRE,idproducto PRODUCTO,ACTIVO, "
|
|||
|
'SQL = SQL & "NivelCta, Alias, Plazo, TipoPlazo "
|
|||
|
'SQL = SQL & "FROM CAT_subproducto ORDER BY SubProducto"
|
|||
|
|
|||
|
SQL = "sp_ConsultarSubProducto 0"
|
|||
|
|
|||
|
CLASSCATALOGOS.LlenaGrid(SQL, Me.GridMaster)
|
|||
|
|
|||
|
txtClave.Focus()
|
|||
|
|
|||
|
'CLASSCATALOGOS.sbLimpiaControlesEsp(PnPais)
|
|||
|
txtClave.Text = ""
|
|||
|
txtClaveSp.Text = ""
|
|||
|
txtNombre.Text = ""
|
|||
|
cmbOrganismo.SelectedIndex = -1
|
|||
|
txtNombre.Enabled = False
|
|||
|
cmbOrganismo.Enabled = False
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, 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
|
|||
|
|
|||
|
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.cmbOrganismo.SelectedValue = Me.GridMaster.Columns("IDPRODUCTO").Value
|
|||
|
Me.chkActivo.Checked = Me.GridMaster.Columns("ACTIVO").Value
|
|||
|
Me.chkActivo.Enabled = False
|
|||
|
|
|||
|
txtClaveSp.Text = GridMaster.Columns("CLAVESUBPRODUCTO").Value
|
|||
|
|
|||
|
If cmbOrganismo.SelectedValue <> GridMaster.Columns("IDPRODUCTO").Value Then
|
|||
|
cmbOrganismo.SelectedIndex = -1
|
|||
|
End If
|
|||
|
|
|||
|
'Me.txtNivelCta.Text = Me.GridMaster.Columns("NivelCta").Value.ToString()
|
|||
|
'Me.txtAlias.Text = Me.GridMaster.Columns("Alias").Value.ToString()
|
|||
|
'Me.txtPlazo.Text = Me.GridMaster.Columns("Plazo").Value.ToString()
|
|||
|
'Me.txtTipoPlazo.Text = Me.GridMaster.Columns("TipoPlazo").Value.ToString()
|
|||
|
|
|||
|
txtClave.Enabled = False
|
|||
|
txtNombre.Enabled = False
|
|||
|
|
|||
|
txtNivelCta.Enabled = False
|
|||
|
txtAlias.Enabled = False
|
|||
|
txtPlazo.Enabled = False
|
|||
|
txtTipoPlazo.Enabled = False
|
|||
|
|
|||
|
Me.cmbOrganismo.Enabled = False
|
|||
|
|
|||
|
BtnEditar.Enabled = True
|
|||
|
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, Button1)
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
End Class
|