X-Git-Url: https://git.llucax.com/z.facultad/75.10/miklolife.git/blobdiff_plain/c36c16908f73901f367fe523aeef8dfb688ac2ff..2be5451ef59289f66dbd3e1d9ff5a69fcc271364:/demo/src/Vistas/EmitirHojeDeRuta.cs?ds=inline diff --git a/demo/src/Vistas/EmitirHojeDeRuta.cs b/demo/src/Vistas/EmitirHojeDeRuta.cs index 58c8697..1618646 100644 --- a/demo/src/Vistas/EmitirHojeDeRuta.cs +++ b/demo/src/Vistas/EmitirHojeDeRuta.cs @@ -5,6 +5,7 @@ using System.Collections; using Gtk; using Glade; +using Controlador; using Controlador.Afiliacion; using Dominio.Afiliados; using Dominio; @@ -25,8 +26,8 @@ public class VEmitirHojaDeRuta /* Creo los modelos para los TreeView y el ComboBox Tipo Doc NroDoc Apellido Nombre */ - disponibles.Model = new ListStore (typeof(string), typeof(int), typeof (string), typeof (string)); - hojaderuta.Model = new ListStore (typeof(string), typeof(int), typeof (string), typeof (string)); + disponibles.Model = new TreeModelSort (new ListStore (typeof(string), typeof(int), typeof (string), typeof (string))); + hojaderuta.Model = new TreeModelSort (new ListStore (typeof(string), typeof(int), typeof (string), typeof (string))); /* Columnas */ disponibles.HeadersVisible = true; @@ -39,13 +40,28 @@ public class VEmitirHojaDeRuta hojaderuta.AppendColumn ("Nro Doc.", new CellRendererText (), "text", 1); hojaderuta.AppendColumn ("Apellido", new CellRendererText (), "text", 2); hojaderuta.AppendColumn ("Nombre", new CellRendererText (), "text", 3); + + int i = 0; + foreach (TreeViewColumn col in disponibles.Columns) { + col.SortColumnId = i++; + } + disponibles.EnableSearch = true; + disponibles.Reorderable = true; + disponibles.HeadersClickable = true; + i = 0; + foreach (TreeViewColumn col in hojaderuta.Columns) { + col.SortColumnId = i++; + } + hojaderuta.EnableSearch = true; + hojaderuta.Reorderable = true; + hojaderuta.HeadersClickable = true; xml.GetWidget ("emitir_hoja_de_ruta").SetSizeRequest (500, 420); /* Cargo promotores */ ListStore l = (ListStore)promotores.Model; l.Clear (); - for(int i=0; i<10; i++) + for(i=0; i<10; i++) l.AppendValues (String.Format ("Promotor {0}", i)); } @@ -59,7 +75,7 @@ public class VEmitirHojaDeRuta int promotor = 0; /* Veo si hay items en la hoja de ruta */ - ListStore store = (ListStore)hojaderuta.Model; + ListStore store = (hojaderuta.Model as TreeModelSort).Model as ListStore; TreeIter iter; if (store.GetIterFirst (out iter) == false) { /* Lista vacia! .. Alarm! Alarm! :) */ @@ -96,13 +112,15 @@ public class VEmitirHojaDeRuta TreeModel model; if (fromSel.GetSelected (out model, out iter)) { - ListStore store1 = (ListStore)disponibles.Model; - ListStore store2 = (ListStore)hojaderuta.Model; + ListStore store1 = (disponibles.Model as TreeModelSort).Model as ListStore; + ListStore store2 = (hojaderuta.Model as TreeModelSort).Model as ListStore; TreeIter nuevo = store2.Append (); for(int i=0; i<4; i++) - store2.SetValue (nuevo, i, store1.GetValue (iter, i)); - store1.Remove (ref iter); + store2.SetValue (nuevo, i, model.GetValue (iter, i)); + + TreeIter rem = (model as TreeModelSort).ConvertIterToChildIter (iter); + store1.Remove (ref rem); } } @@ -114,26 +132,27 @@ public class VEmitirHojaDeRuta TreeModel model; if (fromSel.GetSelected (out model, out iter)) { - ListStore store1 = (ListStore)hojaderuta.Model; - ListStore store2 = (ListStore)disponibles.Model; + ListStore store2 = (disponibles.Model as TreeModelSort).Model as ListStore; + ListStore store1 = (hojaderuta.Model as TreeModelSort).Model as ListStore; TreeIter nuevo = store2.Append (); for(int i=0; i<4; i++) - store2.SetValue (nuevo, i, store1.GetValue (iter, i)); - store1.Remove (ref iter); + store2.SetValue (nuevo, i, model.GetValue (iter, i)); + + TreeIter rem = (model as TreeModelSort).ConvertIterToChildIter (iter); + store1.Remove (ref rem); } } public void OnPromotorSelected (object o, EventArgs args) { - AfiliadoSolicitanteController c = new AfiliadoSolicitanteController (); + RutasController c = new RutasController (); ArrayList sols = c.ObtenerSolicitantesPendientes (); - ListStore store = (ListStore)disponibles.Model; + ListStore store = (disponibles.Model as TreeModelSort).Model as ListStore; foreach (Solicitante s in sols) { TreeIter iter = store.AppendValues (s.TipoDocumento.ToString (), s.NroDocumento, s.Nombre, s.Apellido); - Console.WriteLine ("-- {0}", s.Promotor); } c.Dispose ();