VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "crystl32.ocx"
Begin VB.Form FKardexArticulo 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Kardex por Articulo (10.110.00)"
   ClientHeight    =   3060
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7830
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   3060
   ScaleWidth      =   7830
   Begin VB.CheckBox chkValorizado 
      Caption         =   "Valorizado"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   9
      Top             =   2760
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.Frame fraMoneda 
      Enabled         =   0   'False
      Height          =   975
      Left            =   120
      TabIndex        =   17
      Top             =   2760
      Visible         =   0   'False
      Width           =   5175
      Begin VB.CommandButton cmdBusMoneda 
         Height          =   375
         Left            =   4560
         MouseIcon       =   "FKardexArticulo.frx":0000
         MousePointer    =   99  'Custom
         Picture         =   "FKardexArticulo.frx":0152
         Style           =   1  'Graphical
         TabIndex        =   11
         ToolTipText     =   "Buscar Tipo de Moneda"
         Top             =   360
         Width           =   375
      End
      Begin MSDataListLib.DataCombo dtcMoneda 
         Height          =   315
         Left            =   1320
         TabIndex        =   10
         Top             =   360
         Width           =   3135
         _ExtentX        =   5530
         _ExtentY        =   556
         _Version        =   393216
         Appearance      =   0
         Style           =   2
         Text            =   ""
      End
      Begin VB.Label lblMoneda 
         AutoSize        =   -1  'True
         Caption         =   "Moneda"
         Height          =   195
         Left            =   240
         TabIndex        =   18
         Top             =   360
         Width           =   585
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Rango de Fechas"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   120
      TabIndex        =   16
      Top             =   1800
      Width           =   4455
      Begin MSComCtl2.DTPicker dtpDesde 
         Height          =   375
         Left            =   840
         TabIndex        =   4
         Top             =   360
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         _Version        =   393216
         Format          =   21299201
         CurrentDate     =   37791
      End
      Begin MSComCtl2.DTPicker dtpHasta 
         Height          =   375
         Left            =   2880
         TabIndex        =   5
         Top             =   360
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         _Version        =   393216
         Format          =   21299201
         CurrentDate     =   37791
      End
      Begin VB.Label Label2 
         Caption         =   "Hasta"
         Height          =   255
         Left            =   2280
         TabIndex        =   20
         Top             =   360
         Width           =   495
      End
      Begin VB.Label Label1 
         Caption         =   "Desde"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   360
         Width           =   735
      End
   End
   Begin VB.CommandButton cmdgenerar 
      Caption         =   "&Generar"
      Height          =   855
      Left            =   5400
      Picture         =   "FKardexArticulo.frx":0684
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   1920
      Width           =   1095
   End
   Begin VB.CommandButton cmdsalir 
      Caption         =   "Sa&lir"
      Height          =   855
      Left            =   6600
      Picture         =   "FKardexArticulo.frx":098E
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   1920
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      Caption         =   "Seleccione Articulo y Estación"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   1575
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   7575
      Begin VB.CommandButton cmdBusArticulo 
         Height          =   375
         Left            =   6000
         MouseIcon       =   "FKardexArticulo.frx":0C98
         MousePointer    =   99  'Custom
         Picture         =   "FKardexArticulo.frx":0DEA
         Style           =   1  'Graphical
         TabIndex        =   1
         ToolTipText     =   "Buscar Almacén"
         Top             =   360
         Width           =   375
      End
      Begin VB.CommandButton cmdBusAlmacen 
         Height          =   375
         Left            =   6000
         MouseIcon       =   "FKardexArticulo.frx":131C
         MousePointer    =   99  'Custom
         Picture         =   "FKardexArticulo.frx":146E
         Style           =   1  'Graphical
         TabIndex        =   3
         ToolTipText     =   "Buscar Almacén"
         Top             =   840
         Width           =   375
      End
      Begin MSDataListLib.DataCombo dtcArticulo 
         Height          =   315
         Left            =   2160
         TabIndex        =   0
         Top             =   360
         Width           =   3735
         _ExtentX        =   6588
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin MSDataListLib.DataCombo dtcAlmacen 
         Height          =   315
         Left            =   2160
         TabIndex        =   2
         Top             =   840
         Width           =   3735
         _ExtentX        =   6588
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin VB.Image Image1 
         Height          =   840
         Left            =   6720
         Picture         =   "FKardexArticulo.frx":19A0
         Stretch         =   -1  'True
         Top             =   360
         Width           =   720
      End
      Begin VB.Label lblCodAlm 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   300
         Left            =   960
         TabIndex        =   15
         Top             =   840
         Width           =   1095
      End
      Begin VB.Label lblAlmacen 
         AutoSize        =   -1  'True
         Caption         =   "Almacen"
         Height          =   195
         Left            =   120
         TabIndex        =   14
         Top             =   840
         Width           =   615
      End
      Begin VB.Label lblCodArt 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H00C0E0FF&
         BackStyle       =   0  'Transparent
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   300
         Left            =   960
         TabIndex        =   13
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label lblArticulo 
         Caption         =   "Artículo"
         Height          =   255
         Left            =   120
         TabIndex        =   12
         Top             =   360
         Width           =   735
      End
   End
   Begin Crystal.CrystalReport crReporte 
      Left            =   5280
      Top             =   2640
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   348160
      PrintFileLinesPerPage=   60
   End
