VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form_man_cupon_show 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   5670
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8670
   Icon            =   "Form_man_cupon_show.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5670
   ScaleWidth      =   8670
   Begin VB.Frame Frame_mes 
      Height          =   495
      Left            =   120
      TabIndex        =   10
      Top             =   0
      Width           =   8400
      Begin VB.TextBox txtRuta 
         Height          =   285
         Left            =   4680
         Locked          =   -1  'True
         TabIndex        =   14
         Top             =   160
         Width           =   3255
      End
      Begin VB.CommandButton Btn_Ruta 
         Caption         =   "..."
         Height          =   255
         Left            =   8050
         TabIndex        =   13
         Top             =   160
         Width           =   255
      End
      Begin VB.Label Lbl_Estado_Cupon 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   2520
         TabIndex        =   17
         Top             =   165
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "Estado:"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1800
         TabIndex        =   16
         Top             =   165
         Width           =   735
      End
      Begin VB.Label Lbl_RutaTxt 
         Caption         =   "Ruta Txt:"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   3840
         TabIndex        =   15
         Top             =   165
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "Mes :"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   12
         Top             =   165
         Width           =   495
      End
      Begin VB.Label Lbl_Mes_Cupon 
         Caption         =   "DICIEMBRE"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   720
         TabIndex        =   11
         Top             =   165
         Width           =   1095
      End
   End
   Begin VB.TextBox Txt_Monto_Cupon 
      Alignment       =   1  'Right Justify
      BeginProperty DataFormat 
         Type            =   0
         Format          =   """$"" #.##0"
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   13322
         SubFormatType   =   0
      EndProperty
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   285
      Left            =   2160
      TabIndex        =   4
      Top             =   2760
      Width           =   1455
   End
   Begin VB.TextBox Txt_Venc_Cupon 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   285
      Left            =   1680
      TabIndex        =   3
      Top             =   2400
      Width           =   1455
   End
   Begin VB.Frame Frame_Lst_Cupones 
      Caption         =   "Cupones que serán Tratados"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   3375
      Left            =   5520
      TabIndex        =   0
      Top             =   600
      Width           =   3015
      Begin VB.CommandButton Btn_Accion 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   26
         Top             =   2880
         Width           =   1335
      End
      Begin VB.CommandButton Btn_Salir 
         Caption         =   "Salir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1560
         TabIndex        =   25
         Top             =   2880
         Width           =   1335
      End
      Begin VB.ListBox Lst_Cupones 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   2370
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   2775
      End
   End
   Begin MSComDlg.CommonDialog cd 
      Left            =   8880
      Top             =   3480
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Frame Frame_New_Datos 
      Caption         =   "Nuevos Datos"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1455
      Left            =   5520
      TabIndex        =   18
      Top             =   4080
      Visible         =   0   'False
      Width           =   3015
      Begin VB.TextBox Txt_meses_entrecuotas 
         Alignment       =   1  'Right Justify
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """$"" #.##0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   13322
            SubFormatType   =   0
         EndProperty
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   285
         Left            =   1800
         Locked          =   -1  'True
         MaxLength       =   2
         TabIndex        =   24
         Text            =   "1"
         Top             =   1080
         Width           =   1095
      End
      Begin VB.TextBox Txt_New_Monto 
         Alignment       =   1  'Right Justify
         BeginProperty DataFormat 
            Type            =   0
            Format          =   """$"" #.##0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   13322
            SubFormatType   =   0
         EndProperty
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800000&
         Height          =   285
         Left            =   1800
         MaxLength       =   6
         TabIndex        =   22
         Top             =   720
         Width           =   1095
      End
      Begin VB.ComboBox Cmb_New_Day 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         ItemData        =   "Form_man_cupon_show.frx":2A8B2
         Left            =   1800
         List            =   "Form_man_cupon_show.frx":2A90A
         Style           =   2  'Dropdown List
         TabIndex        =   21
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "Meses entre cuotas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   23
         Top             =   1080
         Width           =   1695
      End
      Begin VB.Label Label4 
         Caption         =   "Monto Cupones $"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   20
         Top             =   720
         Width           =   1575
      End
      Begin VB.Label Label2 
         Caption         =   "Nuevo día Vcto."
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   120
         TabIndex        =   19
         Top             =   360
         Width           =   1575
      End
   End
   Begin VB.Label Lbl_Nom_Cliente 
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   1440
      TabIndex        =   9
      Top             =   1920
      Width           =   3495
   End
   Begin VB.Label Lbl_Rut_Cliente 
      Alignment       =   2  'Center
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   1920
      TabIndex        =   8
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Label Lbl_Num_Cupon 
      Alignment       =   2  'Center
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   3360
      TabIndex        =   7
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Label Lbl_Colegio 
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   470
      TabIndex        =   6
      Top             =   960
      Width           =   4335
   End
   Begin VB.Label Lbl_Cta_Cte 
      Alignment       =   2  'Center
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   255
      Left            =   360
      TabIndex        =   5
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Image Img_Cupon 
      Height          =   4815
      Left            =   120
      Picture         =   "Form_man_cupon_show.frx":2A975
      Stretch         =   -1  'True
      Top             =   720
      Width           =   5220
   End
   Begin VB.Label lblRuta 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1440
      TabIndex        =   2
      Top             =   4800
      Visible         =   0   'False
      Width           =   3615
   End
End
Attribute VB_Name = "Form_man_cupon_show"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim AFilaGrd() As Variant
Dim ArchDefault As String, StrFiltro As String ' Valores para el Common Dialog
Private Sub Btn_Accion_Click()
Select Case Form_man_cupon.Txt_OpeCupon
    Case "EC"
        If Me.txtRuta <> "" Then
            If MsgBox("¿ Está seguro de Eliminar él o los Cupones en detalle ? ", vbYesNo + vbQuestion, "Eliminación de Cupones") = vbYes Then
                Call TxtElimin
                Call EliminarCupon
                Call Refrescar
            End If
        Else
            Call validatexto(Me.txtRuta, "Falta Ruta para generación de Archivos")
            Call Btn_Ruta_Click
        End If
    Case "MC"
        If Me.txtRuta <> "" Then
            If Me.Cmb_New_Day <> "" And Val(Me.Txt_New_Monto) > 0 And Val(Me.Txt_meses_entrecuotas) > 0 And Val(Me.Txt_meses_entrecuotas) <= 12 Then
                If MsgBox("¿ Está seguro de Modificar él o los Cupones en detalle ? ", vbYesNo + vbQuestion, "Eliminación de Cupones") = vbYes Then
                    Call TxtElimin: Call EliminarCupon
                    Call TxtGenerac: Call GenerarCupon
                    Call Refrescar
                End If
            Else
                MsgBox ("Error en los nuevos datos para él o los cupones")
            End If
        Else
            Call validatexto(Me.txtRuta, "Falta Ruta para generación de Archivos")
            Call Btn_Ruta_Click
        End If
    Case "AC"
        If Me.txtRuta <> "" Then
            If MsgBox("¿ Está seguro de Anular él o los Cupones Tratados ? ", vbYesNo + vbQuestion, "Eliminación de Cupones") = vbYes Then
                Call TxtElimin
                Call AnularCupon
                Call Refrescar
            End If
        Else
            Call validatexto(Me.txtRuta, "Falta Ruta para generación de Archivos")
            Call Btn_Ruta_Click
        End If
End Select
End Sub

Private Sub Btn_Ruta_Click()
Call selruta(ArchDefault, StrFiltro)
End Sub

Private Sub Btn_Salir_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim c As Integer
Me.Lbl_Colegio = Tamaño("CONV BCI " & Form_man_cupon.Txt_Conv_Bci & " " & UCase(Form_man_cupon.Cmb_ColegioCup), 37)
Select Case Form_man_cupon.Txt_OpeCupon
    Case "VC"
        Me.Caption = "VISUALIZACIÓN DE CUPÓN"
        Call CtlRuta(False)
        'Me.Txt_Monto_Cupon.Locked = True
        'Me.Txt_Venc_Cupon.Locked = True
        Me.Btn_Salir.Left = 840
        Me.Btn_Accion.Visible = False
    Case "EC"
        Me.Caption = "ELIMINACIÓN DE CUPÓN"
        'Me.Txt_Monto_Cupon.Locked = True
        'Me.Txt_Venc_Cupon.Locked = True
        Me.Btn_Accion.Caption = "Eliminar"
        ArchDefault = "ELIMINA_CUPONES_" & Format(Date, "yyyymmdd") & ".BCI": StrFiltro = "(ELIMINA_CUPONES_" & Format(Date, "yyyymmdd") & ".BCI)|ELIMINA_CUPONES_" & Format(Date, "yyyymmdd") & ".BCI|"
    Case "MC"
        Me.Caption = "MODIFICACIÓN DE  CUPÓN"
        'Me.Txt_Monto_Cupon.Locked = True
        'Me.Txt_Venc_Cupon.Locked = True
        Me.Btn_Accion.Caption = "Modificar"
        Me.Frame_New_Datos.Visible = True
        ArchDefault = "": StrFiltro = "Archivo bci (*.bci)|*.bci|"
    Case "AC"
        Me.Caption = "ANULACIÓN DE CUPÓN"
        'Me.Txt_Monto_Cupon.Locked = True
        'Me.Txt_Venc_Cupon.Locked = True
        Me.Btn_Accion.Caption = "Anular"
        ArchDefault = "elimina_cupones": StrFiltro = "elimina_cupones.bci|elimina_cupones.bci|"
End Select
ReDim AFilaGrd(Val(Form_man_cupon.Txt_Fin_GCup) - Val(Form_man_cupon.Txt_Ini_GCup) + 1)
c = 0
For t = Val(Form_man_cupon.Txt_Ini_GCup) To Val(Form_man_cupon.Txt_Fin_GCup)
    If Form_man_cupon.Txt_OpeCupon = "VC" Or (UCase(Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 6)) <> "ANULADO" And UCase(Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 6)) <> "ELIMINADO") Then
        Me.Lst_Cupones.AddItem Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 2) & " - " & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 3)
        AFilaGrd(c) = t
        c = c + 1
    End If
Next t
If Me.Lst_Cupones.ListCount > 0 Then
    Me.Lst_Cupones.ListIndex = 0
End If
Me.Show
End Sub

Private Sub Form_Unload(Cancel As Integer)
Form_man_cupon.Enabled = True
End Sub

Private Sub Lst_Cupones_Click()
Dim Ind As Integer
Ind = Me.Lst_Cupones.ListIndex
Me.Lbl_Mes_Cupon = UCase(Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(Ind), 3))
Me.Lbl_Estado_Cupon = UCase(Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(Ind), 6))
Me.Lbl_Cta_Cte = Form_man_cupon.Txt_Cta_Cte
Me.Lbl_Num_Cupon = Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(Ind), 2)
Me.Lbl_Rut_Cliente = Left(Form_man_cupon.txt_rut_apo, Len(Form_man_cupon.txt_rut_apo) - 2) & Right(Form_man_cupon.txt_rut_apo, 1)
Me.Lbl_Nom_Cliente = Form_man_cupon.txt_nom_apo
Me.Txt_Venc_Cupon = Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(Ind), 4)
Me.Txt_Monto_Cupon = Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(Ind), 5)
End Sub
Sub CtlRuta(Visible As Boolean)
    Me.Lbl_RutaTxt.Visible = Visible
    Me.txtRuta.Enabled = Visible: Me.Btn_Ruta.Enabled = Visible
    Me.txtRuta.Visible = Visible: Me.Btn_Ruta.Visible = Visible
End Sub
Sub TxtElimin()
Dim CtaCte As String, NumeroCliente As String, IniBol As String, FinBol As String
Dim linea As String
CtaCte = Tamaño(largo("9" & Me.Lbl_Cta_Cte, 12), 13)
NumeroCliente = Tamaño(largo(Mid(Me.Lbl_Rut_Cliente, 1, Len(Me.Lbl_Rut_Cliente) - 1), 10), 11) & Tamaño(Right(Me.Lbl_Rut_Cliente, 1), 2)
IniBol = Tamaño(Mid(Me.Lst_Cupones.List(0), 2, 10), 11)
FinBol = Tamaño(Mid(Me.Lst_Cupones.List(Me.Lst_Cupones.ListCount - 1), 2, 10), 42)
linea = CtaCte & NumeroCliente & IniBol & FinBol
Call CreateFile(linea, Me.lblRuta & "elimina_cupones_" & Format(Date, "yyyymmdd") & ".bci")
End Sub

Sub AnularCupon()
For t = Val(Form_man_cupon.Txt_Ini_GCup) To Val(Form_man_cupon.Txt_Fin_GCup)
    conn.Execute "update fnza_deta_cupones set estado='NU' where folio_cupon =" & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 1)
    Call RegistrarOpeCupon("ANU", Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 7), Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 1), conn)
Next t
End Sub
Sub EliminarCupon()
For t = Val(Form_man_cupon.Txt_Ini_GCup) To Val(Form_man_cupon.Txt_Fin_GCup)
    conn.Execute "update fnza_deta_cupones set estado='EL' where folio_cupon =" & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 1)
    Call RegistrarOpeCupon("ELI", Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 7), Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 1), conn)
Next t
End Sub

Sub GenerarCupon() ' (Elimina y Genera) o Modifica???
Dim Valor As Long, NuevoDia As String, Vcto As Date
For t = Val(Form_man_cupon.Txt_Ini_GCup) To Val(Form_man_cupon.Txt_Fin_GCup)
    ' Ver si es el ultimo dia del mes
    NuevoDia = Me.Cmb_New_Day.Text
    Vcto = Year(Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 4)) & "-" & Month(Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 4)) & "-" & NuevoDia
    Valor = Val(Me.Txt_New_Monto)
    conn.Execute "insert fnza_deta_cupones (numero, mes, vcto, valor, ubicacion, folio_cuponera) values('" & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 2) & "' , " & Val(Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 10)) & " , '" & InvierteFecha(Vcto, "R") & "' , " & Valor & " , " & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 9) & " , " & Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 7) & ")"
    Call RegistrarOpeCupon("GEN", Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 7), Form_man_cupon.Grd_DetaCupon.TextMatrix(t, 1), conn)
Next t
End Sub
Sub Refrescar()
    Unload Me
    Form_man_cupon.Chk_Todos_Cupones.Value = 0
    Form_man_cupon.Cmb_ColegioCup.ListIndex = -1
    Form_man_cupon.Cmb_ColegioCup.ListIndex = Val(Form_man_cupon.Txt_ListIndex)
End Sub

Private Sub Txt_New_Monto_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) >= "0" And Chr(KeyAscii) <= "9") Then
    Exit Sub
ElseIf KeyAscii = 8 Then Exit Sub
ElseIf KeyAscii = 32 Then Exit Sub
End If
KeyAscii = 0
End Sub

Sub TxtGenerac()
Dim Cabecera As String, Cab As String
Dim NomEmpresa As String, CtaCte As String, Ncuotas As String, Moneda As String, ValorDef As String
Dim MesAnho1Cuota As String, DiaVenc As String
Dim NIniBol As String, MesesentreCuotas As String

Dim linea As String
Dim NumeroCliente As String, NomCliente As String, ValorCuota As String, NumCuota As String
Dim FechaPago As String, MesEntreCuotas As String, Filler As String

'Estos campos son necesarios para cabecera y cuerpo

' Si el comienzo de la primera linea no es "1" No existe cabecera en archivo crearla

    NomEmpresa = Tamaño(Me.Lbl_Colegio, 37)                  '2
    CtaCte = Tamaño(Me.Lbl_Cta_Cte, 8)                       '3
    Ncuotas = largo(Trim(str(Me.Lst_Cupones.ListCount)), 2)        '4
    Moneda = "0"                                             '5
    ValorDef = largo(Replace(addCeros(Trim(Form_man_cupon.Txt_Arancel_Base), 3), ",", ""), 12) ' Traer de fnza_descuento                  '6
    MesAnho1Cuota = Format(Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(0), 4), "mmyy")
    MesesentreCuotas = largo(Me.Txt_meses_entrecuotas, 2)    '8
    DiaVenc = largo(Me.Cmb_New_Day, 2)                       '9
    NIniBol = largo(Left(Me.Lst_Cupones.List(0), 11), 11) '10
    Cabecera = "1" & NomEmpresa & CtaCte & Ncuotas & Moneda & ValorDef & MesAnho1Cuota & MesesentreCuotas _
           & DiaVenc & NIniBol
Do
    Cab = CabeceraBci(Me.txtRuta.Text)
    If (Cabecera = Cab) Or Cab = "" Then
        Call CreateFile(Cabecera, txtRuta.Text)
        Exit Do
    'Else
        'MsgBox ("Archivo Seleccionado ya tiene Cabecera y no corresponde a esta generación de cuponeras." & Chr(13) & "Seleccione otro Archivo")
        'Call Btn_Ruta_Click
    'NO IMPORTA QUE LA CABECERA SEA DIFERENTE YA QUE PARA EL BANCO NO INFLUYE
    End If
Loop
NumeroCliente = largo(Me.Lbl_Rut_Cliente, 11)
NomCliente = Tamaño(Form_man_cupon.txt_nom_apo, 20)
ValorCuota = largo(Replace(addCeros(Me.Txt_New_Monto, 3), ",", ""), 12)
NumCuota = largo(Trim(str(Me.Lst_Cupones.ListCount)), 3) ' Número de cupones
FechaPago = Format(Form_man_cupon.Grd_DetaCupon.TextMatrix(AFilaGrd(0), 4), "ddmmyy")
Filler = "              "
linea = "2" & NumeroCliente & NomCliente & ValorCuota & NumCuota & NIniBol & FechaPago _
        & MesesentreCuotas & Filler
Call CreateFile(linea, txtRuta.Text)
End Sub
Sub selruta(NomArch As String, Filtro As String)
    Dim file As String, objText As Control, i As Long, strMsg As String, posicion As Long
    cd.DialogTitle = "Grabar a..."
    cd.FileName = NomArch
    cd.Filter = Filtro
    cd.ShowSave
    
    file = cd.FileName
    If Len(file) > 0 Then
        txtRuta.Text = file
        For i = 1 To Len(file)
            If Mid(file, i, 1) = "\" Then
                posicion = i
            End If
        Next
        Me.lblRuta.Caption = Mid(file, 1, posicion)
    End If
End Sub
