VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_ProtestarCheques 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Protestar Cheques"
   ClientHeight    =   6690
   ClientLeft      =   1380
   ClientTop       =   2355
   ClientWidth     =   11985
   Icon            =   "Form_ProtestarCheques.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6690
   ScaleWidth      =   11985
   Begin VB.Frame Frame2 
      Caption         =   "Protestar Cheques"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1095
      Left            =   120
      TabIndex        =   2
      Top             =   5400
      Width           =   11655
      Begin VB.CommandButton Command2 
         Caption         =   "Cerrar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   9480
         TabIndex        =   4
         Top             =   360
         Width           =   1935
      End
      Begin VB.CommandButton cmd_ProtestarCheques 
         Caption         =   "Protestar Cheques"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   240
         TabIndex        =   3
         Top             =   360
         Width           =   1935
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Listado de Cheques"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   5175
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   11655
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid_Cheques 
         Height          =   4815
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   11415
         _ExtentX        =   20135
         _ExtentY        =   8493
         _Version        =   393216
         FocusRect       =   0
         FillStyle       =   1
         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
         _Band(0).GridLinesBand=   1
         _Band(0).TextStyleBand=   0
         _Band(0).TextStyleHeader=   0
      End
   End
End
Attribute VB_Name = "Form_ProtestarCheques"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Rec2Grid(ByRef REC As ADODB.Recordset, ByRef grid As Object, Optional ByVal Numeracion As Boolean = True)
    grid.ClearStructure
    If REC.RecordCount > 0 Then
        grid.Cols = REC.Fields.count + 1
        grid.Rows = REC.RecordCount + 1
        grid.FixedCols = 1
        grid.FixedRows = 1
        grid.TextMatrix(0, 0) = "Nº"
        grid.ColWidth(0) = IIf(Numeracion, TextWidth(grid.TextMatrix(0, 0)) + 100, 0)
        For i = 1 To REC.Fields.count
            grid.TextMatrix(0, i) = UCase(REC.Fields(i - 1).Name)
            grid.ColWidth(i) = TextWidth(grid.TextMatrix(0, i)) + 100
        Next i
        REC.MoveFirst
        For i = 1 To REC.RecordCount
            grid.TextMatrix(i, 0) = i
            grid.ColWidth(0) = IIf(Numeracion, IIf(TextWidth(grid.TextMatrix(i, 0)) + 100 > grid.ColWidth(0), TextWidth(grid.TextMatrix(i, 0)) + 100, grid.ColWidth(0)), 0)
            For j = 1 To REC.Fields.count
                grid.TextMatrix(i, j) = IIf(IsNull(REC(j - 1)), "Null", REC(j - 1))
                grid.ColWidth(j) = IIf(TextWidth(grid.TextMatrix(i, j)) + 100 > grid.ColWidth(j), TextWidth(grid.TextMatrix(i, j)) + 100, grid.ColWidth(j))
            Next j
            REC.MoveNext
        Next i
    Else
        grid.Cols = 2
        grid.Rows = 2
    End If
End Sub

Private Sub cmd_ProtestarCheques_Click()
  Dim i As Long
  Dim R As Integer
  Dim abonar As Boolean
  Dim var_sql As String
  Dim objRS As ADODB.Recordset
  Set objRS = New ADODB.Recordset
  Dim objRS_dtll As ADODB.Recordset
  Set objRS_dtll = New ADODB.Recordset
  R = MsgBox("¿Esta seguro de que desea protestar los cheques seleccionados?", vbQuestion + vbYesNo, "Mensaje de confirmación")
  If R = 6 Then
  For i = MSHFlexGrid_Cheques.Row To MSHFlexGrid_Cheques.RowSel
        MSHFlexGrid_Cheques.Row = i
        MSHFlexGrid_Cheques.Col = 9
        var_sql = "select fmm.folio_mvto,folio_dtll,monto_pago,fech_pago,estado_cobro" _
                & " from fnza_chq_mvto fcm," _
                & "fnza_movimientos_mensualidad fmm where" _
                & " fcm.folio_mvto = fmm.folio_mvto and folio_chq = " _
                & MSHFlexGrid_Cheques.Text
        objRS.Open var_sql, conn
        If Not objRS.EOF Then
        If objRS("estado_cobro") <> "prto" Then

        While Not objRS.EOF
            'MsgBox Format(Date, "yyyy-mm-dd")
            'Function abonar_detalle(ByVal FolioDtll As Long, ByVal Monto As Long, ByVal FechaAbono As Date, CNX As ADODB.Connection) As Boolean
            abonar = abonar_detalle(objRS("folio_dtll"), -objRS("monto_pago"), Format(Date, "yyyy-mm-dd"), conn)

            var_sql = "update fnza_movimientos_mensualidad set estado_pago = 'prto'" _
                & " where folio_mvto = " & objRS("folio_mvto")
            conn.Execute var_sql

            var_sql = "update fnza_chq_mvto set estado_cobro = 'prto'" _
                & " where folio_mvto = " & objRS("folio_mvto")
            conn.Execute var_sql

            objRS.MoveNext
        Wend
        var_sql = "update fnza_cheques_recibidos set estado_chq = 'prto'" _
                & " where folio_chq = " & MSHFlexGrid_Cheques.Text
        conn.Execute var_sql
        MSHFlexGrid_Cheques.RemoveItem (MSHFlexGrid_Cheques.Row)
        End If
        End If
        objRS.Close
  Next i
  'llena_grilla_cheques
  End If
End Sub
Private Sub Command2_Click()
   
    Unload Me
End Sub

Private Sub Form_Load()
    llena_grilla_cheques
End Sub

Private Sub llena_grilla_cheques()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    Dim color As String

    var_sql = "select dia_cobro as Dia_Cobro,Monto_Cheque Monto,Banco,Numero_Cheque," _
            & "Rut_Titular,Nombre_Titular Titular," _
            & "Nom_alu Nombre_Alumno,curso Curso,folio_chq" _
    & " from fnza_flujocheques_temp" _
    & " order by dia_cobro,banco"
    
    objRS.Open var_sql, conn
    Call Rec2Grid(objRS, MSHFlexGrid_Cheques, True)
    MSHFlexGrid_Cheques.ColAlignment = 1
    MSHFlexGrid_Cheques.ColSel = 9
    objRS.Close
End Sub
