]> git.llucax.com Git - z.facultad/75.10/miklolife.git/blobdiff - demo/src/Vistas/ABMGenerico.cs
- Actualizacion solucion VS con archivos de Rick
[z.facultad/75.10/miklolife.git] / demo / src / Vistas / ABMGenerico.cs
index 4e185db27d25285f88065b3c26e8fb064dc7d5f6..9a757864bb600750932837c0cbeb38c4abeb788b 100644 (file)
@@ -5,14 +5,19 @@ using System.Collections;
 using Gtk;
 using Glade;
 
 using Gtk;
 using Glade;
 
+using Controlador;
+
 public class ABMGenerico
 {
        Glade.XML xml;
        [Widget] Table tabla;
        Type current;
 public class ABMGenerico
 {
        Glade.XML xml;
        [Widget] Table tabla;
        Type current;
+       Hashtable widgets;
 
        public ABMGenerico (Type objectType)
        {
 
        public ABMGenerico (Type objectType)
        {
+               widgets = new Hashtable ();
+
                PropertyInfo[] properties = objectType.GetProperties ();
                current = objectType;
                
                PropertyInfo[] properties = objectType.GetProperties ();
                current = objectType;
                
@@ -28,6 +33,7 @@ public class ABMGenerico
                                tabla.Attach (e, 1, 2, i, i+1);
                                l.Show ();
                                e.Show ();
                                tabla.Attach (e, 1, 2, i, i+1);
                                l.Show ();
                                e.Show ();
+                               widgets[mf.Name] = e;
                        }
                        i++;
                }
                        }
                        i++;
                }
@@ -66,11 +72,35 @@ public class ABMGenerico
        {
                if (args.ResponseId == ResponseType.Cancel)
                        return; 
        {
                if (args.ResponseId == ResponseType.Cancel)
                        return; 
-       }
+       
+               PropertyInfo[] properties = current.GetProperties ();
+
+               System.Object output = Activator.CreateInstance (current);
+               
+               foreach (string key in widgets.Keys) {
+                       PropertyInfo p = current.GetProperty (key);
+                       Entry e = (Entry)widgets[key];
+                       Console.WriteLine ("{0} = {1}", key, e.Text);
+                       if (p.PropertyType.Equals (typeof(string)))
+                               p.SetValue (output, e.Text, null);
+                       if (p.PropertyType.Equals (typeof(int)))
+                               p.SetValue (output, Int32.Parse (e.Text), null);
+                       if (p.PropertyType.Equals (typeof(float))) {
+                               p.SetValue (output, (float)Double.Parse (e.Text), null);
+                       }
+               }
 
 
-       public void Run ()
+               Controller c = new Controller ();
+               
+               c.GenericSave (output);
+
+               c.Dispose ();
+       }
+       
+       public void Run (string title)
        {
                Dialog w = (Dialog)xml.GetWidget ("abm_one");
        {
                Dialog w = (Dialog)xml.GetWidget ("abm_one");
+               w.Title = title;
                w.Run ();
                w.Destroy ();
        }
                w.Run ();
                w.Destroy ();
        }