VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_Deuda 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cartola de Deuda por Apoderado"
   ClientHeight    =   4845
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7785
   Icon            =   "Form_Deuda.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4845
   ScaleWidth      =   7785
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton Command2 
      Caption         =   "Volver"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4080
      TabIndex        =   6
      Top             =   4200
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      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            =   2520
      TabIndex        =   5
      Top             =   4200
      Width           =   1335
   End
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid FlexGrid 
      Height          =   3015
      Left            =   120
      TabIndex        =   4
      Top             =   960
      Width           =   7500
      _ExtentX        =   13229
      _ExtentY        =   5318
      _Version        =   393216
      FixedCols       =   0
      FocusRect       =   0
      HighLight       =   0
      FillStyle       =   1
      ScrollBars      =   2
      SelectionMode   =   1
      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
      _NumberOfBands  =   1
      _Band(0).Cols   =   2
   End
   Begin VB.TextBox Text2 
      BackColor       =   &H80000004&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   285
      Left            =   1800
      Locked          =   -1  'True
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   240
      Width           =   5655
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H80000004&
      BorderStyle     =   0  'None
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   285
      Left            =   1680
      Locked          =   -1  'True
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   480
      Width           =   5895
   End
   Begin VB.Label LAgno 
      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        =   7
      Top             =   4200
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "Fecha de Consulta:"
      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        =   2
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "Apoderado:"
      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        =   0
      Top             =   480
      Width           =   1455
   End
End
Attribute VB_Name = "Form_Deuda"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Form_cta_cte_dialog.Frame2.Visible = False
    Form_cta_cte_dialog.Frame1.Top = 360
    Load Form_cta_cte_dialog
    Form_cta_cte_dialog.Show vbModal
    
    If Form_cta_cte.Impresion_Aceptar Then
        ' Imprimo el reporte
        Form_main.CrystalReport.Formulas(1) = "Hora = '" & Time & "'"
        Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\cartola_deuda.rpt"
        Form_main.CrystalReport.WindowTitle = ""
        Form_main.CrystalReport.WindowState = crptMaximized
        Form_main.CrystalReport.ReplaceSelectionFormula ("")
        'Form_cta_cte.Text1.Text = Rut del apoderado
        Form_main.CrystalReport.ReplaceSelectionFormula ("{fnza_mensualidad.RUN_APO}='" & Form_cta_cte.Text1.Text & "' AND {fnza_mensualidad.AGNO}=" & LAgno.Caption & "")
        If Form_cta_cte.Impresion_Pantalla Then
            Form_main.CrystalReport.Destination = crptToWindow
        Else
            Form_main.CrystalReport.Destination = crptToPrinter
        End If
        Form_main.CrystalReport.Action = 1
    End If
End Sub

Private Sub Command2_Click()
    'Me.Hide
    Unload Me
End Sub

Private Sub Form_Load()
    Text2.Text = Format(Date, "dddd, d mmmm yyyy")
    Text1.Text = Form_cta_cte.Text15.Text
    LAgno = Trim(Form_cta_cte.Cmb_Agno.Text)
    Me.Caption = "Cartola de Deuda por Periodo " & LAgno
    FlexGrid.Cols = 5
    FlexGrid.Rows = 2
    FlexGrid.FormatString = "^Cuota|^Fecha Venc.|>Mensualidad|> Abonado|^Estado|<Fecha Pago"
    FlexGrid.ColWidth(0) = 1000
    FlexGrid.ColWidth(1) = 1150
    FlexGrid.ColWidth(2) = 1100
    FlexGrid.ColWidth(3) = 1100
    FlexGrid.ColWidth(4) = 1150
    FlexGrid.ColWidth(5) = 1400
    
    Call Llenado_Grilla
    
    
End Sub

Private Sub Llenado_Grilla()
    Dim RC As ADODB.Recordset
    Dim Str_Consulta As String
    Dim i As Integer
    
    Set ObjConsulta = New ADODB.Command
    Set RC = New ADODB.Recordset
            
    Str_Consulta = "SELECT folio_mens, mes, fech_venc, monto_mens, abono_mens, estado_mens, if(fech_pago='0000-00-00',null,fech_pago) as fecha_pago FROM fnza_mensualidad WHERE run_apo='" & Form_cta_cte.Text1.Text & "' AND agno=" & LAgno.Caption & " ORDER BY agno, mes, colegio DESC"
    RC.Open Str_Consulta, conn
    
    If (RC.RecordCount = 0) Then
        MsgBox "El apoderado no tiene mensualidades creadas para el periodo " & LAgno & ".", vbOKOnly, "Sin Información"
        RC.Close
        Exit Sub
    End If
    
    i = 0
    RC.MoveFirst
    While Not (RC.EOF)
        i = i + 1
        If IsNull(RC("fecha_pago")) Then
            Me.FlexGrid.AddItem Format(RC("mes") - 2, "00") & Chr(9) & RC("fech_venc") & Chr(9) & RC("monto_mens") & Chr(9) & RC("abono_mens") & Chr(9) & TraduceEstadoMens(RC("estado_mens"), conn) & Chr(9) & "00-00-0000", i
        Else
            Me.FlexGrid.AddItem Format(RC("mes") - 2, "00") & Chr(9) & RC("fech_venc") & Chr(9) & RC("monto_mens") & Chr(9) & RC("abono_mens") & Chr(9) & TraduceEstadoMens(RC("estado_mens"), conn) & Chr(9) & RC("fecha_pago"), i
        End If
        SeleccionaFlex i
        If RC("estado_mens") = "abon" Then
            FlexGrid.CellBackColor = &HC0FFFF
        ElseIf RC("estado_mens") = "clda" Then
            FlexGrid.CellBackColor = &HC0FFC0
        ElseIf RC("estado_mens") = "cred" Then
            FlexGrid.CellBackColor = &HC0C0FF
        End If
        RC.MoveNext
    Wend
    RC.Close
    Set RC = Nothing
    
End Sub

Private Sub SeleccionaFlex(ByVal MyRow As Long)
    Me.FlexGrid.Row = MyRow
    Me.FlexGrid.Col = 0
    Me.FlexGrid.RowSel = MyRow
    Me.FlexGrid.ColSel = 5
End Sub

Private Sub Form_Unload(Cancel As Integer)
Form_cta_cte_dialog.Frame1.Top = 720
Form_cta_cte_dialog.Frame2.Visible = True
End Sub


