VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Object = "{C4DED68B-C40F-11D6-AD1A-000795CA0957}#39.0#0"; "pry_list.ocx"
Begin VB.Form FRelProveArt 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Relación Proveedor Artículo (01.300.00)"
   ClientHeight    =   6150
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8700
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   6150
   ScaleWidth      =   8700
   Begin TabDlg.SSTab STARelProvArti 
      Height          =   6015
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   8655
      _ExtentX        =   15266
      _ExtentY        =   10610
      _Version        =   393216
      Tabs            =   4
      TabsPerRow      =   4
      TabHeight       =   520
      TabCaption(0)   =   "Registro por Código"
      TabPicture(0)   =   "0130000.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Label1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Label2"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "lblproveedor"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "lblarticulo"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Label3"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Label7"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "txtproveedor"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "txtcodarticulo"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "dbregistroarticulo"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "cmdbuscarproveedor"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).Control(10)=   "cmdgrabar"
      Tab(0).Control(10).Enabled=   0   'False
      Tab(0).Control(11)=   "cmdSalir"
      Tab(0).Control(11).Enabled=   0   'False
      Tab(0).Control(12)=   "cmd_cancelar"
      Tab(0).Control(12).Enabled=   0   'False
      Tab(0).Control(13)=   "txtcodcompra"
      Tab(0).Control(13).Enabled=   0   'False
      Tab(0).Control(14)=   "TxtDescripcion"
      Tab(0).Control(14).Enabled=   0   'False
      Tab(0).Control(15)=   "cmdbuscararticulo"
      Tab(0).Control(15).Enabled=   0   'False
      Tab(0).ControlCount=   16
      TabCaption(1)   =   "Registro por Selección"
      TabPicture(1)   =   "0130000.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "lblprovsel"
      Tab(1).Control(1)=   "Label4"
      Tab(1).Control(2)=   "ListRArticulos"
      Tab(1).Control(3)=   "cmdgrabarsel"
      Tab(1).Control(4)=   "cmdsalirsel"
      Tab(1).Control(5)=   "cmdbuscaprovsel"
      Tab(1).Control(6)=   "txtcodprovsel"
      Tab(1).ControlCount=   7
      TabCaption(2)   =   "Replicar en Almacenes"
      TabPicture(2)   =   "0130000.frx":0038
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "ListRAlmacenes"
      Tab(2).ControlCount=   1
      TabCaption(3)   =   "Consultar"
      TabPicture(3)   =   "0130000.frx":0054
      Tab(3).ControlEnabled=   0   'False
      Tab(3).Control(0)=   "lblalmacencons"
      Tab(3).Control(1)=   "lblproveedorcons"
      Tab(3).Control(2)=   "Label5"
      Tab(3).Control(3)=   "Label6"
      Tab(3).Control(4)=   "cmdbusprovcons"
      Tab(3).Control(5)=   "cmdbusalmaccons"
      Tab(3).Control(6)=   "txtalmacencons"
      Tab(3).Control(7)=   "txtproveedorcons"
      Tab(3).Control(8)=   "dbconsulta"
      Tab(3).Control(9)=   "cmdfiltrar"
      Tab(3).ControlCount=   10
      Begin VB.CommandButton cmdbuscararticulo 
         Enabled         =   0   'False
         Height          =   375
         Left            =   3600
         Picture         =   "0130000.frx":0070
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   1200
         Width           =   495
      End
      Begin VB.TextBox TxtDescripcion 
         Enabled         =   0   'False
         Height          =   285
         Left            =   1560
         TabIndex        =   6
         Top             =   1920
         Width           =   4695
      End
      Begin VB.TextBox txtcodcompra 
         Enabled         =   0   'False
         Height          =   285
         Left            =   1560
         TabIndex        =   5
         Top             =   1560
         Width           =   1935
      End
      Begin VB.CommandButton cmd_cancelar 
         Cancel          =   -1  'True
         Caption         =   "Cancelar"
         Enabled         =   0   'False
         Height          =   615
         Left            =   5760
         Picture         =   "0130000.frx":05A2
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   5160
         Width           =   1335
      End
      Begin VB.TextBox txtcodprovsel 
         Height          =   285
         Left            =   -73920
         TabIndex        =   11
         Top             =   720
         Width           =   1935
      End
      Begin VB.CommandButton cmdbuscaprovsel 
         Enabled         =   0   'False
         Height          =   375
         Left            =   -71880
         Picture         =   "0130000.frx":0AD4
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   600
         Width           =   495
      End
      Begin VB.CommandButton cmdsalirsel 
         Caption         =   "Sa&lir"
         Enabled         =   0   'False
         Height          =   615
         Left            =   -67800
         Picture         =   "0130000.frx":1006
         Style           =   1  'Graphical
         TabIndex        =   15
         Top             =   5040
         Width           =   1215
      End
      Begin VB.CommandButton cmdgrabarsel 
         Caption         =   "Grabar"
         Enabled         =   0   'False
         Height          =   615
         Left            =   -67800
         Picture         =   "0130000.frx":1310
         Style           =   1  'Graphical
         TabIndex        =   14
         Top             =   4320
         Width           =   1215
      End
      Begin VB.CommandButton cmdSalir 
         Caption         =   "Sa&lir"
         Enabled         =   0   'False
         Height          =   615
         Left            =   7200
         Picture         =   "0130000.frx":1842
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   5160
         Width           =   1215
      End
      Begin VB.CommandButton cmdgrabar 
         Caption         =   "Grabar"
         Enabled         =   0   'False
         Height          =   615
         Left            =   4200
         Picture         =   "0130000.frx":1B4C
         Style           =   1  'Graphical
         TabIndex        =   8
         Top             =   5160
         Width           =   1455
      End
      Begin VB.CommandButton cmdfiltrar 
         Caption         =   "Filtrar"
         Enabled         =   0   'False
         Height          =   735
         Left            =   -68160
         Picture         =   "0130000.frx":207E
         Style           =   1  'Graphical
         TabIndex        =   22
         Top             =   4920
         Width           =   1335
      End
      Begin MSDataGridLib.DataGrid dbconsulta 
         Height          =   3015
         Left            =   -74640
         TabIndex        =   21
         Top             =   1680
         Width           =   7815
         _ExtentX        =   13785
         _ExtentY        =   5318
         _Version        =   393216
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.TextBox txtproveedorcons 
         Height          =   285
         Left            =   -73800
         TabIndex        =   17
         Top             =   840
         Width           =   1935
      End
      Begin VB.TextBox txtalmacencons 
         Height          =   285
         Left            =   -73800
         TabIndex        =   19
         Top             =   1200
         Width           =   1935
      End
      Begin VB.CommandButton cmdbusalmaccons 
         Enabled         =   0   'False
         Height          =   375
         Left            =   -71760
         Picture         =   "0130000.frx":25B0
         Style           =   1  'Graphical
         TabIndex        =   20
         Top             =   1200
         Width           =   495
      End
      Begin VB.CommandButton cmdbusprovcons 
         Enabled         =   0   'False
         Height          =   375
         Left            =   -71760
         Picture         =   "0130000.frx":2AE2
         Style           =   1  'Graphical
         TabIndex        =   18
         Top             =   720
         Width           =   495
      End
      Begin VB.CommandButton cmdbuscarproveedor 
         Enabled         =   0   'False
         Height          =   375
         Left            =   3600
         Picture         =   "0130000.frx":3014
         Style           =   1  'Graphical
         TabIndex        =   2
         Top             =   840
         Width           =   495
      End
      Begin MSDataGridLib.DataGrid dbregistroarticulo 
         Height          =   2655
         Left            =   240
         TabIndex        =   7
         Top             =   2400
         Width           =   8175
         _ExtentX        =   14420
         _ExtentY        =   4683
         _Version        =   393216
         AllowUpdate     =   -1  'True
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Artículos a Replicar"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   3082
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.TextBox txtcodarticulo 
         Enabled         =   0   'False
         Height          =   285
         Left            =   1560
         TabIndex        =   3
         Top             =   1200
         Width           =   1935
      End
      Begin VB.TextBox txtproveedor 
         Enabled         =   0   'False
         Height          =   285
         Left            =   1560
         TabIndex        =   1
         Top             =   840
         Width           =   1935
      End
      Begin pry_list.ctrl_listarray ListRAlmacenes 
         Height          =   4935
         Left            =   -73680
         TabIndex        =   16
         Top             =   720
         Width           =   6015
         _ExtentX        =   10610
         _ExtentY        =   8705
      End
      Begin pry_list.ctrl_listarray ListRArticulos 
         Height          =   4215
         Left            =   -74400
         TabIndex        =   13
         Top             =   1200
         Width           =   7575
         _ExtentX        =   13361
         _ExtentY        =   7435
      End
      Begin VB.Label Label7 
         Caption         =   "Descripción"
         Height          =   375
         Left            =   240
         TabIndex        =   34
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Label Label3 
         Caption         =   "Código Compra"
         Height          =   375
         Left            =   240
         TabIndex        =   33
         Top             =   1560
         Width           =   1575
      End
      Begin VB.Label Label4 
         Caption         =   "Proveedor"
         Height          =   255
         Left            =   -74760
         TabIndex        =   32
         Top             =   720
         Width           =   1815
      End
      Begin VB.Label lblprovsel 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   -71280
         TabIndex        =   31
         Top             =   720
         Width           =   4215
      End
      Begin VB.Label Label6 
         Caption         =   "Proveedor"
         Height          =   255
         Left            =   -74640
         TabIndex        =   30
         Top             =   840
         Width           =   1815
      End
      Begin VB.Label Label5 
         Caption         =   "Almacén"
         Height          =   255
         Left            =   -74640
         TabIndex        =   29
         Top             =   1200
         Width           =   1215
      End
      Begin VB.Label lblproveedorcons 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   -71160
         TabIndex        =   28
         Top             =   840
         Width           =   4215
      End
      Begin VB.Label lblalmacencons 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   -71160
         TabIndex        =   27
         Top             =   1200
         Width           =   4215
      End
      Begin VB.Label lblarticulo 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   4200
         TabIndex        =   26
         Top             =   1200
         Width           =   4215
      End
      Begin VB.Label lblproveedor 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   4200
         TabIndex        =   25
         Top             =   840
         Width           =   4215
      End
      Begin VB.Label Label2 
         Caption         =   "Artículo"
         Height          =   255
         Left            =   240
         TabIndex        =   24
         Top             =   1200
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "Proveedor"
         Height          =   255
         Left            =   240
         TabIndex        =   23
         Top             =   840
         Width           =   1815
      End
   End
