VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form_ContratoForm 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Formato de Contratos"
   ClientHeight    =   1335
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5760
   Icon            =   "Form_contrato_Formato.frx":0000
   LinkTopic       =   "Form4"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   1335
   ScaleWidth      =   5760
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frm_principal 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   7815
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   8175
      Begin VB.CommandButton Command6 
         Caption         =   "Vista Previa"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4320
         TabIndex        =   16
         Top             =   7200
         Width           =   1575
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Nueva Linea"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2640
         TabIndex        =   14
         Top             =   7200
         Width           =   1575
      End
      Begin VB.Frame Frame3 
         Caption         =   "Lineas"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   2535
         Left            =   240
         TabIndex        =   12
         Top             =   4440
         Width           =   7695
         Begin MSFlexGridLib.MSFlexGrid msfglineas 
            Height          =   2175
            Left            =   120
            TabIndex        =   13
            Top             =   240
            Width           =   7455
            _ExtentX        =   13150
            _ExtentY        =   3836
            _Version        =   393216
            Cols            =   3
            FixedCols       =   0
            BackColorSel    =   16761024
            ForeColorSel    =   -2147483630
            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
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Detalle de Alumnos"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   735
         Left            =   240
         TabIndex        =   10
         Top             =   3600
         Width           =   7695
         Begin VB.Label LBL_DETALLE 
            BackColor       =   &H8000000E&
            BorderStyle     =   1  'Fixed Single
            Caption         =   "Nombre : [NOM_APOALU]       CURSO 2005:[CURSOALU]"
            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        =   11
            Top             =   240
            Width           =   7455
         End
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Guardar"
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   6480
         Picture         =   "Form_contrato_Formato.frx":2A8B2
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   240
         Width           =   1455
      End
      Begin VB.Frame Frame1 
         Caption         =   "Cabecera"
         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            =   240
         TabIndex        =   5
         Top             =   1440
         Width           =   7695
         Begin VB.TextBox txt_cabecera 
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1215
            Left            =   120
            MultiLine       =   -1  'True
            TabIndex        =   6
            Top             =   240
            Width           =   7455
         End
         Begin MSComctlLib.ImageCombo imcbCab 
            Height          =   345
            Index           =   0
            Left            =   3840
            TabIndex        =   7
            Top             =   1560
            Width           =   3735
            _ExtentX        =   6588
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            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
            Locked          =   -1  'True
         End
         Begin VB.Label Label2 
            Alignment       =   2  'Center
            Caption         =   "Datos a Insertar:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Index           =   0
            Left            =   2160
            TabIndex        =   8
            Top             =   1560
            Width           =   1695
         End
      End
      Begin VB.CommandButton Command1 
         Caption         =   "&Nuevo"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   855
         Left            =   3960
         Picture         =   "Form_contrato_Formato.frx":2AF0B
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   240
         Width           =   1455
      End
      Begin VB.Frame frm_agno 
         Caption         =   "Aņo Contrato"
         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            =   240
         TabIndex        =   1
         Top             =   120
         Width           =   3375
         Begin MSComctlLib.ImageCombo cmbiango 
            Height          =   345
            Left            =   840
            TabIndex        =   2
            Top             =   360
            Width           =   2055
            _ExtentX        =   3625
            _ExtentY        =   609
            _Version        =   393216
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            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
            Locked          =   -1  'True
         End
         Begin VB.Label Label1 
            Caption         =   "Aņo:"
            BeginProperty Font 
               Name            =   "Arial"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   360
            TabIndex        =   3
            Top             =   360
            Width           =   495
         End
      End
      Begin VB.Label Label3 
         Alignment       =   2  'Center
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Left            =   240
         TabIndex        =   15
         Top             =   1200
         Width           =   7575
      End
   End
End
Attribute VB_Name = "Form_ContratoForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Public agnoact, cualpos, ordenact As Integer

Private Sub cmbiango_Click()
If Trim(cmbiango.Text) <> "" Then
    Dim buscarcontrato As ADODB.Recordset
    
    Set buscarcontrato = New ADODB.Recordset
    
    buscarcontrato.Open "Select * from cont_formato_cab where agno=" & cmbiango.Text, conn
    
    Me.txt_cabecera.Text = buscarcontrato!txt
    agnoact = Val(buscarcontrato!agno)
    buscarcontrato.Close
    Me.Width = 8325
    Me.Height = 8300
    Me.Label3.Caption = "Contrato Educacional Aņo " & Trim(str(agnoact))
    darformatogrilla
    actualizargrilla
    Me.Command2.Enabled = True
    Me.Command1.Enabled = False
    llenarcmbimgsql Me.imcbCab(0), "Select descripcion as texto, label as clav from cont_camposlabel", True

End If
End Sub

Private Sub Command1_Click()
    Me.Width = 8325
    Me.Height = 8300
    agnoact = Year(Date) + 1
    llenarcmbimgsql Me.imcbCab(0), "Select descripcion as texto, label as clav from cont_camposlabel", True
    Me.Label3.Caption = "Contrato Educacional Aņo " & Trim(str(agnoact))
    Me.Command1.Enabled = False
    Me.Command2.Enabled = True
    darformatogrilla
End Sub

Private Sub Command2_Click()
    grabarCabecera
    Unload Form_ContratoForm
   
End Sub

