client/Reportes/OperatividadBaja.vb

423 lines
17 KiB
VB.net
Raw Normal View History

Public Class OperatividadBaja
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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents btnConsultar As System.Windows.Forms.ToolBarButton
Friend WithEvents btnSalir As System.Windows.Forms.ToolBarButton
Friend WithEvents tlbOperatividadBaja As System.Windows.Forms.ToolBar
Friend WithEvents btnGrafica As System.Windows.Forms.ToolBarButton
Friend WithEvents lblNumReg As System.Windows.Forms.Label
Friend WithEvents cmbProducto As System.Windows.Forms.ComboBox
Friend WithEvents dtpFechaInicio As System.Windows.Forms.DateTimePicker
Friend WithEvents dtpFechaFin As System.Windows.Forms.DateTimePicker
Friend WithEvents dtgOperatividadBaja As System.Windows.Forms.DataGrid
Friend WithEvents btnRefrescar As System.Windows.Forms.ToolBarButton
Friend WithEvents btnExportar As System.Windows.Forms.ToolBarButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(OperatividadBaja))
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.dtpFechaFin = New System.Windows.Forms.DateTimePicker()
Me.dtpFechaInicio = New System.Windows.Forms.DateTimePicker()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.GroupBox2 = New System.Windows.Forms.GroupBox()
Me.cmbProducto = New System.Windows.Forms.ComboBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.dtgOperatividadBaja = New System.Windows.Forms.DataGrid()
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.tlbOperatividadBaja = New System.Windows.Forms.ToolBar()
Me.btnConsultar = New System.Windows.Forms.ToolBarButton()
Me.btnExportar = New System.Windows.Forms.ToolBarButton()
Me.btnGrafica = New System.Windows.Forms.ToolBarButton()
Me.btnRefrescar = New System.Windows.Forms.ToolBarButton()
Me.btnSalir = New System.Windows.Forms.ToolBarButton()
Me.lblNumReg = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.dtgOperatividadBaja, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.dtpFechaFin)
Me.GroupBox1.Controls.Add(Me.dtpFechaInicio)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Location = New System.Drawing.Point(168, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(304, 44)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Fechas"
'
'dtpFechaFin
'
Me.dtpFechaFin.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
Me.dtpFechaFin.Location = New System.Drawing.Point(187, 16)
Me.dtpFechaFin.Name = "dtpFechaFin"
Me.dtpFechaFin.Size = New System.Drawing.Size(104, 20)
Me.dtpFechaFin.TabIndex = 1
'
'dtpFechaInicio
'
Me.dtpFechaInicio.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
Me.dtpFechaInicio.Location = New System.Drawing.Point(44, 16)
Me.dtpFechaInicio.Name = "dtpFechaInicio"
Me.dtpFechaInicio.Size = New System.Drawing.Size(104, 20)
Me.dtpFechaInicio.TabIndex = 0
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.Color.MidnightBlue
Me.Label1.Location = New System.Drawing.Point(12, 20)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(40, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Inicial"
'
'Label2
'
Me.Label2.ForeColor = System.Drawing.Color.MidnightBlue
Me.Label2.Location = New System.Drawing.Point(160, 21)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(30, 14)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Final"
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.cmbProducto)
Me.GroupBox2.Controls.Add(Me.Label3)
Me.GroupBox2.Controls.Add(Me.GroupBox1)
Me.GroupBox2.Location = New System.Drawing.Point(50, 58)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(496, 66)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Parametros de consulta"
'
'cmbProducto
'
Me.cmbProducto.DropDownWidth = 180
Me.cmbProducto.Location = New System.Drawing.Point(18, 32)
Me.cmbProducto.Name = "cmbProducto"
Me.cmbProducto.Size = New System.Drawing.Size(128, 21)
Me.cmbProducto.TabIndex = 2
'
'Label3
'
Me.Label3.ForeColor = System.Drawing.Color.MidnightBlue
Me.Label3.Location = New System.Drawing.Point(16, 18)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.TabIndex = 1
Me.Label3.Text = "Producto"
'
'dtgOperatividadBaja
'
Me.dtgOperatividadBaja.BackgroundColor = System.Drawing.Color.White
Me.dtgOperatividadBaja.DataMember = ""
Me.dtgOperatividadBaja.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dtgOperatividadBaja.Location = New System.Drawing.Point(6, 132)
Me.dtgOperatividadBaja.Name = "dtgOperatividadBaja"
Me.dtgOperatividadBaja.Size = New System.Drawing.Size(580, 244)
Me.dtgOperatividadBaja.TabIndex = 2
'
'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, "")
'
'tlbOperatividadBaja
'
Me.tlbOperatividadBaja.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.btnConsultar, Me.btnExportar, Me.btnGrafica, Me.btnRefrescar, Me.btnSalir})
Me.tlbOperatividadBaja.ButtonSize = New System.Drawing.Size(75, 40)
Me.tlbOperatividadBaja.DropDownArrows = True
Me.tlbOperatividadBaja.ImageList = Me.ImageList1
Me.tlbOperatividadBaja.Location = New System.Drawing.Point(0, 0)
Me.tlbOperatividadBaja.Name = "tlbOperatividadBaja"
Me.tlbOperatividadBaja.ShowToolTips = True
Me.tlbOperatividadBaja.Size = New System.Drawing.Size(592, 42)
Me.tlbOperatividadBaja.TabIndex = 15
'
'btnConsultar
'
Me.btnConsultar.ImageIndex = 8
Me.btnConsultar.Name = "btnConsultar"
Me.btnConsultar.Text = "Consultar"
'
'btnExportar
'
Me.btnExportar.ImageIndex = 9
Me.btnExportar.Name = "btnExportar"
Me.btnExportar.Text = "Exportar"
'
'btnGrafica
'
Me.btnGrafica.ImageIndex = 0
Me.btnGrafica.Name = "btnGrafica"
Me.btnGrafica.Text = "Ver Grafica"
Me.btnGrafica.Visible = False
'
'btnRefrescar
'
Me.btnRefrescar.ImageIndex = 0
Me.btnRefrescar.Name = "btnRefrescar"
Me.btnRefrescar.Text = "Refrescar"
'
'btnSalir
'
Me.btnSalir.ImageIndex = 4
Me.btnSalir.Name = "btnSalir"
Me.btnSalir.Text = "Salir"
'
'lblNumReg
'
Me.lblNumReg.Location = New System.Drawing.Point(372, 382)
Me.lblNumReg.Name = "lblNumReg"
Me.lblNumReg.Size = New System.Drawing.Size(208, 15)
Me.lblNumReg.TabIndex = 27
Me.lblNumReg.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'OperatividadBaja
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(592, 401)
Me.Controls.Add(Me.lblNumReg)
Me.Controls.Add(Me.tlbOperatividadBaja)
Me.Controls.Add(Me.dtgOperatividadBaja)
Me.Controls.Add(Me.GroupBox2)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.MaximizeBox = False
Me.Name = "OperatividadBaja"
Me.Text = "Operatividad Baja"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
CType(Me.dtgOperatividadBaja, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Dim clCmp As clsComplejo = New clsComplejo
Dim clCmp1 As clsComplejo = New clsComplejo
Public Shared No_Cuenta As String
Public Shared _IdProducto As Integer
Public Shared _Fecha As String
Dim Bandera As Boolean = False
Public Shared _Opcion As Integer
Private Sub OperatividadBaja_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub tlbInusualesDivisas_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tlbOperatividadBaja.ButtonClick
'Botones de la toolbar
Select Case e.Button.Text
Case "Consultar"
sbBuscar()
Case "Exportar"
Exportar()
Case "Ver Grafica"
Grafica()
Case "Refrescar"
Refrescar()
Case "Salir"
Me.Close()
End Select
End Sub
Private Sub Exportar()
'llama a las rutinas para exportar a excel
Try
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, <20>Deseas continuar? ", "MINDS", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Resul = DialogResult.Yes Then
Dim clsExcel As aExcel = New aExcel
clsExcel.Titulo = Me.Text
'Utilizo la funcion ExportDataset de la clase aExcel
clsExcel.ExportDataset(clCmp.ds) '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 Grafica()
'Muestra el form de la grafica de operatividad baja
Try
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 resultados ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
'Muestra el form
NoCuenta() 'Llama a la funcion que recuepra datos del grid
Dim frmGrfOperBaja As OperBaja = New OperBaja
frmGrfOperBaja.ShowDialog()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Refrescar()
'Limpia los controles (Combos y datagrid)
Me.cmbProducto.DataSource = Nothing
Me.cmbProducto.Items.Clear()
Me.dtgOperatividadBaja.DataSource = Nothing
Me.dtgOperatividadBaja.DataBindings.Clear()
Bandera = False
End Sub
Private Sub NoCuenta()
'Se ontiene valores del grid
Dim filaActual As Integer
filaActual = Me.dtgOperatividadBaja.CurrentRowIndex
Dim Fila As DataRow
Fila = clCmp.ds.Tables(0).Rows(filaActual)
No_Cuenta = Fila("No_cuenta")
_Fecha = Fila("Fecha")
End Sub
Public Sub sbBuscar()
'realiza una consulta en base al procedimiento almacenado
Try
'Formo el query de consulta
If Me.cmbProducto.Text = "" Then
MessageBox.Show("Es necesario seleccionar un producto", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim SQL As String
SQL = ""
'SQL = fsDefineSQL("sbOperatividadBajaRep ")
SQL = fsDefineSQL("spOperatividadBaja ")
clCmp.fdtDataSetTabla(SQL)
'Llena el grid
Me.dtgOperatividadBaja.SetDataBinding(clCmp.ds, "Tabla")
Catch er As Exception
MessageBox.Show("Error al llenar el grid 'Sub: sbBuscar' " & er.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Try
Dim x As Integer
x = clCmp.ds.Tables(0).Rows.Count
lblNumReg.Text = "N<EFBFBD>mero total de registros: " & x
Catch er As Exception
'MessageBox.Show("Error en el sub 'sbbuscar' en 'inusualesDivisas' " & er.Message)
End Try
End Sub
Private Function fsDefineSQL(ByVal SP As String) As String
'Defino mi cadena para el procedimiento almacenado
Dim lsSQL As String
Dim lsIni As String
Dim lsFin As String
Dim lsProducto As Integer
Dim _Opcion As Integer
Dim Classcom As New clsComplejo
' ************ Fechas ****************
lsIni = Classcom.ObtenFecha(CDate(dtpFechaInicio.Value.ToShortDateString), "yyyymmdd")
lsIni = "'" & lsIni & "'"
lsFin = Classcom.ObtenFecha(CDate(dtpFechaFin.Value.ToShortDateString), "yyyymmdd")
lsFin = "'" & lsFin & "'"
'*************** combo Producto*************
If cmbProducto.SelectedIndex <> -1 Then
lsProducto = CInt(cmbProducto.SelectedValue)
_Opcion = 2 'Se establece que se filtrara a traves del id del producto
Else
_Opcion = 1 'Buscar todos
End If
'Formo el query
lsSQL = ""
lsSQL = lsSQL & SP & " "
lsSQL = lsSQL & lsIni & ", "
lsSQL = lsSQL & lsFin & ", "
'lsSQL = lsSQL & _Opcion & ","
lsSQL = lsSQL & lsProducto
Return lsSQL
End Function
Private Sub dtgOperatividadBaja_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtgOperatividadBaja.DoubleClick
'Al dar doble click sobre una rejilla del grid
Grafica()
End Sub
Private Sub cmbProducto_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbProducto.DropDown
Try
'Lleno el combo de productos
If Bandera = False Then
'Se utiliza un procedimiento almacenado para llenar el combo
clCmp.sbLlenaCombo("spLlenaComboAliasProductos", Me.cmbProducto)
End If
Bandera = True
Catch ex As Exception
MessageBox.Show(ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub dtgOperatividadBaja_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dtgOperatividadBaja.Navigate
End Sub
Private Sub cmbProducto_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbProducto.SelectedIndexChanged
End Sub
End Class