End
Attribute VB_Name = "FRelProveArt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Variables para el Manejo de la Barra
 
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 pbderecho_anular As Boolean
Public pbderecho_emitir As Boolean

Public pb_tiposcreen As String

'Variable para las ayudas
 Public GrecibeUbicacion As BookmarkEnum
 Public GrecibeColumnaID As String
 Public GrecibeColumnaOpcional As String
 Public GrecibeColumnaOpcional2 As String

'Variables para crear las instancias de las Clases

Private MobjAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN
Private MobjArticulo As DB_INV_ARTICULO.C_ARTICULO
Private MobjProveedor As DB_INV_MANTENIMIENTOS.C_PROVEEDOR
Private MobjCorrelativo As DB_CORRELATIVO.C_Correlativos

Private MDblIdentificador As Double
Private MrslistadodeArticulos As ADODB.Recordset
Private MrslistadodeProveedores As ADODB.Recordset
Private MrslistadodeAlmacenes As ADODB.Recordset
Private MdblDatosCargados As Boolean
Sub HabilitarControles(IBlnflag As Boolean)
  txtproveedor.Enabled = IBlnflag
  txtcodarticulo.Enabled = IBlnflag
  txtcodcompra.Enabled = IBlnflag
  TxtDescripcion.Enabled = IBlnflag
  txtcodprovsel.Enabled = IBlnflag
  txtproveedorcons.Enabled = IBlnflag
  txtalmacencons.Enabled = IBlnflag
