VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{F39CBE5C-2D1B-11D6-8D4A-0050043A2E60}#2.0#0"; "ProgBarProzent.ocx"
Begin VB.Form Form_BoletasMasivoBecas100 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   6060
   ClientLeft      =   1605
   ClientTop       =   1965
   ClientWidth     =   11730
   Icon            =   "Form_BoletasMasivoBecas100.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6060
   ScaleWidth      =   11730
   Begin VB.ComboBox cb_agno 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   840
      TabIndex        =   39
      Top             =   240
      Width           =   1215
   End
   Begin VB.CommandButton Btn_Consultar 
      Caption         =   "Mostrar Boletas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   9480
      TabIndex        =   37
      Top             =   120
      Width           =   1455
   End
   Begin VB.ComboBox Cmb_Mes 
      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_BoletasMasivoBecas100.frx":2A8B2
      Left            =   3840
      List            =   "Form_BoletasMasivoBecas100.frx":2A8DD
      Style           =   2  'Dropdown List
      TabIndex        =   31
      Top             =   240
      Width           =   2055
   End
   Begin VB.Frame Frame_Dtll_Pago 
      Caption         =   "Detalle del Pago"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2055
      Left            =   6600
      TabIndex        =   28
      Top             =   1440
      Visible         =   0   'False
      Width           =   3975
      Begin VB.CommandButton Btn_Cerrar_Dtll 
         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            =   1440
         TabIndex        =   29
         Top             =   1440
         Width           =   1215
      End
      Begin MSFlexGridLib.MSFlexGrid Grd_Dtll_Pago 
         Height          =   855
         Left            =   240
         TabIndex        =   30
         Top             =   360
         Width           =   3495
         _ExtentX        =   6165
         _ExtentY        =   1508
         _Version        =   393216
         FixedCols       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
   End
   Begin VB.Frame Frame_Tipo_Folio 
      Caption         =   "Rango de Folios"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1695
      Left            =   3360
      TabIndex        =   23
      Top             =   1440
      Visible         =   0   'False
      Width           =   3015
      Begin VB.CommandButton Btn_Folio_Sel 
         Caption         =   "Folio Inicial"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   26
         Top             =   720
         Width           =   1215
      End
      Begin VB.CommandButton Btn_Folio_Sel 
         Caption         =   "Folio Final"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   1560
         TabIndex        =   25
         Top             =   720
         Width           =   1215
      End
      Begin VB.CommandButton Btn_Cancelar 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   840
         TabIndex        =   24
         Top             =   1200
         Width           =   1215
      End
      Begin VB.Label lbl_boleta 
         Alignment       =   2  'Center
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   12
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   240
         TabIndex        =   27
         Top             =   240
         Width           =   2535
      End
   End
   Begin VB.Frame Frame_Camb_Fecha 
      Caption         =   "Cambiar Fecha"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   2055
      Left            =   960
      TabIndex        =   19
      Top             =   1440
      Visible         =   0   'False
      Width           =   2055
      Begin VB.CommandButton btn_camb_fecha 
         Caption         =   "Cambiar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   21
         Top             =   840
         Width           =   1215
      End
      Begin VB.CommandButton btn_canc_camb_fecha 
         Caption         =   "Cancelar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   480
         TabIndex        =   20
         Top             =   1440
         Width           =   1215
      End
      Begin MSComCtl2.DTPicker DT_Camb_Fecha 
         Height          =   315
         Left            =   360
         TabIndex        =   22
         Top             =   360
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Format          =   51904513
         CurrentDate     =   38527
      End
   End
   Begin VB.TextBox Txt_Folio_Disp 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   7560
      TabIndex        =   17
      Top             =   240
      Width           =   1335
   End
   Begin VB.Frame Frame_Imp_Agrega 
      ForeColor       =   &H00FF0000&
      Height          =   1575
      Left            =   3840
      TabIndex        =   8
      Top             =   3840
      Width           =   7695
      Begin VB.Frame Frame1 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Left            =   5520
         TabIndex        =   34
         Top             =   480
         Width           =   1935
         Begin VB.Label Lbl_Ult_Fola 
            Alignment       =   2  'Center
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   12
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00C00000&
            Height          =   375
            Left            =   120
            TabIndex        =   35
            Top             =   360
            Width           =   1695
         End
      End
      Begin VB.CommandButton Btn_Agregar 
         Caption         =   "Agregar al libro"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3600
         TabIndex        =   12
         Top             =   840
         Width           =   1575
      End
      Begin VB.TextBox Txt_Folio 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   0
         Left            =   240
         Locked          =   -1  'True
         TabIndex        =   11
         Top             =   480
         Width           =   1215
      End
      Begin VB.TextBox Txt_Folio 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Index           =   1
         Left            =   240
         Locked          =   -1  'True
         TabIndex        =   10
         Top             =   1080
         Width           =   1215
      End
      Begin VB.CommandButton Btn_Imprimir 
         Caption         =   "Imprimir"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3600
         TabIndex        =   9
         Top             =   360
         Width           =   1575
      End
      Begin MSComCtl2.DTPicker DTP_Fec_Emision 
         Height          =   405
         Left            =   1800
         TabIndex        =   13
         Top             =   480
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   714
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Format          =   51904513
         CurrentDate     =   40449
      End
      Begin VB.Label Label15 
         Alignment       =   2  'Center
         Caption         =   "Último Folio agregado"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5280
         TabIndex        =   36
         Top             =   240
         Width           =   1935
      End
      Begin VB.Label Label4 
         Caption         =   "Folio Final"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   16
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "Folio Inicial"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   15
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label10 
         Alignment       =   2  'Center
         Caption         =   "Fecha de Emisión"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   1680
         TabIndex        =   14
         Top             =   240
         Width           =   1575
      End
   End
   Begin VB.Frame Frame_Totales 
      Caption         =   "Totales"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1575
      Left            =   120
      TabIndex        =   1
      Top             =   3840
      Width           =   3615
      Begin VB.TextBox txt_tot_pesos 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2040
         Locked          =   -1  'True
         TabIndex        =   4
         Top             =   1080
         Width           =   1215
      End
      Begin VB.TextBox txt_tot_boletas 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2040
         Locked          =   -1  'True
         TabIndex        =   3
         Top             =   360
         Width           =   1215
      End
      Begin VB.TextBox Txt_Monto_Detalle 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   2040
         Locked          =   -1  'True
         TabIndex        =   2
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label8 
         Caption         =   "Total Mensualidades"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   720
         Width           =   1935
      End
      Begin VB.Label Label7 
         Caption         =   "Nº Boletas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   6
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label20 
         Caption         =   "Total Exenciones"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   1080
         Width           =   1455
      End
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   3135
      Left            =   120
      TabIndex        =   0
      Top             =   720
      Width           =   11415
      _ExtentX        =   20135
      _ExtentY        =   5530
      _Version        =   393216
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin ProgBarProzent.ProgBar ProgBar_Boletas 
      Height          =   375
      Left            =   120
      TabIndex        =   33
      Top             =   5520
      Width           =   11415
      _ExtentX        =   20135
      _ExtentY        =   661
   End
   Begin VB.Label Label1 
      Caption         =   "Agno"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   38
      Top             =   240
      Width           =   615
   End
   Begin VB.Label Label14 
      Caption         =   "Mes de Pago"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2520
      TabIndex        =   32
      Top             =   240
      Width           =   1335
   End
   Begin VB.Label Label18 
      Caption         =   "Folio Inicial"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6480
      TabIndex        =   18
      Top             =   240
      Width           =   975
   End
