VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form_edicion_boletas 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Edición de boletas"
   ClientHeight    =   3465
   ClientLeft      =   30
   ClientTop       =   360
   ClientWidth     =   4680
   Icon            =   "Form_edicion_boletas.frx":0000
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3465
   ScaleWidth      =   4680
   Begin VB.Frame Frame2 
      Caption         =   "Cambiar forma de 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          =   855
      Left            =   120
      TabIndex        =   8
      Top             =   1200
      Width           =   3255
      Begin VB.CommandButton Command2 
         Caption         =   "Guardar"
         Height          =   375
         Left            =   1920
         TabIndex        =   10
         Top             =   360
         Width           =   975
      End
      Begin VB.ComboBox cb_fp 
         Height          =   315
         Left            =   120
         TabIndex        =   9
         Top             =   360
         Width           =   1455
      End
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Salir"
      Height          =   372
      Left            =   3600
      TabIndex        =   7
      Top             =   720
      Width           =   972
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Limpiar"
      Height          =   372
      Left            =   3600
      TabIndex        =   6
      Top             =   120
      Width           =   972
   End
   Begin VB.Frame Frame4 
      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          =   975
      Left            =   120
      TabIndex        =   3
      Top             =   2280
      Width           =   3255
      Begin VB.CommandButton Command4 
         Caption         =   "Guardar"
         Height          =   372
         Left            =   1920
         TabIndex        =   5
         Top             =   240
         Width           =   975
      End
      Begin MSComCtl2.DTPicker dtp_fecha 
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   360
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   661
         _Version        =   393216
         Format          =   52756481
         CurrentDate     =   41425
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Ingrese folio a buscar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   852
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3255
      Begin VB.CommandButton Command1 
         Caption         =   "Buscar"
         Height          =   372
         Left            =   1920
         TabIndex        =   2
         Top             =   240
         Width           =   972
      End
      Begin VB.TextBox txt_folio_buscar 
         Height          =   285
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   1335
      End
   End
End
Attribute VB_Name = "Form_edicion_boletas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private arr_dtll(12) As Long
Private arr_monto(12) As Long
Dim folio_ant As Long
Dim fecha_ant As Date
Dim run_apo As String
Dim run_alu As String

Private Sub Command1_Click()
    Dim I As Long
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    var_sql = "SELECT tipo_pago,b.run_apo,b.run_alu,m.folio_dtll,CAST(DATE_FORMAT(fech_venc_cptos,'%m') AS UNSIGNED) AS mes,fech_venc_cptos,monto_pago,mm.folio_mvto,b.folio_blta,fecha_blta,folio_blta_fisico" _
            & " FROM fnza_boletas b,fnza_dtll_mvto n,fnza_movimientos_mensualidad mm,fnza_detalle_mensualidad m" _
            & " WHERE b.folio_blta = n.folio_blta AND n.folio_mvto = mm.folio_mvto AND n.folio_dtll = m.folio_dtll AND " _
            & " folio_blta_fisico = " & txt_folio_buscar.Text & " ORDER BY fech_venc_cptos"
    objRS.Open var_sql, conn
    If objRS.RecordCount = 0 Then
        MsgBox "El folio ingresado en la base de datos no existe", vbInformation
        Exit Sub
    End If
    
'    For i = 0 To 11
'        arr_dtll(i) = 0
'        arr_monto(i) = 0
'    Next i
       
    
    While Not objRS.EOF
        run_apo = objRS("run_apo")
        run_alu = objRS("run_alu")
        fp = objRS("tipo_pago")
        dtp_fecha.Enabled = True
        dtp_fecha.Value = objRS("fecha_blta")
        fecha_ant = objRS("fecha_blta")
        dtp_fecha.Tag = objRS("folio_blta")
        objRS.MoveNext
    Wend
    cb_fp.Text = DevuelveCampo("fnza_cod_forma_pago", "", "descripcion", "forma_pago = '" & fp & "'", conn)
    
    objRS.Close
    Command1.Enabled = False
End Sub

Private Sub Command2_Click()
    Dim var_sql As String
    Dim I As Integer
    Dim suma As Long
    Dim folio_mens As Long
    Dim permiso As Integer
    suma = 0
        
    permiso = val(DevuelveCampo("usuarios", "", "edicion_boletas", "aut_nombre_usuario = '" & Nom_usu_ses & "'", conn))
    If permiso = 0 Then
        MsgBox "Ud. no tiene privilegios para realizar cambios en este modulo", vbInformation
        Exit Sub
    End If
     
    fp = DevuelveCampo("fnza_cod_forma_pago", "", "forma_pago", "descripcion = '" & cb_fp.Text & "'", conn)
    var_sql = "update fnza_movimientos_mensualidad set tipo_pago = '" & fp & "' WHERE folio_mvto IN" _
            & " (SELECT folio_mvto FROM fnza_dtll_mvto WHERE folio_blta IN" _
            & " (SELECT folio_blta FROM fnza_boletas WHERE folio_blta_fisico = " & txt_folio_buscar & " AND tipo_blta = 3 ))"
    conn.Execute var_sql
    
    MsgBox "La forma de pago fue cambiada exitosamente", vbInformation
    Command5_Click
End Sub

