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"
Begin VB.Form FClientePlacaEstacion 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cliente - Placa (01.112.00)"
   ClientHeight    =   2790
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6855
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   2790
   ScaleWidth      =   6855
   Begin TabDlg.SSTab SSTab1 
      Height          =   2775
      Left            =   0
      TabIndex        =   0
      ToolTipText     =   "Agregar Placa"
      Top             =   0
      Width           =   6855
      _ExtentX        =   12091
      _ExtentY        =   4895
      _Version        =   393216
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   520
      TabCaption(0)   =   "Datos Cliente"
      TabPicture(0)   =   "FClientePlacaEstacion.frx":0000
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "lblRuc"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "lblCodigo"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "lblNombre"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "lblDireccion1"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "lblTelefono"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "txtCodigo"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "txtRuc"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "cmdBuscar"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "txtDescripcion"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "txtDireccion1"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).Control(10)=   "txtTelefono"
      Tab(0).Control(10).Enabled=   0   'False
      Tab(0).ControlCount=   11
      TabCaption(1)   =   "Placas Clientes"
      TabPicture(1)   =   "FClientePlacaEstacion.frx":001C
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "cmdAgregar"
      Tab(1).Control(1)=   "txtPlaca"
      Tab(1).Control(2)=   "dbDetallePlacas"
      Tab(1).ControlCount=   3
      Begin VB.TextBox txtTelefono 
         Height          =   285
         Left            =   5040
         MaxLength       =   10
         TabIndex        =   13
         Top             =   1560
         Width           =   1455
      End
      Begin VB.TextBox txtDireccion1 
         Height          =   285
         Left            =   1320
         MaxLength       =   50
         TabIndex        =   8
         Top             =   2040
         Width           =   5175
      End
      Begin VB.TextBox txtDescripcion 
         Height          =   285
         Left            =   1320
         MaxLength       =   50
         TabIndex        =   7
         Top             =   1080
         Width           =   4095
      End
      Begin VB.CommandButton cmdBuscar 
         Enabled         =   0   'False
         Height          =   375
         Left            =   3360
         Picture         =   "FClientePlacaEstacion.frx":0038
         Style           =   1  'Graphical
         TabIndex        =   6
         ToolTipText     =   "Buscar Cliente"
         Top             =   600
         Width           =   375
      End
      Begin VB.TextBox txtRuc 
         Height          =   285
         Left            =   1320
         TabIndex        =   5
         Top             =   1560
         Width           =   1935
      End
      Begin VB.TextBox txtCodigo 
         Height          =   285
         Left            =   1320
         MaxLength       =   20
         TabIndex        =   4
         Top             =   600
         Width           =   1935
      End
      Begin VB.CommandButton cmdAgregar 
         Height          =   375
         Left            =   -72000
         Picture         =   "FClientePlacaEstacion.frx":056A
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   600
         Width           =   615
      End
      Begin VB.TextBox txtPlaca 
         Height          =   375
         Left            =   -74520
         TabIndex        =   2
         Top             =   600
         Width           =   2295
      End
      Begin MSDataGridLib.DataGrid dbDetallePlacas 
         Height          =   2055
         Left            =   -71160
         TabIndex        =   1
         Top             =   480
         Width           =   2655
         _ExtentX        =   4683
         _ExtentY        =   3625
         _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
         Caption         =   "[F3]_Eliminar Registro"
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   10250
               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            =   10250
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.Label lblTelefono 
         AutoSize        =   -1  'True
         Caption         =   "Teléfono"
         Height          =   195
         Left            =   3960
         TabIndex        =   14
         Top             =   1560
         Width           =   630
      End
      Begin VB.Label lblDireccion1 
         AutoSize        =   -1  'True
         Caption         =   "Dirección 1"
         Height          =   195
         Left            =   240
         TabIndex        =   12
         Top             =   2055
         Width           =   810
      End
      Begin VB.Label lblNombre 
         AutoSize        =   -1  'True
         Caption         =   "Razón Social"
         Height          =   195
         Left            =   240
         TabIndex        =   11
         Top             =   1080
         Width           =   945
      End
      Begin VB.Label lblCodigo 
         AutoSize        =   -1  'True
         Caption         =   "Código "
         Height          =   195
         Left            =   240
         TabIndex        =   10
         Top             =   600
         Width           =   540
      End
      Begin VB.Label lblRuc 
         AutoSize        =   -1  'True
         Caption         =   "RUC"
         Height          =   195
         Left            =   240
         TabIndex        =   9
         Top             =   1560
         Width           =   345
      End
   End
