VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{2FF9B179-0BCC-11D7-8EF7-000795CE4721}#1.0#0"; "pry_listpicture.ocx"
Begin VB.Form fstockfisicobloque 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Ingreso de Stock Fisico por Bloque (10.180.00)"
   ClientHeight    =   5280
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9645
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5280
   ScaleWidth      =   9645
   Begin VB.Frame fraImportar 
      BackColor       =   &H80000018&
      Caption         =   "Importar Stock Actual a Stock Fisico"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000D&
      Height          =   975
      Left            =   120
      TabIndex        =   10
      Top             =   4200
      Width           =   5895
      Begin VB.CommandButton cmdImportar 
         Caption         =   "Importar"
         Height          =   735
         Left            =   3840
         Picture         =   "1018000.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   13
         Top             =   120
         Width           =   1095
      End
      Begin MSDataListLib.DataCombo dtcImportar 
         Height          =   315
         Left            =   1080
         TabIndex        =   11
         Top             =   360
         Width           =   2535
         _ExtentX        =   4471
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   ""
      End
      Begin VB.Label Label2 
         BackColor       =   &H80000018&
         Caption         =   "Importar"
         ForeColor       =   &H8000000D&
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "&Ingresar"
      Default         =   -1  'True
      Height          =   800
      Left            =   6480
      Picture         =   "1018000.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   4320
      Width           =   1395
   End
   Begin VB.CommandButton cmdSalir 
      Cancel          =   -1  'True
      Caption         =   "Sa&lir"
      Height          =   800
      Left            =   7920
      Picture         =   "1018000.frx":0614
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   4320
      Width           =   1395
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000004&
      ForeColor       =   &H80000008&
      Height          =   4095
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   9375
      Begin VB.ComboBox cmbcriterio 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         ItemData        =   "1018000.frx":091E
         Left            =   120
         List            =   "1018000.frx":0928
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   720
         Width           =   2175
      End
      Begin pry_listpicture.listpicture ctrl_lista 
         Height          =   3375
         Left            =   2640
         TabIndex        =   1
         Top             =   480
         Width           =   6615
         _ExtentX        =   11668
         _ExtentY        =   5953
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Agrupar Por:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   120
         TabIndex        =   7
         Top             =   360
         Width           =   1080
      End
      Begin VB.Label Label10 
         Caption         =   "Seleccionados"
         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            =   7080
         TabIndex        =   6
         Top             =   240
         Width           =   1575
      End
      Begin VB.Label Label11 
         Caption         =   "Disponibles"
         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            =   3480
         TabIndex        =   5
         Top             =   240
         Width           =   1575
      End
      Begin VB.Image Image3 
         Height          =   480
         Left            =   120
         Picture         =   "1018000.frx":0946
         Top             =   3480
         Width           =   480
      End
      Begin VB.Image Image4 
         Height          =   480
         Left            =   120
         Picture         =   "1018000.frx":0C50
         Top             =   3000
         Width           =   480
      End
      Begin VB.Label Label12 
         Caption         =   "Algunos Articulos"
         Height          =   255
         Left            =   600
         TabIndex        =   4
         Top             =   3600
         Width           =   1335
      End
      Begin VB.Label Label13 
         Caption         =   "Todos los Articulos"
         Height          =   255
         Left            =   600
         TabIndex        =   3
         Top             =   3120
         Width           =   1575
      End
   End
End
Attribute VB_Name = "fstockfisicobloque"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'falta decidir la cantidad de decimales para redondear los precios, calculos y costos
'debe obtenerse de la tabla in_setup
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 pb_tiposcreen As String

Dim mobj_calmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Dim mobj_ccategoria As DB_INV_MANTENIMIENTOS.C_CATEGORIA
Dim mobj_csubcategoria As DB_INV_MANTENIMIENTOS.C_SUBCATEGORIA
Dim LBOL_ESTADOINVENTARIO As Boolean
Dim mobj_inventario As DB_INV_TOMADEINVENTARIO.C_inventario




Sub Llena_Combo(rsAuxiliar As ADODB.Recordset)
Set dtcImportar.RowSource = Nothing
Set dtcImportar.RowSource = rsAuxiliar
'MsgBox CStr(rsAuxiliar.RecordCount)
'rsAuxiliar.Fields(0).Name

dtcImportar.ListField = rsAuxiliar.Fields(1).Name '"Descr"
dtcImportar.BoundColumn = rsAuxiliar.Fields(0).Name '"classid"
dtcImportar.Text = ""
dtcImportar.BoundText = ""
End Sub


Private Sub cmbcriterio_Click()
Dim ls_criterio As String
ls_criterio = cmbcriterio.Text
Select Case ls_criterio
    Case "Categoria"
        ctrl_lista.llena_lista mobj_inventario.CAT_SELECCIONADAS
        Call Llena_Combo(mobj_inventario.CAT_SELECCIONADAS)
    Case "Sub Categoria"
        ctrl_lista.llena_lista mobj_inventario.SCAT_SELECCIONADAS
        Call Llena_Combo(mobj_inventario.SCAT_SELECCIONADAS)
End Select
End Sub

Private Sub cmdaceptar_Click()
Dim ls_criterio As String
Dim ls_condicion As String
Dim li_todos                ' 1 todos los elementos, 0 algunos
Dim LS_MONEDA As String
Dim LS_TLISTA As String
Dim ls_dmoneda As String
Dim ls_dtlista As String
Dim ls_rutar As String  'ruta de los reportes