End
Attribute VB_Name = "FKardexArticulo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'Variables para el Control de la Barra General
 
 Public pb_tiposcreen  As String
 Public pb_editar As Boolean
 Public pb_agregar As Boolean
 Public pb_primerregistro As Boolean
 Public pb_ultimoregistro As Boolean
 Public pbderecho_agregar As Boolean
 Public pbderecho_consultar As Boolean
 Public pbderecho_editar As Boolean
 Public pbderecho_borrar As Boolean
 Public pbderecho_imprimir As Boolean

Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String

Private objAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Private objMoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
Private objArticulo As DB_INV_ARTICULO.C_ARTICULO
Private objMovimientos As DB_INV_MOVIMIENTOS.C_MOVIMIENTOS

Private Sub chkValorizado_Click()
If chkValorizado.Value = 1 Then
    fraMoneda.Enabled = True
Else
    Call CargaDataCombo(Dtcmoneda, objMoneda.ListarMonedas, "CuryId", "Descr")
    fraMoneda.Enabled = False
End If
End Sub

Private Sub cmdBusAlmacen_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "Siteid"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "Name"
    ArrayBusqueda(2, 2) = "Descripción "
    ArrayBusqueda(2, 3) = 4000
      
    FBusquedasInv.GObtenerRegistros objAlmacen.ListarAlmacenesPorStatus(1), ArrayBusqueda, 2, 2
    FBusquedasInv.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
        dtcAlmacen.BoundText = GrecibeColumnaID
    End If
End Sub

Private Sub cmdBusArticulo_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "INVTIDSKU"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1000
    ArrayBusqueda(2, 1) = "Descr"
    ArrayBusqueda(2, 2) = "Descripción "
    ArrayBusqueda(2, 3) = 4000
      
    FBusquedasInv.GObtenerRegistros objArticulo.ListarArticulosayuda, ArrayBusqueda, 2, 2
    FBusquedasInv.Show vbModal
    
    If GrecibeUbicacion <> 0 Then
        dtcArticulo.BoundText = GrecibeColumnaID
    End If
End Sub

