client/Reportes/VigenciaAlertas/frmVigenciaCon.vb

354 lines
13 KiB
VB.net

Public Class frmVigenciaCon
Dim clsVar As clsVaribles = New clsVaribles
Private ConTran As Boolean = False
Private SinTran As Boolean = False
Public Sub New(Opcion As Integer)
MyBase.New()
InitializeComponent()
If Opcion = 0 Then
ConTran = True
End If
If Opcion = 1 Then
SinTran = True
End If
End Sub
Private Sub frmVigenciaCon_Load(sender As Object, e As EventArgs) Handles MyBase.Load
llenarCombos()
If ConTran Then
DesHeader.Text = "Vigencia Alertas Con Transacción"
Me.Text = "Vigencia Alertas Con Transacción"
IsCon()
BuscarCon()
End If
If SinTran Then
DesHeader.Text = "Vigencia Alertas sin Transacción"
Me.Text = "Vigencia Alertas sin Transacción"
isSin()
BuscarSin()
End If
lblAlarmados.BackColor = System.Drawing.Color.CornflowerBlue
lblNoalarmados.BackColor = System.Drawing.Color.LightGray
End Sub
Private Sub IsCon()
gb1.Visible = True
gb2.Visible = False
End Sub
Private Sub isSin()
gb1.Visible = False
gb2.Visible = True
End Sub
Private Sub llenarCombos()
Dim CLIENTE As New clsComplejo
CLIENTE.sbLlenaCombo("spLlenaComboCliente " & clsVaribles.liPerfilB, Me.cmbCliente) ' ClsVaribles
cmbCliente.SelectedIndex = -1
CLIENTE = New clsComplejo()
CLIENTE.sbLlenaCombo("SELECT IDTIPOALARMA CLAVE, ALARMA NOMBRE FROM CAT_TIPO_ALARMA WHERE IDTIPOALARMA IN (2,3)", Me.cmbPatron) ' ClsVaribles
cmbPatron.SelectedIndex = -1
CLIENTE = New clsComplejo()
CLIENTE.sbLlenaCombo("SELECT IDTIPOALARMA CLAVE, ALARMA NOMBRE FROM CAT_TIPO_ALARMA WHERE IDTIPOALARMA IN (2,3)", Me.cmbAlarmas) ' ClsVaribles
cmbAlarmas.SelectedIndex = -1
End Sub
Private Sub BuscarSin()
Dim sql As String
Dim MyDs As New DataSet
Dim clCmp As New clsComplejo
Dim i As Integer
sql = ArmarSQLss()
MyDs = clCmp.fdtDataSetTablaESP(sql)
clsVaribles.VarSQL = sql
Me.C1TrueDBGrid1.DataSource = Nothing
Me.C1TrueDBGrid1.Columns.Clear()
Me.C1TrueDBGrid1.Refresh()
Me.C1TrueDBGrid1.DataSource = MyDs.Tables(0)
Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0).Visible = False
lblNumReg.Text = "Total de Registros " & Me.C1TrueDBGrid1.RowCount
For i = 0 To C1TrueDBGrid1.Columns.Count - 1
C1TrueDBGrid1.Splits(0).DisplayColumns(i).AutoSize()
Next
End Sub
Private Sub BuscarCon()
Dim sql As String
Dim MyDs As New DataSet
Dim clCmp As New clsComplejo
sql = ArmarSQL()
MyDs = clCmp.fdtDataSetTablaESP(sql)
clsVaribles.VarSQL = sql
Me.C1TrueDBGrid1.DataSource = Nothing
Me.C1TrueDBGrid1.Columns.Clear()
Me.C1TrueDBGrid1.Refresh()
Me.C1TrueDBGrid1.DataSource = MyDs.Tables(0)
Dim valItem As C1.Win.C1TrueDBGrid.ValueItemCollection
valItem = Me.C1TrueDBGrid1.Columns("Marcar").ValueItems.Values
valItem.Add(New C1.Win.C1TrueDBGrid.ValueItem("0", False))
valItem.Add(New C1.Win.C1TrueDBGrid.ValueItem("1", True))
Me.C1TrueDBGrid1.Columns("Marcar").ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox
Me.C1TrueDBGrid1.Columns("Marcar").ValueItems.Translate = True
For Each col As C1.Win.C1TrueDBGrid.C1DisplayColumn In C1TrueDBGrid1.Splits(0).DisplayColumns
col.AutoSize()
If InStr(col.Name, "ID") > 0 Then
col.Visible = False
End If
Next
'Me.C1TrueDBGrid1.Columns(13).NumberFormat = "Currency"
'Me.C1TrueDBGrid1.Columns(14).NumberFormat = "Currency"
'Me.C1TrueDBGrid1.Columns(39).NumberFormat = "Currency"
'Me.C1TrueDBGrid1.Columns(40).NumberFormat = "Currency"
'Me.C1TrueDBGrid1.Columns(62).NumberFormat = "Currency"
Me.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy
Dim Cont As Integer
lblNumReg.Text = "Total de Registros " & Me.C1TrueDBGrid1.RowCount
clCmp.ColsGridAutosize(Me.C1TrueDBGrid1)
Me.C1TrueDBGrid1.Columns(2).GroupInfo.ColumnVisible = True
Me.C1TrueDBGrid1.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy
'Dim s1 As New C1.Win.C1TrueDBGrid.Style
's1.ForeColor = Color.White
's1.BackColor = Color.Red
'C1TrueDBGrid1.Splits(0).DisplayColumns(2).AddRegexCellStyle(C1.Win.C1TrueDBGrid.CellStyleFlag.AllCells, s1, "DIAS")
End Sub
Private Function ArmarSQL() As String
Dim IdTipo As String = "NULL"
Dim Cliente As String = "NULL"
Dim Cuenta As String = "NULL"
ArmarSQL = "SPR_InusualesNoInvestigados "
If cmbPatron.SelectedIndex > -1 Then
IdTipo = cmbPatron.SelectedValue
End If
If cmbCliente.SelectedIndex > -1 Then
Cliente = cmbCliente.SelectedValue
End If
If txtCuenta.Text.Trim.Length > 0 Then
Cuenta = "'" & txtCuenta.Text & "'"
End If
ArmarSQL += IdTipo + "," + Cliente + "," + Cuenta
End Function
Private Function ArmarSQLss() As String
Dim IdTipo As String = "NULL"
ArmarSQLss = "SPR_InusualesNoInvestigadosSinTX "
If cmbAlarmas.SelectedIndex > -1 Then
IdTipo = cmbAlarmas.SelectedValue
End If
ArmarSQLss += IdTipo
End Function
Private Sub LimpiarCon()
cmbCliente.SelectedIndex = -1
cmbPatron.SelectedIndex = -1
cmbCliente.SelectedIndex = -1
cmbPatron.SelectedIndex = -1
txtCuenta.Text = ""
End Sub
Private Sub Agrupar()
Try
Dim cuentaMarcados As Integer = 0
Dim listaTransacciones As String = ""
Dim arreglo(0 To 10000, 0 To 2) As String
Dim Cerrado As Boolean = False
Dim Enviado As Boolean = False
Dim TranCerradas As String = ""
Dim TranEnviadas As String = ""
Dim sTexto As String = ""
Application.DoEvents()
For i As Integer = 0 To C1TrueDBGrid1.RowCount - 1
If C1TrueDBGrid1.Columns("Marcar").CellText(i) = "True" Then
cuentaMarcados += 1
listaTransacciones &= C1TrueDBGrid1.Columns("IDTRANSACCION").CellText(i) & "; "
arreglo(cuentaMarcados - 1, 0) = C1TrueDBGrid1.Columns("IDTRANSACCION").CellText(i)
arreglo(cuentaMarcados - 1, 1) = C1TrueDBGrid1.Columns("IDPRODUCTO").CellText(i)
arreglo(cuentaMarcados - 1, 2) = C1TrueDBGrid1.Columns("IDPATRON").CellText(i)
If C1TrueDBGrid1.Columns("IDESTATUSALARMA").CellText(i) = "4" Then
Cerrado = True
TranCerradas &= C1TrueDBGrid1.Columns("IdTransaccion").CellText(i) & "; "
End If
If C1TrueDBGrid1.Columns("IDESTATUSALARMA").CellText(i) = "5" Then
Enviado = True
TranEnviadas &= C1TrueDBGrid1.Columns("IdTransaccion").CellText(i) & "; "
End If
End If
Next
If Cerrado = True Then
sTexto = "Los elementos seleccionados de la lista con id. transacción " & TranCerradas & " tienen estatus cerrado, no se pueden gestionar." & vbCrLf
End If
If Enviado = True Then
sTexto = sTexto & "Los elementos seleccionados de la lista con id. transacción " & TranEnviadas & " tienen estatus enviado, no se pueden gestionar." & vbCrLf
End If
If Cerrado = True Or Enviado = True Then
MsgBox(sTexto & " Favor de revisar!", MsgBoxStyle.Exclamation, "MINDS")
Else
If cuentaMarcados < 2 Then
MsgBox("Debe seleccionar al menos dos elementos de la lista, favor de verificar!", MsgBoxStyle.Exclamation, "MINDS")
Else
Dim xCierreGrupal As New CierreGrupal
xCierreGrupal.ListaTransacciones = listaTransacciones
xCierreGrupal.arreglo = arreglo
'*******************************************************************************************
'CIERRE GRUPAL - Asigna ids's en arrays para Agregar evidencias
For i As Integer = 0 To C1TrueDBGrid1.RowCount - 1
If C1TrueDBGrid1.Columns("Marcar").CellText(i) = "True" Then
clsVar.Id_Producto += C1TrueDBGrid1.Columns("IDPRODUCTO").CellValue(i) & " , "
clsVar.Id_Patron += C1TrueDBGrid1.Columns("IDPATRON").CellValue(i) & " , "
End If
Next
'*******************************************************************************************
xCierreGrupal.ShowDialog(Me)
BuscarCon()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub BtnConsul_Click(sender As Object, e As EventArgs) Handles BtnConsul.Click
If ConTran Then
BuscarCon()
End If
If SinTran Then
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnLimpiar.Click
If ConTran Then
LimpiarCon()
End If
If SinTran Then
End If
End Sub
Private Sub btnAgrupar_Click(sender As Object, e As EventArgs) Handles btnAgrupar.Click
Agrupar()
End Sub
Private Sub C1TrueDBGrid1_DoubleClick(sender As Object, e As EventArgs) Handles C1TrueDBGrid1.DoubleClick
If ConTran Then
dobleCon()
End If
If SinTran Then
dobleSIN()
End If
End Sub
Private Sub dobleCon()
Try
Dim FilaActual As Integer
FilaActual = Me.C1TrueDBGrid1.Row
If Me.C1TrueDBGrid1.RowCount <= 0 Then
Exit Sub
End If
clsVaribles.ReportadoPor = C1TrueDBGrid1.Columns("PATRON").Text ' Cambio clsVar 8 lineas por clsVaribles
clsVaribles.Nombre = C1TrueDBGrid1.Columns("CLIENTE").Text
clsVaribles.No_Referencia = C1TrueDBGrid1.Columns("NUMEROREFERENCIA").Text
clsVaribles.Id_Transaccion = C1TrueDBGrid1.Columns("IDTransaccion").Text
clsVaribles.Id_Producto = C1TrueDBGrid1.Columns("IdProducto").Text
clsVaribles.Id_SubProducto = C1TrueDBGrid1.Columns("IdSubproducto").Text
clsVaribles.Id_Patron = C1TrueDBGrid1.Columns("IdPatron").Text
clsVaribles.Id_EstatusTransaccion = C1TrueDBGrid1.Columns("IDESTATUSALARMA").Text
Dim frmDetalles As Detalles = New Detalles
frmDetalles.Text = "Detalle"
frmDetalles.fecha24 = C1TrueDBGrid1.Columns("fecha").Text
frmDetalles.IdTipoAlarma = C1TrueDBGrid1.Columns("IDTIPOALARMA").Text
frmDetalles.ShowDialog()
BuscarCon()
Catch ex As Exception
MessageBox.Show("Surgio un problema " & vbCrLf & Err.Number & " " & Err.Description, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub dobleSIN()
Try
Dim FilaActual As Integer
FilaActual = Me.C1TrueDBGrid1.Row
If Me.C1TrueDBGrid1.RowCount <= 0 Then
Exit Sub
End If
Dim frmDetalles As DetallesSin = New DetallesSin
clsVaribles.Nombre = C1TrueDBGrid1.Columns("NOMBRE").Text & " " & C1TrueDBGrid1.Columns("APELLIDO PATERNO").Text & " " & C1TrueDBGrid1.Columns("APELLIDO MATERNO").Text
clsVaribles.No_Referencia = C1TrueDBGrid1.Columns("ID").Text
clsVaribles.Id_Transaccion = C1TrueDBGrid1.Columns("ID").Text
clsVaribles.Id_EstatusTransaccion = C1TrueDBGrid1.Columns("ID ESTATUS TRANSACCIÓN").Text
frmDetalles.ShowDialog()
BuscarSin()
Catch ex As Exception
MessageBox.Show("Surgio un problema " & vbCrLf & Err.Number & " " & Err.Description, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub C1TrueDBGrid1_FetchRowStyle(sender As Object, e As C1.Win.C1TrueDBGrid.FetchRowStyleEventArgs) Handles C1TrueDBGrid1.FetchRowStyle
Dim S As String = C1TrueDBGrid1.Columns("DIAS VENCIMIENTO").CellText(e.Row).ToString
If S < "0" Then
e.CellStyle.BackColor = System.Drawing.Color.CornflowerBlue
Else
e.CellStyle.BackColor = System.Drawing.Color.LightGray
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
BuscarSin()
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnLimpiarSin.Click
cmbAlarmas.SelectedValue = -1
End Sub
Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class