ls_criterio = cmbcriterio.Text
If ctrl_lista.ndisponibles = 0 Or ctrl_lista.nseleccionados = 0 Then
    li_todos = 1
    ls_condicion = "*"
Else
    li_todos = 0
    ls_condicion = ctrl_lista.listar_codigos_seleccionados
End If
Select Case ls_criterio
     Case "Categoria"
         ls_tcriterio = "CAT"
     Case "Sub Categoria"
         ls_tcriterio = "SCA"
     Case Else
         MsgBox "Debe Seleccionar un Criterio", vbCritical
         cmbcriterio.SetFocus
         Exit Sub
 End Select
 fingresostockbloque.txt_lista.Text = ls_condicion
 fingresostockbloque.TXT_TODOS.Text = li_todos
 fingresostockbloque.txt_grupo.Text = ls_criterio
 fingresostockbloque.Show vbModal
End Sub

Private Sub cmdImportar_Click()
Dim rsAyuda As New ADODB.Recordset
Dim lsCat As String, lsSCat As String, lsInvt As String
Dim CadElimina As String, CadInserta As String

If Len(Trim(dtcImportar.Text)) < 1 Or Len(Trim(dtcImportar.BoundText)) < 1 Then
    MsgBox "Debe Seleccionar un item!!!", vbExclamation + 0
    dtcImportar.SetFocus
    Exit Sub
End If
'MsgBox dtcImportar.BoundText

Select Case Trim(cmbcriterio.Text)
     Case "Categoria"
        CadSql = " SELECT * FROM VW_ARTSELECCIONADOS_CLUSTER WHERE CLASSID ='" & _
        Trim(dtcImportar.BoundText) & "' order by classid,descr"
        
        CadElimina = " Delete IN_INVENTPHISICAL WHERE CLASSID ='" & Trim(dtcImportar.BoundText) & "'"
        
        CadInserta = "Insert into IN_INVENTPHISICAL " & _
        "Select ID.SITEID,I.INVTIDSKU,I.CLASSID,I.CLASSUBID,ID.QTYAVAIL " & _
        "FROM IN_INVENTORY I (NOLOCK) INNER JOIN " & _
        "IN_INVENTORYDAT ID (NOLOCK) ON I.INVTIDSKU = ID.INVTIDSKU " & _
        "WHERE I.CLASSID ='" & Trim(dtcImportar.BoundText) & "'"
        
     Case "Sub Categoria"
        CadSql = " SELECT * FROM VW_ARTSELECCIONADOS_CLUSTER WHERE CLASSubID ='" & _
        Trim(dtcImportar.BoundText) & "' order by classid,classubid,descr"
        
        CadElimina = " Delete IN_INVENTPHISICAL WHERE CLASSUBID ='" & Trim(dtcImportar.BoundText) & "'"
        
        CadInserta = "Insert into IN_INVENTPHISICAL " & _
        "Select ID.SITEID,I.INVTIDSKU,I.CLASSID,I.CLASSUBID,ID.QTYAVAIL " & _
        "FROM IN_INVENTORY I (NOLOCK) INNER JOIN " & _
        "IN_INVENTORYDAT ID (NOLOCK) ON I.INVTIDSKU = ID.INVTIDSKU " & _
        "WHERE I.CLASSUBID ='" & Trim(dtcImportar.BoundText) & "'"
        
End Select

rsAyuda.Open CadSql, MyCon, adOpenStatic, adLockOptimistic
If Not rsAyuda.EOF Then
    If MsgBox("Se han detectado registros de inventario fisico para la " & Trim(cmbcriterio.Text) & " seleccionada." & Chr(13) & _
    "Este procedimiento reemplazara todos estos registros. żEsta seguro de continuar?", vbQuestion + vbYesNo + vbDefaultButton2, "Importar Stock Actual") = vbNo Then Exit Sub
End If

'Eliminando
MyCon.BeginTrans
MyCon.Execute CadElimina, , ADODB.adExecuteNoRecords
MyCon.CommitTrans

'Insertando
MyCon.BeginTrans
MyCon.Execute CadInserta, , ADODB.adExecuteNoRecords
MyCon.CommitTrans

MsgBox "Se importo Stock actual con exito!", vbInformation + 0
'    End If


End Sub

Private Sub cmdSalir_Click()
Call salir_formulario
End Sub

Private Sub Form_Activate()
Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
Call gactualiza_barra(Me)
'Call gactualiza_barra(pb_editar, pb_primerregistro, pb_ultimoregistro)
'lineas nuevas
If pbderecho_consultar = False Then
    Unload Me
End If

If Not LBOL_ESTADOINVENTARIO Then
    MsgBox "La toma de inventario no esta activada" + Chr(13) + "No puede Ingresar a esta Pantalla", vbExclamation, "Atencion"
    Call salir_formulario
End If

End Sub

Private Sub Form_Load()
Call gseguridad(Me)
If pbderecho_consultar Then
    'VALIDAR EL ESTADO DEL INVENTARIO, SI NO ESTA INICIADO NO DEBE INGRESAR
    Set mobj_calmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
    Set mobj_inventario = New DB_INV_TOMADEINVENTARIO.C_inventario
    LBOL_ESTADOINVENTARIO = mobj_calmacen.estadoinventarioAlmacen()
    cmbcriterio.Text = "Categoria"
    ctrl_lista.Size 18, 30
    
    Me.Top = 300
    Me.Left = (Screen.Width - Me.Width) / 2
Else
    MsgBox ("No tiene Derechos de Consultar en este formulario")
End If


End Sub

Public Sub salir_formulario()
Unload Me
End Sub
