3 using System.Collections;
7 using Controlador.Afiliacion;
8 using Dominio.Afiliados;
9 using Dominio.Autorizaciones;
13 public class VMantenerPlanes
15 Dialog wIngresarSolicitud;
17 Glade.XML alta_plan_xml;
19 [Widget] TreeView lista;
21 /* Alta Plan Window */
22 [Widget] Entry descripcion;
23 [Widget] SpinButton categoria;
24 [Widget] SpinButton permanencia_minima;
25 [Widget] TreeView coberturas;
28 [Widget] Entry codigo_prestacion;
29 [Widget] Entry carencia;
30 [Widget] SpinButton cobertura;
31 [Widget] SpinButton limite_anual;
32 [Widget] RadioButton tipo_auth;
34 PlanesController planc;
36 public VMantenerPlanes ()
38 xml = new Glade.XML (null, "mantener_planes.glade", "mantener_planes", null);
39 xml.Autoconnect (this);
41 ListStore m = new ListStore (typeof(string), typeof(float), typeof(float));
43 lista.HeadersVisible = true;
44 lista.AppendColumn ("Descripción", new CellRendererText (), "text", 0);
45 lista.AppendColumn ("Categoría", new CellRendererText (), "text", 1);
46 lista.AppendColumn ("Permanencia Mínima", new CellRendererText (), "text", 2);
51 private void CargarPlanes ()
53 ListStore store = (ListStore)lista.Model;
56 planc = new PlanesController ();
57 ArrayList lst = planc.ObtenerPlanesVigentes ();
58 foreach (Plan p in lst) {
59 TreeIter iter = store.Append ();
60 store.SetValue (iter, 0, p.Descripcion);
61 store.SetValue (iter, 1, p.Categoria);
62 store.SetValue (iter, 2, p.PermanenciaMinima);
68 public void OnDialogResponse (object o, ResponseArgs args)
72 public void OnAdd (object o, EventArgs args)
74 alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_plan", null);
75 alta_plan_xml.Autoconnect (this);
77 coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (float), typeof (int), typeof(string));
78 coberturas.HeadersVisible = true;
79 coberturas.AppendColumn ("Prestacion", new CellRendererText (), "text", 0);
80 coberturas.AppendColumn ("Carencia", new CellRendererText (), "text", 1);
81 coberturas.AppendColumn ("Cobertura", new CellRendererText (), "text", 2);
82 coberturas.AppendColumn ("Limite Anual", new CellRendererText (), "text", 3);
83 coberturas.AppendColumn ("Tipo", new CellRendererText (), "text", 4);
85 Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_plan");
92 public void OnAltaPlan (object o, ResponseArgs args)
94 if (args.ResponseId == ResponseType.Cancel)
98 string desc = descripcion.Text;
99 float cat = (float)categoria.Value;
100 int perma = permanencia_minima.ValueAsInt;
102 planc = new PlanesController ();
103 planc.CrearPlan (desc, cat, perma);
104 TreeModel model = coberturas.Model;
106 model.Foreach (AgregarCoberturaAlPlan);
112 bool AgregarCoberturaAlPlan (TreeModel model, TreePath path, TreeIter iter)
114 int codprestador = (int)model.GetValue (iter, 0);
115 float carencia = (float)model.GetValue (iter, 1);
116 float percent = (float)model.GetValue (iter, 2);
117 int limite = (int)model.GetValue (iter, 3);
118 string t = (string)model.GetValue (iter, 4);
119 ETipoAutorizacion tipo;
120 if (t.Equals ("Manual"))
121 tipo = ETipoAutorizacion.MANUAL;
123 tipo = ETipoAutorizacion.AUTOMATICA;
125 planc.AgregarCobertura (codprestador, carencia, percent, limite, tipo);
129 public void OnProperties (object o, EventArgs args)
133 public void OnDelete (object o, EventArgs args)
137 public void OnAddCobertura (object o, EventArgs args)
139 alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_cobertura", null);
140 alta_plan_xml.Autoconnect (this);
142 Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_cobertura");
143 if (w.Run () != -6) {
144 ListStore store = (ListStore)coberturas.Model;
145 TreeIter nuevo = store.Append ();
147 store.SetValue (nuevo, 0, Int32.Parse (codigo_prestacion.Text));
148 store.SetValue (nuevo, 1, (float)Double.Parse (carencia.Text));
149 store.SetValue (nuevo, 2, (float)cobertura.Value);
150 store.SetValue (nuevo, 3, limite_anual.ValueAsInt);
151 if (tipo_auth.Active == true)
152 store.SetValue (nuevo, 4, "Manual");
154 store.SetValue (nuevo, 4, "Automatica");
159 public void OnBuscarPrestacion (object o, EventArgs args)
161 VBuscarPrestacion v = new VBuscarPrestacion ();
165 codigo_prestacion.Text = r;
171 Dialog w = (Dialog)xml.GetWidget ("mantener_planes");