ComboBox categoria;
TreeView lista;
+ string codigo_retorno = null;
+
public VBuscarPrestacion ()
{
xml = new Glade.XML (null, "buscar_prestacion.glade", "buscar_prestacion", null);
categoria = (ComboBox)xml.GetWidget ("categoria");
lista = (TreeView)xml.GetWidget ("lista");
- lista.Model = new ListStore (typeof(string), typeof(string), typeof(string), typeof (DateTime));
+ lista.Model = new ListStore (typeof(string), typeof(string), typeof(string), typeof (string));
/* Columnas */
lista.HeadersVisible = true;
{
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)) {
+ codigo_retorno = (string)model.GetValue (iter, 0);
+ }
}
public void OnBuscar (object o, EventArgs args)
{
+ TreeIter iter;
+ if (categoria.GetActiveIter (out iter) == false)
+ return;
+
+ PrestacionesController c = new PrestacionesController ();
+ ArrayList lst = c.Prestaciones ((string)categoria.Model.GetValue (iter, 0));
+ ListStore store = (ListStore)lista.Model;
+ store.Clear ();
+ foreach (Prestacion p in lst) {
+ TreeIter i = store.Append ();
+ store.SetValue (i, 0, p.Codigo);
+ store.SetValue (i, 1, p.Nombre);
+ store.SetValue (i, 2, (string)categoria.Model.GetValue (iter, 0));
+ if (p._fechaBaja == DateTime.MinValue)
+ store.SetValue (i, 3, "Activo");
+ else
+ store.SetValue (i, 3, p._fechaBaja.ToString ());
+ }
+
+ c.Dispose ();
}
- public void Run ()
+ public string Run ()
{
Dialog w = (Dialog)xml.GetWidget ("buscar_prestacion");
w.Run ();
w.Destroy ();
+
+ return codigo_retorno;
}
}