X-Git-Url: https://git.llucax.com/z.facultad/75.10/miklolife.git/blobdiff_plain/c27e0207e5f08b9bbe8d15ed4eb655fe2ac6239a..bc4c4747eaf6bf6c1368fb63505f331561f1dc0c:/carpeta/disenio_grafico/src/Controlador/AfiliadoSolicitanteController.cs diff --git a/carpeta/disenio_grafico/src/Controlador/AfiliadoSolicitanteController.cs b/carpeta/disenio_grafico/src/Controlador/AfiliadoSolicitanteController.cs index 8cf6b97..74f1150 100644 --- a/carpeta/disenio_grafico/src/Controlador/AfiliadoSolicitanteController.cs +++ b/carpeta/disenio_grafico/src/Controlador/AfiliadoSolicitanteController.cs @@ -9,10 +9,21 @@ using com.db4o; 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 () { @@ -50,13 +61,10 @@ public class AfiliadoSolicitanteController 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; } @@ -75,7 +83,6 @@ public class AfiliadoSolicitanteController { Solicitante c = new Solicitante (tipoDoc, nroDoc, null, null); - ObjectContainer db=Db4o.openFile("os.yap"); bool existe = false; try { //do something with db4o @@ -86,9 +93,6 @@ public class AfiliadoSolicitanteController catch (Exception e) { Console.WriteLine (e); } - finally { - db.close(); - } return existe; } @@ -133,7 +137,6 @@ public class AfiliadoSolicitanteController private bool SaveSolicitante (Solicitante s) { - ObjectContainer db=Db4o.openFile("os.yap"); try { //do something with db4o db.set (s); @@ -141,9 +144,6 @@ public class AfiliadoSolicitanteController catch (Exception e) { Console.WriteLine (e); } - finally { - db.close(); - } return true; } @@ -161,7 +161,6 @@ public class AfiliadoSolicitanteController private ArrayList GetSolicitantes (Solicitante s) { - ObjectContainer db=Db4o.openFile("os.yap"); ArrayList lst = new ArrayList (); try { ObjectSet result = db.get(s); @@ -173,12 +172,7 @@ public class AfiliadoSolicitanteController } } catch (Exception e) { - Console.WriteLine ("----- GetSolicitantes ------"); Console.WriteLine (e); - Console.WriteLine ("----------------------------"); - } - finally { - db.close(); } return lst; } @@ -193,22 +187,16 @@ public class AfiliadoSolicitanteController 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(); - } } }