4 using System.Collections;
9 using Controlador.Afiliacion;
10 using Dominio.Afiliados;
13 public class VRegistrarVisitas
17 [Widget] TreeView visitas;
18 [Widget] Entry fechaNac;
20 public VRegistrarVisitas ()
22 xml = new Glade.XML (null, "registrar_visitas.glade", "registrar_visitas", null);
23 xml.Autoconnect (this);
25 RegistrarVisitasController c = new RegistrarVisitasController (null);
27 ArrayList l = c.ObtenerSolicitantesAsignados ();
29 visitas.Model = new ListStore (typeof(string), typeof(int), typeof (string), typeof (string));
31 visitas.HeadersVisible = true;
32 visitas.AppendColumn ("Tipo Doc.", new CellRendererText (), "text", 0);
33 visitas.AppendColumn ("Nro Doc.", new CellRendererText (), "text", 1);
34 visitas.AppendColumn ("Apellido", new CellRendererText (), "text", 2);
35 visitas.AppendColumn ("Nombre", new CellRendererText (), "text", 3);
37 ListStore store = (ListStore)visitas.Model;
38 foreach (Solicitante s in l) {
39 TreeIter iter = store.AppendValues (s.TipoDocumento.ToString (), s.NroDocumento, s.Nombre, s.Apellido);
40 Console.WriteLine ("Agregando {0}", s.Nombre);
45 public void OnEstablecerPendiente (object o, EventArgs args)
47 TreeSelection fromSel = visitas.Selection;
50 ListStore store = (ListStore)visitas.Model;
52 if (fromSel.GetSelected (out model, out iter) == false) {
53 /* Nada seleccionado */
56 ETipoDocumento tipoDoc;
58 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
59 nroDoc = (int)store.GetValue (iter, 1);
61 RegistrarVisitasController c = new RegistrarVisitasController (null);
62 c.EstablecerPendiente (tipoDoc, nroDoc);
64 store.Remove (ref iter);
67 public void OnEliminarSolicitante (object o, EventArgs args)
69 TreeSelection fromSel = visitas.Selection;
72 ListStore store = (ListStore)visitas.Model;
74 if (fromSel.GetSelected (out model, out iter) == false) {
75 /* Nada seleccionado */
78 ETipoDocumento tipoDoc;
80 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
81 nroDoc = (int)store.GetValue (iter, 1);
83 RegistrarVisitasController c = new RegistrarVisitasController (null);
84 c.EliminarSolicitante (tipoDoc, nroDoc);
87 store.Remove (ref iter);
90 public void OnAfiliar (object o, EventArgs args)
92 TreeSelection fromSel = visitas.Selection;
95 ListStore store = (ListStore)visitas.Model;
97 if (fromSel.GetSelected (out model, out iter) == false) {
98 /* Nada seleccionado */
101 ETipoDocumento tipoDoc;
103 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
104 nroDoc = (int)store.GetValue (iter, 1);
106 RegistrarVisitasController c = new RegistrarVisitasController (null);
107 /* Obtengo la cantidad de familiares */
108 int familiares = c.ObtenerCantidadFamiliares (tipoDoc, nroDoc);
110 if (familiares > 0) {
111 for (int i=0; i<familiares; i++) {
112 AgregarFamiliar (i+1, familiares);
117 store.Remove (ref iter);
120 private void AgregarFamiliar (int n, int total)
122 Glade.XML xml1 = new Glade.XML (null, "registrar_visitas.glade", "agregar_familiar", null);
123 xml1.Autoconnect (this);
125 Dialog w = (Dialog)xml1.GetWidget ("agregar_familiar");
126 w.Title = String.Format ("Agregar Familiar {0} de {1}", n, total);
131 public void OnSeleccionarFechaClicked (object o, EventArgs args)
134 if (fechaNac.Text.Equals (""))
135 d = new CalendarDialog ();
137 d = new CalendarDialog (fechaNac.Text);
143 fechaNac.Text = d.Date.ToLongDateString ();
149 Dialog w = (Dialog)xml.GetWidget ("registrar_visitas");