End Sub

Private Sub cmd_cancelar_Click()
  MobjArticulo.BorrarTMP_IN_VENDORINVTREL MDblIdentificador
  
  Set dbregistroarticulo.DataSource = MobjArticulo.MostrarDetalleTMP_IN_VENDORINVTREL(MDblIdentificador, txtproveedor.Text)
  dbregistroarticulo.Caption = "Artículos a Replicar"
  dbregistroarticulo.Columns(0).Width = 1200
  dbregistroarticulo.Columns(1).Width = 3900
  dbregistroarticulo.Columns(2).Width = 1200
  dbregistroarticulo.Columns(3).Width = 3900
  
  dbregistroarticulo.Refresh
End Sub

Private Sub cmdbusalmaccons_Click()
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "SITEID"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1000
  LArrayBusqueda(2, 1) = "NAME"
  LArrayBusqueda(2, 2) = "Almacén"
  LArrayBusqueda(2, 3) = 6000
            
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  FBusquedasMa.GObtenerRegistros MrslistadodeAlmacenes, LArrayBusqueda, 2, 2
  FBusquedasMa.Show vbModal
  If GrecibeUbicacion <> 0 Then
     txtalmacencons.Text = GrecibeColumnaID
     lblalmacencons.Caption = GrecibeColumnaOpcional
     cmdfiltrar.SetFocus
  End If
