using System;
using System.Collections;
-public class AfiliadoSolicitanteController
+public class AfiliadoSolicitanteController : IDisposable
{
private ArrayList _afiliados;
private ArrayList _solicitantes;
+ private ObjectContainer db;
+
+ public AfiliadoSolicitanteController ()
+ {
+ db = Db4o.openFile("os.yap");
+ }
+
+ public void Dispose ()
+ {
+ db.close ();
+ }
public ArrayList obtenerSolicitantesAfiliar ()
{
public bool afiliarTitular (ETipoDocumento tipoDoc, int nroDo, Plan plan)
{
- ObjectContainer db=Db4o.openFile("os.yap");
try {
//do something with db4o
}
- finally {
- db.close();
- }
+ catch (Exception e){}
return true;
}
{
Solicitante c = new Solicitante (tipoDoc, nroDoc, null, null);
- ObjectContainer db=Db4o.openFile("os.yap");
bool existe = false;
try {
//do something with db4o
catch (Exception e) {
Console.WriteLine (e);
}
- finally {
- db.close();
- }
return existe;
}
private bool SaveSolicitante (Solicitante s)
{
- ObjectContainer db=Db4o.openFile("os.yap");
try {
//do something with db4o
db.set (s);
catch (Exception e) {
Console.WriteLine (e);
}
- finally {
- db.close();
- }
return true;
}
private ArrayList GetSolicitantes (Solicitante s)
{
- ObjectContainer db=Db4o.openFile("os.yap");
ArrayList lst = new ArrayList ();
try {
ObjectSet result = db.get(s);
}
}
catch (Exception e) {
- Console.WriteLine ("----- GetSolicitantes ------");
Console.WriteLine (e);
- Console.WriteLine ("----------------------------");
- }
- finally {
- db.close();
}
return lst;
}
public void AsociarPromotor (ETipoDocumento tipoDoc, int nroDoc, int promotor)
{
- ObjectContainer db=Db4o.openFile("os.yap");
try {
- Solicitante s = new Solicitante (tipoDoc, nroDoc, null, null);
- ObjectSet result = db.get(s);
+ Solicitante s = GetSolicitante (tipoDoc, nroDoc);
- s = (Solicitante)result.next ();
Promotor p = new Promotor (ETipoDocumento.DNI, 12345678, "123", "123");
s.Promotor = p;
- db.set(s);
+ SaveSolicitante (s);
}
catch (Exception e) {
Console.WriteLine (e);
}
- finally {
- db.close();
- }
}
}