End
Attribute VB_Name = "Form_BoletasMasivoBecas100"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim BolSel As String
Dim APagos_Bci() As String, Registros As Long
Dim Ultimofolio As String, Fila As Long, FilaBol As Long, Filaini As Long, Filafin As Long
Dim FilaDif As Long
Dim mes As String ' el numero de mes seleccionado
Dim Conectant  As Boolean

Private Sub Btn_Agregar_Click()
Dim accion_detalle As String
On Error GoTo Controlerror
If (Len(Trim(Me.Txt_Folio(0))) > 0 And Len(Trim(Me.Txt_Folio(1))) > 0) And (val(Me.Txt_Folio(1)) >= val(Me.Txt_Folio(0))) Then
    If MsgBox("Las Boletas que agregará al Libro" & vbCrLf & vbCrLf & "¿Se encuentran impresas?", vbYesNo, "Verificación") = vbNo Then
        If MsgBox("¿Desea agregar estas boletas al libro de todas formas?", vbExclamation + vbYesNo, "Verificación") = vbYes Then
            Dim CMD As ADODB.Command
            Dim QRT As String
            Set CMD = New ADODB.Command
            CMD.CommandType = adCmdText
            CMD.ActiveConnection = conn
            QRT = "CREATE TABLE IF NOT EXISTS `fnza_log_boletas_no_impresas` (`FOLIO` bigint(20) unsigned NOT NULL auto_increment,`USUARIO_LOGIN` varchar(100) NOT NULL default '',`USUARIO_NOMBRE` varchar(100) NOT NULL default '', `FOLIO_INICIAL` bigint(20) NOT NULL default '0', `FOLIO_FINAL` bigint(20) NOT NULL default '0', `FECHA` datetime NOT NULL default '0000-00-00 00:00:00', `IMPRESO` varchar(2) NOT NULL default 'NO', PRIMARY KEY  (`FOLIO`) ) ENGINE=MyISAM;"
            CMD.CommandText = QRT
            CMD.Execute
            
            QRT = "INSERT fnza_log_boletas_no_impresas(usuario_login,usuario_nombre,folio_inicial,folio_final,fecha) VALUES('" & Nom_usu_ses & "','" & Nom_com_usu_ses & "'," & val(Me.Txt_Folio(0)) & "," & val(Me.Txt_Folio(1)) & ",concat(current_date,' ',current_time))"
            CMD.CommandText = QRT
            CMD.Execute
        Else
            Exit Sub
        End If
    End If
    Dim ADetBol(2, 1) As Long ' Columna , Fila
    Abarra = 0
    Me.ProgBar_Boletas.ShowProgress 0
    Me.ProgBar_Boletas.MaxValue = Filafin - Filaini
    'Me.ProgBar_Boletas.MaxValue = Filafin
    Me.ProgBar_Boletas.Zusatztext = "% Agregado"
    For p = val(Filaini) To val(Filafin)
        If UCase(Me.MSFlexGrid1.TextMatrix(p, 6)) <> "CANCELADA" Then
            RutApo = Me.MSFlexGrid1.TextMatrix(p, 0)
            Rutalu = Me.MSFlexGrid1.TextMatrix(p, 2)
            CodEmpresa = Me.MSFlexGrid1.TextMatrix(p, 9)
            Folio = val(Me.MSFlexGrid1.TextMatrix(p, 6))
            FEmision = Format(Me.DTP_Fec_Emision.Value, "yyyy-mm-dd")
            FPago = Format(Me.MSFlexGrid1.TextMatrix(p, 7), "yyyy-mm-dd")
            agno = CLng(Me.MSFlexGrid1.TextMatrix(p, 10))
            If agno <> "2004" Then 'o preguntar por el colegio vacio
                ADetBol(1, 1) = Me.MSFlexGrid1.TextMatrix(p, 11): ADetBol(2, 1) = Me.MSFlexGrid1.TextMatrix(p, 4) - Me.MSFlexGrid1.TextMatrix(p, 5)
                If crear_boleta(Folio, Mid(CodEmpresa, 1, 6), RutApo, Rutalu, FEmision, FPago, ADetBol(2, 1), ProcPago, TipoPago, ADetBol(), "", "", 0, 0, conn) Then
                    info = "Boleta creada con el folio detalle " & ADetBol(1, 1) & " para el alumno " & Rutalu & " , apoderado " & RutApo & " por $" & ADetBol(2, 1)
                    Call Log_AddAnotacion(info, True)
                    Me.Lbl_Ult_Fola = Folio
                 '   If Val(Me.MSFlexGrid1.TextMatrix(fila, 4)) >= Val(Me.MSFlexGrid1.TextMatrix(fila, 24)) Then
                 '       conn.Execute "update fnza_deta_cupones set estado='PA' where folio_cupon = " & Val(Me.MSFlexGrid1.TextMatrix(fila, 23))
                 '       Call RegistrarOpeCupon("PAG", Val(Me.MSFlexGrid1.TextMatrix(t, 22)), Val(Me.MSFlexGrid1.TextMatrix(p, 23)), conn)
                 '       Call Act_Estado_Cuponera(Val(Me.MSFlexGrid1.TextMatrix(p, 22)), conn)
                 '   End If
                'Log fnza_historico_log
                accion_detalle = "Se a generado la boleta con folio " & Folio _
                               & " con monto " & MSFlexGrid1.TextMatrix(p, 5) _
                               & " para el año " & agno
                Call Inserta_Vitacora_Finanza(CStr(Rutalu), CStr(RutApo), "Boletas masivo", accion_detalle, 0, 0)
                'fin de log
