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; 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 (); } 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; } 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 (); } public void Run () { Dialog w = (Dialog)xml.GetWidget ("registrar_visitas"); w.Run (); w.Destroy (); } }