Private Sub Command3_Click()
    Dim var_sql As String
    Dim Existe As Long
    Dim permiso As Integer
    
    permiso = val(DevuelveCampo("usuarios", "", "edicion_boletas", "aut_nombre_usuario = '" & Nom_usu_ses & "'", conn))
    If permiso = 0 Then
        MsgBox "Ud. no tiene privilegios para realizar cambios en este modulo", vbInformation
        Exit Sub
    End If
    
    Existe = val(DevuelveCampo("fnza_boletas", "", "folio_blta_fisico", "folio_blta_fisico = " & txt_folio.Text, conn))
    If CLng(Existe) <> CLng(txt_folio.Text) Then
        var_sql = "UPDATE fnza_boletas SET folio_blta_fisico = " & txt_folio.Text & " WHERE folio_blta = " & txt_folio.Tag
        conn.Execute var_sql
    Else
        MsgBox "Folio no puede ser cambiado, porque el folio especificado ya existe en la base de datos"
        Exit Sub
    End If
    MsgBox "El folio fue cambiado exitosamente", vbInformation
    
    
    accion_detalle = "Se a modificado el folio de " & folio_ant & " a " & txt_folio.Text & " a la boleta "
                       
    Call Inserta_Vitacora_Finanza(run_alu, run_apo, "Edición de boletas", CStr(accion_detalle), folio_ant, txt_folio.Text)
    
    Command5_Click
End Sub

Private Sub Command4_Click()
    Dim var_sql As String
    Dim permiso As Integer
    
    permiso = val(DevuelveCampo("usuarios", "", "edicion_boletas", "aut_nombre_usuario = '" & Nom_usu_ses & "'", conn))
    If permiso = 0 Then
        MsgBox "Ud. no tiene privilegios para realizar cambios en este modulo", vbInformation
        Exit Sub
    End If
    
    var_sql = "UPDATE fnza_boletas SET fecha_blta = '" & Format(dtp_fecha.Value, "yyyy/mm/dd") & "',fecha_pago = '" _
    & Format(dtp_fecha.Value, "yyyy/mm/dd") & "' WHERE folio_blta = " & dtp_fecha.Tag
    conn.Execute var_sql
    
    cole = DevuelveCampo("cfg", "", "valor", "param = 'CODBC'", conn)
    aaa = ConectarSQL(connSQL, "192.168.7.13", colegio, "sa", "passCORPsa.2024", True)
    If cole = "HUE001" Then
        var_sql = "UPDATE HUECHURABA.softland.iw_gsaen" _
                & " SET fecha = '" & dtp_fecha.Value & "',fechavenc = '" & dtp_fecha.Value & "'" _
                & " WHERE tipo = 'B' AND folio = " & txt_folio_buscar.Text
        connSQL.Execute var_sql
        
        var_sql = "UPDATE HUECHURABA.softland.dte_doccab" _
                & " SET fchemis = '" & dtp_fecha.Value & "',FchVenc = '" & dtp_fecha.Value & "'" _
                & " WHERE tipo = 'B' AND folio = " & txt_folio_buscar.Text
        connSQL.Execute var_sql
    Else
        var_sql = "UPDATE CORPORACIONBC.softland.iw_gsaen" _
                & " SET fecha = '" & dtp_fecha.Value & "',fechavenc = '" & dtp_fecha.Value & "'" _
                & " WHERE tipo = 'B' AND folio = " & txt_folio_buscar.Text
        connSQL.Execute var_sql
        
        var_sql = "UPDATE CORPORACIONBC.softland.dte_doccab" _
                & " SET fchemis = '" & dtp_fecha.Value & "',FchVenc = '" & dtp_fecha.Value & "'" _
                & " WHERE tipo = 'B' AND folio = " & txt_folio_buscar.Text
        connSQL.Execute var_sql
    End If
    connSQL.Close
    
    MsgBox "La fecha fue cambiada exitosamente en Gescol y Softland", vbInformation
    
    accion_detalle = "Se a modificado la fecha de la boleta de " & fecha_ant & " a " & dtp_fecha.Value & " del folio " _
                       & folio_ant
    Call Inserta_Vitacora_Finanza(run_alu, run_apo, "Edición de boletas", CStr(accion_detalle), txt_folio_buscar.Text, txt_folio_buscar.Text)
    
    Command5_Click
End Sub

Private Sub Command5_Click()
    Dim I As Integer
'    txt_folio.Enabled = True
'    txt_folio.Text = ""
'    txt_folio.Tag = ""
    
'    For i = 0 To 11
''        Text_1(i).Enabled = False
''        Text_1(i).Text = ""
''        Text_1(i).Tag = ""
'
'    Next i
    dtp_fecha.Enabled = False
'    txt_folio.Text = ""
'    txt_folio.Tag = ""
    Command1.Enabled = True
End Sub

Private Sub Command6_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim objRS As ADODB.Recordset
    Set objRS = New ADODB.Recordset
    Dim var_sql As String
    var_sql = "SELECT descripcion FROM fnza_cod_forma_pago"
    objRS.Open var_sql, conn
    While Not objRS.EOF
        cb_fp.AddItem objRS("descripcion")
        objRS.MoveNext
    Wend
    objRS.Close
    Command5_Click
End Sub

