client/Reportes/FrTransaccionesXGpo.vb

849 lines
40 KiB
VB.net
Raw Normal View History

'Imports Microsoft.Office.Interop
Imports System.Collections.Generic
Public Class FrTransaccionesXGpo
Dim VarSQL As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTConsultar.Click
Try
Dim SQL As String
Dim Classcom As New clsComplejo
Dim NombreProd As String
If Me.CMBProducto.SelectedIndex = -1 Then MsgBox("Es Necesario Seleccionar un Producto") : Exit Sub
Dim listaParametros As New List(Of String)
Dim IdStyle As Integer
IdStyle = 0
If cmbCliente.Text <> "" Then
listaParametros.Add(cmbCliente.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
If cmbCuenta.Text <> "" Then
listaParametros.Add(cmbCuenta.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
If CMBEstatus.Text <> "" Then
listaParametros.Add(CMBEstatus.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
If CMBTipoAlarma.Text <> "" Then
listaParametros.Add(CMBTipoAlarma.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
listaParametros.Add("'" & dtpFechaInicio.Value.ToString("yyyyMMdd") & "'")
listaParametros.Add("'" & dtpFechaFin.Value.ToString("yyyyMMdd") & "'")
If cmbMontos.SelectedIndex <> -1 Then
listaParametros.Add(cmbMontos.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
If cmbTipoPersona.SelectedIndex <> -1 Then
listaParametros.Add(cmbTipoPersona.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
If cmbInsMone.SelectedIndex <> -1 Then
listaParametros.Add(cmbInsMone.SelectedValue.ToString())
Else
listaParametros.Add("NULL")
End If
Dim lstParams2 As New List(Of String)
lstParams2.Clear()
lstParams2.Add(IIf(cmbCliente.SelectedValue <> Nothing, cmbCliente.SelectedValue, "NULL"))
lstParams2.Add(IIf(cmbCuenta.SelectedValue <> Nothing, cmbCuenta.SelectedValue, "NULL"))
lstParams2.Add("'" & dtpFechaInicio.Value.ToString("yyyyMMdd") & "'")
lstParams2.Add("'" & dtpFechaFin.Value.ToString("yyyyMMdd") & "'")
If cmbMontos.SelectedIndex <> -1 Then
lstParams2.Add(cmbMontos.SelectedValue.ToString())
Else
lstParams2.Add("NULL")
End If
If cmbTipoPersona.SelectedIndex <> -1 Then
lstParams2.Add(cmbTipoPersona.SelectedValue.ToString())
Else
lstParams2.Add("NULL")
End If
If cmbInsMone.SelectedIndex <> -1 Then
lstParams2.Add(cmbInsMone.SelectedValue.ToString())
Else
lstParams2.Add("NULL")
End If
Select Case CMBProducto.Text
Case "CREDITO"
If CMBTipoAlarma.Text = "" And CMBEstatus.Text = "" Then
SQL = "sp_ReportTransaccionesClienteCtaCDTO "
SQL = SQL & String.Join(",", lstParams2.ToArray())
IdStyle = 1
Else
SQL = "sp_ReportTransaccionesCDTO "
SQL = SQL & String.Join(",", listaParametros.ToArray())
IdStyle = 2
End If
Case "BANCA INTERNACIONAL"
If CMBTipoAlarma.Text = "" And CMBEstatus.Text = "" Then
SQL = "sp_ReportTransaccionesClienteCtaBI "
SQL = SQL & String.Join(",", lstParams2.ToArray())
IdStyle = 3
Else
SQL = "sp_ReportTransaccionesBI "
SQL = SQL & String.Join(",", listaParametros.ToArray())
IdStyle = 4
End If
Case "MERCADO DE CAPITALES" '"MERCADO DE CAPITALES"
If CMBTipoAlarma.Text = "" And CMBEstatus.Text = "" Then
SQL = "sp_ReportTransaccionesClienteCtaMCapitales "
SQL = SQL & String.Join(",", lstParams2.ToArray())
IdStyle = 5
Else
SQL = "sp_ReportTransaccionesMCAPITALES "
SQL = SQL & String.Join(",", listaParametros.ToArray())
IdStyle = 6
End If
Case "BANCA TRADICIONAL"
If CMBTipoAlarma.Text = "" And CMBEstatus.Text = "" Then
SQL = "sp_ReportTransaccionesClienteCtaBT "
SQL = SQL & String.Join(",", lstParams2.ToArray())
IdStyle = 7
Else
SQL = "sp_ReportTransaccionesBT "
SQL = SQL & String.Join(",", listaParametros.ToArray())
IdStyle = 8
End If
Case "DIVISAS"
If CMBTipoAlarma.Text = "" And CMBEstatus.Text = "" Then
SQL = "sp_ReportTransaccionesClienteCtaDivisa "
SQL = SQL & String.Join(",", lstParams2.ToArray())
IdStyle = 9
Else
SQL = "sp_ReportTransaccionesDIVISAS "
SQL = SQL & String.Join(",", listaParametros.ToArray())
IdStyle = 10
End If
Case Else
Exit Sub
End Select
Classcom = New clsComplejo
Classcom.fdtDataSetTabla(SQL)
GrdPrincipal.SetDataBinding(Classcom.ds, "Tabla", False)
GridStyle(IdStyle)
Classcom.ColsGridAutosize(GrdPrincipal)
lblResultados.Text = "Total de Registros " & GrdPrincipal.RowCount
clsVaribles.strSQLGlobal = SQL
GrdPrincipal.Visible = True
'--<2D>Lopez
Me.GrdPrincipal.Columns(2).GroupInfo.ColumnVisible = True
Me.GrdPrincipal.DataView = C1.Win.C1TrueDBGrid.DataViewEnum.GroupBy
''Auditoria
Dim ClassAud As New ClassMyUtils
Dim sTextoAud As String
sTextoAud = "Reporte de transacciones, Periodo del " & Me.dtpFechaInicio.Value.Date & " al " & Me.dtpFechaFin.Value.Date
If CMBTipoAlarma.Text <> "" Then
sTextoAud = sTextoAud & ", Operación Detectada:" & CMBTipoAlarma.Text
End If
If CMBEstatus.Text <> "" Then
sTextoAud = sTextoAud & ", Estatus:" & CMBEstatus.Text
End If
If CMBProducto.Text <> "" Then
sTextoAud = sTextoAud & ", Producto:" & CMBProducto.Text
End If
If cmbCliente.Text <> "" Then
sTextoAud = sTextoAud & ", IdCliente:" & cmbCliente.SelectedValue
End If
If cmbCuenta.Text <> "" Then
sTextoAud = sTextoAud & ", NoCuenta:" & cmbCuenta.Text
End If
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 118, 1, sTextoAud)
''Fin de auditoria
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub GridStyle(IdStyle As Integer)
Try
Me.GrdPrincipal.Splits(0).DisplayColumns(1).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(4).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(6).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(8).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(10).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(12).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(14).Visible = False
Select Case IdStyle
Case 1
Case 2
Me.GrdPrincipal.Splits(0).DisplayColumns(26).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(28).Visible = False
Case 3
GridBI()
Case 4
GridBI()
Me.GrdPrincipal.Splits(0).DisplayColumns(45).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(47).Visible = False
Case 5
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(18).Visible = False
Case 6
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(18).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(34).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(36).Visible = False
Case 7
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(18).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(20).Visible = False
Case 8
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(18).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(20).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(37).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(39).Visible = False
Case 9
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Case 10
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(26).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(28).Visible = False
End Select
Catch ex As Exception
End Try
End Sub
Private Sub GridBI()
Try
Me.GrdPrincipal.Splits(0).DisplayColumns(16).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(18).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(20).Visible = False
Me.GrdPrincipal.Splits(0).DisplayColumns(36).Visible = False
Catch ex As Exception
End Try
End Sub
Private Sub FrTransacciones_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Classcom As New clsComplejo
Dim SQL As String
Label7.Text = ""
'-- vcarga combo de tipos de alarma, no i ncluye las preocupantes '-- CMBTipoAlarma
'SQL = "SELECT idTipoAlarma clave ,rtrim(TipoAlarma) nombre from Cat_Tipoalarma " ''A peticion de Angel Frias y autorizado por Eduardo se quita la condicion: "where idTipoAlarma <> 3"
SQL = "SELECT IDTIPOALARMA clave ,rtrim(ALARMA) nombre from CAT_TIPO_ALARMA " ''A peticion de Angel Frias y autorizado por Eduardo se quita la condicion: "where idTipoAlarma <> 3"
Classcom.sbLlenaComboESP(SQL, CMBTipoAlarma, "Nombre")
CMBTipoAlarma.SelectedIndex = -1
SQL = "SELECT idTipoPersona as clave, TipoPersona as nombre from Cat_Tipopersona where ACTIVO = 1"
Classcom.sbLlenaComboESP(SQL, Me.cmbTipoPersona, "nombre")
cmbTipoPersona.SelectedIndex = -1
SQL = "SELECT idMontosEfectivo as clave, descripcion as nombre from cat_MontosEfectivo where activo = 1"
Classcom.sbLlenaComboESP(SQL, Me.cmbMontos, "nombre")
cmbMontos.SelectedIndex = -1
SQL = "SELECT IDINSTRUMENTOMONETARIO as clave, NOMBRE as nombre from CAT_INSTRUMENTOMONETARIO where activo = 1"
Classcom.sbLlenaComboESP(SQL, Me.cmbInsMone, "nombre")
cmbInsMone.SelectedIndex = -1
Me.CMBTipoAlarma.Text = ""
'CMBTipoAlarma.DataSource = Nothing
Me.CMBEstatus.Enabled = False
''LLena combo de cliente
SQL = "SELECT idcliente as clave, rtrim(NOMBREORAZONS) + ' ' + isnull(APATERNO,'') + ' ' + isnull(AMATERNO,'') as nombre from Cliente "
SQL = SQL + " where NOMBREORAZONS is not null and ltrim(rtrim(isnull(NOMBREORAZONS,''))) <> ''"
SQL = SQL + " order by rtrim(NOMBREORAZONS) + ' ' + isnull(APATERNO,'') + ' ' + isnull(AMATERNO,'') "
Classcom.sbLlenaComboESP(SQL, Me.cmbCliente, "Nombre")
Me.cmbCliente.SelectedIndex = -1
Me.cmbCliente.SelectedIndex = -1
Me.cmbCuenta.DataSource = Nothing
Me.cmbCuenta.Items.Clear()
''LLena combo producto
SQL = "sp_ConsultarProducto null,1"
Classcom.sbLlenaCombo(SQL, Me.CMBProducto)
Me.CMBProducto.SelectedIndex = -1
desHeader.Text = Me.Text
End Sub
Private Sub cmbCliente_DropDown(sender As Object, e As System.EventArgs) Handles cmbCliente.DropDown
cmbCuenta.SelectedIndex = -1
End Sub
Private Sub cmbCliente_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCliente.Leave
''Busca la opcion seleccionada en el ComboBox.
'Dim iMiItem As Integer
'iMiItem = cmbCliente.FindString(cmbCliente.Text)
'If iMiItem > -1 Then
' cmbCliente.SelectedIndex = iMiItem
' ''Llena combo de cuenta
' LLenaComboCuenta()
'Else
' cmbCliente.SelectedIndex = -1
' cmbCliente.SelectedIndex = -1
'End If
End Sub
Private Sub CMBProducto_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBProducto.DropDown
'Dim Classcom As New clsComplejo
'Dim SQL As String
'SQL = "SELECT 0 clave, '<Todos> Estadistico Operaciones' nombre"
'SQL = SQL & " UNION "
'SQL = SQL & " SELECT 99 clave, '<Todos> Detalle de Operaciones' nombre"
'SQL = SQL & " UNION "
'SQL = SQL & " SELECT IdProducto as clave, PRODUCTO AS NOMBRE"
''SQL = SQL & " SELECT IdProducto as clave, CASE PRODUCTO WHEN 'TESORERIA' THEN 'DIVISA' ELSE PRODUCTO END aS NOMBRE"
'SQL = SQL & " FROM cat_producto"
'SQL = SQL & " WHERE activo = 1"
'cmbCuenta.DataSource = Nothing
''SQL = "sp_ConsultarProducto null,1"
''Classcom.sbLlenaCombo(SQL, Me.CMBProducto)
'''-- limpia seleccion de subproducto
''CMBSubProducto.DataSource = Nothing
End Sub
Private Sub CMBProducto_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMBProducto.SelectedIndexChanged
End Sub
Private Sub CMBTipoAlarma_DropDown(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Classcom As New clsComplejo
Dim SQL As String
SQL = "SELECT 0 clave, '<Todos> ' nombre"
SQL = SQL & " UNION "
SQL = "SELECT idTipoAlarma as clave ,rtrim(TipoAlarma) as nombre from cat_Tipoalarma where idTipoAlarma <> 4"
Classcom.sbLlenaComboESP(SQL, Me.CMBTipoAlarma, "Nombre")
End Sub
Private Sub CMBTipoAlarma_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub CMBEstatus_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBEstatus.DropDown
Dim Classcom As New clsComplejo
Dim SQL As String
SQL = "SELECT 0 clave, '<Todos> ' nombre"
SQL = SQL & " UNION "
'SQL = "SELECT idestatusTransaccion as clave ,rtrim(EstatusTransaccion) as nombre from cat_EstatusTransaccion order by 1"
SQL = "SELECT IDESTATUSALARMA as clave ,rtrim(ESTATUSALARMA) as nombre from CAT_ESTATUSALARMA order by 1"
Classcom.sbLlenaComboESP(SQL, Me.CMBEstatus, "Nombre")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTLimpiar.Click
'-- Limpia TODOS los filtros (COMBOS)
GrdPrincipal.DataSource = Nothing
cmbCliente.SelectedIndex = -1
cmbCliente.SelectedIndex = -1
CMBProducto.SelectedIndex = -1
CMBTipoAlarma.SelectedIndex = -1
CMBEstatus.SelectedIndex = -1
Me.CMBEstatus.Enabled = False
'GrdPrincipal.SE = -1
CMBGrupo.SelectedIndex = -1
CMBSubProducto.SelectedIndex = -1
''Borra las cuentas
cmbCuenta.DataSource = Nothing
cmbCuenta.SelectedIndex = -1
CMBProducto.SelectedIndex = -1
CMBEstatus.SelectedIndex = -1
cmbMontos.SelectedIndex = -1
cmbMontos.SelectedIndex = -1
cmbTipoPersona.SelectedIndex = -1
cmbTipoPersona.SelectedIndex = -1
cmbInsMone.SelectedIndex = -1
cmbInsMone.SelectedIndex = -1
lblResultados.Text = "Total de Registros "
End Sub
Private Sub BTExportar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTExportar.Click
Dim Classcom As New clsComplejo
'Dim oApp As New Excel.Application()
'Dim m_Excel As New Excel.Application
'm_Excel = New Excel.Application
If GrdPrincipal.DataSource Is Nothing Then
MessageBox.Show("No hay datos para exportar ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
If clsVaribles.strSQLGlobal = "" Then Exit Sub
Classcom.fdtDataSetTabla(clsVaribles.strSQLGlobal)
'GrdPrincipal.SaveLayout( "C:\EXP.XLS")
Try
If Classcom.ds.Tables.Count = 0 Then
MessageBox.Show("Realiza una consulta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
If Classcom.ds.Tables(0).Rows.Count = 0 Then
MessageBox.Show("No hay datos para exportar ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim Resul As DialogResult
Resul = MessageBox.Show("Este proceso puede tardar varios minutos, ¿Deseas continuar? ", "MINDS", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Resul = DialogResult.Yes Then
'Creamos una copia del dataset
Dim copyDS As DataSet = Classcom.ds.Copy()
'Quitamos las siguientes columnas para no exportarlas
'Creo una instancia de la clase aExcel
Dim clsExcel As aExcel = New aExcel
'Obtenemos el nombre o el titulo del form
clsExcel.Titulo = Me.Text
'Utilizo la funcion ExportDataset de la clase aExcel
clsExcel.ExportDataset(copyDS) 'Asigno el dataset a exportar
End If
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub GrdPrincipal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GrdPrincipal.Click
End Sub
Public Function ArmaQuery() As String
Dim Result As String
Dim strsql As String
Dim ClassFrac As New SenteciasSQL.ClassSQL
Dim fila As DataRow
Dim Classcom As New clsComplejo
strsql = "SELECT Producto ,idproducto FROM cat_producto WHERE ACTIVO = 1"
Dim CtlCuenta As String
ClassFrac.fdtDataSet(strsql)
strsql = ""
If ClassFrac.ds.Tables(0).Rows.Count <> 0 Then
For i As Integer = 0 To ClassFrac.ds.Tables(0).Rows.Count - 1
fila = ClassFrac.ds.Tables(0).Rows(i)
strsql = strsql & " select '" & fila("Producto") & "' AS 'PRODUCTO', "
strsql = strsql & " (select count(1) from " & fila("Producto") & " where fecha between CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112) and CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112) "
If cmbCuenta.Text <> "" Then
strsql = strsql & " AND Idcuenta = (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta ='" & Me.cmbCuenta.SelectedValue & "') "
End If
strsql = strsql & " ) as 'Operaciones Cargadas',"
strsql = strsql & " (select isnull(sum(convert(decimal(20,2),montomb)),0) from " & fila("Producto") & " where fecha between CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112) and CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112)"
If cmbCuenta.Text <> "" Then
strsql = strsql & " AND Idcuenta = (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta ='" & Me.cmbCuenta.SelectedValue & "') "
End If
strsql = strsql & " ) as 'total Monto Op. Cargadas',"
strsql = strsql & " count(1) 'Numero de Operaciones Alarmadas',isnull(sum(convert(decimal(20,2),montomb)),0) 'Total Monto Op. Alarmadas' "
strsql = strsql & " ,count( CASE t.idalarma WHEN 1 THEN t.idalarma END ) Relevantes"
strsql = strsql & " ,count( CASE t.idalarma WHEN 2 THEN t.idalarma END ) Inusuales"
strsql = strsql & " ,count( CASE t.idalarma WHEN 3 THEN t.idalarma END ) Preocupantes"
strsql = strsql & " ,count( CASE t.idalarma WHEN 3 THEN t.idalarma END ) Fraccionadas"
strsql = strsql & " from " & fila("Producto") & " p"
strsql = strsql & " inner join transaccionreporte t on t.idTransaccion = p.idTransaccion and idproducto = " & fila("idproducto")
strsql = strsql & " AND t.Nota <> 'DECREMENTO SU OPERATIVIDAD' "
'modificado por jtc If CMBTipoAlarma.SelectedIndex <> -1 Then
' strsql = strsql & " and idalarma =" & CMBTipoAlarma.SelectedValue
'End If
strsql = strsql & " and p.fecha between CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112) and CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112)"
'-- selecciona solo las cuentas del grupo o solo la cuenta
If CMBGrupo.Text <> "" Then
Label7.Text = "Reporte de Transacciones, Estadistico de Operaciones por Grupo y/o Cuenta"
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
strsql = strsql & " AND P.Idcuenta = (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta ='" & Me.cmbCuenta.SelectedValue & "') "
Else
strsql = strsql & " AND P.Idcuenta in (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta IN "
strsql = strsql & "(select noCuenta from CuentaAsociada where idgrupo = '" & RTrim(CMBGrupo.Text) & "')) "
End If
Else
Label7.Text = "Reporte de Transacciones, Estadistico de Operaciones por Grupo y/o Cuenta"
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
strsql = strsql & " AND P.Idcuenta = (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta ='" & Me.cmbCuenta.SelectedValue & "') "
End If
End If
strsql = strsql & " union"
Next i
End If
Result = Mid(strsql, 1, Len(strsql) - 5)
Return Result
End Function
Private Sub CMBSubProducto_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBSubProducto.DropDown
'-- llena combo de subproductos
Dim Classcom As New clsComplejo
Dim SQL As String
If CMBProducto.Text <> "" Then
SQL = "SELECT 0 clave, '<Todos> ' nombre"
SQL = SQL & " UNION "
SQL = SQL & " SELECT IdSubProducto as clave, rtrim(SubProducto) as nombre"
SQL = SQL & " FROM cat_SubProducto"
SQL = SQL & " WHERE activo = 1 "
SQL = SQL & " AND idProducto = " & CMBProducto.SelectedValue
Classcom.sbLlenaComboESP(SQL, Me.CMBSubProducto, "Nombre")
End If
End Sub
Private Sub CMBGrupo_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBGrupo.DropDown
Dim Classcom As New clsComplejo
Dim SQL As String
cmbCliente.DataSource = Nothing
cmbCuenta.DataSource = Nothing
'-- carga combo de grupos
Sql = "SELECT id clave ,rtrim(idGrupo) nombre from CuentaAsociadaGrupo where activo = 1"
Classcom.sbLlenaComboESP(SQL, Me.CMBGrupo, "Nombre")
End Sub
Public Function ArmaQueryTodos() As String
Dim Result As String
Dim strsql, Sql As String
Dim ClassFrac As New SenteciasSQL.ClassSQL
Dim fila As DataRow
Dim Classcom As New clsComplejo
strsql = "SELECT Producto ,idproducto FROM cat_producto WHERE ACTIVO = 1"
Dim CtlCuenta As String
ClassFrac.fdtDataSet(strsql)
Sql = ""
If ClassFrac.ds.Tables(0).Rows.Count <> 0 Then
For i As Integer = 0 To ClassFrac.ds.Tables(0).Rows.Count - 1
fila = ClassFrac.ds.Tables(0).Rows(i)
If CMBProducto.Text <> "" And Me.CMBEstatus.Text = "" And Me.CMBTipoAlarma.Text = "" And Me.cmbCliente.Text = "" Then
Label7.Text = "Reporte de Transacciones de TODOS los productos"
Sql = Sql & " SELECT "
Sql = Sql & " cl.nombre + ' ' + isnull(cl.ApellidoPaterno,'') + ' ' + isnull(cl.ApellidoMaterno,'') as 'Nombre Cliente'"
Sql = Sql & " ,cta.numCuenta as 'Numero Cuenta'"
Sql = Sql & " ,cl.IdCliente as 'No. Cliente MINDS', "
Sql = Sql & "'" & fila("Producto") & "'" & " as 'Producto',"
Sql = Sql & " (SELECT subproducto FROM cat_subproducto WHERE idproducto = " & CMBProducto.SelectedValue & " and alias = p.IdSubProducto) 'SubProducto' "
Sql = Sql & " ,p.IdTransaccion,p.idCuenta,p.IdSubProducto,p.Fecha,p.NumeroReferencia,p.IdTipoOperacion, "
Sql = Sql & " p.IdMoneda,p.IDInstrumentoMonetario,p.Monto,p.MontoMB, "
If fila("Producto") = "BANCATRADICIONAL" Then
Sql = Sql & " CONVERT(TIME, p.Hora , 108) as Hora "
Else
Sql = Sql & " p.Hora "
End If
Sql = Sql & " FROM " & fila("Producto") & " P "
Sql = Sql & " INNER JOIN cuenta cta ON cta.idcuenta = p.idcuenta "
Sql = Sql & " INNER JOIN cliente cl ON cl.idcliente = cta.idcliente"
Sql = Sql & " WHERE"
Sql = Sql & " P.FECHA >= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112)"
Sql = Sql & " AND P.FECHA <= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112)"
'-- selecciona solo las cuentas del grupo o solo la cuenta
If CMBGrupo.Text <> "" Then
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND P.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
Else
Label7.Text = "Reporte de Transacciones de TODOS los productos del grupo: " & CMBGrupo.Text
Sql = Sql & " AND P.Idcuenta in (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta IN "
Sql = Sql & " (select noCuenta from CuentaAsociada where idgrupo = '" & RTrim(CMBGrupo.Text) & "')) "
End If
Else
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND P.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
End If
End If
Sql = Sql & " union"
ElseIf CMBProducto.Text <> "" And Me.CMBEstatus.Text = "" And Me.CMBTipoAlarma.Text = "" And Me.cmbCliente.Text <> "" Then
Label7.Text = "Reporte de TODAS las Transacciones"
Sql = Sql & " SELECT "
Sql = Sql & " c.nombre + ' ' + isnull(c.ApellidoPaterno,'') + ' ' + isnull(c.ApellidoMaterno,'') as 'Nombre Cliente'"
Sql = Sql & " ,cta.numCuenta as 'Numero Cuenta'"
Sql = Sql & " ,c.IdCliente as 'No. Cliente MINDS', "
Sql = Sql & "'" & fila("Producto") & "'" & " as 'Producto',"
Sql = Sql & " (SELECT subproducto FROM cat_subproducto WHERE idproducto = " & CMBProducto.SelectedValue & " and alias = p.IdSubProducto) 'SubProducto' "
Sql = Sql & " ,p.IdTransaccion,p.idCuenta,p.IdSubProducto,p.Fecha,p.NumeroReferencia,p.IdTipoOperacion, "
Sql = Sql & " p.IdMoneda,p.IDInstrumentoMonetario,p.Monto,p.MontoMB, "
If fila("Producto") = "BANCATRADICIONAL" Then
Sql = Sql & " CONVERT(TIME, p.Hora , 108) as Hora "
Else
Sql = Sql & " p.Hora "
End If
Sql = Sql & " FROM " & fila("Producto") & " P "
Sql = Sql & " INNER JOIN CUENTA CTA ON CTA.IDCUENTA = P.IDCUENTA"
Sql = Sql & " INNER JOIN CLIENTE C ON C.IDCLIENTE = CTA.IDCLIENTE"
Sql = Sql & " WHERE P.FECHA >= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112) AND P.FECHA <= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112) "
Sql = Sql & " AND C.IDCLIENTE = " & Me.cmbCliente.SelectedValue
'-- selecciona solo las cuentas del grupo o solo la cuenta
If CMBGrupo.Text <> "" Then
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND P.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
Else
Label7.Text = "Reporte de TODAS las Transacciones del grupo: " & CMBGrupo.Text
Sql = Sql & " AND P.Idcuenta in (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta IN "
Sql = Sql & "(select noCuenta from CuentaAsociada where idgrupo = '" & RTrim(CMBGrupo.Text) & "')) "
End If
Else
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND P.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
End If
End If
Sql = Sql & " union"
ElseIf Me.CMBEstatus.Text <> "" Or Me.CMBTipoAlarma.Text <> "" Then
Label7.Text = "Reporte de Transacciones"
Sql = Sql & " SELECT "
Sql = Sql & " cl.nombre + ' ' + isnull(cl.ApellidoPaterno,'') + ' ' + isnull(cl.ApellidoMaterno,'') as 'Nombre Cliente', "
Sql = Sql & " p.idproducto, p.producto 'Producto',"
Sql = Sql & " (SELECT subproducto FROM cat_subproducto WHERE idproducto = p.idproducto and alias = tr.idsubproducto) 'SubProducto',"
Sql = Sql & " CONVERT(DATE, PROD.fecha, 103) as 'Fecha', "
Sql = Sql & " PROD.numeroreferencia 'Numero Referencia',"
Sql = Sql & " PROD.idTransaccion 'Num.transacción',"
Sql = Sql & " cta.numCuenta 'Cuenta',"
Sql = Sql & " (SELECT TipoOperacion FROM cat_tipoOperacion WHERE idtipooperacion = prod.idtipooperacion) 'Tipo Operacion',"
Sql = Sql & " PROD.MONTOmb 'Monto',"
Sql = Sql & " (SELECT Moneda FROM cat_moneda WHERE idmoneda = prod.idmoneda) 'Divisa',"
Sql = Sql & " (SELECT Patron FROM patron WHERE idpatron = tr.idpatron) 'Reportado Por',"
Sql = Sql & " (SELECT EstatusTransaccion FROM Cat_EstatusTransaccion WHERE idEstatusTransaccion = tr.idestatustransaccion) 'Estatus',"
Sql = Sql & " prod.idtransaccion 'Numero Minds',"
Sql = Sql & " TR.razon 'Razon', "
Sql = Sql & " isnull(tr.idFuncCierre,'') as 'Funcionario Cierre', "
Sql = Sql & " isnull(tr.dtfcerrado,'') as 'Fecha Cierre' "
Sql = Sql & " FROM "
Sql = Sql & " Transaccionreporte tr"
Sql = Sql & " INNER JOIN " & fila("Producto") & " Prod ON TR.IDTRANSACCION = PROD.IDTRANSACCION"
Sql = Sql & " INNER JOIN cat_producto p ON p.idproducto = tr.idproducto"
Sql = Sql & " INNER JOIN cuenta cta ON cta.idcuenta = prod.idcuenta "
Sql = Sql & " INNER JOIN cliente cl ON cl.idcliente = cta.idcliente"
Sql = Sql & " where PROD.FECHA >= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaInicio.Value.Date, "yyyymmdd") & "',112)"
Sql = Sql & " AND PROD.FECHA <= CONVERT(DATETIME,'" & Classcom.ObtenFecha(Me.dtpFechaFin.Value.Date, "yyyymmdd") & "',112)"
Sql = Sql & " AND tr.Nota <> 'DECREMENTO SU OPERATIVIDAD'"
Sql = Sql & " AND tr.Nota <> 'DECREMENTO SU OPERATIVIDAD'"
If CMBProducto.Text <> "" Then
Sql = Sql & " AND TR.IDPRODUCTO = " & fila("idProducto")
End If
If Me.CMBEstatus.Text <> "" Then
Sql = Sql & " AND TR.IDESTATUSTRANSACCION = " & CMBEstatus.SelectedValue
End If
If Me.CMBTipoAlarma.Text <> "" Then
Sql = Sql & " AND TR.IDalarma = " & Me.CMBTipoAlarma.SelectedValue
End If
If Me.cmbCliente.Text <> "" Then
Sql = Sql & " AND CL.IDCLIENTE = " & Me.cmbCliente.SelectedValue
End If
'-- selecciona solo las cuentas del grupo o solo la cuenta
If CMBGrupo.Text <> "" Then
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND PROD.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
Else
Label7.Text = "Reporte de Transacciones del grupo: " & CMBGrupo.Text
Sql = Sql & " AND PROD.Idcuenta in (SELECT IdCuenta FROM Cuenta WHERE NumeroCuenta IN "
Sql = Sql & "(select noCuenta from CuentaAsociada where idgrupo = '" & RTrim(CMBGrupo.Text) & "')) "
End If
Else
'-- valida con respecto num cuenta
If cmbCuenta.Text <> "" Then
Sql = Sql & " AND PROD.Idcuenta = " & Me.cmbCuenta.SelectedValue & " "
End If
End If
Sql = Sql & " union"
End If
Next i
End If
'-- regresa el valor obtenido del sql
Result = Mid(Sql, 1, Len(Sql) - 5)
Return Result
End Function
Private Sub btnCerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCerrar.Click
Me.Close()
End Sub
Private Sub cmbCuenta_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles cmbCuenta.KeyPress
If ValidaTexto.Istext(e.KeyChar) = True Then
''e.Handled = True
If cmbCliente.SelectedValue Is Nothing Then
MessageBox.Show("Seleccione primero un cliente.", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub
'Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
'End Sub
Private Sub CMBTipoAlarma_SelectedIndexChanged_1(sender As System.Object, e As System.EventArgs) Handles CMBTipoAlarma.SelectedIndexChanged
If CMBTipoAlarma.SelectedIndex = -1 Then
CMBEstatus.Enabled = False
Else
CMBEstatus.Enabled = True
End If
End Sub
Private Sub CMBGrupo_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles CMBGrupo.SelectedIndexChanged
Dim Classcom As New clsComplejo
Dim SQL As String
Sql = "SELECT idcliente as clave, rtrim(Nombre) + ' ' + isnull(ApellidoPaterno,'') + ' ' + isnull(ApellidoMaterno,'') as nombre from Cliente"
Sql = Sql + " where nombre is not null and ltrim(rtrim(isnull(nombre,''))) <> ''"
SQL = SQL + " and idcliente in (select idcliente from CuentaAsociada where idgrupo = '" & RTrim(CMBGrupo.SelectedValue) & "') "
Sql = Sql + " order by ltrim(rtrim(nombre))"
Classcom.sbLlenaComboESP(Sql, Me.cmbCliente, "Nombre")
Me.cmbCuenta.DataSource = Nothing
Me.cmbCuenta.Items.Clear()
End Sub
Private Sub LLenaComboCuenta()
Dim Classcom As New clsComplejo
Dim SQL As String
''If Not IsNothing(cmbCliente.SelectedValue) Then
'If CMBProducto.Text = "" Then
' MessageBox.Show("Seleccione un Producto", "Minds Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information)
' CMBProducto.Focus()
' Exit Sub
'End If
If cmbCliente.SelectedIndex > -1 Then
'jtc SQL = "SELECT NumeroCuenta as clave,NumeroCuenta as nombre from cuenta where idcliente = " & cmbCliente.SelectedValue
'SQL = "SELECT idCuenta as clave,NOCUENTA as nombre from cuenta where idcliente = " & cmbCliente.SelectedValue.ToString()
'SQL = "sp_ConsultarCtaXProducto " & cmbCliente.SelectedValue & ",'" & CMBProducto.Text.Replace(" ", "") & "'"
SQL = "sp_S_ConsultarCtas " & cmbCliente.SelectedValue
Classcom.sbLlenaCombo(SQL, Me.cmbCuenta)
Me.cmbCuenta.SelectedIndex = -1
Me.cmbCuenta.SelectedIndex = -1
Else
MsgBox("Seleccione un Cliente", MsgBoxStyle.Information)
End If
End Sub
'Private Sub cmbCliente_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCliente.SelectedIndexChanged
' Dim Classcom As New clsComplejo
' Dim SQL As String
' ''If Not IsNothing(cmbCliente.SelectedValue) Then
' If cmbCliente.SelectedIndex > -1 Then
' 'jtc SQL = "SELECT NumeroCuenta as clave,NumeroCuenta as nombre from cuenta where idcliente = " & cmbCliente.SelectedValue
' SQL = "SELECT idCuenta as clave,numcuenta as nombre from cuenta where idcliente = " & cmbCliente.SelectedValue.ToString()
' Classcom.sbLlenaComboESP(SQL, Me.cmbCuenta, "Nombre")
' Me.cmbCuenta.SelectedIndex = -1
' Me.cmbCuenta.SelectedIndex = -1
' End If
'End Sub
Private Sub cmbCliente_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbCliente.SelectedIndexChanged
End Sub
Private Sub cmbCuenta_DropDown(sender As System.Object, e As System.EventArgs) Handles cmbCuenta.DropDown
If cmbCliente.SelectedValue <> Nothing Then
LLenaComboCuenta()
End If
End Sub
Private Sub cmbCuenta_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbCuenta.SelectedIndexChanged
End Sub
Private Sub panel2_Paint(sender As Object, e As PaintEventArgs) Handles panel2.Paint
End Sub
End Class