VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Begin VB.Form Fcodcompra 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Modificar Códigos de Compra"
   ClientHeight    =   3465
   ClientLeft      =   5520
   ClientTop       =   6300
   ClientWidth     =   6795
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3465
   ScaleWidth      =   6795
   Begin VB.Frame Frame1 
      Height          =   2415
      Left            =   120
      TabIndex        =   7
      Top             =   0
      Width           =   6615
      Begin VB.CommandButton cdmbusalmacen 
         Height          =   375
         Left            =   6000
         Picture         =   "FNuevModicodcompra.frx":0000
         Style           =   1  'Graphical
         TabIndex        =   16
         Top             =   720
         Width           =   495
      End
      Begin VB.CommandButton cdmbuscarproveedor 
         Height          =   375
         Left            =   6000
         Picture         =   "FNuevModicodcompra.frx":0532
         Style           =   1  'Graphical
         TabIndex        =   15
         Top             =   360
         Width           =   495
      End
      Begin MSDataListLib.DataCombo Dtcalmacen 
         Height          =   315
         Left            =   1920
         TabIndex        =   1
         Top             =   750
         Width           =   3975
         _ExtentX        =   7011
         _ExtentY        =   556
         _Version        =   393216
         Text            =   ""
      End
      Begin VB.TextBox txtdescripcion 
         Height          =   285
         Left            =   1920
         TabIndex        =   3
         Top             =   1560
         Width           =   3975
      End
      Begin VB.TextBox txtcodcompra 
         Height          =   285
         Left            =   1920
         TabIndex        =   2
         Top             =   1170
         Width           =   2535
      End
      Begin MSDataListLib.DataCombo DtcProveedor 
         Height          =   315
         Left            =   1920
         TabIndex        =   0
         Top             =   360
         Width           =   3975
         _ExtentX        =   7011
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   "DataCombo1"
      End
      Begin MiControl.CtrlNumber ctncosto 
         Height          =   375
         Left            =   1920
         TabIndex        =   4
         Top             =   1920
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   661
         BackColor       =   -2147483643
         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
      End
      Begin MSDataListLib.DataCombo DTcmoneda 
         Height          =   315
         Left            =   3720
         TabIndex        =   5
         Top             =   1920
         Width           =   2175
         _ExtentX        =   3836
         _ExtentY        =   556
         _Version        =   393216
         Style           =   2
         Text            =   "DataCombo1"
      End
      Begin VB.Label Label6 
         Caption         =   "Almacén"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   750
         Width           =   1575
      End
      Begin VB.Label Label5 
         Caption         =   "en"
         Height          =   255
         Left            =   3360
         TabIndex        =   13
         Top             =   1920
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "Costo"
         Height          =   255
         Left            =   240
         TabIndex        =   12
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Label Label3 
         Caption         =   "Descripción"
         Height          =   255
         Left            =   240
         TabIndex        =   11
         Top             =   1560
         Width           =   1575
      End
      Begin VB.Label Label2 
         Caption         =   "Código de Compra"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   1155
         Width           =   1575
      End
      Begin VB.Label Label1 
         Caption         =   "Proveedor"
         Height          =   375
         Left            =   240
         TabIndex        =   9
         Top             =   360
         Width           =   1695
      End
   End
   Begin VB.CommandButton cmdsalir 
      Caption         =   "&Cancelar"
      Height          =   735
      Left            =   5520
      Picture         =   "FNuevModicodcompra.frx":0A64
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   2640
      Width           =   1215
   End
   Begin VB.CommandButton cmdgrabar 
      Caption         =   "&Grabar"
      Height          =   735
      Left            =   4200
      Picture         =   "FNuevModicodcompra.frx":0D6E
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   2640
      Width           =   1335
   End
End
Attribute VB_Name = "Fcodcompra"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'Busquedas ***********************************************
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As Variant
Public GrecibeColumnaOpcional2 As Variant
'*********************************************************
Public GstrCodCompra As String
Public GstrCodAlmacen As String
Public GDBLCosto As Double
Public GSTRdescripcion As String
Public Gblnagregando As Boolean
Public GblnModificando As Boolean
Public GDblIdentificador As Double
Public GstrcodProveedor As String
Public GstrcodArticulo As String
Public GSTRMonedaBase As String
Public GSTRMonedaRecibida As String
Private MrsListadoMoneda As ADODB.Recordset
Private MrsListadoProveedor  As ADODB.Recordset
Private MrsListadoAlmacen As ADODB.Recordset
Private MobjArticulo As DB_INV_ARTICULO.C_ARTICULO
Private MobjProveedor As DB_INV_MANTENIMIENTOS.C_PROVEEDOR
Private MobjMoneda As DB_MA_MANTENIMIENTOS.C_MONEDA
Private MobjAlmacen As DB_INV_MANTENIMIENTOS.C_ALMACEN

Private Sub cdmbusalmacen_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) = "Descripción "
  LArrayBusqueda(2, 3) = 4000
  
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
    
  FBusGeneral.GObtenerRegistros MrsListadoAlmacen.Clone, LArrayBusqueda, 2, 2, 7800, , 3400, 3800, , "CODCOMPRA"
  FBusGeneral.Show vbModal
  
  If GrecibeUbicacion <> 0 Then
     Dtcalmacen.BoundText = GrecibeColumnaID
  End If
     
End Sub