End Sub

Private Sub cmdbuscaprovsel_Click()
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "VENDIDSS"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1000
  LArrayBusqueda(2, 1) = "DESCR"
  LArrayBusqueda(2, 2) = "Descripción"
  LArrayBusqueda(2, 3) = 6000
            
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  FBusquedasMa.GObtenerRegistros MrslistadodeProveedores, LArrayBusqueda, 2, 2
  FBusquedasMa.Show vbModal
  If GrecibeUbicacion <> 0 Then
     txtcodprovsel.Text = GrecibeColumnaID
     lblprovsel.Caption = GrecibeColumnaOpcional
  End If
End Sub

Private Sub cmdbuscararticulo_Click()
On Error GoTo errhandler
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "INVTIDSKU"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1000
  LArrayBusqueda(2, 1) = "DESCR"
  LArrayBusqueda(2, 2) = "Descripción"
  LArrayBusqueda(2, 3) = 6000
      
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  FBusquedasMa.GObtenerRegistros MrslistadodeArticulos, LArrayBusqueda, 2, 2
  FBusquedasMa.Show vbModal
  If GrecibeUbicacion <> 0 Then
     txtcodarticulo.Text = GrecibeColumnaID
     lblarticulo.Caption = GrecibeColumnaOpcional
     txtcodcompra.SetFocus
  End If

Exit Sub
errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbExclamation, "Advertencia"

End Sub

Private Sub cmdbuscarproveedor_Click()
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "VENDIDSS"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1000
  LArrayBusqueda(2, 1) = "DESCR"
  LArrayBusqueda(2, 2) = "Descripción"
  LArrayBusqueda(2, 3) = 6000
            
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  FBusquedasMa.GObtenerRegistros MrslistadodeProveedores, LArrayBusqueda, 2, 2
  FBusquedasMa.Show vbModal
  If GrecibeUbicacion <> 0 Then
     txtproveedor.Text = GrecibeColumnaID
     lblproveedor.Caption = GrecibeColumnaOpcional
     txtcodarticulo.SetFocus
  End If
End Sub

Private Sub cmdbusprovcons_Click()
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "VENDIDSS"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1000
  LArrayBusqueda(2, 1) = "DESCR"
  LArrayBusqueda(2, 2) = "Descripción"
  LArrayBusqueda(2, 3) = 6000
            
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  FBusquedasMa.GObtenerRegistros MrslistadodeProveedores, LArrayBusqueda, 2, 2
  FBusquedasMa.Show vbModal
  If GrecibeUbicacion <> 0 Then
     txtproveedorcons.Text = GrecibeColumnaID
     lblproveedorcons.Caption = GrecibeColumnaOpcional
     txtalmacencons.SetFocus
  End If

End Sub

Private Sub cmdfiltrar_Click()
     
  Set dbconsulta.DataSource = MobjArticulo.ListarArticulosporSiteidProved(txtalmacencons.Text, txtproveedorcons.Text)
  dbconsulta.Refresh
  dbconsulta.Columns(0).Width = 2000
  dbconsulta.Columns(1).Width = 5500
  
End Sub

Private Sub cmdgrabar_Click()