21:
                Else
                    info = "Error: No fue posible crear boleta con el folio detalle " & ADetBol(1, 1) & " para el alumno " & Rutalu & " , apoderado " & RutApo & " por $" & ADetBol(2, 1)
                    Call Log_AddAnotacion(info, True)
                End If
            Else ' Si es cuota del 2004
                If ExistReg("gescol2004.BOL_APO_X_ALU", "FOLIO =" & Folio & " and cod_conv_bci ='" & CodConvBci & "'", conn) Then
                    If MsgBox("FOLIO Nº " & Folio & " YA EXISTE NO SE AGREGARÁ " & Chr(13) & "¿ Desea seguir ?", vbYesNo) = vbNo Then
                        Exit Sub
                    End If
                Else
                    'conn.Execute "INSERT INTO bol_apo_x_alu(RUT_APO, CI_ALU, FOLIO, FEC_EMISION, MONTO_ARANCEL, MONTO_EXENCION, MONTO_CPADRES, MONTO_APORTES, MONTO_OTROS, MONTO_TOTAL, NULA, FEC_NULA, PROCEDENCIA, COD_CONV_BCI, IND_CHEQUE) values('" & RutApo & "', '" & Rutalu & "', '" & Folio & "', '" & FEmision & "','" & MArancel & "', '" & MExencion & "', 0, 0, 0, " & MTotal & ", '" & Nula & "', '" & FNula & "', '" & Procedencia & "', '" & CodConvBci & "','0')"
                    FVencCuota = InvierteFecha(Me.MSFlexGrid1.TextMatrix(p, 10), "R")
                    MArancel = val(Me.MSFlexGrid1.TextMatrix(p, 2))
                    MExencion = val(Me.MSFlexGrid1.TextMatrix(p, 3))
                    MCPadres = 0
                    MAportes = 0
                    MOtros = 0
                    MTotal = (MArancel - MExencion) + MCPadres + MAportes + MOtros
                    Dim Folio2004 As String
                    Folio2004 = FillconStr(Trim(Folio), 8, "0", "IZQ")
                    conn.Execute "INSERT INTO gescol2004.bol_apo_x_alu(RUT_APO, CI_ALU, FOLIO, FEC_EMISION, FEC_VEN_CUOTA, FEC_PAGO, MONTO_ARANCEL, MONTO_EXENCION, MONTO_CPADRES, MONTO_APORTES, MONTO_OTROS, MONTO_TOTAL, NULA, FEC_NULA, PROCEDENCIA, COD_CONV_BCI, IND_CHEQUE) values('" & RutApo & "', '" & Rutalu & "', '" & Folio2004 & "', '" & FEmision & "', '" & FVencCuota & "', '" & FPago & "', '" & MArancel & "', '" & MExencion & "', 0, 0, 0, " & MTotal & ", '0', '1111-11-11', '2', '" & CodConvBci & "','0')"
                    'If Nula <> "1" Then
                        idcuota = DevuelveCampo("gescol2004.anualidad_x_apo", "", "id_cuota", "rut_apo ='" & RutApo & "' and month(fecha_venc)='" & Month(FVencCuota) & "'", conn)
                        If Not ExistReg("gescol2004.pagos", "rut_apo='" & RutApo & "' and id_cuota='" & idcuota & "' and cod_conv_bci ='" & CodConvBci & "' and ci_alu='" & Rutalu & "'", conn) Then
                            conn.Execute "INSERT INTO gescol2004.pagos(RUT_APO, ID_CUOTA, COD_CONV_BCI, FOLIO, FEC_PAGO, CI_ALU, MONTO) values('" & RutApo & "', '" & idcuota & "', '" & CodConvBci & "', '" & Folio2004 & "', '" & FPago & "', '" & Rutalu & "', " & MTotal & ")"
                            conn.Execute "update gescol2004.anualidad_x_apo set pagado = pagado + " & MTotal & " where rut_apo ='" & RutApo & "' and id_cuota ='" & idcuota & "'"
                            Call CrearBoleta2004(val(Folio), CodEmpresa, "gescol", FPago, FEmision, val(MTotal), RutApo, Rutalu, conn)
                        End If
                        
                    'Log fnza_historico_log
                        accion_detalle = "Se a generado la boleta con folio " & Folio _
                                   & " con monto " & val(MTotal) _
                                   & " para el año " & agno
                        Call Inserta_Vitacora_Finanza(CStr(Rutalu), CStr(RutApo), "Boletas masivo", accion_detalle, 0, 0)
                    'fin de log
                        
                    'End If
                    ' Separar los últimos folios agregados
                    'Me.Lbl_Ult_Fola.Caption = Folio
                    'Me.Lbl_Ult_Fola.Refresh
                End If
            End If
        End If
        
        Abarra = Abarra + 1
        Me.ProgBar_Boletas.ShowProgress (Abarra + 0)
        DoEvents
    Next p
    Me.ProgBar_Boletas.ShowProgress 0