Private Sub cdmbuscarproveedor_Click()
  
 Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "VENDIDSS"
  LArrayBusqueda(1, 2) = "Código"
  LArrayBusqueda(1, 3) = 1100
  LArrayBusqueda(2, 1) = "descr"
  LArrayBusqueda(2, 2) = "Nombre"
  LArrayBusqueda(2, 3) = 4500
  
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  
  
  FBusGeneral.GObtenerRegistros MrsListadoProveedor.Clone, LArrayBusqueda, 2, 2, 7800, , 3400, 3800, , "CODCOMPRA"
  FBusGeneral.Show vbModal
  
  If GrecibeUbicacion <> 0 Then
     DtcProveedor.BoundText = GrecibeColumnaID
  End If


End Sub

Private Sub cmdgrabar_Click()
On Error GoTo ErrorHandler
   If Trim(DtcProveedor.Text) = Empty Then
      MsgBox "Ingrese Proveedor", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
      DtcProveedor.SetFocus
      Exit Sub
   End If
   If Trim(txtcodcompra.Text) = Empty Then
      MsgBox "Ingrese Código de Compra", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
      txtcodcompra.SetFocus
      Exit Sub
   End If
   If Trim(txtdescripcion.Text) = Empty Then
      MsgBox "Ingrese descripción", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
      txtdescripcion.SetFocus
      Exit Sub
   End If
   
   
   If Gblnagregando = True Then
      MobjArticulo.GrabarCodigoCompraenTemp GDblIdentificador, DtcProveedor.BoundText, GstrcodArticulo, _
                                             Dtcalmacen.BoundText, txtcodcompra.Text, txtdescripcion.Text, DTcmoneda.BoundText, _
                                             ctncosto.Text
   Else
     'Se va ha Modificar
      MobjArticulo.ActualizarCodigoCompraenTemp GDblIdentificador, DtcProveedor.BoundText, GstrcodArticulo, _
                                             Dtcalmacen.BoundText, txtcodcompra.Text, txtdescripcion.Text, DTcmoneda.BoundText, _
                                             ctncosto.Text
     
   End If
   
   Unload Me
Exit Sub
ErrorHandler:
    
   MsgBox MensajedeError(ERR.Number, ERR.Description), vbExclamation + vbDefaultButton1, "Advertencia"
      
End Sub

Private Sub cmdSalir_Click()
   Unload Me
End Sub

Private Sub Form_Activate()

   If Not MrsListadoMoneda.EOF Then
    If Gblnagregando = True Then
       DTcmoneda.BoundText = GSTRMonedaBase
       txtdescripcion.Text = GSTRdescripcion
       ctncosto.Text = GFormatodeNumero(0, GintDecCosto)
    Else
       If GblnModificando = True Then
          DTcmoneda.BoundText = GSTRMonedaRecibida
          DtcProveedor.BoundText = GstrcodProveedor
          Dtcalmacen.BoundText = GstrCodAlmacen
          txtcodcompra.Text = GstrCodCompra
          txtdescripcion.Text = GSTRdescripcion
          ctncosto.Text = GFormatodeNumero(GDBLCosto, GintDecCosto)
       End If
    End If
   End If
   
   
End Sub

Private Sub Form_Load()

  Me.Top = 4300
  Me.Left = 4800

  ctncosto.Enteros = 8
  ctncosto.Decimales = GintDecCosto
  ctncosto.ValorPorDefecto
  
  Set MobjArticulo = New DB_INV_ARTICULO.C_ARTICULO
  Set MobjProveedor = New DB_INV_MANTENIMIENTOS.C_PROVEEDOR
  Set MobjMoneda = New DB_MA_MANTENIMIENTOS.C_MONEDA
  Set MobjAlmacen = New DB_INV_MANTENIMIENTOS.C_ALMACEN
     
  'Carga el DataCombo con Almacenes
  
  Set MrsListadoAlmacen = MobjAlmacen.ListarAlmacenesAyuda
     
  Set Dtcalmacen.DataSource = MrsListadoAlmacen
  Dtcalmacen.DataField = "name"
  Set Dtcalmacen.RowSource = MrsListadoAlmacen
  Dtcalmacen.ListField = "name"
  Dtcalmacen.BoundColumn = "siteid"
  If Not MrsListadoAlmacen.EOF Then
    Dtcalmacen.BoundText = MrsListadoAlmacen.Fields("name")
  End If
     
  
  'Carga el Datacombo de Proveedor
  Set MrsListadoProveedor = MobjProveedor.ListarProveedoresAyuda
   
  Set DtcProveedor.DataSource = MrsListadoProveedor
  DtcProveedor.DataField = "descr"
  Set DtcProveedor.RowSource = MrsListadoProveedor
  DtcProveedor.ListField = "descr"
  DtcProveedor.BoundColumn = "VENDIDSS"
  If Not MrsListadoProveedor.EOF Then
    DtcProveedor.BoundText = MrsListadoProveedor.Fields("descr")
  End If
 
  
  'Cargar el Datacombo de Moneda
  
  Set MrsListadoMoneda = MobjMoneda.ListarMonedas
    
  Set DTcmoneda.DataSource = MrsListadoMoneda
  DTcmoneda.DataField = "descr"
  Set DTcmoneda.RowSource = MrsListadoMoneda
  DTcmoneda.ListField = "descr"
  DTcmoneda.BoundColumn = "curyid"
  If Not MrsListadoMoneda.EOF Then
    DTcmoneda.BoundText = MrsListadoMoneda.Fields("descr")
  End If
  
  
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Set MrsListadoMoneda = Nothing
  Set MrsListadoProveedor = Nothing
  Set MobjArticulo = Nothing
  Set MobjProveedor = Nothing
  Set MobjMoneda = Nothing
End Sub


Private Sub txtcodcompra_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub

Private Sub txtDescripcion_KeyPress(KeyAscii As Integer)
  KeyAscii = GBloqueaCaracter(KeyAscii)
End Sub
