VERSION 5.00
Object = "{69F9D01E-F1DE-11D4-9536-002018603DA2}#7.0#0"; "ControlNumber.ocx"
Begin VB.Form FClienteProducto 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Agregar Cliente Producto"
   ClientHeight    =   3405
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6900
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3405
   ScaleWidth      =   6900
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox TxtCodigoPro 
      Height          =   285
      Left            =   1800
      TabIndex        =   9
      Top             =   360
      Width           =   2535
   End
   Begin VB.CheckBox ChkDesc 
      Caption         =   "Si lo Marcas es Aumento %  Si no lo Marcas Descuento %"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   8
      Top             =   1320
      Width           =   2895
   End
   Begin VB.CommandButton cmdcancelar 
      Cancel          =   -1  'True
      Caption         =   "Cancelar"
      Height          =   735
      Left            =   5400
      Picture         =   "FClienteProducto.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2520
      Width           =   1215
   End
   Begin VB.TextBox TxtDescripPro 
      Height          =   285
      Left            =   1800
      TabIndex        =   1
      Top             =   840
      Width           =   4695
   End
   Begin VB.CommandButton cmdBusTipoGar 
      Height          =   375
      Left            =   4440
      MouseIcon       =   "FClienteProducto.frx":030A
      MousePointer    =   99  'Custom
      Picture         =   "FClienteProducto.frx":045C
      Style           =   1  'Graphical
      TabIndex        =   0
      ToolTipText     =   "Buscar Tipo de Garantia"
      Top             =   360
      Width           =   375
   End
   Begin MiControl.CtrlNumber CtnPorcDesc 
      Height          =   255
      Left            =   1800
      TabIndex        =   2
      Top             =   1920
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   450
      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 VB.CommandButton cmdaceptar 
      Caption         =   "&Grabar"
      Height          =   735
      Left            =   4080
      Picture         =   "FClienteProducto.frx":098E
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2520
      Width           =   1335
   End
   Begin VB.Line Line2 
      X1              =   240
      X2              =   6600
      Y1              =   2400
      Y2              =   2400
   End
   Begin VB.Line Line1 
      X1              =   240
      X2              =   6600
      Y1              =   120
      Y2              =   120
   End
   Begin VB.Label lblTipoGar 
      AutoSize        =   -1  'True
      Caption         =   "Producto"
      Height          =   195
      Left            =   360
      TabIndex        =   7
      Top             =   360
      Width           =   645
   End
   Begin VB.Label lblDescrGar 
      Caption         =   "Descripción de Producto"
      Height          =   435
      Left            =   360
      TabIndex        =   6
      Top             =   840
      Width           =   1020
   End
   Begin VB.Label lblMontoGar 
      Caption         =   "Porcentaje"
      Height          =   255
      Left            =   360
      TabIndex        =   5
      Top             =   1920
      Width           =   855
   End
End
Attribute VB_Name = "FClienteProducto"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String


Public GlngCorrelativo As Long
Public GstrcodCliente As String
Public GstrCodProducto As String
Public GstrDesProducto As String
Public GstrDestAumt As String
Public GstrPorcDesc As Double
Public GblnModificando As Boolean
'
'Public GstrcodCliente As String
'Public GstrTipoGarantia As String
'Public GstrcodCliente As String
'Public GstrTipoGarantia As String
  
Public Gintayuda As Integer
Public GintStatus As Integer
Public GintBloqueaVentas As Integer
Public GintEsCombustible As Integer
Public GintVentCombenAutomatic As Integer
  

Public MobjArticulos As DB_INV_ARTICULO.C_ARTICULO
Public GobjFacturacionCombust As DB_OP_FACTURACION.C_VENTASPLAYA
Public objCliente As DB_MA_MANTENIMIENTOS.C_CLIENTE

Private MrslistadodeArticulos As ADODB.Recordset

Public Sub agregar_registro()
    Call gagregar_registro(Me, TxtCodigoPro)
    Call Limpiar
    MlngCorrelativo = objCorrelativo.ObtenerCorrelativo(GCUSERID)
    
End Sub

Private Sub Limpiar()
'funcionabilidad    : pone en blanco todos los controles de un formulario