Else
    MsgBox ("Error en los Folios Seleccionados")
End If
Exit Sub
Controlerror:
    If Err.Number = (vbObjectError + 521) Then
        Dim descri As String
        Dim Source As String
        descri = Err.Description
        Source = Err.Source
        MsgBox descri & vbCrLf & Source, vbExclamation, "ALERTA DE VALIDACIÓN"
        Log_AddAnotacion vbCrLf & "   (Error)" & (vbObjectError + 521) & " : " & descri & " : " & Source & vbCrLf, True
        Resume 21
    End If
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source, vbCritical, "ALERTA DE ANOMALÍA"

End Sub

Private Sub btn_camb_fecha_Click()
    Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.Row, Me.MSFlexGrid1.Col) = Me.DT_Camb_Fecha.Value
    Me.Frame_Camb_Fecha.Visible = False

End Sub

Private Sub btn_canc_camb_fecha_Click()
    Me.Frame_Camb_Fecha.Visible = False
End Sub

Private Sub btn_Cancelar_Click()
Me.Frame_Tipo_Folio.Visible = False
Me.MSFlexGrid1.Enabled = True
Me.MSFlexGrid1.SetFocus
End Sub

Private Sub Btn_Consultar_Click()
MSFlexGrid1.Clear
MSFlexGrid1.Rows = 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "Rut Apoderado"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Nombre"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Rut Alumno"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "Nombre"
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = "Mensualidad"
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = "Exencion"
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = "Folio"
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = "Fecha Vcto."
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = "Curso"
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = "Colegio"
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = "Año"
MSFlexGrid1.Col = 11
MSFlexGrid1.Text = "folio_dtll"
    mmes = val(Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex))
    FOL = val(Txt_Folio_Disp)
    tot_mens = 0
    tot_exen = 0
    canbol = 0
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String

    var_sql = "select d.rut_apo,e.noms_apo,e.ape1_apo,e.ape2_apo,a.run_alu as Rut,c.ape_pat_alu , " _
            & "c.APE_MAT_ALU,c.nom_alu,a.monto_total as mensualidad," _
            & "a.monto_exen_bca as beca,B.cod_ens,a.mes,b.num_gra,b.let_cur,a.fech_venc,a.colegio,a.agno,a.folio_dtll from fnza_detalle_mensualidad a " _
            & "inner join alu_x_cur b on run_alu=b.ci_alu " _
            & "inner join postulantes c on run_alu=c.ci_alu " _
            & "inner join apo_x_alu d on run_alu=d.ci_alu " _
            & "inner join apoderados e on d.rut_apo=e.rut_apo " _
            & "Where b.activo_alu = 'SI' and a.Mes = " & mmes & " and a.agno = " & cb_agno.Text & " and b.agno = " & cb_agno.Text _
            & " and d.agno = " & cb_agno.Text & " And a.Monto_Total = a.monto_exen_bca" _
            & " and folio_dtll not IN " _
            & "(select folio_dtll from fnza_movimientos_mensualidad where monto_pago = 0)" _
            & "order by rut_apo"
            
    objRS.Open var_sql, conn
    
    Do Until objRS.EOF
            MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
            i = MSFlexGrid1.Rows - 1
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 0
            MSFlexGrid1.Text = objRS!rut_apo
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 1
            MSFlexGrid1.Text = objRS!Noms_Apo + " " + objRS!ape1_apo + " " + objRS!ape2_apo
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 2
            MSFlexGrid1.Text = objRS!rut
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 3
            MSFlexGrid1.Text = objRS!Nom_Alu + " " + objRS!ape_pat_alu + " " + objRS!ape_mat_alu
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 4
            MSFlexGrid1.Text = objRS!Mensualidad
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 5
            MSFlexGrid1.Text = objRS!Beca
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 6
            MSFlexGrid1.Text = FOL
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 7
            MSFlexGrid1.Text = objRS!fech_venc
            If objRS!Cod_Ens = 110 Then
                ccu = objRS!Num_Gra + " " + objRS!Let_Cur + " " + " EB"
            ElseIf objRS!Cod_Ens = 310 Then
                ccu = objRS!Num_Gra + " " + objRS!Let_Cur + " " + " EM"
            ElseIf objRS!Cod_Ens = 10 Then
                ccu = objRS!Num_Gra + " " + objRS!Let_Cur + " " + " K"
            ElseIf val(objRS!Cod_Ens) = 0 Then
                ccu = objRS!Num_Gra + " " + objRS!Let_Cur + " " + " PK"
            End If
            MSFlexGrid1.Col = 8
            MSFlexGrid1.Text = ccu
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 9
            MSFlexGrid1.Text = objRS!colegio
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 10
            MSFlexGrid1.Text = objRS!agno
            MSFlexGrid1.Row = i
            MSFlexGrid1.Col = 11
            MSFlexGrid1.Text = objRS!folio_dtll

            FOL = FOL + 1
            canbol = canbol + 1
            tot_men = tot_men + objRS!Mensualidad
            tot_exen = tot_exen + objRS!Beca
            objRS.MoveNext
            ccu = " "
            
     Loop
  objRS.Close
  txt_tot_boletas.Text = canbol
  Txt_Monto_Detalle.Text = tot_men
  txt_tot_pesos.Text = tot_exen
  