On Error GoTo errhandler

  Dim LArrayAlmacenes()
     
  LArrayAlmacenes = ListRAlmacenes.llenar_matriz
  Lintfilas = UBound(LArrayAlmacenes) - 1
  
  If Lintfilas = 0 Then
     MsgBox "Debe seleccionar un Almacen", vbDefaultButton1 + vbExclamation, "Advertencia"
     Exit Sub
  End If
  
  If MsgBox("Desea replicar los artículos seleccionados para el proveedor " & lblproveedor.Caption & " en los almacenes seleccionados", vbYesNo + vbQuestion, "Advertencia") = vbNo Then
     Exit Sub
  End If
     
  Screen.MousePointer = vbHourglass
     
  For i = 1 To Lintfilas
      MobjArticulo.GrabarRelacionProvArt MDblIdentificador, LArrayAlmacenes(i, 1)
  Next
   
  MsgBox "Artículos registrados", vbDefaultButton1 + vbInformation, "Mensaje"
   
  'Limpiar los Temporales
  MobjArticulo.BorrarTMP_IN_VENDORINVTREL MDblIdentificador
  
  Set dbregistroarticulo.DataSource = MobjArticulo.MostrarDetalleTMP_IN_VENDORINVTREL(MDblIdentificador, txtproveedor.Text)
  dbregistroarticulo.Caption = "Artículos a Replicar"
  dbregistroarticulo.Columns(0).Width = 1200
  dbregistroarticulo.Columns(1).Width = 3900
  dbregistroarticulo.Columns(2).Width = 1200
  dbregistroarticulo.Columns(3).Width = 3900
  
  dbregistroarticulo.Refresh
   
  Screen.MousePointer = 0
Exit Sub
errhandler:
  Screen.MousePointer = 0
  MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbExclamation, "Advertencia"
End Sub

Private Sub cmdgrabarsel_Click()
 
 On Error GoTo errhandler

 Dim LArrayAlmacenes()
 Dim LArrayArticulo()
 Dim Lintfilas As Integer
 Dim LintfilasArticulo As Integer
 
  LArrayArticulo = ListRArticulos.llenar_matriz
  LArrayAlmacenes = ListRAlmacenes.llenar_matriz
  
  Lintfilas = UBound(LArrayAlmacenes) - 1
  LintfilasArticulo = UBound(LArrayArticulo) - 1
  
  If Trim(txtcodprovsel.Text) = Empty Then
     MsgBox "Debe Ingresar un Proveedor", vbDefaultButton1 + vbExclamation, "Advertencia"
     txtcodprovsel.SetFocus
     Exit Sub
  End If
  If LintfilasArticulo = 0 Then
     MsgBox "Debe seleccionar un Artículo", vbDefaultButton1 + vbExclamation, "Advertencia"
     Exit Sub
  End If
  If Lintfilas = 0 Then
     MsgBox "Debe seleccionar un Almacen", vbDefaultButton1 + vbExclamation, "Advertencia"
     Exit Sub
  End If
    
  Screen.MousePointer = vbHourglass
  
  For j = 1 To LintfilasArticulo
   For i = 1 To Lintfilas
       MobjArticulo.AsignarProveedor txtcodprovsel.Text, LArrayArticulo(j, 1), LArrayArticulo(j, 2), GstrCodMonedaBase, LArrayAlmacenes(i, 1)
   Next
  Next
  Screen.MousePointer = 0
  MsgBox "Artículos registrados", vbDefaultButton1 + vbInformation, "Mensaje"
  
Exit Sub
errhandler:
   Screen.MousePointer = 0
   MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbExclamation, "Advertencia"
 
End Sub

Private Sub cmdSalir_Click()
  Unload Me
End Sub

Private Sub cmdsalirsel_Click()
 Unload Me
End Sub
Public Sub primer_registro()
End Sub
Public Sub ultimo_registro()
End Sub
Public Sub registro_anterior()
End Sub
Public Sub registro_siguiente()
End Sub

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

Private Sub Form_Initialize()
    Call gHabilitarReg(Me, False)
End Sub

