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 */
79 /* Confirmo la operacion */
80 MessageDialog md = new MessageDialog (
82 DialogFlags.DestroyWithParent,
84 ButtonsType.YesNo, "Esta seguro de quere eliminar el solicitante?"
87 ResponseType result = (ResponseType)md.Run ();
89 if (result == ResponseType.No) {
95 ETipoDocumento tipoDoc;
97 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
98 nroDoc = (int)store.GetValue (iter, 1);
100 RegistrarVisitasController c = new RegistrarVisitasController (null);
101 c.EliminarSolicitante (tipoDoc, nroDoc);
104 store.Remove (ref iter);
107 public void OnAfiliar (object o, EventArgs args)
109 TreeSelection fromSel = visitas.Selection;
112 ListStore store = (ListStore)visitas.Model;
114 if (fromSel.GetSelected (out model, out iter) == false) {
115 /* Nada seleccionado */
118 ETipoDocumento tipoDoc;
120 tipoDoc = (ETipoDocumento)Enum.Parse (typeof (ETipoDocumento), (string)store.GetValue (iter, 0), true);
121 nroDoc = (int)store.GetValue (iter, 1);
123 RegistrarVisitasController c = new RegistrarVisitasController (null);
124 /* Obtengo la cantidad de familiares */
125 int familiares = c.ObtenerCantidadFamiliares (tipoDoc, nroDoc);
127 if (familiares > 0) {
128 for (int i=0; i<familiares; i++) {
129 AgregarFamiliar (i+1, familiares, tipoDoc, nroDoc);
133 c.Visitado (tipoDoc, nroDoc);
136 store.Remove (ref iter);
139 private void AgregarFamiliar (int n, int total, ETipoDocumento tipo, int nro)
141 VAgregarFamiliar w = new VAgregarFamiliar (n, total, tipo, nro);
145 public void OnSeleccionarFechaClicked (object o, EventArgs args)
148 if (fechaNac.Text.Equals (""))
149 d = new CalendarDialog ();
151 d = new CalendarDialog (fechaNac.Text);
157 fechaNac.Text = d.Date.ToLongDateString ();
163 Dialog w = (Dialog)xml.GetWidget ("registrar_visitas");