End Sub

Private Sub Btn_Folio_Sel_Click(Index As Integer)
Select Case Index
    Case 0
        Filaini = FilaBol
    Case 1
        Filafin = FilaBol
End Select
Me.MSFlexGrid1.Col = 6
Me.MSFlexGrid1.Enabled = True
Me.Txt_Folio(Index) = BolSel
Me.Frame_Tipo_Folio.Visible = False
Me.MSFlexGrid1.SetFocus
End Sub


Private Sub Btn_Imprimir_Click()
If (Len(Trim(Me.Txt_Folio(0))) > 0 And Len(Trim(Me.Txt_Folio(1))) > 0) And (val(Me.Txt_Folio(1)) >= val(Me.Txt_Folio(0))) Then
    If MsgBox("¿Fecha de emisión es correcta ? " & Me.DTP_Fec_Emision.Value, vbYesNo + vbQuestion) = vbYes Then
        Dim MArancel As Long, MExencion As Long, MPagado As Long, MTotal As Long
        Dim MCPadres As String, MAportes As String, MOtros As String, MParcial As Long
        Dim FEmision As String, NomApo As String, RutApo As String, NomAlu As String, curso As String
        Dim suma As String, Mensual As String
        Dim iniPrinter As String
        Dim ResetPrinter As String
        Dim FormFeed As String
        Dim CuotaCero As Integer
        
        Set cNum2Let = New clsNum2Let
        'las secuencias para enviar una boleta a la impresora de matriz son
        'iniPrinter = Chr(27) + Chr(67) + Chr(51) + Chr(13) + Chr(27) + Chr(74) + Chr(120)
        '027 067 051 013 027 074 120 (pagina de 8 pulgadas o 51 lineas)
        'esta es la secuencia de reposicion, cuando termina el proceso es una especie de reset
        'iniPrinter = Chr(27) + "@" + Chr(27) + "C" + Chr(24) + Chr(13) '+ Chr(12) '+ Chr(0) + Chr(4)
        
        iniPrinter = Chr(27) + Chr(67) + Chr(51) + Chr(13) + Chr(27) + Chr(74) + Chr(120)
        ResetPrinter = Chr(27) + "@"
        FormFeed = Chr(12)
       ' Open "C:\LPT1.txt" For Output As 1
        Open "LPT1:" For Output As 1

        For t = val(Filaini) To val(Filafin)
            If UCase(Me.MSFlexGrid1.TextMatrix(t, 6)) <> "CANCELADA" Then
                RutApo = Me.MSFlexGrid1.TextMatrix(t, 0)
                If RutApo = "08942158-6" Then
                    MsgBox "stop mario", vbCritical + vbExclamation + vbInformation + vbOKOnly, "Critical Stop for Debug Information!"
                End If
                NomApo = Left(Me.MSFlexGrid1.TextMatrix(t, 1), 31)
                Mensualidad = Me.MSFlexGrid1.TextMatrix(t, 4)
                Folio = "" ' Me.msflexgrid1.TextMatrix(t, 6)
                Pagado = Me.MSFlexGrid1.TextMatrix(t, 4)
                NomAlu = Me.MSFlexGrid1.TextMatrix(t, 3)
                curso = Me.MSFlexGrid1.TextMatrix(t, 8)
                
                'IF (funcion que determine si es una primera cuota) then
                '
                'CuotaCero = MesCuotaCero(Me.MSFlexGrid1.TextMatrix(t, 10), Val(Trim(Me.MSFlexGrid1.TextMatrix(t, 15))), conn)
                
                'If (Month(CDate(Me.MSFlexGrid1.TextMatrix(t, 10))) = CuotaCero) And (Val(Trim(Me.MSFlexGrid1.TextMatrix(t, 15))) > 2004) Then
                '    Mes = Me.Cmb_Mes.List(Month(CDate(Me.MSFlexGrid1.TextMatrix(t, 10)))) & " 1 de 2."
                'ElseIf (Month(CDate(Me.MSFlexGrid1.TextMatrix(t, 10))) = (CuotaCero + 1)) And (Val(Trim(Me.MSFlexGrid1.TextMatrix(t, 15))) > 2004) Then
                '    Mes = Me.Cmb_Mes.List(Month(CDate(Me.MSFlexGrid1.TextMatrix(t, 10))) - 1) & " 2 de 2."
                'Else
                '    Mes = Me.Cmb_Mes.List(Month(CDate(Me.MSFlexGrid1.TextMatrix(t, 10))) - 1)
                'End If
                
                '
                'FIN del IF.
                FEmision = Me.DTP_Fec_Emision.Value
                MArancel = CLng(Me.MSFlexGrid1.TextMatrix(t, 4))
               ' If CLng(Me.MSFlexGrid1.TextMatrix(t, 25)) = 0 Then
               '     OtrasExencion = CLng(Me.MSFlexGrid1.TextMatrix(t, 3))
                    MExencion = CLng(Me.MSFlexGrid1.TextMatrix(t, 5))
                    MParcial = (MArancel - MExencion)
                '    MParcial1 = (MArancel - OtrasExencion)
                    MTotal = MParcial1
                'Else
                    OtrasExencion = 0
                '    MExencion = CLng(Me.MSFlexGrid1.TextMatrix(t, 25))
                '    MParcial = (MArancel - MExencion)
                '    MParcial1 = MParcial
                '    MTotal = MParcial1
                'End If
                MAportes = ""
                MCPadres = ""
                MOtros = ""
                'MTotal = MParcial '+ MCPadres + MAportes + MOtros
                cNum2Let.Numero = MTotal
                EnPalabras = cNum2Let.ALetra
                letra = 1: TOTAL_LETRAS = 10: agno_v = 5
                Print #1, Chr(15) & _
                vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf & _
                vbCrLf + vbCrLf & _
                vbCrLf + Space(23) + NomApo + Space(11) + RutApo & _
                vbCrLf + vbCrLf + Space(23) + NomAlu & _
                vbCrLf + vbCrLf + Space(23) + mes + " " + Me.MSFlexGrid1.TextMatrix(t, 7) + Space(34) + curso & _
                vbCrLf + vbCrLf + Space(25) + Pagado + Space(15) + EnPalabras & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(51) + CStr(MArancel) & _
                vbCrLf + vbCrLf + Space(51) + Space(Xc) + CStr(MExencion) + Space(20) + CStr(MParcial) & _
                vbCrLf + vbCrLf + Space(51) + Space(Xc1) + CStr(OtrasExencion) + Space(20) + CStr(MParcial1) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MAportes) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MCPadres) & _
                vbCrLf + vbCrLf + Space(72) + CStr(MOtros) & _
                vbCrLf + vbCrLf + Space(76) + CStr(MTotal) & _
                vbCrLf + vbCrLf + vbCrLf + vbCrLf + vbCrLf + Space(20) + FEmision & _
                vbCrLf + vbCrLf
            Else
             MsgBox "STOP"
            End If
        Next t
    Print #1, ResetPrinter
    Close 1
        If MsgBox("¿Desea Agregar al libro ? ", vbYesNo + vbQuestion) = vbYes Then
            Call Btn_Agregar_Click
        End If
    Else
        Me.DTP_Fec_Emision.SetFocus
    End If

