Mensaje :
gbx3: warning: circular references detected:
gbx3: 1 CDB
gbx3: warning: 19 allocation(s) non freed.
Codigo :
Inherits Connection
Private $hRes As Result
Public Procedure connect_on() As Connection
Try Me.Close
Try Me.Open
If Error Then
Message.Error(Subst(MMesgTitle.MERR_001, DConv$(Error.Text)) & "\n KRC finalizará ahora.")
Quit
End If
End
Public Procedure connect_off() As Connection
Try Me.Close()
If Error Then Message.Error(MMesgTitle.MERR_011)
End
Public Function statement(Optional sQuery As String, Optional sMode_stat As String, Optional sTable As String, Optional sField As String, Optional sParam As String) As Result
If Not sMode_stat Then sMode_stat = "QUE"
Select Case sMode_stat
Case "QUE"
conection_query(sQuery)
Case "INS"
conection_insert(sTable, sField, sParam)
Case "DEL"
conection_delete(sTable, sField)
End Select
Try Return $hRes
End
Public Function unique_field(sTable As String, sParam As String) As Result
If sTable And sParam Then $hRes = Me.Find(sTable, sParam)
Return $hRes
End
Public Function load_combobox(cmb As ComboBox, sQuery As String, sField_1 As String, Optional sField_2 As String)
cmb.Tag = New Variant[]
If Not sQuery Or Not cmb Or Not sField_1 Then Message.Error(MMesgTitle.MERR_006)
$hRes = Me.Exec(sQuery)
cmb.Add("", 0)
cmb.Tag.Add("")
Do While $hRes.Available
cmb.Add($hRes[sField_1])
cmb.Tag.Add($hRes[sField_2])
$hRes.MoveNext
Loop
End
Public Function load_listbox(lbx As ListBox, sQuery As String, Optional sParam1 As String, Optional sParam2 As String)
If Not sQuery Then
Message.Error(MMesgTitle.MERR_006)
Endif
$hRes = Me.Exec(sQuery)
Do While $hRes.Available
lbx.Add($hRes[sParam1], $hRes[sParam2])
$hRes.MoveNext()
Loop
End
Private Procedure conection_query(sQuery As String) As Result
If Not sQuery Then
Message.Error(MMesgTitle.MERR_006)
Return $hRes
Endif
$hRes = Me.Exec(sQuery)
Catch
Me.connect_on()
Try $hRes = Me.Exec(sQuery)
check_error()
End
Private Procedure conection_insert(sTable As String, Optional sField As String, sParam As String) As Result
Dim sQuery_ins As String
If Not sTable Or Not sParam Then
Message.Error(MMesgTitle.MERR_006)
Return $hRes
Endif
If Not IsNull(sField) Then
sQuery_ins = Subst$("INSERT (&1) INTO &2 VALUES(&3)", sField, sTable, sParam)
Else
sQuery_ins = Subst$("INSERT INTO &1 VALUES(&2)", sTable, sParam)
Endif
$hRes = Me.Exec(sQuery_ins)
If $hRes.Count < 0 Then Message.Error(MMesgTitle.MERR_002)
Try
Message.Info(MMesgTitle.MINF_001, "Aceptar")
Catch
Me.connect_on()
Try $hRes = Me.Exec(sQuery_ins)
check_error()
End
Private Procedure conection_delete(sTable As String, sField As String) As Result
Me.Delete(sTable, sField)
Catch
Me.connect_on()
Try Me.Delete(sTable, sField)
check_error()
End
Private Function check_error() As Result
If Error Then
Message.Error(Subst(MMesgTitle.MERR_005, Error.Text))
Return $hres
Endif
End