Private Sub cmdBusMoneda_Click()
    'Lineas que llaman al Formulario de Búsqueda
     
     Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
     ArrayBusqueda(1, 1) = "CuryId"
     ArrayBusqueda(1, 2) = "Código "
     ArrayBusqueda(1, 3) = 1000
     ArrayBusqueda(2, 1) = "Descr"
     ArrayBusqueda(2, 2) = "Descripción "
     ArrayBusqueda(2, 3) = 4000
       
     FBusquedasInv.GObtenerRegistros objMoneda.ListarMonedas, ArrayBusqueda, 2, 2
     FBusquedasInv.Show vbModal
     
     If GrecibeUbicacion <> 0 Then
         Dtcmoneda.BoundText = GrecibeColumnaID
     End If
End Sub

Private Sub cmdgenerar_Click()
On Error GoTo TrataError

    If GVDATO(dtcArticulo.BoundText) = Empty Then
        MsgBox "Seleccione algún artículo", vbExclamation, "Kardex por Artículo"
        dtcArticulo.SetFocus
        Exit Sub
    End If

    If GVDATO(dtcAlmacen.BoundText) = Empty Then
        MsgBox "Seleccione algún almacen", vbExclamation, "Kardex por Artículo"
        dtcAlmacen.SetFocus
        Exit Sub
    End If

    If dtpDesde.Value > dtpHasta.Value Then
        MsgBox "Rango de fechas incorrecto", vbExclamation, "Kardex por Artículo"
        dtpDesde.SetFocus
        Exit Sub
    End If


    Screen.MousePointer = 11
    
    Dim datFechainicioReproceso As Date
    Dim datFechafinReproceso As Date
    Dim dblSaldoini As Double
    Dim rsSaldoIni As ADODB.Recordset
    
    dblSaldoini = 0
    

    datFechainicioReproceso = DateAdd("d", 1 - Day(dtpDesde.Value), dtpDesde.Value)
    datFechafinReproceso = DateAdd("d", -1, dtpDesde.Value)
    If Month(datFechainicioReproceso) = Month(datFechafinReproceso) Then
        Set rsSaldoIni = objMovimientos.ObtieneSaldoInicialenKardex(dtpDesde.Value, datFechainicioReproceso, datFechafinReproceso, dtcAlmacen.BoundText, dtcArticulo.BoundText)
    Else
        Set rsSaldoIni = objMovimientos.ObtieneSaldoInicialenKardex(dtpDesde.Value, datFechainicioReproceso, datFechafinReproceso, dtcAlmacen.BoundText, dtcArticulo.BoundText)
    End If
    dblSaldoini = rsSaldoIni!SALDOINI


    MstrFechaIni = CStr(Format(dtpDesde.Value, "YYYYMMdd"))
    MstrFechaFin = CStr(Format(dtpHasta.Value, "YYYYMMdd"))

    Dim cadFecha As String
    cadFecha = "(" & CStr(Format(dtpDesde.Value, "DD/MM/YYYY")) & " - " & CStr(Format(dtpHasta.Value, "DD/MM/YYYY")) & ")"
    
    crReporte.ReportFileName = GstrReportesInv + "rpt_Kardex_NV_Por_Articulo.rpt"

                
    crReporte.WindowTitle = "Kardex No Valorizado por Artículo"
    crReporte.Formulas(1) = "formUsuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
    crReporte.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='10.110.00'"
    crReporte.Formulas(3) = "formFecha=stringvar Fecha; Fecha:='" & cadFecha & "'"
    crReporte.Formulas(4) = "formNDStock=" & GintDecStock
    crReporte.Formulas(5) = "formNDCosto=" & GintDecCosto
    crReporte.Formulas(6) = "formCodArt=stringvar strCA; strCA:='" & Trim(dtcArticulo.BoundText) & "'"
    crReporte.Formulas(7) = "formDesArt=stringvar strDA; strDA:='" & Trim(dtcArticulo.Text) & "'"
    crReporte.Formulas(8) = "formCodEst=stringvar strCE; strCE:='" & Trim(dtcAlmacen.BoundText) & "'"
    crReporte.Formulas(9) = "formDesEst=stringvar strDE; strDE:='" & Trim(dtcAlmacen.Text) & "'"
    crReporte.Formulas(10) = "formSaldoUni=" & dblSaldoini

    crReporte.WindowState = crptMaximized
    crReporte.WindowShowPrintSetupBtn = True
    'crReporte.WindowShowGroupTree = True
    
    crReporte.StoredProcParam(0) = MstrFechaIni
    crReporte.StoredProcParam(1) = MstrFechaFin
    crReporte.StoredProcParam(2) = dtcAlmacen.BoundText
    crReporte.StoredProcParam(3) = dtcArticulo.BoundText
    crReporte.StoredProcParam(4) = dblSaldoini
    
    crReporte.Connect = "DSN=SIES"
    crReporte.Action = 1
    crReporte.Reset
    
    Screen.MousePointer = 0
    
    Exit Sub
    