End
Attribute VB_Name = "FClientePlacaEstacion"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Programador: Edgar Cancho Ruiz
' Empresa Texaco
' Modulo de Maestra de Clientes
' Fecha : 18/11/2002

'Option Explicit
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

Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String

Public rs_Clientes As ADODB.Recordset
Public objCliente As DB_MA_MANTENIMIENTOS.C_CLIENTE


Dim objCorrelativo As DB_CORRELATIVO.C_Correlativos
Dim MlngCorrelativo As Long 'correlativo por usuario, que se almacenara en cada insert en tablas temporales

Private Sub cmdAgregarPlaca_Click()
    FClientePlaca.GlngCorrelativo = MlngCorrelativo
    FClientePlaca.GstrcodCliente = txtCodigo.Text
    FClientePlaca.Show vbModal
    CargaGrillaPlacas Empty, MlngCorrelativo, False
End Sub


Private Sub cmdAgregar_Click()
On Error GoTo ErrorHandler

  If Trim(txtPlaca.Text) = Empty Then
     MsgBox "Ingrese Número de Placa", vbDefaultButton1 + vbExclamation, "Faltan Parámetros"
     txtPlaca.SetFocus
     Exit Sub
  End If

  objCliente.AgregarPlacaEnTmp MlngCorrelativo, Trim(txtPlaca.Text)
  CargaGrillaPlacas Empty, MlngCorrelativo, False
  txtPlaca.Text = ""

Exit Sub

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

Private Sub cmdBuscar_Click()
    'Lineas que llaman al Formulario de Búsqueda
    
    Dim ArrayBusqueda(1 To 2, 1 To 3) As Variant
    ArrayBusqueda(1, 1) = "CUSTIDSS"
    ArrayBusqueda(1, 2) = "Código "
    ArrayBusqueda(1, 3) = 1200
    ArrayBusqueda(2, 1) = "CUSTNAME"
    ArrayBusqueda(2, 2) = "Nombre "
    ArrayBusqueda(2, 3) = 4000
      
          
    FBusquedasMa.GObtenerRegistros objCliente.ListarClientesAyuda(0), ArrayBusqueda, 2, 2
    FBusquedasMa.Show vbModal
    If GrecibeUbicacion <> 0 And GrecibeUbicacion <= rs_Clientes.RecordCount Then
          rs_Clientes.AbsolutePosition = GrecibeUbicacion
          asigna_campos
          Call gestadoactualrs(Me, rs_Clientes)
          Call gactualiza_barra(Me)
    End If
  
End Sub

Private Sub dbDetallePlacas_KeyUp(KeyCode As Integer, Shift As Integer)
 If cmdAgregar.Enabled Then
    If dbDetallePlacas.Bookmark <> 0 Or Not IsNull(dbDetallePlacas.Bookmark) Then
        If KeyCode = vbKeyF3 Then
            If MsgBox("Está seguro de Eliminar Placa. ", vbQuestion + vbYesNo, "Eliminar") = vbNo Then
                Exit Sub
            End If
            
            objCliente.EliminarPlacaEnTmp MlngCorrelativo, dbDetallePlacas.Columns(0).Text
            CargaGrillaPlacas Empty, MlngCorrelativo, False
     
        End If
    End If
 End If
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
    End If