Else
    MsgBox ("Error en los Folios Seleccionados")
End If
End Sub

Private Sub Cmb_Mes_Click()
mmes = val(Me.Cmb_Mes.ItemData(Me.Cmb_Mes.ListIndex))
End Sub

Private Sub Form_Load()
Dim i As Integer
Me.Caption = "IMPRESIÓN DE BOLETAS X BECAS 100% AÑO ESCOLAR " & Anno
MSFlexGrid1.Rows = 1
MSFlexGrid1.Cols = 12
MSFlexGrid1.ColWidth(0) = 1000
MSFlexGrid1.ColWidth(1) = 4000
MSFlexGrid1.ColWidth(2) = 1000
MSFlexGrid1.ColWidth(3) = 4000
MSFlexGrid1.ColWidth(4) = 1000
MSFlexGrid1.ColWidth(5) = 1000
MSFlexGrid1.ColWidth(6) = 1000
MSFlexGrid1.ColWidth(7) = 1000
MSFlexGrid1.ColWidth(8) = 1000
MSFlexGrid1.ColWidth(9) = 1000
MSFlexGrid1.ColWidth(10) = 1000
MSFlexGrid1.ColWidth(11) = 1000
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "Rut Apoderado"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Nombre"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Rut Alumno"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "Nombre"
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = "Mensualidad"
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = "Exencion"
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = "Folio"
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = "Fecha Vcto."
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = "Curso"
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = "Colegio"
MSFlexGrid1.Col = 10
MSFlexGrid1.Text = "Año"
MSFlexGrid1.Col = 11
MSFlexGrid1.Text = "folio_dtll"

