client/Reportes/frmEBR.vb

381 lines
16 KiB
VB.net
Raw Normal View History

2020-01-20 18:14:59 -06:00
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Windows.Forms.DataVisualization.Charting
Imports System.ComponentModel
Imports System.Drawing.Imaging
Public Class frmEBR
Private dtN As DataTable
Private dtE As DataTable
Private dtO As DataTable
Private Sub frmEBR_Load(sender As Object, e As EventArgs) Handles Me.Load
GenerarEBR("0")
CargaCombos()
CargarEBR()
Dim ClassAud As New ClassMyUtils
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 86, 1, "Entrando EBR")
End Sub
Private Sub GenerarEBR(opc As String)
Dim Classcom As New clsComplejo
Dim SQL As String = String.Empty
SQL = "SP_EBR " & opc
Classcom.sbInserta(SQL)
End Sub
Private Sub CargarEBR()
Try
Dim Classcom As New clsComplejo
Dim ClassCatalogos As New ClassCatalogos
Dim SQL As String = String.Empty
Dim idInherent As Integer
Dim idConrolEfeect As Integer
SQL = "SP_EBR_CONSULTA"
Dim dsGral As DataSet = Classcom.fdtDataSet(SQL)
p1.Text = dsGral.Tables(0).Rows(0)(0)
r1.Text = dsGral.Tables(0).Rows(0)(1)
rg1.Text = "Riesgo " & dsGral.Tables(0).Rows(0)(1)
v1.Text = dsGral.Tables(0).Rows(0)(2)
p2.Text = dsGral.Tables(0).Rows(1)(0)
r2.Text = dsGral.Tables(0).Rows(1)(1)
rg2.Text = "Riesgo " & dsGral.Tables(0).Rows(1)(1)
v2.Text = dsGral.Tables(0).Rows(1)(2)
p3.Text = dsGral.Tables(0).Rows(2)(0)
r3.Text = dsGral.Tables(0).Rows(2)(1)
rg3.Text = "Riesgo " & dsGral.Tables(0).Rows(2)(1)
v3.Text = dsGral.Tables(0).Rows(2)(2)
p4.Text = dsGral.Tables(0).Rows(3)(0)
r4.Text = dsGral.Tables(0).Rows(3)(1)
rg4.Text = "Riesgo " & dsGral.Tables(0).Rows(3)(1)
v4.Text = dsGral.Tables(0).Rows(3)(2)
p5.Text = dsGral.Tables(0).Rows(4)(0)
r5.Text = dsGral.Tables(0).Rows(4)(1)
rg5.Text = "Riesgo " & dsGral.Tables(0).Rows(4)(1)
v5.Text = dsGral.Tables(0).Rows(4)(2)
p6.Text = dsGral.Tables(0).Rows(5)(0)
r6.Text = dsGral.Tables(0).Rows(5)(1)
rg6.Text = "Riesgo " & dsGral.Tables(0).Rows(5)(1)
v6.Text = dsGral.Tables(0).Rows(5)(2)
Riesgo.Text = dsGral.Tables(1).Rows(0)(0)
Riesgo2.Text = dsGral.Tables(1).Rows(0)(2)
Label91.Text = dsGral.Tables(1).Rows(0)(2)
Label60.Text = dsGral.Tables(1).Rows(0)(0)
idInherent = dsGral.Tables(1).Rows(0)(1)
Chart1.Series.Clear()
Chart1.Series.Add("Grado de Riesgo")
Chart1.Series(0).IsValueShownAsLabel = True
Chart1.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(0))
Chart1.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(1))
Chart1.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(2))
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
Chart2.Series.Clear()
Chart2.Series.Add("Tipo de Cliente")
Chart2.Series(0).IsValueShownAsLabel = True
Chart2.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(3))
Chart2.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(4))
Chart2.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(5))
Chart2.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
Chart3.Series.Clear()
Chart3.Series.Add("PEP")
Chart3.Series(0).IsValueShownAsLabel = True
Chart3.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(7))
'Chart3.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(4))
Chart3.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(6))
Chart3.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
Chart4.Series.Clear()
Chart4.Series.Add("Servicio de inversión Asesorado y No Asesorado")
Chart4.Series(0).IsValueShownAsLabel = True
Chart4.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(9))
'Chart4.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(9))
Chart4.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(8))
Chart4.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
Chart5.Series.Clear()
Chart5.Series.Add("Domicilio Principal")
Chart5.Series(0).IsValueShownAsLabel = True
Chart5.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(10))
Chart5.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(11))
Chart5.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(12))
Chart5.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
Chart6.Series.Clear()
Chart6.Series.Add("Principal lugar de operación")
Chart6.Series(0).IsValueShownAsLabel = True
Chart6.Series(0).Points.AddXY("Bajo", dsGral.Tables(2).Rows(0)(13))
Chart6.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(14))
Chart6.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(15))
Chart6.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
C1TrueDBGrid1.SetDataBinding(dsGral.Tables(3), "")
Chart7.Series.Clear()
Chart7.Series.Add("Historico")
Chart7.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Area
Chart7.ChartAreas(0).AxisY.Maximum = 3
For Each dr As DataRow In dsGral.Tables(3).Rows
Chart7.Series(0).Points.AddXY(dr("MES-AÑO").ToString, Convert.ToInt16(dr("IDRISK")))
Next
Chart8.Series.Clear()
Chart8.Series.Add("Canales de envío")
Chart8.Series(0).IsValueShownAsLabel = True
Chart8.Series(0).Points.AddXY("Bajo", 100)
'Chart8.Series(0).Points.AddXY("Medio", dsGral.Tables(2).Rows(0)(14))
'Chart8.Series(0).Points.AddXY("Alto", dsGral.Tables(2).Rows(0)(15))
Chart8.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Doughnut
cmbAML.SelectedValue = dsGral.Tables(4).Rows(0)("ID_CE_SCALE")
ComboBox1.SelectedValue = dsGral.Tables(4).Rows(1)("ID_CE_SCALE")
ComboBox2.SelectedValue = dsGral.Tables(4).Rows(2)("ID_CE_SCALE")
ComboBox3.SelectedValue = dsGral.Tables(4).Rows(3)("ID_CE_SCALE")
ComboBox4.SelectedValue = dsGral.Tables(4).Rows(4)("ID_CE_SCALE")
ComboBox5.SelectedValue = dsGral.Tables(4).Rows(5)("ID_CE_SCALE")
ComboBox6.SelectedValue = dsGral.Tables(4).Rows(6)("ID_CE_SCALE")
CheckBox1.Checked = IIf(dsGral.Tables(4).Rows(7)("VALUE") = "50", True, False)
txtAML.Text = dsGral.Tables(4).Rows(0)("TXT_CE")
TextBox1.Text = dsGral.Tables(4).Rows(1)("TXT_CE")
TextBox2.Text = dsGral.Tables(4).Rows(2)("TXT_CE")
TextBox3.Text = dsGral.Tables(4).Rows(3)("TXT_CE")
TextBox4.Text = dsGral.Tables(4).Rows(4)("TXT_CE")
TextBox5.Text = dsGral.Tables(4).Rows(5)("TXT_CE")
TextBox6.Text = dsGral.Tables(4).Rows(6)("TXT_CE")
Label58.Text = dsGral.Tables(5).Rows(0)("SUBTOTAL")
Label57.Text = dsGral.Tables(5).Rows(0)("DESCRIPCION")
Label95.Text = dsGral.Tables(5).Rows(0)("TOTAL")
Label94.Text = dsGral.Tables(5).Rows(0)("DESCRIPCIONt")
Label92.Text = dsGral.Tables(5).Rows(0)("DESCRIPCIONt")
Label59.Text = dsGral.Tables(5).Rows(0)("TOTAL")
idConrolEfeect = dsGral.Tables(5).Rows(0)("ID_SCALE_TOTAL")
If idConrolEfeect = 1 And idInherent = 1 Then
Button4.Location = Panel5.Location
Label93.Text = "Bajo"
ElseIf idConrolEfeect = 2 And idInherent = 1 Then
Button4.Location = Panel6.Location
Label93.Text = "Bajo"
ElseIf idConrolEfeect = 3 And idInherent = 1 Then
Button4.Location = Panel9.Location
Label93.Text = "Medio"
ElseIf idConrolEfeect = 1 And idInherent = 2 Then
Button4.Location = Panel7.Location
Label93.Text = "Bajo"
ElseIf idConrolEfeect = 2 And idInherent = 2 Then
Button4.Location = Panel8.Location
Label93.Text = "Medio"
ElseIf idConrolEfeect = 3 And idInherent = 2 Then
Button4.Location = Panel11.Location
Label93.Text = "Alto"
ElseIf idConrolEfeect = 1 And idInherent = 3 Then
Button4.Location = Panel10.Location
Label93.Text = "Medio"
ElseIf idConrolEfeect = 2 And idInherent = 3 Then
Button4.Location = Panel12.Location
Label93.Text = "Alto"
ElseIf idConrolEfeect = 3 And idInherent = 3 Then
Button4.Location = Panel13.Location
Label93.Text = "Alto"
End If
Label28.Text = dsGral.Tables(6).Rows(0)(0)
Label34.Text = dsGral.Tables(6).Rows(1)(0)
Label35.Text = dsGral.Tables(6).Rows(2)(0)
Label31.Text = dsGral.Tables(7).Rows(0)(0)
Label37.Text = dsGral.Tables(7).Rows(1)(0)
Label38.Text = dsGral.Tables(7).Rows(2)(0)
Label40.Text = dsGral.Tables(8).Rows(0)(0)
Label32.Text = dsGral.Tables(9).Rows(0)(0)
Label41.Text = dsGral.Tables(9).Rows(1)(0)
Label43.Text = dsGral.Tables(9).Rows(2)(0)
Label44.Text = dsGral.Tables(9).Rows(3)(0)
Label45.Text = dsGral.Tables(9).Rows(4)(0)
Label47.Text = "Domicilios Nacionales: " & dsGral.Tables(10).Rows(0)(0)
dtN = dsGral.Tables(11)
Label48.Text = "Domicilios Extranjeros: " & dsGral.Tables(12).Rows(0)(0)
dtE = dsGral.Tables(13)
Label33.Text = "Lugares de Operacion: " & dsGral.Tables(14).Rows(0)(0)
dtO = dsGral.Tables(15)
Label96.Text = dsGral.Tables(16).Rows(0)(0)
Label97.Text = dsGral.Tables(16).Rows(0)(0)
Label100.Text = dsGral.Tables(16).Rows(0)(0)
Label101.Text = dsGral.Tables(17).Rows(0)(0)
Label21.Text = dsGral.Tables(18).Rows(0)(0)
Label22.Text = dsGral.Tables(18).Rows(1)(0)
Label23.Text = dsGral.Tables(18).Rows(2)(0)
Label24.Text = dsGral.Tables(18).Rows(3)(0)
Label25.Text = dsGral.Tables(18).Rows(4)(0)
Label26.Text = dsGral.Tables(18).Rows(5)(0)
Label27.Text = dsGral.Tables(18).Rows(6)(0)
colorLabel(Me)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Public Sub colorLabel(ByRef MainParent As Control)
If Not MainParent.HasChildren Then Exit Sub
For Each x As Control In MainParent.Controls()
If x.HasChildren Then colorLabel(x)
Select Case True
Case TypeOf x Is Label
If x.Text.Contains("Bajo") And IsNothing(x.Tag) Then
x.ForeColor = Color.Green
ElseIf x.Text.Contains("Medio") And IsNothing(x.Tag) Then
x.ForeColor = Color.Orange
ElseIf x.Text.Contains("Alto") And IsNothing(x.Tag) Then
x.ForeColor = Color.Red
End If
End Select
Next
End Sub
Private Sub BtnConsul_Click(sender As Object, e As EventArgs) Handles BtnConsul.Click
Me.Cursor = Cursors.WaitCursor
GenerarEBR("1")
CargarEBR()
Me.Cursor = Cursors.Default
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Close()
End Sub
Private Sub Chart5_Click(sender As Object, e As EventArgs) Handles Chart5.Click
End Sub
Private Sub CargaCombos()
Dim cls As New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.cmbAML)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox1)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox2)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox3)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox4)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox5)
cls = New clsComplejo
cls.sbLlenaCombo("SELECT DESCRIPCION nombre, ID clave FROM EBR_CAT_CE_SCALE", Me.ComboBox6)
cmbAML.SelectedIndex = 0
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
ComboBox3.SelectedIndex = 0
ComboBox4.SelectedIndex = 0
ComboBox5.SelectedIndex = 0
ComboBox6.SelectedIndex = 0
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
GuardarMitigantes()
End Sub
Private Sub GuardarMitigantes()
Dim cls As New clsComplejo
Dim SSQL As String = cmbAML.SelectedValue.ToString() & ",'" & txtAML.Text & "',"
SSQL += ComboBox1.SelectedValue.ToString() & ",'" & TextBox1.Text & "',"
SSQL += ComboBox2.SelectedValue.ToString() & ",'" & TextBox2.Text & "',"
SSQL += ComboBox3.SelectedValue.ToString() & ",'" & TextBox3.Text & "',"
SSQL += ComboBox4.SelectedValue.ToString() & ",'" & TextBox4.Text & "',"
SSQL += ComboBox5.SelectedValue.ToString() & ",'" & TextBox5.Text & "',"
SSQL += ComboBox6.SelectedValue.ToString() & ",'" & TextBox6.Text & "',"
SSQL += Convert.ToInt16(CheckBox1.Checked) & ",'" & TextBox7.Text & "'"
SSQL = "SP_U_EBR_CONTROLEFFEC " & SSQL
If cls.fnInserta(SSQL) = "" Then
MessageBox.Show("Informacion Guardada.", "MINDS")
End If
CargarEBR()
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
TextBox7.Enabled = CheckBox1.Checked
TextBox7.Text = ""
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim fr As New frmEBRDomicilios
fr.DT = dtN
fr.Show()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim fr As New frmEBRDomicilios
fr.DT = dtE
fr.Show()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim fr As New frmEBRDomicilios
fr.DT = dtO
fr.Show()
End Sub
Private Sub frmEBR_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
Dim ClassAud As New ClassMyUtils
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 86, 1, "Cerrando EBR")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Dim bmpScreenshot As Bitmap = New Bitmap(Width, Height, PixelFormat.Format32bppArgb)
TabPage1.Height = 1000
Dim bmp As Bitmap = New Bitmap(TabPage1.Width, TabPage1.Height)
TabPage1.DrawToBitmap(bmp, TabPage1.ClientRectangle)
bmp.Save("C:\albert\Form1.jpg", ImageFormat.Jpeg)
' Create a graphics object from the bitmap
'Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)
' Take a screenshot of the entire Form1
'gfxScreenshot.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, Me.Size, CopyPixelOperation.SourceCopy)
' Save the screenshot
'bmpScreenshot.Save("C:\albert\Form1.jpg", ImageFormat.Jpeg)
End Sub
End Class