End Sub

Public Sub primer_registro()
    Call Gprimer_registro(Me, rs_Clientes)
    Call asigna_campos
End Sub

Public Sub ultimo_registro()
    Call Gultimo_registro(Me, rs_Clientes)
    Call asigna_campos
End Sub

Public Sub registro_anterior()
    Call Gregistro_anterior(Me, rs_Clientes)
    Call asigna_campos
End Sub
Public Sub registro_siguiente()
    Call Gregistro_siguiente(Me, rs_Clientes)
    Call asigna_campos
End Sub
Private Sub Form_Initialize()
    Call gHabilitarReg(Me, False)
End Sub

Private Sub Form_Load()
    'seguridad
    Call gseguridad(Me)
    If pbderecho_consultar Then

        InstanciaObjetos
    
        Call obtener_datos
        LlenaDataCombos
        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
    

    SSTab1.Tab = 0
    
    Me.Top = 100
    Me.Left = (Screen.Width - Me.Width) / 2
    
End Sub
Public Sub borrar_registro()

'On Error GoTo errhandler
'
'    objCliente.EliminarCliente txtCodigo
'    Call gborrar_Registro(Me, rs_Clientes, txtCodigo)
'
'Exit Sub
'errhandler:
'    MsgBox MensajedeError(Err.Number, Err.Description), vbDefaultButton1 + vbCritical, "Error"
'
End Sub
Function valida_datos()
    If GVDATO(txtCodigo.Text) = Empty Then
        valida_datos = False
        MsgBox "Ingrese Código de Cliente", vbExclamation, "Error"
        SSTab1.Tab = 0
        txtCodigo.SetFocus
        Exit Function
    End If
    
    valida_datos = True
End Function
Public Sub grabar_registro()

On Error GoTo errhandler
    
    Dim LARRAY(1, 7) As Variant

    
    LARRAY(1, 1) = Trim(txtCodigo)
    LARRAY(1, 2) = Trim(txtDescripcion)
    LARRAY(1, 3) = Trim(txtRuc)
    LARRAY(1, 4) = Trim(txtTelefono)
    LARRAY(1, 5) = Trim(txtDireccion1)
    LARRAY(1, 6) = GCUSERID
    LARRAY(1, 7) = MlngCorrelativo
    
    If valida_datos() = True Then
        ' llamada al proc de grabacion
        If pb_agregar Then
            objCliente.Auxiliar1 LARRAY
        Else
            objCliente.Auxiliar2 LARRAY
        End If
        Call ggrabar_registro(Me)
        actualizar_registro
        SSTab1.Tab = 0
    End If
    
Exit Sub
errhandler:
    MsgBox MensajedeError(ERR.Number, ERR.Description), vbDefaultButton1 + vbCritical, "Error"
    

End Sub
Public Sub actualizar_registro()
    'llamar al procedimiento de carga
    Call obtener_datos
    Call asigna_campos
    'MsgBox ("Registros Actualizados")
End Sub
Public Sub agregar_registro()
    Call gagregar_registro(Me, txtCodigo)
    Limpiar
    MlngCorrelativo = objCorrelativo.ObtenerCorrelativo(GCUSERID)
    
End Sub
Public Sub modificar_registro()
    Call gmodificar_registro(Me, txtCodigo)
    MlngCorrelativo = objCorrelativo.ObtenerCorrelativo(GCUSERID)
    objCliente.CargarTablasTemporales MlngCorrelativo, txtCodigo.Text
End Sub
Public Sub descartar_registro()
    ' Revertir cambios
    'adodc1.Recordset.CancelUpdate
    Call gdescartar_registro(Me)
    Call asigna_campos
End Sub

