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 ()
{
return false;
}
- public ArrayList obtenerFamiliares (ETipoDocumento tipoDoc, int nroDoc)
+ public ArrayList ObtenerFamiliares (ETipoDocumento tipoDoc, int nroDoc)
{
ArrayList salida = new ArrayList ();
/* Afiliado a = GETAFILIADO(tipoDoc, nroDoc
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;
}
public bool ExisteSolicitante (ETipoDocumento tipoDoc, int nroDoc)
{
- return false;
+ Solicitante c = new Solicitante (tipoDoc, nroDoc, null, null);
+
+ bool existe = false;
+ try {
+ //do something with db4o
+ ObjectSet result = db.get(c);
+ if (result.next() != null)
+ existe = true;
+ }
+ catch (Exception e) {
+ Console.WriteLine (e);
+ }
+ return existe;
}
public void AgregarSolicitante (
d.Telefono = telefono;
s.Direccion = d;
+
+ SaveSolicitante (s);
}
public void EliminarAfiliado () {}
private bool SaveSolicitante (Solicitante s)
{
- ObjectContainer db=Db4o.openFile("os.yap");
try {
//do something with db4o
db.set (s);
}
- finally {
- db.close();
+ catch (Exception e) {
+ Console.WriteLine (e);
}
return true;
}
- private Afiliado Restore (int codigo)
+ private Solicitante GetSolicitante (ETipoDocumento tipoDoc, int nroDoc)
+ {
+ Solicitante s = new Solicitante (tipoDoc, nroDoc, null, null);
+
+ ArrayList lst = GetSolicitantes (s);
+
+ if (lst.Count == 0)
+ return null;
+
+ return (Solicitante)lst[0];
+ }
+
+ private ArrayList GetSolicitantes (Solicitante s)
{
- /* restora de la db */
- return null;
+ ArrayList lst = new ArrayList ();
+ try {
+ ObjectSet result = db.get(s);
+ if (result == null)
+ return lst;
+
+ while ((s = (Solicitante)result.next ()) != null) {
+ lst.Add (s);
+ }
+ }
+ catch (Exception e) {
+ Console.WriteLine (e);
+ }
+ return lst;
}
+ public ArrayList ObtenerSolicitantesPendientes ()
+ {
+ Solicitante s = new Solicitante (0, 0, null, null);
+ Promotor p = null; // new Promotor (0, 0, null, null);
+ s.Promotor = p;
+ return GetSolicitantes (s);
+ }
+
+ public void AsociarPromotor (ETipoDocumento tipoDoc, int nroDoc, int promotor)
+ {
+ try {
+ Solicitante s = new Solicitante (tipoDoc, nroDoc, null, null);
+ ObjectSet result = db.get(s);
+
+ s = (Solicitante)result.next ();
+ Promotor p = new Promotor (ETipoDocumento.DNI, 12345678, "123", "123");
+ s.Promotor = p;
+ db.set(s);
+ }
+ catch (Exception e) {
+ Console.WriteLine (e);
+ }
+ }
+
}
}