VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Form_mant_glosa 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Glosas Notas de Credito"
   ClientHeight    =   5685
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5250
   Icon            =   "Form_mant_glosa.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5685
   ScaleWidth      =   5250
   Begin VB.Frame Frame4 
      Caption         =   "Editar"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1935
      Left            =   480
      TabIndex        =   9
      Top             =   2040
      Visible         =   0   'False
      Width           =   4335
      Begin VB.TextBox Text2 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   840
         TabIndex        =   13
         Top             =   720
         Width           =   3135
      End
      Begin VB.CommandButton Command6 
         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            =   2880
         TabIndex        =   12
         Top             =   1320
         Width           =   1215
      End
      Begin VB.CommandButton Command5 
         Caption         =   "Eliminar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1560
         TabIndex        =   11
         Top             =   1320
         Visible         =   0   'False
         Width           =   1215
      End
      Begin VB.CommandButton Command4 
         Caption         =   "Editar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   240
         TabIndex        =   10
         Top             =   1320
         Width           =   1215
      End
      Begin VB.Label Label4 
         Caption         =   "Label4"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2880
         TabIndex        =   16
         Top             =   360
         Visible         =   0   'False
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "Glosa Actual"
         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             =   360
         Width           =   3735
      End
      Begin VB.Label Label2 
         Caption         =   "Glosa"
         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        =   14
         Top             =   720
         Width           =   855
      End
   End
   Begin VB.Frame Frame3 
      Height          =   735
      Left            =   120
      TabIndex        =   7
      Top             =   4800
      Width           =   4935
      Begin VB.CommandButton Command3 
         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            =   3600
         TabIndex        =   8
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Glosas Ingresadas"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   3255
      Left            =   120
      TabIndex        =   5
      Top             =   1440
      Width           =   4935
      Begin MSHierarchicalFlexGridLib.MSHFlexGrid grilla 
         Height          =   2895
         Left            =   120
         TabIndex        =   6
         Top             =   240
         Width           =   4695
         _ExtentX        =   8281
         _ExtentY        =   5106
         _Version        =   393216
         BackColor       =   16777215
         FixedCols       =   0
         BackColorSel    =   14737632
         ForeColorSel    =   16711680
         BackColorBkg    =   16777215
         AllowBigSelection=   0   'False
         HighLight       =   2
         FillStyle       =   1
         GridLinesUnpopulated=   2
         SelectionMode   =   1
         FormatString    =   "Cod|<Glosa"
         RowSizingMode   =   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).TextStyleBand=   0
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Agregar Descripcion de glosa Nueva"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   1215
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4935
      Begin VB.TextBox Text1 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   840
         TabIndex        =   4
         Top             =   480
         Width           =   2415
      End
      Begin VB.CommandButton Command2 
         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            =   3480
         TabIndex        =   2
         Top             =   720
         Width           =   1215
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Agregar"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3480
         TabIndex        =   1
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "Glosa"
         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        =   3
         Top             =   480
         Width           =   615
      End
   End
End
Attribute VB_Name = "Form_mant_glosa"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    Dim sql As String
    If Trim(Text1.Text) = "" Then
        Exit Sub
    End If
    sql = "INSERT INTO fnza_glosa (descripcion) values ('" & Replace(Text1.Text, "'", "\'") & "');"
    conn.Execute sql
    Command2_Click
End Sub

Private Sub Command2_Click()
    Text1.Text = ""
    SeteaGrilla
    LlenaGrilla
End Sub

Private Sub Command3_Click()
    LlenaComboGlosa
    Unload Me
End Sub

Private Sub LlenaComboGlosa()
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    Dim i As Integer
    Dim sql As String
    Form_NTCR.cmb_glosa.ComboItems.Clear
    sql = "SELECT * FROM fnza_glosa WHERE valido = 'SI'"
    RC.Open sql, conn
    i = 1
    While Not RC.EOF
        Form_NTCR.cmb_glosa.ComboItems.Add i, "A" & RC("cod_glosa"), RC("descripcion")
        RC.MoveNext
        i = i + 1
    Wend
    Set Form_NTCR.cmb_glosa.SelectedItem = Form_NTCR.cmb_glosa.ComboItems.Item(1)
    Form_NTCR.cmb_glosa.ComboItems.Add i, "OTRO", "Agregar Nueva Glosa..."
End Sub


Private Sub Command4_Click()
    Dim sql As String
    If Text2.Text = "" Then
        Exit Sub
    End If
    If MsgBox("Esta seguro que desea editar la glosa con el siguiente mensaje :" & vbLf & vbCrLf & Text2.Text, vbQuestion + vbYesNo) = vbYes Then
        sql = "UPDATE fnza_glosa SET descripcion = '" & Replace(Text2.Text, "'", "\'") & "' WHERE cod_glosa = " & Label4.Caption & ";"
        conn.Execute sql
        Command6_Click
    End If
End Sub

Private Sub Command5_Click()
    Dim sql As String
    If MsgBox("Esta seguro que desea Eliminar la glosa ", vbQuestion + vbYesNo) = vbYes Then
        sql = "UPDATE fnza_glosa SET valido = 'NO' WHERE cod_glosa = " & Label4.Caption & ";"
        conn.Execute sql
        Command6_Click
    End If
End Sub

Private Sub Command6_Click()
    Frame4.Visible = False
    Frame1.Enabled = True
    Frame3.Enabled = True
    grilla.Enabled = True
    Command2_Click
End Sub

Private Sub Form_Load()
    SeteaGrilla
    LlenaGrilla
End Sub

Private Sub SeteaGrilla()
    grilla.ClearStructure
    grilla.Rows = 2
    grilla.FormatString = "Cod|<Glosa|<valido"
    grilla.ColWidth(0) = 0
    grilla.ColWidth(1) = 4100
    grilla.ColWidth(2) = 0
End Sub

Private Sub LlenaGrilla()
    Dim QR As String
    Dim RC As ADODB.Recordset
    Set RC = New ADODB.Recordset
    
    QR = "SELECT * FROM fnza_glosa where cod_glosa > 1"
    RC.Open QR, conn
    If RC.RecordCount = 0 Then
        RC.Close
        Exit Sub
    End If
    For i = 1 To RC.RecordCount
        grilla.AddItem RC("cod_glosa") & Chr(9) & RC("descripcion") & Chr(9) & RC("valido"), i
        grilla.Col = 0
        grilla.Row = i
        grilla.RowSel = i
        grilla.ColSel = 2
        If (RC("valido") = "NO") Then
            grilla.CellBackColor = &HC0C0FF
        End If
        RC.MoveNext
    Next i
    RC.Close
End Sub

Private Sub Grilla_DblClick()
    If grilla.TextMatrix(grilla.Row, 2) = "NO" Then
        Exit Sub
    End If
    If grilla.TextMatrix(grilla.Row, 2) = "" Then
        Exit Sub
    End If
    Label3.Caption = "Glosa Actual : " & grilla.TextMatrix(grilla.Row, 1)
    Text2.Text = ""
    Label4.Caption = grilla.TextMatrix(grilla.Row, 0)
    grilla.Enabled = False
    Frame4.Visible = True
    Frame1.Enabled = False
    Frame3.Enabled = False
End Sub
