VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form F_CASHDROP 
   AutoRedraw      =   -1  'True
   Caption         =   "Cash Drop"
   ClientHeight    =   5475
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11850
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   5475
   ScaleWidth      =   11850
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmd_bvendedor 
      Height          =   375
      Left            =   3840
      Picture         =   "FCASHDROP.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   720
      Width           =   375
   End
   Begin VB.CommandButton cmd_bcliente 
      Height          =   320
      Left            =   9040
      Picture         =   "FCASHDROP.frx":0532
      Style           =   1  'Graphical
      TabIndex        =   6
      Top             =   5520
      Visible         =   0   'False
      Width           =   350
   End
   Begin VB.TextBox ctrl_monto 
      Alignment       =   1  'Right Justify
      Height          =   315
      Left            =   10630
      MaxLength       =   11
      TabIndex        =   8
      Top             =   5520
      Visible         =   0   'False
      Width           =   975
   End
   Begin VB.TextBox txt_clave 
      Height          =   285
      IMEMode         =   3  'DISABLE
      Left            =   1440
      PasswordChar    =   "*"
      TabIndex        =   2
      Top             =   1080
      Width           =   2295
   End
   Begin MSDataListLib.DataCombo dtc_vendedor 
      Height          =   315
      Left            =   1440
      TabIndex        =   0
      Top             =   720
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   556
      _Version        =   393216
      Style           =   2
      Text            =   ""
   End
   Begin VB.TextBox txt_correlativo 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3240
      TabIndex        =   20
      Top             =   120
      Width           =   1935
   End
   Begin VB.CommandButton cmd_eliminar 
      Caption         =   "&Eliminar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   2040
      Picture         =   "FCASHDROP.frx":0A64
      Style           =   1  'Graphical
      TabIndex        =   10
      Tag             =   "R ASDASD"
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmd_agregar 
      Caption         =   "&Agregar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   240
      Picture         =   "FCASHDROP.frx":0D6E
      Style           =   1  'Graphical
      TabIndex        =   9
      Tag             =   "R ASDASD"
      Top             =   4560
      Width           =   1215
   End
   Begin VB.TextBox txt_turno 
      Enabled         =   0   'False
      Height          =   285
      Left            =   9000
      TabIndex        =   19
      Top             =   1080
      Width           =   375
   End
   Begin VB.TextBox txt_fechaproceso 
      Enabled         =   0   'False
      Height          =   285
      Left            =   7200
      TabIndex        =   18
      Top             =   1080
      Width           =   1095
   End
   Begin VB.TextBox txt_site 
      Enabled         =   0   'False
      Height          =   285
      Left            =   7200
      TabIndex        =   17
      Top             =   720
      Width           =   1935
   End
   Begin VB.CommandButton CMD_CANCELAR 
      Cancel          =   -1  'True
      Caption         =   "&Cancelar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   9360
      Picture         =   "FCASHDROP.frx":1078
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   4560
      Width           =   1335
   End
   Begin VB.CommandButton CMD_Grabar 
      Caption         =   "&Grabar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   7680
      Picture         =   "FCASHDROP.frx":1382
      Style           =   1  'Graphical
      TabIndex        =   11
      Tag             =   "R ASDASD"
      Top             =   4560
      Width           =   1215
   End
   Begin MSDataListLib.DataCombo DTC_TARJETA 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   """S/."" #,##0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   10250
         SubFormatType   =   0
      EndProperty
      Height          =   315
      Left            =   2020
      TabIndex        =   4
      Top             =   5520
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   556
      _Version        =   393216
      IntegralHeight  =   0   'False
      MatchEntry      =   -1  'True
      Style           =   2
      Text            =   ""
   End
   Begin MSDataListLib.DataCombo DTC_MONEDA 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   """S/."" #,##0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   10250
         SubFormatType   =   0
      EndProperty
      Height          =   315
      Left            =   9400
      TabIndex        =   7
      Top             =   5520
      Visible         =   0   'False
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   556
      _Version        =   393216
      IntegralHeight  =   0   'False
      MatchEntry      =   -1  'True
      Style           =   2
      Text            =   ""
   End
   Begin MSDataListLib.DataCombo dtc_cliente 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   """S/."" #,##0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   10250
         SubFormatType   =   0
      EndProperty
      Height          =   315
      Left            =   5560
      TabIndex        =   5
      Top             =   5520
      Visible         =   0   'False
      Width           =   3495
      _ExtentX        =   6165
      _ExtentY        =   556
      _Version        =   393216
      IntegralHeight  =   0   'False
      MatchEntry      =   -1  'True
      Style           =   2
      Text            =   ""
   End
   Begin MSDataListLib.DataCombo dtc_tdeposito 
      BeginProperty DataFormat 
         Type            =   0
         Format          =   """S/."" #,##0.00"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   10250
         SubFormatType   =   0
      EndProperty
      Height          =   315
      Left            =   480
      TabIndex        =   3
      Top             =   5520
      Visible         =   0   'False
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   556
      _Version        =   393216
      IntegralHeight  =   0   'False
      MatchEntry      =   -1  'True
      Style           =   2
      Text            =   ""
   End
   Begin MSDataGridLib.DataGrid DBDETALLE 
      Height          =   2415
      Left            =   120
      TabIndex        =   24
      TabStop         =   0   'False
      Top             =   1920
      Width           =   11655
      _ExtentX        =   20558
      _ExtentY        =   4260
      _Version        =   393216
      AllowUpdate     =   0   'False
      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.Label Label7 
      Caption         =   "F3 Eliminar      F5 Agregar        F7 Grabar"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6600
      TabIndex        =   23
      Top             =   1680
      Width           =   4575
   End
   Begin VB.Label Label6 
      Caption         =   "Clave Personal:"
      Height          =   255
      Left            =   120
      TabIndex        =   22
      Top             =   1080
      Width           =   1215
   End
   Begin VB.Label Label5 
      Caption         =   "CORRELATIVO:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   960
      TabIndex        =   21
      Top             =   120
      Width           =   2175
   End
   Begin VB.Label Label4 
      Caption         =   "Turno:"
      Enabled         =   0   'False
      Height          =   255
      Left            =   8520
      TabIndex        =   16
      Top             =   1080
      Width           =   495
   End
   Begin VB.Label Label3 
      Caption         =   "Fecha Proceso:"
      Height          =   255
      Left            =   6000
      TabIndex        =   15
      Top             =   1080
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "Vendedor:"
      Height          =   255
      Left            =   600
      TabIndex        =   14
      Top             =   720
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "Almacen:"
      Height          =   255
      Left            =   6360
      TabIndex        =   13
      Top             =   720
      Width           =   735
   End
