X-Git-Url: https://git.llucax.com/z.facultad/75.10/miklolife.git/blobdiff_plain/e826fb5076f847072bfe16584c36e3b2da8a442d..5421c84a95c42db5c3b2753d556dd7efbd1a6b4e:/demo/src/Vistas/MantenerPlanes.cs diff --git a/demo/src/Vistas/MantenerPlanes.cs b/demo/src/Vistas/MantenerPlanes.cs index d0f5257..2405cb8 100644 --- a/demo/src/Vistas/MantenerPlanes.cs +++ b/demo/src/Vistas/MantenerPlanes.cs @@ -6,6 +6,8 @@ using Glade; using Controlador.Afiliacion; using Dominio.Afiliados; +using Dominio.Autorizaciones; +using Dominio.Planes; using Dominio; public class VMantenerPlanes @@ -29,10 +31,40 @@ public class VMantenerPlanes [Widget] SpinButton limite_anual; [Widget] RadioButton tipo_auth; + PlanesController planc; + public VMantenerPlanes () { xml = new Glade.XML (null, "mantener_planes.glade", "mantener_planes", null); xml.Autoconnect (this); + + ListStore m = new ListStore (typeof(int), typeof(string), typeof(float), typeof(float)); + lista.Model = m; + lista.HeadersVisible = true; + lista.AppendColumn ("Código", new CellRendererText (), "text", 0); + lista.AppendColumn ("Descripción", new CellRendererText (), "text", 1); + lista.AppendColumn ("Categoría", new CellRendererText (), "text", 2); + lista.AppendColumn ("Permanencia Mínima", new CellRendererText (), "text", 3); + + CargarPlanes (); + } + + private void CargarPlanes () + { + ListStore store = (ListStore)lista.Model; + store.Clear (); + + planc = new PlanesController (); + ArrayList lst = planc.ObtenerPlanesVigentes (); + foreach (Plan p in lst) { + TreeIter iter = store.Append (); + store.SetValue (iter, 0, p.Codigo); + store.SetValue (iter, 1, p.Descripcion); + store.SetValue (iter, 2, p.Categoria); + store.SetValue (iter, 3, p.PermanenciaMinima); + } + + planc.Dispose (); } public void OnDialogResponse (object o, ResponseArgs args) @@ -44,16 +76,42 @@ public class VMantenerPlanes alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_plan", null); alta_plan_xml.Autoconnect (this); - coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (string), typeof (float)); + coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (float), typeof (int), typeof(string)); coberturas.HeadersVisible = true; coberturas.AppendColumn ("Prestacion", new CellRendererText (), "text", 0); coberturas.AppendColumn ("Carencia", new CellRendererText (), "text", 1); coberturas.AppendColumn ("Cobertura", new CellRendererText (), "text", 2); coberturas.AppendColumn ("Limite Anual", new CellRendererText (), "text", 3); + coberturas.AppendColumn ("Tipo", new CellRendererText (), "text", 4); Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_plan"); w.Run (); w.Destroy (); + + CargarPlanes (); + } + + private void CargarCoberturas (int codplan) + { + ListStore store = (ListStore)coberturas.Model; + store.Clear (); + + planc = new PlanesController (); + ArrayList lst = planc.ObtenerCoberturas (codplan); + + foreach (Cobertura c in lst) { + TreeIter iter = store.Append (); + store.SetValue (iter, 0, c.Prestacion.Codigo); + store.SetValue (iter, 1, c.Carencia); + store.SetValue (iter, 2, c.Porcentaje); + store.SetValue (iter, 3, c.LimiteAnual); + if (c.TipoAutorizacion == ETipoAutorizacion.MANUAL) + store.SetValue (iter, 4, "Manual"); + else + store.SetValue (iter, 4, "Automatica"); + } + + planc.Dispose (); } public void OnAltaPlan (object o, ResponseArgs args) @@ -61,11 +119,65 @@ public class VMantenerPlanes if (args.ResponseId == ResponseType.Cancel) return; + + string desc = descripcion.Text; + float cat = (float)categoria.Value; + int perma = permanencia_minima.ValueAsInt; + + planc = new PlanesController (); + planc.CrearPlan (desc, cat, perma); + TreeModel model = coberturas.Model; + +#warning model.Foreach (AgregarCoberturaAlPlan()); + + planc.CommitPlan (); + planc.Dispose (); + } + bool AgregarCoberturaAlPlan (TreeModel model, TreePath path, TreeIter iter) + { + int codprestador = (int)model.GetValue (iter, 0); + float carencia = (float)model.GetValue (iter, 1); + float percent = (float)model.GetValue (iter, 2); + int limite = (int)model.GetValue (iter, 3); + string t = (string)model.GetValue (iter, 4); + ETipoAutorizacion tipo; + if (t.Equals ("Manual")) + tipo = ETipoAutorizacion.MANUAL; + else + tipo = ETipoAutorizacion.AUTOMATICA; + + planc.AgregarCobertura (codprestador, carencia, percent, limite, tipo); + Console.WriteLine ("Agrege una cobertura"); + return false; } public void OnProperties (object o, EventArgs args) { + alta_plan_xml = new Glade.XML (null, "mantener_planes.glade", "alta_plan", null); + alta_plan_xml.Autoconnect (this); + + coberturas.Model = new ListStore (typeof(int), typeof(float), typeof (float), typeof (int), typeof(string)); + coberturas.HeadersVisible = true; + coberturas.AppendColumn ("Prestacion", new CellRendererText (), "text", 0); + coberturas.AppendColumn ("Carencia", new CellRendererText (), "text", 1); + coberturas.AppendColumn ("Cobertura", new CellRendererText (), "text", 2); + coberturas.AppendColumn ("Limite Anual", new CellRendererText (), "text", 3); + coberturas.AppendColumn ("Tipo", new CellRendererText (), "text", 4); + + TreeSelection sel = lista.Selection; + TreeModel model; + TreeIter iter; + + sel.GetSelected (out model, out iter); + int codplan = (int)model.GetValue (iter, 0); + + CargarCoberturas (codplan); + Dialog w = (Dialog)alta_plan_xml.GetWidget ("alta_plan"); + w.Run (); + w.Destroy (); + + CargarPlanes (); } public void OnDelete (object o, EventArgs args) @@ -83,13 +195,27 @@ public class VMantenerPlanes TreeIter nuevo = store.Append (); store.SetValue (nuevo, 0, Int32.Parse (codigo_prestacion.Text)); - store.SetValue (nuevo, 1, (float)Double.Parse (categoria.Text)); - store.SetValue (nuevo, 2, descripcion.Text)); - store.SetValue (nuevo, 3, Int32.Parse (codigo_prestacion.Text)); + store.SetValue (nuevo, 1, (float)Double.Parse (carencia.Text)); + store.SetValue (nuevo, 2, (float)cobertura.Value); + store.SetValue (nuevo, 3, limite_anual.ValueAsInt); + if (tipo_auth.Active == true) + store.SetValue (nuevo, 4, "Manual"); + else + store.SetValue (nuevo, 4, "Automatica"); } w.Destroy (); } + public void OnBuscarPrestacion (object o, EventArgs args) + { + VBuscarPrestacion v = new VBuscarPrestacion (); + string r = v.Run (); + + if (r != null) { + codigo_prestacion.Text = r; + } + } + public void Run () { Dialog w = (Dialog)xml.GetWidget ("mantener_planes");