TrataError:
    MsgBox "error"
    Screen.MousePointer = 0
    
End Sub

Private Sub cmdSalir_Click()
Unload Me
End Sub


Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As Recordset, istrCampo1 As String, istrCampo2 As String)

    Set objDataCombo.DataSource = rsSource
    objDataCombo.DataField = istrCampo2
    Set objDataCombo.RowSource = rsSource
    objDataCombo.ListField = istrCampo2
    objDataCombo.BoundColumn = istrCampo1
    
    If Not rsSource.EOF Then
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If

End Sub

Private Sub dtcAlmacen_Change()
lblCodAlm.Caption = Trim(dtcAlmacen.BoundText)
End Sub

Private Sub dtcAlmacen_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then
    cmdBusAlmacen_Click
End If
End Sub

Private Sub dtcArticulo_Change()
lblCodArt.Caption = Trim(dtcArticulo.BoundText)
End Sub

Private Sub dtcArticulo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF2 Then
    cmdBusArticulo_Click
End If
End Sub

Private Sub Form_Load()
'********************************************************************************
 'Código que se Tiene que Copiar para Invocar a la Rutina de Seguridad para poder
  Call gseguridad(Me)
  If pbderecho_consultar Then
  Else
     MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
  End If
 '********************************************************************************
    
    Call InstanciaObjetos
    Call CargaDataCombo(dtcAlmacen, objAlmacen.ListarAlmacenesPorStatus(1), "SiteId", "Name")
    Call CargaDataCombo(Dtcmoneda, objMoneda.ListarMonedas, "CuryId", "Descr")
    Call CargaDataCombo(dtcArticulo, objArticulo.ListarArticulosayuda, "INVTIDSKU", "Descr")
    
    Me.Top = 100
    Me.Left = (Screen.Width - Me.Width) / 2
    
    fraMoneda.Enabled = False
    dtpDesde.Day = 1
    dtpDesde.Month = Month(Now)
    dtpDesde.Year = Year(Now)
    dtpHasta.Value = Now
    
End Sub


Private Sub InstanciaObjetos()
    Set objAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set objMoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
    Set objArticulo = New DB_INV_ARTICULO.C_ARTICULO
    Set objMovimientos = New DB_INV_MOVIMIENTOS.C_MOVIMIENTOS
End Sub

Private Sub DestruyeObjetos()
    Set objAlmacen = Nothing
    Set objMoneda = Nothing
    Set objArticulo = Nothing
    Set objMovimientos = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call DestruyeObjetos
End Sub
Sub actualizar_registro()

End Sub
Sub salir_formulario()
 gformmdi.Toolbar1.Buttons(18).Caption = "Salir"
 Unload Me
End Sub

Private Sub Form_Activate()
 '********************************************************************************
 'Código que se Tiene que Copiar para Invocar a la Rutina de Seguridad para poder
    Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
    Call gactualiza_barra(Me) 'pb_editar, pb_primerregistro, pb_ultimoregistro)
    If pbderecho_consultar = False Then
       Unload Me
    End If
 '********************************************************************************
End Sub