Private Sub Form_Load()

    Call gseguridad(Me)
    If pbderecho_consultar Then
        Set MobjAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
        Set MobjArticulo = New DB_INV_ARTICULO.C_ARTICULO
        Set MobjProveedor = New DB_INV_MANTENIMIENTOS.C_PROVEEDOR
        Set MobjCorrelativo = New DB_CORRELATIVO.C_Correlativos
                  
        STARelProvArti.Tab = 0
         
        'LLenar la lista con Almacenes
        
        ListRAlmacenes.llena_lista Nothing, MobjAlmacen.ListarAlmacenesPorStatus(1)
        ListRAlmacenes.Size (26)
          
        'LLenar la lista con Articulo
        
        ListRArticulos.llena_lista MobjArticulo.ListarArticulosayuda, Nothing
        ListRArticulos.Size 24, 30
        
        'Obtener Correlativo
          
        Set MobjCorrelativo = New DB_CORRELATIVO.C_Correlativos
        MDblIdentificador = MobjCorrelativo.ObtenerCorrelativo(GCUSERID)
        Set MobjCorrelativo = Nothing
          
          
        Set MrslistadodeArticulos = MobjArticulo.ListarArticulosayuda
        Set MrslistadodeProveedores = MobjProveedor.ListarProveedoresAyuda
        Set MrslistadodeAlmacenes = MobjAlmacen.ListarAlmacenesPorStatus(1)
            
        Call asigna_campos
        pb_primerregistro = True
        
    'lineas nuevas
    Else
        'Unload Me
        MsgBox ("No tiene Derechos de Consultar en este formulario"), vbCritical + vbDefaultButton1, "Mensaje"
    End If
  
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Set MrslistadodeArticulos = Nothing
  Set MrslistadodeProveedores = Nothing
  Set MrslistadodeAlmacenes = Nothing
  Set MobjAlmacen = Nothing
  
  'Limpiar Temporal
  If Not MobjArticulo Is Nothing Then
    MobjArticulo.BorrarTMP_IN_VENDORINVTREL MDblIdentificador
  End If
  Set MobjArticulo = Nothing
  
  Set MobjProveedor = Nothing
  
End Sub

Private Sub STARelProvArti_Click(PreviousTab As Integer)
  
  If STARelProvArti.Tab = 1 Then
     If Not MobjArticulo.MostrarDetalleTMP_IN_VENDORINVTREL(MDblIdentificador, txtproveedor.Text).EOF Then
        MsgBox "Está utilizando la opción de Registro por Código", vbDefaultButton1 + vbExclamation, "Advertencia"
        STARelProvArti.Tab = PreviousTab
     End If
  End If
  
  If STARelProvArti.Tab = o Then
     If ListRArticulos.nseleccionados > 0 Then
        MsgBox "Está utilizando la opción de Registro por Selección", vbDefaultButton1 + vbExclamation, "Advertencia"
        STARelProvArti.Tab = PreviousTab
     End If
  End If
  
End Sub

Private Sub txtalmacencons_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF2 Then cmdbusalmaccons_Click
End Sub

Private Sub txtalmacencons_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
  If KeyAscii = 13 Then
     If Not MobjAlmacen.ListarPorAlmacenID(txtalmacencons.Text).EOF Then
        lblalmacencons.Caption = MobjAlmacen.ListarPorAlmacenID(txtalmacencons.Text)!Name
        cmdfiltrar.SetFocus
     Else
        MsgBox "Código de Almacén no existe ", vbDefaultButton1 + vbExclamation, "Advertencia"
        lblalmacencons.Caption = Empty
        txtalmacencons.SetFocus
     End If
  End If
End Sub

Private Sub txtcodarticulo_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF2 Then cmdbuscararticulo_Click
End Sub

Private Sub Txtcodarticulo_KeyPress(KeyAscii As Integer)
On Error GoTo errhanlder
  KeyAscii = GBloqueaCaracter(KeyAscii)
  If KeyAscii = 13 Then
     lblarticulo.Caption = MobjArticulo.ObtenerDescripcion(txtcodarticulo.Text)
     If Trim(lblarticulo.Caption) = Empty Then
        MsgBox "Código de artículo no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
        lblarticulo.Caption = Empty
        txtcodarticulo.SetFocus
     Else
        txtcodcompra.SetFocus
     End If
  End If
Exit Sub
errhanlder:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbExclamation, "Advertencia"
End Sub
Private Sub txtcodcompra_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     TxtDescripcion.SetFocus
  End If
End Sub

Private Sub txtcodprovsel_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyF2 Then cmdbuscaprovsel_Click
End Sub

Private Sub txtcodprovsel_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
  If KeyAscii = 13 Then
     If Not MobjProveedor.ListarPorProveedorID(txtcodprovsel.Text).EOF Then
        lblprovsel.Caption = MobjProveedor.ListarPorProveedorID(txtcodprovsel.Text)!DESCR
     Else
        MsgBox "Código de Proveedor no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
        lblprovsel.Caption = Empty
        txtcodprovsel.SetFocus
     End If
  End If

End Sub