Me.DTP_Fec_Emision.Value = Date

For i = 2010 To Anno
    cb_agno.AddItem i
Next i

End Sub

Private Sub MSFlexGrid1_Click()
''MsgBox (msflexgrid1.Col & " " & msflexgrid1.Row)
Fila = MSFlexGrid1.Row

If MSFlexGrid1.Col = 10 Then
    If Not (MSFlexGrid1.TextMatrix(Fila, MSFlexGrid1.Col) = "") Then
        Me.DT_Camb_Fecha.Value = CDate(MSFlexGrid1.TextMatrix(Fila, MSFlexGrid1.Col))
        Me.Frame_Camb_Fecha.Visible = True
    End If
Else
    If UCase(MSFlexGrid1.TextMatrix(Fila, 6)) <> "CANCELADA" And MSFlexGrid1.TextMatrix(Fila, 6) <> "" Then
        FilaBol = MSFlexGrid1.Row
        BolSel = MSFlexGrid1.TextMatrix(FilaBol, 6)
        MSFlexGrid1.Enabled = False
        Me.lbl_boleta.Caption = BolSel
        Me.Frame_Tipo_Folio.Visible = True
        Me.Btn_Folio_Sel(0).SetFocus
    Else
        If UCase(MSFlexGrid1.TextMatrix(Fila, 6)) = "CANCELADA" And MSFlexGrid1.TextMatrix(Fila, 21) <> "" Then
            ' Mostrar detalle del pago
            Me.Frame_Dtll_Pago.Visible = True
            Call LlenaGrilla(Me.Grd_Dtll_Pago, "Folio          , Emisión         , Pago           , Estado            ", "fnza_dtll_mvto fm, fnza_boletas fb, fnza_movimientos_mensualidad fmm, fnza_cod_estado_blta feb", "fb.folio_blta_fisico; fb.fecha_blta; fmm.fech_pago; feb.estado_blta", "fb.folio_blta=fm.folio_blta and fm.folio_mvto=fmm.folio_mvto and fb.estado_blta=feb.estado_blta and fb.tipo_doc = 'blta' and fm.folio_dtll =" & val(MSFlexGrid1.TextMatrix(Fila, 21)), conn)
        ElseIf UCase(MSFlexGrid1.TextMatrix(Fila, 6)) = "CANCELADA" And MSFlexGrid1.TextMatrix(Fila, 21) = "" Then
            MsgBox "Pago año anterior"
        End If
    End If
End If
End Sub


Private Sub Txt_TextoLog_Change()

End Sub
