162 lines
7.2 KiB
VB.net
162 lines
7.2 KiB
VB.net
|
Public Class FrmUmbral
|
|||
|
Private Sub FrmUmbral_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|||
|
Dim Cliente As clsComplejo = New clsComplejo 'para llenar combo cliente
|
|||
|
CLIENTE.sbLlenaCombo("spLlenaComboCliente " & clsVaribles.liPerfilB, Me.cmbCliente) ' ClsVaribles
|
|||
|
cmbCliente.SelectedIndex = -1
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BTEjecutar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTEjecutar.Click
|
|||
|
Dim Classcom As New clsComplejo
|
|||
|
Dim SQL As String
|
|||
|
Try
|
|||
|
''Exec spSReporteUmbrales 2014, 01, 2014,8, 1005270
|
|||
|
'SQL = "spSReporteUmbrales " & DTPInicial.Value.Year.ToString() & ", " & DTPInicial.Value.Month.ToString() & ", " & DTPFinal.Value.Year.ToString() & ", " & DTPFinal.Value.Month.ToString()
|
|||
|
|
|||
|
SQL = "sp_ReporteUmbrales " & IIf(cmbCliente.SelectedValue <> Nothing, cmbCliente.SelectedValue, "NULL")
|
|||
|
SQL = SQL & "," & DTPInicial.Value.ToString("yyyy")
|
|||
|
SQL = SQL & "," & DTPInicial.Value.ToString("MM")
|
|||
|
SQL = SQL & "," & DTPFinal.Value.ToString("yyyy")
|
|||
|
SQL = SQL & "," & DTPFinal.Value.ToString("MM")
|
|||
|
|
|||
|
'If cmbCliente.SelectedIndex = -1 Then
|
|||
|
' SQL = SQL & ", NULL"
|
|||
|
'Else
|
|||
|
' SQL = SQL & ", " & cmbCliente.SelectedValue
|
|||
|
'End If
|
|||
|
|
|||
|
Classcom.fdtDataSetTabla(SQL)
|
|||
|
|
|||
|
Me.GRDMasterRep.SetDataBinding(Classcom.ds, "Tabla")
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(0).Width = 80
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(1).Width = 50
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(2).Width = 50
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(3).Width = 150
|
|||
|
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(9).Visible = False
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(10).Visible = False
|
|||
|
Me.GRDMasterRep.Splits(0).DisplayColumns(11).Visible = False
|
|||
|
|
|||
|
|
|||
|
' cambiar
|
|||
|
'Me.GRDMasterRep.Columns(4).NumberFormat = "Currency"
|
|||
|
'Me.GRDMasterRep.Columns(7).NumberFormat = "###,###,##0.00"
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(8).Width = 70
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(9).Width = 80
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(10).Width = 250
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(11).Width = 70
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(12).Width = 110
|
|||
|
|
|||
|
' ''Aplica Color Rojo
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(8).FetchStyle = True
|
|||
|
'Me.GRDMasterRep.Splits(0).DisplayColumns(9).FetchStyle = True
|
|||
|
|
|||
|
clsVaribles.strSQL = SQL
|
|||
|
LblNumReg.Text = "Elementos: " & Me.GRDMasterRep.RowCount
|
|||
|
GRDMasterRep.Visible = True
|
|||
|
|
|||
|
''Auditoria
|
|||
|
Dim ClassAud As New ClassMyUtils
|
|||
|
Dim sTextoAud As String
|
|||
|
sTextoAud = "Reporte de Umbrales, mes y año inicial: " & DTPInicial.Value.ToString("MMMM/yyyy") & ", mes y año final: " & DTPFinal.Value.ToString("MMMM/yyyy")
|
|||
|
If cmbCliente.SelectedIndex = -1 Then
|
|||
|
sTextoAud = sTextoAud & ". Todos los clientes."
|
|||
|
Else
|
|||
|
sTextoAud = sTextoAud & ", Cliente: " & cmbCliente.SelectedValue
|
|||
|
End If
|
|||
|
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 118, 1, sTextoAud)
|
|||
|
''Fin de auditoria
|
|||
|
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
End Try
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
Private Sub BTExportar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTExportar.Click
|
|||
|
Dim Clcmp As New clsComplejo
|
|||
|
|
|||
|
Try
|
|||
|
|
|||
|
Clcmp.fdtDataSetTabla(clsVaribles.strSQL)
|
|||
|
|
|||
|
If Clcmp.ds.Tables.Count = 0 Then
|
|||
|
MessageBox.Show("Realiza una consulta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|||
|
Else
|
|||
|
If Clcmp.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 = Clcmp.ds.Copy()
|
|||
|
'Quitamos las siguientes columnas para no exportarlas
|
|||
|
|
|||
|
'copyDS.Tables(0).Columns.Remove("Id_Transaccion")
|
|||
|
'copyDS.Tables(0).Columns.Remove("Id_Producto")
|
|||
|
|
|||
|
'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 BTSalir_Click(sender As System.Object, e As System.EventArgs) Handles BTSalir.Click
|
|||
|
Me.Close()
|
|||
|
End Sub
|
|||
|
|
|||
|
'Private Sub GRDMasterRep_FetchCellStyle(sender As System.Object, e As C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs)
|
|||
|
|
|||
|
' ''Si se cumple que el umbral sea mayor > que NivelCuenta entonces se coloca en rojo la celda o el renglon
|
|||
|
' ''Columna umbral 8; Columna NivelCuenta 9
|
|||
|
' Dim ValorUmbral As Integer = Me.GRDMasterRep(e.Row, 8)
|
|||
|
' Dim ValorNivCta As Integer = Me.GRDMasterRep(e.Row, 9)
|
|||
|
|
|||
|
' If ValorUmbral > ValorNivCta Then
|
|||
|
' e.CellStyle.BackColor = System.Drawing.Color.Red
|
|||
|
' e.CellStyle.ForeColor = System.Drawing.Color.Black
|
|||
|
' End If
|
|||
|
|
|||
|
'End Sub
|
|||
|
|
|||
|
|
|||
|
Private Sub GRDMasterRep_FetchCellStyle(sender As System.Object, e As C1.Win.C1TrueDBGrid.FetchCellStyleEventArgs) Handles GRDMasterRep.FetchCellStyle
|
|||
|
Try
|
|||
|
''Si se cumple que el umbral sea mayor > que NivelCuenta entonces se coloca en rojo la celda o el renglon
|
|||
|
''Columna umbral 8; Columna NivelCuenta 9
|
|||
|
Dim ValorUmbral As Integer
|
|||
|
Dim ValorNivCta As Integer
|
|||
|
|
|||
|
If Me.GRDMasterRep(e.Row, 8) Is DBNull.Value Then
|
|||
|
ValorUmbral = 0
|
|||
|
Else
|
|||
|
ValorUmbral = Me.GRDMasterRep(e.Row, 8)
|
|||
|
End If
|
|||
|
|
|||
|
If Me.GRDMasterRep(e.Row, 9) Is DBNull.Value Then
|
|||
|
ValorNivCta = 0
|
|||
|
Else
|
|||
|
ValorNivCta = Me.GRDMasterRep(e.Row, 9)
|
|||
|
End If
|
|||
|
|
|||
|
If ValorUmbral > ValorNivCta Then
|
|||
|
e.CellStyle.BackColor = System.Drawing.Color.Red
|
|||
|
e.CellStyle.ForeColor = System.Drawing.Color.Black
|
|||
|
End If
|
|||
|
Catch ex As Exception
|
|||
|
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|||
|
End Try
|
|||
|
|
|||
|
End Sub
|
|||
|
|
|||
|
|
|||
|
End Class
|