VERSION 5.00
Begin VB.Form fajusteautomaticoinventario 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cierre Inventario Fisico (10.200.00)"
   ClientHeight    =   3030
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3885
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3030
   ScaleWidth      =   3885
   Begin VB.CheckBox opt_ajuste 
      Caption         =   "Realizar Ajuste Automatico"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   2
      Top             =   240
      Value           =   1  'Checked
      Width           =   3255
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "&Procesar"
      Height          =   735
      Left            =   600
      Picture         =   "1020000.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   2160
      Width           =   1215
   End
   Begin VB.CommandButton cmdSalir 
      Cancel          =   -1  'True
      Caption         =   "Cancelar"
      Height          =   735
      Left            =   2040
      Picture         =   "1020000.frx":030A
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   2160
      Width           =   1215
   End
   Begin VB.Shape Shape1 
      Height          =   1815
      Left            =   120
      Top             =   120
      Width           =   3615
   End
   Begin VB.Label lblCambio 
      BorderStyle     =   1  'Fixed Single
      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            =   1920
      TabIndex        =   8
      Top             =   1440
      Width           =   1575
   End
   Begin VB.Label lblFecha 
      BorderStyle     =   1  'Fixed Single
      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            =   1920
      TabIndex        =   7
      Top             =   1080
      Width           =   1575
   End
   Begin VB.Label lblUsuario 
      BorderStyle     =   1  'Fixed Single
      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            =   1920
      TabIndex        =   6
      Top             =   720
      Width           =   1575
   End
   Begin VB.Label Label3 
      Caption         =   "Tipo de Cambio"
      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            =   360
      TabIndex        =   5
      Top             =   1440
      Width           =   1455
   End
   Begin VB.Label Label2 
      Caption         =   "Usuario"
      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            =   360
      TabIndex        =   4
      Top             =   720
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "Fecha de Ajuste"
      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            =   360
      TabIndex        =   3
      Top             =   1080
      Width           =   1455
   End
End
Attribute VB_Name = "fajusteautomaticoinventario"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mobj_cseguridad As DB_SE_MANTENIMIENTOS.c_seguridad
Dim mobj_calmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Dim mobj_tomainventario As DB_INV_TOMADEINVENTARIO.C_inventario

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 pb_tiposcreen As String

Private Sub cmdAceptar_Click()

Dim lint_ajuste As Integer
Dim lint_seguro As Integer
Dim lbol_ajustado As Boolean
Dim lbol_DIF As Boolean

Set mobj_calmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN

If CDbl(lblCambio.Caption) = 0 Then
    MsgBox "No existe tipo de cambio para la fecha de Ajuste", vbExclamation, "Ajuste Automático"
    Exit Sub
End If
    
lint_seguro = MsgBox(" El proceso de cierre de inventario no puede ser revertido" + Chr(13) + Chr(13) + _
                     " Esta seguro de continuar", vbYesNo + vbQuestion, "Precaución")
                     
If lint_seguro <> 6 Then
    Exit Sub
End If

If opt_ajuste.Value = 0 Then
    lint_ajuste = MsgBox("Ha decidido no realizar el ajuste automatico" + Chr(13) + _
                        "despues de cerrado el inventario no podra realizaro" + Chr(13) + Chr(13) + _
                        "Esta seguro de continuar", vbYesNo, "Precaucion")
     If lint_ajuste <> 6 Then
        Exit Sub
    End If
    frm_procesocierre.txt_generar = "NO"
Else
    lbol_ajustado = mobj_calmacen.ESTADO_AJUSTE()
    If lbol_ajustado Then   'el ajuste automatico ya se realizo
                MsgBox "El proceso de Ajuste Automatico ya se realizo" + Chr(13) + _
                        "y no puede volver a realizarse ", vbExclamation + vbExclamation, "Atencion"
                MsgBox "Proceso Cancelado", vbExclamation, "Atencion"
                Exit Sub
    End If
End If

'lbol_DIF = mobj_calmacen.diferencias_excedidas()
'If lbol_DIF Then   'articulos con diferencias maximas
'             MsgBox "Existen Items con diferencias que exceden el porcentaje permitido" + Chr(13) + _
'                     "y no puede cerrarse la toma de inventario ", vbExclamation, "Atencion"
'             MsgBox "Proceso Cancelado", vbExclamation, "Atencion"
'             Exit Sub
'End If
    
frm_procesocierre.txt_generar = "SI"
frm_procesocierre.Show vbModal
Unload Me
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Sub salir_formulario()
Call cmdSalir_Click
End Sub
Private Sub Form_Activate()
 Call gactualizaopcion(pbderecho_agregar, pbderecho_editar, pbderecho_borrar, pbderecho_imprimir)
 Call gactualiza_barra(Me)
 If pbderecho_consultar = False Then
     Unload Me
 End If

 Dim LBOL_ESTADOINVENTARIO As Boolean
 LBOL_ESTADOINVENTARIO = mobj_calmacen.estadoinventarioAlmacen()
 If Not LBOL_ESTADOINVENTARIO Then
     MsgBox "La toma de Inventario no esta Activada", vbCritical, "No Puede Ingresar a esta Pantalla"
     Unload Me
 End If
End Sub
Private Sub Form_Load()
'seguridad
Set mobj_calmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
Set mobj_cseguridad = New DB_SE_MANTENIMIENTOS.c_seguridad
Set mobj_tomainventario = New DB_INV_TOMADEINVENTARIO.C_inventario

Call gseguridad(Me)
If pbderecho_consultar Then
    lblUsuario.Caption = GCUSERID
    lblFecha.Caption = mobj_calmacen.ObtenerFechaIniciodeToma(GstrSiteProce) - 1
    lblCambio.Caption = mobj_tomainventario.ObtieneTipoCambio(Format(CDate(lblFecha.Caption), "DD/MM/YYYY"), GstrCodMonedaBase)
Else
    MsgBox ("No tiene Derechos de Consultar en este formulario")
End If

    Me.Top = 300
    Me.Left = (Screen.Width - Me.Width) / 2
End Sub
