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(int), typeof(string), typeof(float), typeof(float));
43 lista.HeadersVisible = true;
44 lista.AppendColumn ("Código", new CellRendererText (), "text", 0);
45 lista.AppendColumn ("Descripción", new CellRendererText (), "text", 1);
46 lista.AppendColumn ("Categoría", new CellRendererText (), "text", 2);
47 lista.AppendColumn ("Permanencia Mínima", new CellRendererText (), "text", 3);
52 private void CargarPlanes ()
54 ListStore store = (ListStore)lista.Model;
57 planc = new PlanesController ();
58 ArrayList lst = planc.ObtenerPlanesVigentes ();
59 foreach (Plan p in lst) {
60 TreeIter iter = store.Append ();
61 store.SetValue (iter, 0, p.Codigo);
62 store.SetValue (iter, 1, p.Descripcion);
63 store.SetValue (iter, 2, p.Categoria);
64 store.SetValue (iter, 3, p.PermanenciaMinima);
70 public void OnDialogResponse (object o, ResponseArgs args)
74 public void OnAdd (object o, EventArgs args)
76 alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_plan", null);
77 alta_plan_xml.Autoconnect (this);
79 coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (float), typeof (int), typeof(string));
80 coberturas.HeadersVisible = true;
81 coberturas.AppendColumn ("Prestacion", new CellRendererText (), "text", 0);
82 coberturas.AppendColumn ("Carencia", new CellRendererText (), "text", 1);
83 coberturas.AppendColumn ("Cobertura", new CellRendererText (), "text", 2);
84 coberturas.AppendColumn ("Limite Anual", new CellRendererText (), "text", 3);
85 coberturas.AppendColumn ("Tipo", new CellRendererText (), "text", 4);
87 Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_plan");
94 private void CargarCoberturas (int codplan)
96 ListStore store = (ListStore)coberturas.Model;
99 planc = new PlanesController ();
100 ArrayList lst = planc.ObtenerCoberturas (codplan);
102 foreach (Cobertura c in lst) {
103 TreeIter iter = store.Append ();
104 store.SetValue (iter, 0, c.Prestacion.Codigo);
105 store.SetValue (iter, 1, c.Carencia);
106 store.SetValue (iter, 2, c.Porcentaje);
107 store.SetValue (iter, 3, c.LimiteAnual);
108 if (c.TipoAutorizacion == ETipoAutorizacion.MANUAL)
109 store.SetValue (iter, 4, "Manual");
111 store.SetValue (iter, 4, "Automatica");
117 public void OnAltaPlan (object o, ResponseArgs args)
119 if (args.ResponseId == ResponseType.Cancel)
123 string desc = descripcion.Text;
124 float cat = (float)categoria.Value;
125 int perma = permanencia_minima.ValueAsInt;
127 planc = new PlanesController ();
128 planc.CrearPlan (desc, cat, perma);
129 TreeModel model = coberturas.Model;
131 #warning model.Foreach (AgregarCoberturaAlPlan());
137 bool AgregarCoberturaAlPlan (TreeModel model, TreePath path, TreeIter iter)
139 int codprestador = (int)model.GetValue (iter, 0);
140 float carencia = (float)model.GetValue (iter, 1);
141 float percent = (float)model.GetValue (iter, 2);
142 int limite = (int)model.GetValue (iter, 3);
143 string t = (string)model.GetValue (iter, 4);
144 ETipoAutorizacion tipo;
145 if (t.Equals ("Manual"))
146 tipo = ETipoAutorizacion.MANUAL;
148 tipo = ETipoAutorizacion.AUTOMATICA;
150 planc.AgregarCobertura (codprestador, carencia, percent, limite, tipo);
151 Console.WriteLine ("Agrege una cobertura");
155 public void OnProperties (object o, EventArgs args)
157 alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_plan", null);
158 alta_plan_xml.Autoconnect (this);
160 coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (float), typeof (int), typeof(string));
161 coberturas.HeadersVisible = true;
162 coberturas.AppendColumn ("Prestacion", new CellRendererText (), "text", 0);
163 coberturas.AppendColumn ("Carencia", new CellRendererText (), "text", 1);
164 coberturas.AppendColumn ("Cobertura", new CellRendererText (), "text", 2);
165 coberturas.AppendColumn ("Limite Anual", new CellRendererText (), "text", 3);
166 coberturas.AppendColumn ("Tipo", new CellRendererText (), "text", 4);
168 TreeSelection sel = lista.Selection;
172 sel.GetSelected (out model, out iter);
173 int codplan = (int)model.GetValue (iter, 0);
175 CargarCoberturas (codplan);
176 Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_plan");
183 public void OnDelete (object o, EventArgs args)
187 public void OnAddCobertura (object o, EventArgs args)
189 alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_cobertura", null);
190 alta_plan_xml.Autoconnect (this);
192 Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_cobertura");
193 if (w.Run () != -6) {
194 ListStore store = (ListStore)coberturas.Model;
195 TreeIter nuevo = store.Append ();
197 store.SetValue (nuevo, 0, Int32.Parse (codigo_prestacion.Text));
198 store.SetValue (nuevo, 1, (float)Double.Parse (carencia.Text));
199 store.SetValue (nuevo, 2, (float)cobertura.Value);
200 store.SetValue (nuevo, 3, limite_anual.ValueAsInt);
201 if (tipo_auth.Active == true)
202 store.SetValue (nuevo, 4, "Manual");
204 store.SetValue (nuevo, 4, "Automatica");
209 public void OnBuscarPrestacion (object o, EventArgs args)
211 VBuscarPrestacion v = new VBuscarPrestacion ();
215 codigo_prestacion.Text = r;
221 Dialog w = (Dialog)xml.GetWidget ("mantener_planes");