using System; using System.Collections; using Gtk; using Glade; using Controlador; using Controlador.Afiliacion; using Dominio.Afiliados; using Dominio; public class VRegistrarVisitas { Glade.XML xml; [Widget] TreeView visitas; [Widget] Entry fechaNac; public VRegistrarVisitas () { xml = new Glade.XML (null, "registrar_visitas.glade", "registrar_visitas", null); xml.Autoconnect (this); RegistrarVisitasController c = new RegistrarVisitasController (null); ArrayList l = c.ObtenerSolicitantesAsignados (); visitas.Model = new ListStore (typeof(string), typeof(int), typeof (string), typeof (string)); visitas.HeadersVisible = true; visitas.AppendColumn ("Tipo Doc.", new CellRendererText (), "text", 0); visitas.AppendColumn ("Nro Doc.", new CellRendererText (), "text", 1); visitas.AppendColumn ("Apellido", new CellRendererText (), "text", 2); visitas.AppendColumn ("Nombre", new CellRendererText (), "text", 3); ListStore store = (ListStore)visitas.Model; foreach (Solicitante s in l) { TreeIter iter = store.AppendValues (s.TipoDocumento.ToString (), s.NroDocumento, s.Nombre, s.Apellido); Console.WriteLine ("Agregando {0}", s.Nombre); } c.Dispose (); } public void OnEstablecerPendiente (object o, EventArgs args) { TreeSelection fromSel = visitas.Selection; TreeIter iter; TreeModel model; ListStore store = (ListStore)visitas.Model; if (fromSel.GetSelected (out model, out iter) == false) { /* Nada seleccionado */ return; } ETipoDocumento tipoDoc; int nroDoc; tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true); nroDoc = (int)store.GetValue (iter, 1); RegistrarVisitasController c = new RegistrarVisitasController (null); c.EstablecerPendiente (tipoDoc, nroDoc); c.Dispose (); store.Remove (ref iter); } public void OnEliminarSolicitante (object o, EventArgs args) { TreeSelection fromSel = visitas.Selection; TreeIter iter; TreeModel model; ListStore store = (ListStore)visitas.Model; if (fromSel.GetSelected (out model, out iter) == false) { /* Nada seleccionado */ return; } /* Confirmo la operacion */ MessageDialog md = new MessageDialog ( null, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.YesNo, "Esta seguro de quere eliminar el solicitante?" ); ResponseType result = (ResponseType)md.Run (); if (result == ResponseType.No) { md.Destroy (); return; } md.Destroy (); ETipoDocumento tipoDoc; int nroDoc; tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true); nroDoc = (int)store.GetValue (iter, 1); RegistrarVisitasController c = new RegistrarVisitasController (null); c.EliminarSolicitante (tipoDoc, nroDoc); c.Dispose (); store.Remove (ref iter); } public void OnAfiliar (object o, EventArgs args) { TreeSelection fromSel = visitas.Selection; TreeIter iter; TreeModel model; ListStore store = (ListStore)visitas.Model; if (fromSel.GetSelected (out model, out iter) == false) { /* Nada seleccionado */ return; } ETipoDocumento tipoDoc; int nroDoc; tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true); nroDoc = (int)store.GetValue (iter, 1); RegistrarVisitasController c = new RegistrarVisitasController (null); /* Obtengo la cantidad de familiares */ int familiares = c.ObtenerCantidadFamiliares (tipoDoc, nroDoc); bool error = false; if (familiares > 0) { for (int i=0; i