Private Sub txtDescripcion_KeyPress(KeyAscii As Integer)
On Error GoTo errhanlder
  If KeyAscii = 13 Then
     If Trim(txtproveedor.Text) = Empty Then
        MsgBox "Ingrese Código de Proveedor", vbDefaultButton1 + vbExclamation, "Advertencia"
        txtproveedor.SetFocus
        Exit Sub
     End If
     If Trim(txtcodcompra.Text) = Empty Then
        MsgBox "Ingrese Código de Compra", vbDefaultButton1 + vbExclamation, "Advertencia"
        txtcodcompra.SetFocus
        Exit Sub
     End If
     If Trim(TxtDescripcion.Text) = Empty Then
        MsgBox "Ingrese Descripción", vbDefaultButton1 + vbExclamation, "Advertencia"
        TxtDescripcion.SetFocus
        Exit Sub
     End If
     
     MobjArticulo.GrabarArticuloenTMP_IN_VENDORINVTREL MDblIdentificador, txtproveedor.Text, txtcodarticulo.Text, txtcodcompra.Text, TxtDescripcion.Text, GstrCodMonedaBase
     
     'Refrescar la grilla
     
     Set dbregistroarticulo.DataSource = MobjArticulo.MostrarDetalleTMP_IN_VENDORINVTREL(MDblIdentificador, txtproveedor.Text)
     dbregistroarticulo.Caption = "Artículos a Replicar"
     dbregistroarticulo.Columns(0).Width = 1200
     dbregistroarticulo.Columns(1).Width = 3900
     dbregistroarticulo.Columns(2).Width = 1200
     dbregistroarticulo.Columns(3).Width = 3900
     dbregistroarticulo.Refresh
     
     txtcodarticulo.Text = Empty
     lblarticulo.Caption = Empty
     txtcodcompra.Text = Empty
     TxtDescripcion.Text = Empty
     
     txtcodarticulo.SetFocus
     
  End If
Exit Sub
errhanlder:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbExclamation, "Advertencia"
End Sub

Private Sub txtproveedor_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF2 Then cmdbuscarproveedor_Click
End Sub

Private Sub txtproveedor_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
  If KeyAscii = 13 Then
     If Not MobjProveedor.ListarPorProveedorID(txtproveedor.Text).EOF Then
        lblproveedor.Caption = MobjProveedor.ListarPorProveedorID(txtproveedor.Text)!DESCR
        txtcodarticulo.SetFocus
     Else
        MsgBox "Código de Proveedor no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
        lblproveedor.Caption = Empty
        txtproveedor.SetFocus
     End If
  End If
End Sub

Private Sub txtproveedorcons_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyF2 Then cmdbusprovcons_Click
End Sub

Private Sub txtproveedorcons_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
  If KeyAscii = 13 Then
     If Not MobjProveedor.ListarPorProveedorID(txtproveedorcons.Text).EOF Then
        lblproveedorcons.Caption = MobjProveedor.ListarPorProveedorID(txtproveedorcons.Text)!DESCR
        txtalmacencons.SetFocus
     Else
        MsgBox "Código de Proveedor no existe", vbDefaultButton1 + vbExclamation, "Advertencia"
        lblproveedorcons.Caption = Empty
        txtproveedorcons.SetFocus
     End If
  End If
End Sub
Public Sub agregar_registro()
    'Call gagregar_registro(Me, txtCodigo)
End Sub
Public Sub modificar_registro()
    'Call gmodificar_registro(Me, txtCodigo)
End Sub
Public Sub descartar_registro()
   ' Revertir cambios
    'adodc1.Recordset.CancelUpdate
    Call gdescartar_registro(Me)
    'Call asigna_campos
End Sub
Sub obtener_datos()
 
End Sub
Sub salir_formulario()
    ' validar que no haya procesos pendientes
    ' si no hay problemas
    MDIFMaestros.Toolbar1.Buttons(18).Caption = "Salir"    ' boton salir
    Unload Me
End Sub
Sub asigna_campos() ' falta decidir si va ha ser public o private
End Sub
Sub imprimir()
End Sub
Public Sub actualizar_registro()
End Sub
Public Sub grabar_registro()

On Error GoTo errhandler

    If valida_datos() = True Then
        ' llamada al proc de grabacion
        If pb_agregar Then
        Else
        End If
        Call ggrabar_registro(Me)
    End If
    
Exit Sub

errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"

End Sub
Function valida_datos()
 valida_datos = True
End Function

Public Sub borrar_registro()

On Error GoTo errhandler
        
    Call actualizar_registro
    
Exit Sub
errhandler:
    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Advertencia"
End Sub
