4 using System.Collections;
9 using Controlador.Afiliacion;
10 using Dominio.Afiliados;
13 public class VEmitirHojaDeRuta
15 Dialog wIngresarSolicitud;
18 [Widget] ComboBox promotores;
19 [Widget] TreeView disponibles;
20 [Widget] TreeView hojaderuta;
22 public VEmitirHojaDeRuta ()
24 xml = new Glade.XML (null, "emitir_hoja_de_ruta.glade", "emitir_hoja_de_ruta", null);
25 xml.Autoconnect (this);
27 /* Creo los modelos para los TreeView y el ComboBox
28 Tipo Doc NroDoc Apellido Nombre */
29 disponibles.Model = new TreeModelSort (new ListStore (typeof(string), typeof(int), typeof (string), typeof (string)));
30 hojaderuta.Model = new TreeModelSort (new ListStore (typeof(string), typeof(int), typeof (string), typeof (string)));
33 disponibles.HeadersVisible = true;
34 disponibles.AppendColumn ("Tipo Doc.", new CellRendererText (), "text", 0);
35 disponibles.AppendColumn ("Nro Doc.", new CellRendererText (), "text", 1);
36 disponibles.AppendColumn ("Apellido", new CellRendererText (), "text", 2);
37 disponibles.AppendColumn ("Nombre", new CellRendererText (), "text", 3);
38 hojaderuta.HeadersVisible = true;
39 hojaderuta.AppendColumn ("Tipo Doc.", new CellRendererText (), "text", 0);
40 hojaderuta.AppendColumn ("Nro Doc.", new CellRendererText (), "text", 1);
41 hojaderuta.AppendColumn ("Apellido", new CellRendererText (), "text", 2);
42 hojaderuta.AppendColumn ("Nombre", new CellRendererText (), "text", 3);
45 foreach (TreeViewColumn col in disponibles.Columns) {
46 col.SortColumnId = i++;
48 disponibles.EnableSearch = true;
49 disponibles.Reorderable = true;
50 disponibles.HeadersClickable = true;
53 foreach (TreeViewColumn col in hojaderuta.Columns) {
54 col.SortColumnId = i++;
56 hojaderuta.EnableSearch = true;
57 hojaderuta.Reorderable = true;
58 hojaderuta.HeadersClickable = true;
59 xml.GetWidget ("emitir_hoja_de_ruta").SetSizeRequest (500, 420);
61 /* Cargo promotores */
62 ListStore l = (ListStore)promotores.Model;
65 l.AppendValues (String.Format ("Promotor {0}", i));
68 public void OnDialogResponse (object o, ResponseArgs args)
70 if (args.ResponseId == ResponseType.Cancel)
73 /* Armo la hoja de ruta */
74 /* TODO : No tengo de donde sacarlo, creo uno pedorro para test */
77 /* Veo si hay items en la hoja de ruta */
78 ListStore store = (hojaderuta.Model as TreeModelSort).Model as ListStore;
80 if (store.GetIterFirst (out iter) == false) {
81 /* Lista vacia! .. Alarm! Alarm! :) */
82 MessageDialog md = new MessageDialog (null, DialogFlags.DestroyWithParent,
83 MessageType.Error, ButtonsType.Close, "La hoja de ruta está vacía.");
90 AfiliadoSolicitanteController c = new AfiliadoSolicitanteController ();
92 ETipoDocumento tipoDoc;
94 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
95 nroDoc = (int)store.GetValue (iter, 1);
96 c.AsociarPromotor (tipoDoc, nroDoc, promotor);
98 while (store.IterNext (ref iter) == true) {
99 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
100 nroDoc = Int32.Parse ((string)store.GetValue (iter, 1));
101 c.AsociarPromotor (tipoDoc, nroDoc, promotor);
107 public void OnAgregarClicked (object o, EventArgs args)
109 /* Obtengo el TreeIter seleccionado de disponibles */
110 TreeSelection fromSel = disponibles.Selection;
114 if (fromSel.GetSelected (out model, out iter)) {
115 ListStore store1 = (disponibles.Model as TreeModelSort).Model as ListStore;
116 ListStore store2 = (hojaderuta.Model as TreeModelSort).Model as ListStore;
117 TreeIter nuevo = store2.Append ();
119 for(int i=0; i<4; i++)
120 store2.SetValue (nuevo, i, model.GetValue (iter, i));
122 TreeIter rem = (model as TreeModelSort).ConvertIterToChildIter (iter);
123 store1.Remove (ref rem);
127 public void OnBorrarClicked (object o, EventArgs args)
129 /* Obtengo el TreeIter seleccionado de disponibles */
130 TreeSelection fromSel = hojaderuta.Selection;
134 if (fromSel.GetSelected (out model, out iter)) {
135 ListStore store2 = (disponibles.Model as TreeModelSort).Model as ListStore;
136 ListStore store1 = (hojaderuta.Model as TreeModelSort).Model as ListStore;
137 TreeIter nuevo = store2.Append ();
139 for(int i=0; i<4; i++)
140 store2.SetValue (nuevo, i, model.GetValue (iter, i));
142 TreeIter rem = (model as TreeModelSort).ConvertIterToChildIter (iter);
143 store1.Remove (ref rem);
147 public void OnPromotorSelected (object o, EventArgs args)
149 RutasController c = new RutasController ();
151 ArrayList sols = c.ObtenerSolicitantesPendientes ();
152 ListStore store = (disponibles.Model as TreeModelSort).Model as ListStore;
154 foreach (Solicitante s in sols) {
155 TreeIter iter = store.AppendValues (s.TipoDocumento.ToString (), s.NroDocumento, s.Nombre, s.Apellido);
163 Dialog w = (Dialog)xml.GetWidget ("emitir_hoja_de_ruta");