Dim curcontrol As Control
    With Me
    For Each curcontrol In .Controls
        If TypeOf curcontrol Is TextBox Then
                curcontrol.Text = ""
        End If
         If TypeOf curcontrol Is DataCombo Then
                 curcontrol.Text = ""
        End If
         If TypeOf curcontrol Is ComboBox Then
              curcontrol.Text = ""
        End If
        If TypeOf curcontrol Is CtrlNumber Then
              curcontrol.ValorPorDefecto
        End If
        If TypeOf curcontrol Is CheckBox Then
              curcontrol.Value = 0
        End If
        
        If TypeOf curcontrol Is DTPicker Then
              curcontrol.Value = Now
        End If
    
    Next
    End With
    
    'dtpFechaProceso.Value = GDatFechaProceso
    
    lblDescripcion.Caption = Empty
    lblNumero.Caption = Empty
    lblEstado.Caption = Empty
    lblAprobar.Caption = Empty
    lblPrecioAnt.Caption = Empty
    lblCosto.Caption = Empty
    ''Call CargaGrid(-1)
    
End Sub


Sub CargarObgetos()
    ''Set MobjArticulos = New DB_INV_ARTICULO.C_ARTICULO
    ''Set MrslistadodeArticulos = MobjArticulos.ListarArticulos

    Set GobjFacturacionCombust = New DB_OP_FACTURACION.C_VENTASPLAYA
    Set MrslistadodeArticulos = GobjFacturacionCombust.ObtenerListadodeArticulos(GstrSiteProce, "PEN")
End Sub


Private Sub cmdAceptar_Click()

On Error GoTo ErrorHandler

  If Trim(TxtCodigoPro.Text) = Empty Then
     MsgBox "Ingrese Tipo de Garantia", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
     dtcTipoGarantia.SetFocus
     Exit Sub
  End If
  
  If Trim(TxtDescripPro.Text) = Empty Then
     MsgBox "Ingrese Descripción de Garantía", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
     txtDescGarantia.SetFocus
     Exit Sub
  End If
  
  Dim Operador As String
  Operador = IIf(ChkDesc.Value = 0, "-", "+")
 ' Operador = "A"
    If Not GblnModificando Then
   '  AgregarCliProdEnTmp GlngCorrelativo, Trim(TxtCodigoPro.Text)
     
     AgregarCliProEnTmp GlngCorrelativo, Trim(TxtCodigoPro.Text), _
                          Trim(TxtDescripPro.Text), Operador, CDbl(CtnPorcDesc.Text)

                      
    Else
       ActualizarCliProEnTmp GlngCorrelativo, Trim(TxtCodigoPro.Text), _
                          Trim(TxtDescripPro.Text), Operador, CDbl(CtnPorcDesc.Text)
    End If
    
  Unload Me

Exit Sub

ErrorHandler:
    
    MsgBox MensajedeError(ERR.Number, ERR.Description), vbCritical + vbDefaultButton1, "Advertencia"
End Sub

Private Sub cmdBusMonedaGar_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
       
     FBusquedasMa2.GObtenerRegistros objMoneda.ListarMonedas, ArrayBusqueda, 2, 2
     FBusquedasMa2.GnroPantalla = 0
     FBusquedasMa2.Show vbModal
     
     If GrecibeUbicacion <> 0 Then
         dtcMonedaGar.BoundText = GrecibeColumnaID
     End If
End Sub