End
Attribute VB_Name = "F_CASHDROP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public mobj_cventasgen As DB_OP_FACTURACION.C_VENTASGENERAL
Public MOBJ_CORRE As DB_CORRELATIVO.C_Correlativos
Public rs_cab As ADODB.Recordset
Public rs_det As ADODB.Recordset
Public MINT_CORRE As Integer
Public mint_correcash As Integer
Public GrecibeUbicacion As BookmarkEnum
Public GrecibeColumnaID As String
Public GrecibeColumnaOpcional As String
Public GrecibeColumnaOpcional2 As String
Public GrecibeColumnaOpcional3 As String
Private Sub cmd_agregar_Click()
If dtc_tdeposito.Text = "" And DTC_MONEDA.Text = "" Then
    MsgBox "Debe Completar los Datos" + Chr(13) + "Para agregar un nuevo registro", vbExclamation, "Atencion"
    Exit Sub
End If
With rs_det
    .AddNew
    !SITEID = GstrSiteProce
    !batnbrdeposit = mint_correcash
End With
Call mostrar_objetos
DBDETALLE_RowColChange 0, 0
actualiza_datos
dtc_tdeposito.SetFocus
End Sub

Private Sub cmd_bcliente_Click()
  Dim LArrayBusqueda(1 To 4, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "CUSTIDSS"
  LArrayBusqueda(1, 2) = "Id Cliente"
  LArrayBusqueda(1, 3) = 1000
  
  LArrayBusqueda(2, 1) = "CUSTNAME"
  LArrayBusqueda(2, 2) = "Cliente"
  LArrayBusqueda(2, 3) = 4000
  
  LArrayBusqueda(3, 1) = "TAXREGNBR"
  LArrayBusqueda(3, 2) = "R.U.C."
  LArrayBusqueda(3, 3) = 1800
  
  LArrayBusqueda(4, 1) = "ADDR1"
  LArrayBusqueda(4, 2) = "DIRECCION"
  LArrayBusqueda(4, 3) = 2700
  
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  GrecibeColumnaOpcional2 = Empty
  
  fbusquedas_cashdrop.GObtenerRegistros mobj_cventasgen.ListarClientesAyuda, LArrayBusqueda, 4, 2, 10000
  fbusquedas_cashdrop.Show vbModal
   
  If GrecibeUbicacion <> 0 Then
     dtc_cliente.BoundText = GrecibeColumnaID
     rs_det!CLIENTE = GrecibeColumnaOpcional
     rs_det!ruc = GrecibeColumnaOpcional2
  End If


End Sub

Private Sub cmd_bvendedor_Click()
  Dim LArrayBusqueda(1 To 2, 1 To 3) As Variant
  LArrayBusqueda(1, 1) = "salesperid"
  LArrayBusqueda(1, 2) = "Id Vendedor"
  LArrayBusqueda(1, 3) = 1000
  
  LArrayBusqueda(2, 1) = "SALESPERNAME"
  LArrayBusqueda(2, 2) = "Vendedor"
  LArrayBusqueda(2, 3) = 4000
  
  GrecibeUbicacion = 0
  GrecibeColumnaID = Empty
  GrecibeColumnaOpcional = Empty
  GrecibeColumnaOpcional2 = Empty
  
  fbusquedas_cashdrop.GObtenerRegistros mobj_cventasgen.ListarvendedorAyuda, LArrayBusqueda, 2, 2, 10000
  fbusquedas_cashdrop.Show vbModal
   
  If GrecibeUbicacion <> 0 Then
     dtc_vendedor.BoundText = GrecibeColumnaID
     txt_clave.SetFocus
  End If


End Sub
Private Sub cmd_Cancelar_Click()
Unload Me
End Sub
Private Sub cmd_eliminar_Click()
If rs_det.RecordCount > 1 Then
    rs_det.Delete
    If rs_det.RecordCount > 1 Then
        rs_det.MoveLast
         actualiza_datos                       'no hay registros
    End If
Else
    dtc_tdeposito.Text = ""
    DTC_TARJETA.Text = ""
    dtc_cliente.Text = ""
    DTC_MONEDA.Text = ""
    ctrl_monto.Text = ""
End If
End Sub
Private Sub CMD_Grabar_Click()
If validadet() Then
    Call grabar_deposito
    Unload Me
End If
End Sub

Public Function validadet() As Boolean
Dim li_nfilas As Integer
Dim li_nlinea As Integer
Dim ls_tdeposito As String
Dim ls_tarjeta As Variant
Dim ls_idcliente As Variant
Dim ls_moneda As String
Dim ls_monto As String

Dim qwerty As String
Dim ytrewq As String
Dim validar As Integer
qwerty = UCase(Trim(dtc_vendedor.BoundText))
ytrewq = UCase(Trim(txt_clave.Text))
If Len(qwerty) = 0 Then
    MsgBox ("Debe ingresar un usuario")
    dtc_vendedor.SetFocus
    Exit Function
End If
If Len(ytrewq) = 0 Then
    MsgBox ("Debe ingresar un password")
    txt_clave.SetFocus
    Exit Function
End If
validar = mobj_cventasgen.Validarvendedor(qwerty, ytrewq)
'Call MENSAJES_VENDEDOR(validar)
If validar <> 0 Then
    MsgBox "Clave incorrecta"
    txt_clave.SetFocus
    Exit Function
End If

li_nlinea = 1
li_nfilas = rs_det.RecordCount
If li_nfilas > 0 Then
    rs_det.MoveFirst
    Do While Not rs_det.EOF
        ls_tdeposito = rs_det!deposittypeid
        ls_tarjeta = rs_det!CARDID
        ls_idcliente = rs_det!custidss
        ls_moneda = rs_det!curyid
        ls_monto = rs_det!monto
        If Val(ls_monto) = 0 And Len(Trim(ls_moneda)) = 0 And Len(Trim(ls_tdeposito)) = 0 And _
            (Len(Trim(ls_tarjeta)) = 0 Or IsNull(ls_tarjeta)) And _
            (Len(Trim(ls_idcliente)) = 0 Or IsNull(ls_idcliente)) Then
            rs_det.Delete
        End If
        If Len(ls_tdeposito) = 0 Then
            MsgBox "Debe Ingresar un tipo de deposito en la linea " + Str(li_nlinea), vbCritical, "Datos Incompletos"
            dtc_tdeposito.SetFocus
            validadet = False
            Exit Function
        End If
        If ls_tdeposito = "E" Then
            DTC_TARJETA.BoundText = ""
            dtc_cliente.BoundText = ""
            rs_det!CARDID = Null
            rs_det!custidss = Null
        End If
        If ls_tdeposito = "T" Then
            dtc_cliente.BoundText = ""
            rs_det!custidss = Null
            If Len(Trim(ls_tarjeta)) = 0 Or IsNull(ls_tarjeta) Then
                MsgBox "Debe Ingresar un tipo de tarjeta en la linea " + Str(li_nlinea), vbCritical, "Datos Incompletos"
                DTC_TARJETA.SetFocus
                validadet = False
                Exit Function
            End If
        End If
        If ls_tdeposito = "V" Then
            DTC_TARJETA.BoundText = ""
            rs_det!CARDID = Null
            If Len(Trim(ls_idcliente)) = 0 Or IsNull(ls_idcliente) Then
                MsgBox "Debe Ingresar un Cliente en la linea " + Str(li_nlinea), vbCritical, "Datos Incompletos"
                dtc_cliente.SetFocus
                validadet = False
                Exit Function
            End If
        End If
        If Len(Trim(ls_moneda)) = 0 Then
            MsgBox "Debe Ingresar una moneda en la linea " + Str(li_nlinea), vbCritical, "Datos Incompletos"
            DTC_MONEDA.SetFocus
            validadet = False
            Exit Function
        End If
        If Val(ls_monto) = 0 Then
            MsgBox "Debe Ingresar un monto en la linea " + Str(li_nlinea), vbCritical, "Datos Incompletos"
            ctrl_monto.SetFocus
            validadet = False
            Exit Function
        End If
        rs_det!SEQUENCE = Val(li_nlinea)
        li_nlinea = li_nlinea + 1
        rs_det.MoveNext
    Loop
End If
validadet = True
End Function

Private Sub CTRL_MONTO_Change()
If Len(ctrl_monto) = 0 Then
    ctrl_monto.Text = "0"
End If
If rs_det.RecordCount > 0 Then
    rs_det!monto = Val(ctrl_monto.Text)
End If
End Sub

Private Sub ctrl_monto_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
    If rs_det.AbsolutePosition > 1 Then
        rs_det.MovePrevious
    End If
End If

If KeyCode = vbKeyDown Or KeyCode = 13 Then
    If rs_det.AbsolutePosition < rs_det.RecordCount And rs_det.AbsolutePosition >= 0 Then
        rs_det.MoveNext
    Else
        cmd_agregar_Click
    End If
End If

If KeyCode = vbKeyF5 Then
    cmd_agregar_Click
End If
If KeyCode = vbKeyF3 Then
    cmd_eliminar_Click
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub

Private Sub DBDETALLE_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Dim lint_col As Integer
Dim lint_row As Integer
lint_col = DBDetalle.Col
lint_row = DBDetalle.Row
If lint_col = -1 Then
    Exit Sub
End If
Call actualiza_datos
Call mover_objetos(lint_row)

End Sub

Private Sub dtc_cliente_Change()
If rs_det.RecordCount > 0 Then
    rs_det!custidss = dtc_cliente.BoundText
    rs_det!CLIENTE = dtc_cliente.Text
    rs_det!ruc = mobj_cventasgen.obtenerruccliente(dtc_cliente.BoundText)
End If
End Sub

Private Sub DTC_MONEDA_Change()
If rs_det.RecordCount > 0 Then
    rs_det!moneda = DTC_MONEDA.Text
    rs_det!curyid = DTC_MONEDA.BoundText
End If
End Sub

Private Sub DTC_TARJETA_Change()
If rs_det.RecordCount > 0 Then
    rs_det!TARJETA = DTC_TARJETA.Text
    rs_det!CARDID = DTC_TARJETA.BoundText
End If
End Sub

Private Sub dtc_tdeposito_Change()
If rs_det.RecordCount > 0 Then
    rs_det!tipo_deposito = dtc_tdeposito.Text
    rs_det!deposittypeid = dtc_tdeposito.BoundText
End If
End Sub

Private Sub dtc_vendedor_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
If KeyCode = vbKeyF2 Then
    cmd_bvendedor_Click
End If
If KeyCode = 13 Then
    'KeyCode = vbKeyTab
    txt_clave.SetFocus
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub

Private Sub dtr_depositos_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyDown Then
    If rs_det.RecordCount = rs_det.AbsolutePosition Then
        Call cmd_agregar_Click
    End If
End If
If KeyCode = vbKeyF3 Then
    Call cmd_eliminar_Click
End If
If KeyCode = vbKeyF5 Then
    Call cmd_agregar_Click
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub

Private Sub dtc_vendedor_Validate(Cancel As Boolean)
If Len(Trim(dtc_vendedor.Text)) = 0 Then
    MsgBox "Debe Ingresar un Vendedor"
    Cancel = True
Else
    Cancel = False
    txt_clave.SetFocus
End If

End Sub

Private Sub Form_Activate()
Call actualiza_datos
If DBDetalle.Row < 1 Then
    Call mover_objetos(0)
Else
    Call mover_objetos(DBDetalle.Row)
End If
'dtc_vendedor.SetFocus
End Sub

Private Sub Form_Load()

'Call GObtenerDatosdePtoVta(GstrPuntodeVenta)
    Me.Top = 2000
    Me.Left = (Screen.Width - Me.Width) / 2
    
    Set rs_cab = New ADODB.Recordset
    Set rs_det = New ADODB.Recordset
    
    rs_cab.CursorLocation = adUseClient
    rs_det.CursorLocation = adUseClient
    
    Set mobj_cventasgen = New DB_OP_FACTURACION.C_VENTASGENERAL
    Set MOBJ_CORRE = New DB_CORRELATIVO.C_Correlativos
    
    MINT_CORRE = MOBJ_CORRE.ObtenerCorrelativo(GCUSERID)   '************SW*************
    Set rs_det = mobj_cventasgen.Listardepositdet(MINT_CORRE)
    Set DBDetalle.DataSource = rs_det
    Call FormatoGrilla
    
    txt_fechaproceso.Text = CStr(GDatFechaProcesoVentas)
    txt_site.Text = mobj_cventasgen.obtenernombresite(GStrSitePtovta)
    mint_correcash = mobj_cventasgen.obtenercorrelativocashdrop
    txt_correlativo.Text = Str(mint_correcash)
    Call CargaDataCombo(dtc_vendedor, mobj_cventasgen.ListarvendedorAyuda, "SALESPERID", "SALESPERNAME")
    
    Call CargaDataCombo(dtc_tdeposito, mobj_cventasgen.ListartipodepositoAyuda, "DEPOSITTYPEID", "DESCRDEPOSTITYPE")
    Call CargaDataCombo(DTC_TARJETA, mobj_cventasgen.ListartarjetaAyuda, "CARDID", "DESCR")
    Call CargaDataCombo(DTC_MONEDA, mobj_cventasgen.ListarmonedaAyuda, "CURYID", "DESCR")
    Call CargaDataCombo(dtc_cliente, mobj_cventasgen.ListarClientesAyuda, "CUSTIDSS", "CUSTNAME")


With rs_det
    .AddNew
    !SITEID = GstrSiteProce
    !batnbrdeposit = mint_correcash
End With
Call mostrar_objetos
DBDETALLE_RowColChange 0, 0
actualiza_datos

End Sub
Private Sub grabar_deposito()
Dim li_nfilas As Integer
Dim li_nlinea As Integer
Dim ls_tdeposito As String
Dim ls_tarjeta As Variant
Dim ls_idcliente As Variant
Dim ls_moneda As String
Dim ld_monto As Double
Dim LI_ERROR As Integer
Dim LI_SEQ As Integer
Dim LI_BATNBR As Integer
Dim LS_SITE As String
Dim li_turno As Integer
Dim ls_fecha As String
Dim ls_fechaproceso As String
Dim ls_vendedor As String
li_nlinea = 1
li_nfilas = rs_det.RecordCount
rs_det.MoveFirst
li_turno = Val(txt_turno.Text)
ls_fecha = CStr(Date)
ls_fechaproceso = txt_fechaproceso.Text
ls_vendedor = dtc_vendedor.BoundText

If li_nfilas > 0 Then
    rs_det.MoveFirst
    LI_ERROR = mobj_cventasgen.aumentarcorrelativocashdrop
    Do While Not rs_det.EOF
        ls_tdeposito = rs_det!deposittypeid
        ls_tarjeta = rs_det!CARDID
        ls_idcliente = rs_det!custidss
        ls_moneda = rs_det!curyid
        ld_monto = rs_det!monto
        LS_SITE = rs_det!SITEID
        LI_SEQ = rs_det!SEQUENCE
        
        
        LI_ERROR = mobj_cventasgen.GRABAR_TMP_DEPOSITDET(MINT_CORRE, mint_correcash, LS_SITE, LI_SEQ, ls_tarjeta, _
                                                 ld_monto, ls_idcliente, ls_moneda, ls_tdeposito)
        If LI_ERROR <> 0 Then
            MsgBox "Error Grabando Detalle", vbCritical, "Fallo al Grabar"
            Exit Sub
        End If
        li_nlinea = li_nlinea + 1
        rs_det.MoveNext
    Loop
    LI_ERROR = mobj_cventasgen.grabardeposit(MINT_CORRE, mint_correcash, LS_SITE, li_turno, _
                                            ls_fecha, ls_fechaproceso, ls_vendedor, GCUSERID)
    If LI_ERROR <> 0 Then
        MsgBox "Error Grabando Cash Drop", vbCritical, "Fallo al Grabar"
        Exit Sub
    Else
        MsgBox "Deposito Grabado Correctamente", vbInformation, "OK"
    End If
End If
End Sub
Private Sub txt_clave_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    KeyCode = vbKeyTab
    Call txt_clave_Validate(False)
    'dtc_tdeposito.SetFocus
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub
Private Sub FormatoGrilla()
    DBDetalle.Columns(0).Width = dtc_tdeposito.Width
    DBDetalle.Columns(1).Width = DTC_TARJETA.Width
    DBDetalle.Columns(3).Width = 250
    DBDetalle.Columns(3).Width = dtc_cliente.Width + cmd_bcliente.Width
    DBDetalle.Columns(4).Width = DTC_MONEDA.Width
    DBDetalle.Columns(5).Width = ctrl_monto.Width
    DBDetalle.Columns(5).Alignment = dbgRight
    DBDetalle.Columns(5).NumberFormat = GMascara(2)
    DBDetalle.Columns(6).Visible = False
    DBDetalle.Columns(7).Visible = False
    DBDetalle.Columns(8).Visible = False
    DBDetalle.Columns(9).Visible = False
    DBDetalle.Columns(10).Visible = False
    DBDetalle.Columns(11).Visible = False
    DBDetalle.Columns(12).Visible = False
    DBDetalle.AllowRowSizing = False
    DBDetalle.Columns(0).AllowSizing = False
    DBDetalle.Columns(1).AllowSizing = False
    DBDetalle.Columns(2).AllowSizing = False
    DBDetalle.Columns(3).AllowSizing = False
    DBDetalle.Columns(4).AllowSizing = False
    DBDetalle.Columns(5).AllowSizing = False
    DBDetalle.Columns(6).AllowSizing = False
    DBDetalle.Columns(7).AllowSizing = False
    DBDetalle.Columns(8).AllowSizing = False
    DBDetalle.Columns(9).AllowSizing = False
    DBDetalle.RowHeight = dtc_tdeposito.Height - 20
End Sub


Private Sub ctrl_monto_KeyPress(KeyAscii As Integer)
If ((KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or _
    Chr(KeyAscii) = "." Or _
    KeyAscii = vbKeyClear Or _
    KeyAscii = vbKeyTab Or _
    KeyAscii = vbKeyBack) And _
    (Chr(KeyAscii) = "." And InStr(ctrl_monto.Text, ".")) = 0 Then
    
    If Len(ctrl_monto) >= 7 And InStr(ctrl_monto, ".") = 0 And IsNumeric(Chr(KeyAscii)) Then
        KeyAscii = 0
    End If
    If Len(ctrl_monto) = 1 And Trim(ctrl_monto.Text) = "0" Then
        ctrl_monto.Text = ""
    End If
 Else
     KeyAscii = 0
End If
If (KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete) And Len(Trim(ctrl_monto.Text)) = 1 Then
    ctrl_monto.Text = "0"
End If
End Sub
Private Sub ctrl_monto_Validate(Cancel As Boolean)
If ctrl_monto.Text = "" Or Len(ctrl_monto.Text) = 0 Then
    ctrl_monto.Text = "0"
End If
End Sub
Private Sub dtc_tdeposito_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    If dtc_tdeposito.BoundText = "V" Then
        DTC_TARJETA.Text = ""
        dtc_cliente.SetFocus
    End If
    If dtc_tdeposito.BoundText = "E" Then
        DTC_TARJETA.Text = ""
        dtc_cliente.Text = ""
       rs_det!ruc = ""
        DTC_MONEDA.SetFocus
    End If
    If dtc_tdeposito.BoundText = "T" Then
        dtc_cliente.Text = ""
        rs_det!ruc = ""
        DTC_TARJETA.SetFocus
    End If
End If
If KeyCode = vbKeyF5 Then
    cmd_agregar_Click
End If
If KeyCode = vbKeyF3 Then
    cmd_eliminar_Click
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub
Private Sub dtc_cliente_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    DTC_MONEDA.SetFocus
End If

If KeyCode = vbKeyF2 Then
    cmd_bcliente_Click
End If

If KeyCode = vbKeyF5 Then
    cmd_agregar_Click
End If
If KeyCode = vbKeyF3 Then
    cmd_eliminar_Click
End If

End Sub


Private Sub DTC_MONEDA_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    ctrl_monto.SetFocus
End If
If KeyCode = vbKeyF5 Then
    cmd_agregar_Click
End If
If KeyCode = vbKeyF3 Then
    cmd_eliminar_Click
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub

Private Sub DTC_TARJETA_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    DTC_MONEDA.SetFocus
End If
If KeyCode = vbKeyF5 Then
    cmd_agregar_Click
End If
If KeyCode = vbKeyF3 Then
    cmd_eliminar_Click
End If
If KeyCode = vbKeyF7 Then
    CMD_Grabar_Click
End If
End Sub

Public Sub actualiza_datos()
If rs_det.RecordCount <= 0 Then
    dtc_tdeposito.Text = ""
    DTC_TARJETA.Text = ""
    dtc_cliente.Text = ""
    DTC_MONEDA.Text = ""
    ctrl_monto.Text = ""
Else
    If rs_det.RecordCount > 0 And Not rs_det.EOF Then
        dtc_tdeposito.Text = IIf(IsNull(rs_det.Fields(0)), "", rs_det.Fields(0))
        DTC_TARJETA.Text = IIf(IsNull(rs_det.Fields(1)), "", rs_det.Fields(1))
        dtc_cliente.Text = IIf(IsNull(rs_det.Fields(3)), "", rs_det.Fields(3))
        DTC_MONEDA.Text = IIf(IsNull(rs_det.Fields(4)), "", rs_det.Fields(4))
        ctrl_monto.Text = Val(rs_det.Fields(5))
    End If
End If
End Sub
Public Sub mover_objetos(fila As Integer)
If fila < 0 Then
    fila = 0
End If
Dim lint_alto As Integer
Dim lint_inc As Integer
lint_alto = dtc_tdeposito.Height
lint_inc = 220
dtc_tdeposito.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)
DTC_TARJETA.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)
dtc_cliente.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)
cmd_bcliente.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)
DTC_MONEDA.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)
ctrl_monto.Top = DBDetalle.Top + lint_inc + (fila * lint_alto)

End Sub
Public Sub mostrar_objetos()
    dtc_tdeposito.Visible = True
    DTC_TARJETA.Visible = True
    dtc_cliente.Visible = True
    cmd_bcliente.Visible = True
    DTC_MONEDA.Visible = True
    ctrl_monto.Visible = True
End Sub

Private Sub txt_clave_Validate(Cancel As Boolean)
Dim lstr_usuario As String
Dim lstr_clave As String
Dim validar As Integer

lstr_usuario = dtc_vendedor.BoundText
lstr_clave = UCase(Trim(Encrip(txt_clave.Text)))

Cancel = False
If Len(Trim(txt_clave.Text)) = 0 Then
    MsgBox "Debe Ingresar una Clave"
    Cancel = True
    Exit Sub
End If

validar = mobj_cventasgen.Validarvendedor(lstr_usuario, lstr_clave)
'Call MENSAJES_VENDEDOR(validar)
If validar <> 0 Then
    MsgBox "Clave incorrecta"
    Cancel = True
    Exit Sub
End If
dtc_tdeposito.SetFocus
End Sub