Private Sub Command3_Click()
    Me.frm_principal.Enabled = False
    Me.Enabled = False
    Load Form_Contrato_linea
    Form_Contrato_linea.Show
    Form_Contrato_linea.txt_linea.Text = " "
    cualpos = Me.msfglineas.Rows
    If cualpos > 0 Then
        Dim ordinal As ADODB.Recordset
        Set ordinal = New ADODB.Recordset
        ordinal.Open "Select cardinal from cardinales where orden=" & Trim(str(cualpos)), conn
        ordenact = cualpos
         Form_Contrato_linea.lbl_linea.Caption = ordinal!cardinal
        ordinal.Close
    End If
     llenarcmbimgsql Form_Contrato_linea.imcbCab(1), "Select descripcion as texto, label as clav from cont_camposlabel", True
  
End Sub





Private Sub Command6_Click()
      Call LimpiaFormulas(Form_main.CrystalReport, 30)
      Form_main.CrystalReport.ReportFileName = App.Path & "\rpt\contrato.rpt"
      Form_main.CrystalReport.WindowState = crptMaximized
      Form_main.CrystalReport.WindowTitle = "Vista Previa"
      Form_main.CrystalReport.ReplaceSelectionFormula ("")
      Form_main.CrystalReport.ReplaceSelectionFormula ("{cont_formato_cab.agno}=" & Trim(str(agnoact)))
      Form_main.CrystalReport.Destination = crptToWindow
      Form_main.CrystalReport.Action = 1
      Call LimpiaFormulas(Form_main.CrystalReport, 30)
 
End Sub

Private Sub Form_Load()
      llenarcmbimgsql Me.cmbiango, "Select agno as texto from cont_formato_cab order by agno", False
End Sub
Private Sub llenarcmbimgsql(cmbi As ImageCombo, constr As String, campovalor As Boolean)
    Dim tablaconsulta As ADODB.Recordset
    Dim contador As Integer
    cmbi.ComboItems.Clear
    contador = 0
    
    Set tablaconsulta = New ADODB.Recordset

    tablaconsulta.Open constr, conn
    contador = 1
    cmbi.ComboItems.Clear
    If tablaconsulta.RecordCount > 0 Then
        While Not tablaconsulta.EOF
            If campovalor Then
                cmbi.ComboItems.Add contador, tablaconsulta!clav, tablaconsulta!texto
            Else
                cmbi.ComboItems.Add contador, , tablaconsulta!texto
            End If
            contador = contador + 1
            tablaconsulta.MoveNext
        Wend
        tablaconsulta.Close
        Set cmbi.SelectedItem = cmbi.ComboItems.Item(1)
    End If
End Sub




Private Sub darformatogrilla()
    
    With Me.msfglineas
    .Rows = 1
    .Row = 0
    .Col = 0
    .ColWidth(0) = 0
    .Col = 1
    .ColWidth(1) = 900
    .CellAlignment = 2
    .CellFontBold = True
    .Text = "Linea"
    .Col = 2
    .ColWidth(2) = 6000
    .CellAlignment = 0
    .CellFontBold = True
    .Text = "Parrafo"
    End With
End Sub

Public Sub actualizargrilla()
    Dim xconsulta As ADODB.Recordset
    Dim xx As Integer
    Set xconsulta = New ADODB.Recordset
    
    xconsulta.Open "Select cont_formato_linea.orden as orden, cont_formato_linea.txt as txt, cardinales.cardinal as cardinal from cont_formato_linea ,cardinales where cont_formato_linea.orden=cardinales.orden and agno=" & agnoact & " order by cont_formato_linea.orden", conn
    xx = 1
    Me.msfglineas.Rows = xconsulta.RecordCount + 1
    If xconsulta.RecordCount > 0 Then
        While Not xconsulta.EOF
            Me.msfglineas.Row = xx
            Me.msfglineas.Col = 0
            Me.msfglineas.Text = xconsulta!Orden
            Me.msfglineas.Col = 1
            Me.msfglineas.Text = xconsulta!cardinal
            Me.msfglineas.Col = 2
            Me.msfglineas.Text = xconsulta!txt
            xx = xx + 1
            xconsulta.MoveNext
        Wend
        Me.msfglineas.Col = 0
        Me.msfglineas.ColSel = Me.msfglineas.Cols - 1
    End If
End Sub
Public Sub grabarCabecera()
    Dim grabardatos As ADODB.Command
    
    Set grabardatos = New ADODB.Command
    
    grabardatos.CommandText = "Replace into cont_formato_cab set agno=" & agnoact & ", txt='" & Me.txt_cabecera.Text & "'"
    grabardatos.ActiveConnection = conn
    grabardatos.CommandType = adCmdText
    grabardatos.Execute
End Sub


Private Sub imcbCab_Click(Index As Integer)
    If Index = 0 Then Me.txt_cabecera.Text = Me.txt_cabecera.Text & Trim(Me.imcbCab(Index).SelectedItem.Key)

End Sub

Private Sub msfglineas_Click()
    llenarcuadrolinea
    llenarcmbimgsql Form_Contrato_linea.imcbCab(1), "Select descripcion as texto, label as clav from cont_camposlabel", True

End Sub
Private Sub llenarcuadrolinea()
    Dim xactual As Integer
    Dim cualponer As ADODB.Recordset
    
    Set cualponer = New ADODB.Recordset
    Load Form_Contrato_linea
    Form_Contrato_linea.Show
    
    Me.msfglineas.Col = 0
    xactual = Val(Me.msfglineas.Text)
    cualponer.Open "Select cont.orden as orden, cont.txt as txt, card.cardinal as cardinal from cont_formato_linea as cont, cardinales as card where cont.orden=" & Trim(str(xactual)) & " and card.orden=cont.orden and cont.agno=" & agnoact, conn
    ordenact = cualponer!Orden
    Form_Contrato_linea.lbl_linea.Caption = cualponer!cardinal
    Form_Contrato_linea.txt_linea.Text = cualponer!txt
    cualponer.Close
    Me.frm_principal.Enabled = False
    Me.Enabled = False
End Sub