Private Sub cmdBusTipoGar_Click()
'  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
'  LArrayBusqueda(1, 1) = "INVTIDSKU"
'  LArrayBusqueda(1, 2) = "Código"
'  LArrayBusqueda(1, 3) = 1800
'  LArrayBusqueda(2, 1) = "DESCR"
'  LArrayBusqueda(2, 2) = "Descripción"
'  LArrayBusqueda(2, 3) = 4800
'
'  GrecibeUbicacion = 0
'  GrecibeColumnaID = Empty
'  GrecibeColumnaOpcional = Empty

 Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
              
       Gintayuda = 2
       CliPro = 1
       
       'LArrayBusqueda(1, 1) = "Codigo"
       'LArrayBusqueda(1, 2) = "Código"
       'LArrayBusqueda(1, 3) = 1200
       'LArrayBusqueda(2, 1) = "Descripcion"
       'LArrayBusqueda(2, 2) = "Descripción"
       'LArrayBusqueda(2, 3) = 3500
       'LArrayBusqueda(3, 1) = "PConvert"
       'LArrayBusqueda(3, 2) = "Precio_Venta"
       'LArrayBusqueda(3, 3) = 1200
       'LArrayBusqueda(4, 1) = "StockActual"
       'LArrayBusqueda(4, 2) = "Stock"
       'LArrayBusqueda(4, 3) = 1200
       
       
       LArrayBusqueda(1, 1) = "Codigo"
       LArrayBusqueda(1, 2) = "Código"
       LArrayBusqueda(1, 3) = 1800
       LArrayBusqueda(2, 1) = "Descripcion"
       LArrayBusqueda(2, 2) = "Descripción"
       LArrayBusqueda(2, 3) = 4800
              
       GrecibeUbicacion = 0
       GrecibeColumnaID = Empty
       GrecibeColumnaOpcional = Empty
       
       ' Inicializar Variables del Articulo
       GintStatus = 0
       GintBloqueaVentas = 0
       GintEsCombustible = 0
       GintVentCombenAutomatic = 0
  
       FBusquedasMa.GObtenerRegistros MrslistadodeArticulos, LArrayBusqueda, 2, 2, 7500
       FBusquedasMa.DBListar.BackColor = RGB(0, 65, 128)
       FBusquedasMa.DBListar.ForeColor = RGB(255, 255, 255)
       FBusquedasMa.Show vbModal

       '  FBusquedasMa.GObtenerRegistros MrslistadodeArticulos, LArrayBusqueda, 2, 2
       '  FBusquedasMa.Show vbModal
       If FClienteProducto.GrecibeUbicacion <> 0 Then
          MrslistadodeArticulos.AbsolutePosition = FClienteProducto.GrecibeUbicacion
          Me.TxtCodigoPro.Text = FClienteProducto.GrecibeColumnaID
          Me.TxtDescripPro.Text = FClienteProducto.GrecibeColumnaOpcional
       End If
End Sub
Public Sub CargaDataCombo(objDataCombo As DataCombo, rsSource As ADODB.Recordset, istrCampo1 As String, istrCampo2 As String)
    If rsSource.RecordCount <> 0 Then
        Set objDataCombo.DataSource = rsSource
        objDataCombo.DataField = istrCampo2
        Set objDataCombo.RowSource = rsSource
        objDataCombo.ListField = istrCampo2
        objDataCombo.BoundColumn = istrCampo1
        objDataCombo.BoundText = rsSource.Fields(istrCampo2)
    End If
End Sub

Private Sub cmdCancelar_Click()
  Unload Me
  Set objCliente = Nothing
End Sub


Private Sub ctnMontoGar_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        dtpFecha.SetFocus
    End If
End Sub

Private Sub dtcMonedaGar_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        ctnMontoGar.SetFocus
    End If
End Sub

Private Sub dtcTipoGarantia_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        txtDescGarantia.SetFocus
    End If
End Sub

Private Sub dtpFecha_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = 13 Then
        cmdaceptar.SetFocus
    End If
End Sub

Private Sub Form_Load()
   CtnPorcDesc.Enteros = 8
   CtnPorcDesc.Decimales = GintDecResultado
        
   CargarObgetos
    
    
   TxtCodigoPro.Text = GstrCodProducto
   TxtCodigoPro.Enabled = Not GblnModificando
   TxtDescripPro.Text = GstrDesProducto
   ChkDesc.Value = IIf(Trim(GstrDestAumt) = "-", 0, 1)
   Me.CtnPorcDesc.Text = GFormatodeNumero(GstrPorcDesc, GintDecResultado)
   TxtDescripPro.Enabled = Not GblnModificando
   cmdBusTipoGar.Enabled = Not GblnModificando
End Sub

Private Sub Form_Unload(Cancel As Integer)
    GstrTipoGarantia = Empty
    GblnModificando = False
End Sub

Private Sub txtDescGarantia_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then
        dtcMonedaGar.SetFocus
    End If
End Sub

