client/Busquedas/PaisBol.vb

490 lines
21 KiB
VB.net
Raw Permalink Blame History

Public Class PaisesBol
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents lblResultados As System.Windows.Forms.Label
Friend WithEvents cmbPais As System.Windows.Forms.ComboBox
Friend WithEvents cmbTipoPais As System.Windows.Forms.ComboBox
Friend WithEvents BntSalie As System.Windows.Forms.Button
Friend WithEvents BtnImprimir As System.Windows.Forms.Button
Friend WithEvents BtnLimpiar As System.Windows.Forms.Button
Friend WithEvents btnConsulta As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents cmbOrganismo As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(PaisesBol))
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.cmbPais = New System.Windows.Forms.ComboBox()
Me.cmbTipoPais = New System.Windows.Forms.ComboBox()
Me.cmbOrganismo = New System.Windows.Forms.ComboBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
Me.lblResultados = New System.Windows.Forms.Label()
Me.BntSalie = New System.Windows.Forms.Button()
Me.BtnImprimir = New System.Windows.Forms.Button()
Me.BtnLimpiar = New System.Windows.Forms.Button()
Me.btnConsulta = New System.Windows.Forms.Button()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Turquoise
Me.ImageList1.Images.SetKeyName(0, "")
Me.ImageList1.Images.SetKeyName(1, "")
Me.ImageList1.Images.SetKeyName(2, "")
Me.ImageList1.Images.SetKeyName(3, "")
Me.ImageList1.Images.SetKeyName(4, "")
Me.ImageList1.Images.SetKeyName(5, "")
Me.ImageList1.Images.SetKeyName(6, "")
Me.ImageList1.Images.SetKeyName(7, "")
Me.ImageList1.Images.SetKeyName(8, "")
Me.ImageList1.Images.SetKeyName(9, "")
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.cmbPais)
Me.GroupBox1.Controls.Add(Me.cmbTipoPais)
Me.GroupBox1.Controls.Add(Me.cmbOrganismo)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Location = New System.Drawing.Point(22, 54)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(734, 62)
Me.GroupBox1.TabIndex = 18
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Parametros de busqueda"
'
'cmbPais
'
Me.cmbPais.Location = New System.Drawing.Point(160, 34)
Me.cmbPais.Name = "cmbPais"
Me.cmbPais.Size = New System.Drawing.Size(136, 21)
Me.cmbPais.TabIndex = 2
'
'cmbTipoPais
'
Me.cmbTipoPais.Location = New System.Drawing.Point(308, 33)
Me.cmbTipoPais.Name = "cmbTipoPais"
Me.cmbTipoPais.Size = New System.Drawing.Size(202, 21)
Me.cmbTipoPais.TabIndex = 1
'
'cmbOrganismo
'
Me.cmbOrganismo.Location = New System.Drawing.Point(28, 34)
Me.cmbOrganismo.Name = "cmbOrganismo"
Me.cmbOrganismo.Size = New System.Drawing.Size(121, 21)
Me.cmbOrganismo.TabIndex = 0
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(307, 16)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(139, 18)
Me.Label3.TabIndex = 21
Me.Label3.Text = "Tipo de pais"
Me.Label3.ForeColor = System.Drawing.Color.MidnightBlue
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(160, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(67, 21)
Me.Label2.TabIndex = 20
Me.Label2.Text = "Pais"
Me.Label2.ForeColor = System.Drawing.Color.MidnightBlue
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(28, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(121, 20)
Me.Label1.TabIndex = 19
Me.Label1.Text = "Organismo"
Me.Label1.ForeColor = System.Drawing.Color.MidnightBlue
'
'GroupBox2
'
Me.GroupBox2.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.GroupBox2.Controls.Add(Me.DataGrid1)
Me.GroupBox2.Location = New System.Drawing.Point(4, 127)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(752, 242)
Me.GroupBox2.TabIndex = 19
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Resultados"
'
'DataGrid1
'
Me.DataGrid1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.DataGrid1.BackgroundColor = System.Drawing.Color.White
Me.DataGrid1.CaptionBackColor = System.Drawing.Color.Silver
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(3, 13)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.RowHeaderWidth = 100
Me.DataGrid1.Size = New System.Drawing.Size(746, 223)
Me.DataGrid1.TabIndex = 0
'
'lblResultados
'
Me.lblResultados.Location = New System.Drawing.Point(4, 375)
Me.lblResultados.Name = "lblResultados"
Me.lblResultados.Size = New System.Drawing.Size(100, 14)
Me.lblResultados.TabIndex = 20
Me.lblResultados.Text = "Resultados:"
Me.lblResultados.TextAlign = System.Drawing.ContentAlignment.TopRight
Me.lblResultados.ForeColor = System.Drawing.Color.MidnightBlue
'
'BntSalie
'
Me.BntSalie.BackColor = System.Drawing.Color.White
Me.BntSalie.Cursor = System.Windows.Forms.Cursors.Hand
Me.BntSalie.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BntSalie.ForeColor = System.Drawing.Color.MidnightBlue
Me.BntSalie.Image = CType(resources.GetObject("BntSalie.Image"), System.Drawing.Image)
Me.BntSalie.Location = New System.Drawing.Point(762, 263)
Me.BntSalie.Name = "BntSalie"
Me.BntSalie.Size = New System.Drawing.Size(106, 33)
Me.BntSalie.TabIndex = 63
Me.BntSalie.Text = "Cerrar"
Me.BntSalie.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.BntSalie.UseVisualStyleBackColor = True
'
'BtnImprimir
'
Me.BtnImprimir.BackColor = System.Drawing.Color.White
Me.BtnImprimir.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnImprimir.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnImprimir.ForeColor = System.Drawing.Color.MidnightBlue
Me.BtnImprimir.Image = CType(resources.GetObject("BtnImprimir.Image"), System.Drawing.Image)
Me.BtnImprimir.Location = New System.Drawing.Point(762, 224)
Me.BtnImprimir.Name = "BtnImprimir"
Me.BtnImprimir.Size = New System.Drawing.Size(106, 33)
Me.BtnImprimir.TabIndex = 62
Me.BtnImprimir.Text = "Exportar"
Me.BtnImprimir.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.BtnImprimir.UseVisualStyleBackColor = True
'
'BtnLimpiar
'
Me.BtnLimpiar.BackColor = System.Drawing.Color.White
Me.BtnLimpiar.Cursor = System.Windows.Forms.Cursors.Hand
Me.BtnLimpiar.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnLimpiar.ForeColor = System.Drawing.Color.MidnightBlue
Me.BtnLimpiar.Image = CType(resources.GetObject("BtnLimpiar.Image"), System.Drawing.Image)
Me.BtnLimpiar.Location = New System.Drawing.Point(762, 185)
Me.BtnLimpiar.Name = "BtnLimpiar"
Me.BtnLimpiar.Size = New System.Drawing.Size(106, 33)
Me.BtnLimpiar.TabIndex = 61
Me.BtnLimpiar.Text = "Limpiar"
Me.BtnLimpiar.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.BtnLimpiar.UseVisualStyleBackColor = True
'
'btnConsulta
'
Me.btnConsulta.BackColor = System.Drawing.Color.White
Me.btnConsulta.Cursor = System.Windows.Forms.Cursors.Hand
Me.btnConsulta.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnConsulta.ForeColor = System.Drawing.Color.MidnightBlue
Me.btnConsulta.Image = CType(resources.GetObject("btnConsulta.Image"), System.Drawing.Image)
Me.btnConsulta.Location = New System.Drawing.Point(762, 146)
Me.btnConsulta.Name = "btnConsulta"
Me.btnConsulta.Size = New System.Drawing.Size(106, 33)
Me.btnConsulta.TabIndex = 60
Me.btnConsulta.Text = "Consulta"
Me.btnConsulta.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnConsulta.UseVisualStyleBackColor = True
'
'PictureBox1
'
Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox1.ErrorImage = CType(resources.GetObject("PictureBox1.ErrorImage"), System.Drawing.Image)
Me.PictureBox1.Image = Global.CLIENTE.My.Resources.Resources.Logo_Empresa
Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(142, 43)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 64
Me.PictureBox1.TabStop = False
'
'PaisesBol
'
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(874, 393)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.BntSalie)
Me.Controls.Add(Me.BtnImprimir)
Me.Controls.Add(Me.BtnLimpiar)
Me.Controls.Add(Me.btnConsulta)
Me.Controls.Add(Me.lblResultados)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "PaisesBol"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Paises boletinados"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim clCmp1 As clsComplejo = New clsComplejo
Dim clCmp2 As clsComplejo = New clsComplejo
Dim clCmp3 As clsComplejo = New clsComplejo
Dim clGrid As clsComplejo = New clsComplejo
Dim BanOrg, BanPais, BanTipoPais As Boolean
Private Sub PaisesBol_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BanOrg = False
BanPais = False
BanTipoPais = False
End Sub
Private Sub tlbInusualesDivisas_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)
'Botones de la toolbar
Select Case e.Button.Text
Case "Consultar"
sbBuscar()
Case "Exportar"
Exportar()
Case "Refrescar"
Refrescar()
Case "Salir"
Me.Close()
End Select
End Sub
Private Sub Exportar()
Dim ClassAud As New ClassMyUtils
'llama a las rutinas para exportar el grid a excel
Try
If clsVaribles.lbDemo = True Then Exit Sub
If clGrid.ds.Tables.Count = 0 Then
MessageBox.Show("Realiza una consulta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
If clGrid.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, <20>Deseas continuar? ", "MINDS", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Resul = DialogResult.Yes Then
'Creo una instancia de la clase aExcel
Dim clsExcel As aExcel = New aExcel
'Utilizo la funcion ExportDataset de la clase aExcel
clsExcel.ExportDataset(clGrid.ds) 'Asigno el dataset a exportar
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 113, 1, "EXPORTACI<EFBFBD>N DE PAISES BOLETINADOS")
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 sbBuscar()
Try
'If clsVaribles.lbDemo = True Then Exit Sub
'Se utiliza el procedimiento almacenado "spBuscaPaisBol" para buscar
Dim SQL As String
SQL = ""
SQL = fsDefineSQL("spBuscaPaisBol ")
clGrid.fdtDataSetTabla(SQL)
Me.DataGrid1.SetDataBinding(clGrid.ds, "Tabla") 'Llena el grid
Dim cont As Integer
cont = clGrid.ds.Tables(0).Rows.Count
lblResultados.Text = "Elementos: " & cont
Catch ex As Exception
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Function fsDefineSQL(ByVal SP As String) As String
'Defino mi cadena para el procedimiento almacenado
'Declaro varables para pasar los parametros al procedimiento almacenado
Dim lsSQL As String
Dim _Opcion As Integer
Dim _Organismo As String
Dim _Pais As String
Dim _TipoPais As String
If clsVaribles.lbDemo = True Then Exit Function
If Me.cmbOrganismo.Text = "" And Me.cmbPais.Text = "" And Me.cmbTipoPais.Text = "" Then
_Opcion = 1
_Organismo = ", NULL, "
_Pais = " NULL, "
_TipoPais = " NULL "
ElseIf Me.cmbOrganismo.Text = "" And Me.cmbPais.Text = "" And Me.cmbTipoPais.Text <> "" Then
_Opcion = 2
_Organismo = ", NULL, "
_Pais = " NULL, "
_TipoPais = CInt(Me.cmbTipoPais.SelectedValue)
ElseIf Me.cmbOrganismo.Text = "" And Me.cmbPais.Text <> "" And Me.cmbTipoPais.Text = "" Then
_Opcion = 3
_Organismo = ", NULL, "
_Pais = CInt(Me.cmbPais.SelectedValue)
_TipoPais = ", NULL "
ElseIf Me.cmbOrganismo.Text = "" And Me.cmbPais.Text <> "" And Me.cmbTipoPais.Text <> "" Then
_Opcion = 4
_Organismo = ", NULL, "
_Pais = CInt(Me.cmbPais.SelectedValue) & ", "
_TipoPais = CInt(Me.cmbTipoPais.SelectedValue)
ElseIf Me.cmbOrganismo.Text <> "" And Me.cmbPais.Text = "" And Me.cmbTipoPais.Text = "" Then
_Opcion = 5
_Organismo = ", " & CInt(Me.cmbOrganismo.SelectedValue) & ", "
_Pais = " NULL, "
_TipoPais = " NULL "
ElseIf Me.cmbOrganismo.Text <> "" And Me.cmbPais.Text = "" And Me.cmbTipoPais.Text <> "" Then
_Opcion = 6
_Organismo = ", " & CInt(Me.cmbOrganismo.SelectedValue) & ", "
_Pais = " NULL, "
_TipoPais = CInt(Me.cmbTipoPais.SelectedValue)
ElseIf Me.cmbOrganismo.Text <> "" And Me.cmbPais.Text <> "" And Me.cmbTipoPais.Text = "" Then
_Opcion = 7
_Organismo = ", " & CInt(Me.cmbOrganismo.SelectedValue) & ", "
_Pais = CInt(Me.cmbPais.SelectedValue) & ", "
_TipoPais = " NULL "
ElseIf Me.cmbOrganismo.Text <> "" And Me.cmbPais.Text <> "" And Me.cmbTipoPais.Text <> "" Then
_Opcion = 8
_Organismo = ", " & CInt(Me.cmbOrganismo.SelectedValue) & ", "
_Pais = CInt(Me.cmbPais.SelectedValue) & ", "
_TipoPais = CInt(Me.cmbTipoPais.SelectedValue)
End If
'Formo el query
lsSQL = lsSQL & SP & " "
lsSQL = lsSQL & _Opcion
lsSQL = lsSQL & _Organismo
lsSQL = lsSQL & _Pais
lsSQL = lsSQL & _TipoPais
Return lsSQL
End Function
Private Sub Refrescar()
'Limpia los combos, datagrid y la caja de texto
Me.cmbPais.DataSource = Nothing
Me.cmbPais.Items.Clear()
Me.cmbOrganismo.DataSource = Nothing
Me.cmbOrganismo.Items.Clear()
Me.cmbTipoPais.DataSource = Nothing
Me.cmbTipoPais.Items.Clear()
Me.DataGrid1.DataSource = Nothing
Me.DataGrid1.DataBindings.Clear()
'Para que se puedan a llenar otra vez los combos
BanPais = False
BanOrg = False
BanTipoPais = False
End Sub
Private Sub cmbOrganismo_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbOrganismo.DropDown
If BanOrg = False Then
'Para llenar el combo de organismo se utiliza el procedimiento almacenado "spLlenaComboOrgInt"
clCmp1.sbLlenaCombo("spLlenaComboOrgInt", Me.cmbOrganismo)
End If
BanOrg = True
End Sub
Private Sub cmbPais_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbPais.DropDown
If clsVaribles.lbDemo = True Then Exit Sub
If BanPais = False Then
'Para llenar el combo de Pais se utiliza el porcedimiento almacenado "spListaPais"
clCmp2.sbLlenaCombo("spListaPais", Me.cmbPais)
End If
BanPais = True
End Sub
Private Sub cmbTipoPais_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTipoPais.DropDown
If clsVaribles.lbDemo = True Then Exit Sub
If BanTipoPais = False Then
'Para llenar el combo de tipo de Pais se utiliza el porcedimiento almacenado "spLlenaTipoPais"
clCmp3.sbLlenaCombo("spLlenaTipoPais", Me.cmbTipoPais)
End If
BanTipoPais = True
End Sub
Private Sub btnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsulta.Click
sbBuscar()
End Sub
Private Sub BtnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnImprimir.Click
Exportar()
End Sub
Private Sub BtnLimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLimpiar.Click
Refrescar()
End Sub
Private Sub BntSalie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BntSalie.Click
Me.Close()
End Sub
End Class