Sub obtener_datos()
    Set rs_Clientes = objCliente.ListarClientes(0)
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
    If rs_Clientes.RecordCount <> 0 Then
        txtCodigo.Text = rs_Clientes!CUSTIDSS
        txtDescripcion.Text = rs_Clientes!CUSTNAME
        txtRuc.Text = rs_Clientes!Taxregnbr
        txtDireccion1.Text = rs_Clientes!Addr1
        txtTelefono.Text = GVDATO(rs_Clientes!PHONE)
        
        CargaGrillaPlacas rs_Clientes!CUSTIDSS, Empty, True

        
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If pb_editar Then
        If MsgBox("Desea Cancelar los Cambios", vbYesNo, "Esta Modificando un registro") = vbNo Then
            Cancel = True
        Else
            Call gdesactiva_barra
        End If
    Else
        Call gdesactiva_barra
    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 Form_Unload(Cancel As Integer)
   DestruyeObjetos
End Sub

Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then
        txtDescripcion.SetFocus
    End If
End Sub



Private Sub txtDescripcion_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then
        txtRuc.SetFocus
    End If
End Sub



Private Sub txtDireccion1_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then

    End If

End Sub

Private Sub txtDireccion2_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then
        txtTelefono.SetFocus
    End If
End Sub



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

Private Sub txtRuc_KeyPress(KeyAscii As Integer)
    KeyAscii = GBloqueaCaracter(KeyAscii)
    If KeyAscii = 13 Then

    End If
End Sub

Private Sub txtTelefono_KeyPress(KeyAscii As Integer)
    KeyAscii = MValidaNumeros(KeyAscii)
    If KeyAscii = 13 Then
        
    End If
End Sub

Private Function MValidaNumeros(KeyAscii As Integer) As Integer
    If (KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 13 Or KeyAscii = 8 Then
        MValidaNumeros = KeyAscii
    Else
        MValidaNumeros = 0
    End If
End Function

Sub imprimir()
 
'    crCliente.ReportFileName = GstrReportesInv + "rpt_Cliente.rpt"
'    crCliente.WindowTitle = "Reporte de Clientes"
'    crCliente.Formulas(1) = "formusuario=stringvar strusuario; strusuario:='" & GCUSERID & "'"
'    crCliente.Formulas(2) = "formscreen=stringvar strscreen; strscreen:='01.110.00'"
'    crCliente.WindowState = crptMaximized
'    crCliente.WindowShowPrintSetupBtn = True
'    crCliente.Action = 1
  
End Sub


' Procedimiento de carga de los DataCombos del formulario
Private Sub LlenaDataCombos()
 
End Sub

Private Sub UbicaItemEnDataCombo()
On Error Resume Next
'    dtcTipoIngreso.BoundText = MstrTipoMovimiento
'    dtcAlmacen.BoundText = MstrAlmacen
'    dtcProveedor.BoundText = MstrProveedor
'    dtcTipoDoc.BoundText = MstrTipoDoc
'    dtcMoneda.BoundText = MstrMoneda
'    txtArticulo.Text = MstrArticulo
End Sub

Private Sub InstanciaObjetos()
    
    Set objCorrelativo = New DB_CORRELATIVO.C_Correlativos
    Set rs_Clientes = New ADODB.Recordset
    Set objCliente = New DB_MA_MANTENIMIENTOS.C_CLIENTE
    
End Sub

Private Sub DestruyeObjetos()
    Set objCorrelativo = Nothing
    Set rs_Clientes = Nothing
    Set objCliente = Nothing

End Sub

Private Sub CargaGrillaPlacas(CodCliente As String, Correlativo As Long, Flag As Boolean)
    If Flag Then
        Set dbDetallePlacas.DataSource = objCliente.ListarPlacas(CodCliente)
    Else
        Set dbDetallePlacas.DataSource = objCliente.SeleccionaEnTmpCustBadge(Correlativo)
    End If
    dbDetallePlacas.Columns(0).Width = 2000
    dbDetallePlacas.Refresh
End Sub



Private Sub Limpiar()
    CargaGrillaPlacas Empty, Empty, True
    SSTab1.Tab = 0
End Sub



