using System; using System.Collections; using Gtk; using Glade; using Controlador.Afiliacion; using Dominio.Autorizaciones; using Dominio.Planes; using Dominio.Afiliados; using Dominio; public class VBuscarPlan { Glade.XML xml; string retorno = null; [Widget] TreeView lista; public VBuscarPlan () { xml = new Glade.XML (null, "buscar_plan.glade", "buscar_plan", null); xml.Autoconnect (this); ListStore store; lista.Model = store = new ListStore (typeof(int), typeof(float), typeof (string)); /* Columnas */ lista.HeadersVisible = true; lista.AppendColumn ("Codigo", new CellRendererText (), "text", 0); lista.AppendColumn ("Categoria", new CellRendererText (), "text", 1); lista.AppendColumn ("Descripcion", new CellRendererText (), "text", 2); PlanesController c = new PlanesController (); ArrayList lst = c.ObtenerPlanesVigentes (); foreach (Plan p in lst) { TreeIter iter = store.Append (); store.SetValue (iter, 0, p.Codigo); store.SetValue (iter, 1, p.Categoria); store.SetValue (iter, 2, p.Descripcion); } } public void OnDialogResponse (object o, ResponseArgs args) { if (args.ResponseId == ResponseType.Cancel) return; /* Todo el seleccionado. TODO : abortar si no hay nada seleccionado! :) */ TreeSelection fromSel = lista.Selection; TreeIter iter; TreeModel model; if (fromSel.GetSelected (out model, out iter)) { retorno = String.Format ("{0}", (int)model.GetValue (iter, 0)); } } public string Run () { Dialog w = (Dialog)xml.GetWidget ("buscar_plan"); w.Run (); w.Destroy (); return retorno; } }