Esempio n. 1
0
        public CategoriaListView()
        {
            TreeViewHelper t=new TreeViewHelper(treeView,"Select * from categoria");
            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);
            //tengo acceso al actionGroup de IEntityListView
            actionGroup.Add(refreshAction);
            refreshAction.Activated += delegate {t.Refresh ();};
            Gtk.Action editAction = new Gtk.Action("editAction", null, null, Stock.Edit);
            actionGroup.Add(editAction);
            editAction.Activated += delegate {
                Window ventana=new Window("Editar");
                ventana.SetDefaultSize(500,500);
                VBox h=new VBox(true,10);
                ventana.Add (h);
                Label enunciado=new Label("Introduce el nuevo valor:");
                h.Add (enunciado);
                Entry caja=new Entry();
                h.Add (caja);
                Button b=new Button("Editar");
                h.Add (b);
                b.Clicked+=delegate
                {
                    IDbCommand dbCommand=App.Instance.DbConnection.CreateCommand();
                    dbCommand.CommandText =
                    string.Format ("update categoria set nombre='{1}' where id={0}", t.Id,caja.Text);
                    dbCommand.ExecuteNonQuery ();
                };

                ventana.ShowAll();

            };
        }
Esempio n. 2
0
        public ArticuloListView()
        {
            TreeViewHelper treeViewHelper = new TreeViewHelper(treeView, App.Instance.DbConnection,
                "select * from articulo"
            );

            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);

            refreshAction.Activated += delegate {
                treeViewHelper.Refresh();
            };
            actionGroup.Add(refreshAction);
        }
Esempio n. 3
0
        public CategoriaListView()
        {
            TreeViewHelper treeViewHelper = new TreeViewHelper(treeView, App.Instance.DbConnection, "select id, nombre from categoria");

            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);
            refreshAction.Activated += delegate {
                treeViewHelper.Refresh ();
            };
            actionGroup.Add (refreshAction);

            Gtk.Action editAction = new Gtk.Action("editAction", null, null, Stock.Edit);
            editAction.Activated += delegate {
                Categoria categoria = Categoria.Load (treeViewHelper.Id);
                CategoriaView categoriaView = new CategoriaView();
                new CategoriaController(categoria,CategoriaView);
                categoriaView.Show();

            };
            actionGroup.Add (editAction);
        }
Esempio n. 4
0
        public CategoriaListView()
        {
            App.Instance.DbConnection = new MySqlConnection(
                "Server=localhost;Database=dbprueba;User Id=root;Password=sistemas"
            );
            TreeViewHelper treeViewHelper = new TreeViewHelper(
                treeView,
                App.Instance.DbConnection,
                "select id, nombre from categoria order by nombre desc"
            );

            Gtk.Action addAction = new Gtk.Action("addAction", null, null, Stock.Add);
            addAction.Activated += delegate {
                IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand ();
                dbCommand.CommandText =
                    string.Format ("insert into categoria (nombre) values ('{0}')", DateTime.Now);
                dbCommand.ExecuteNonQuery ();
            };
            actionGroup.Add (addAction);

            Gtk.Action removeAction = new Gtk.Action("removeAction", null, null, Stock.Remove);
            removeAction.Activated += delegate {
                IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand ();
                dbCommand.CommandText =
                    string.Format ("delete from categoria where id={0}", treeViewHelper.Id);
                dbCommand.ExecuteNonQuery ();
            };
            actionGroup.Add(removeAction);

            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);
            refreshAction.Activated += delegate {treeViewHelper.Refresh ();	};
            actionGroup.Add (refreshAction);

            treeView.Selection.Changed += delegate {
                Console.WriteLine("treeViewHelper.Id='{0}'", treeViewHelper.Id);
                removeAction.Sensitive = treeView.Selection.CountSelectedRows() > 0;
            };

            removeAction.Sensitive = false;
        }
Esempio n. 5
0
        public CategoriaListView()
        {
            TreeViewHelper treeViewHelper = new TreeViewHelper(treeView, App.Instance.DbConnection,
                "select id, nombre from categoria"
            );

            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);
            refreshAction.Activated += delegate {
                treeViewHelper.Refresh();
            };
            actionGroup.Add(refreshAction);

            Gtk.Action editAction = new Gtk.Action ("editAction", null, null, Stock.Edit);
            editAction.Activated += delegate {

            };
            actionGroup.Add (editAction);

            treeView.Selection.Changed += delegate {
                Console.WriteLine("treeViewHelper.Id='{0}'", treeViewHelper.Id);
                editAction.Sensitive = treeView.Selection.CountSelectedRows() > 0;
            };
        }
Esempio n. 6
0
        public ArticuloListView()
        {
            TreeViewHelper t=new TreeViewHelper(treeView,"Select * from articulo");
            Gtk.Action addAction = new Gtk.Action("addAction", null, null, Stock.Add);
            //tengo acceso al actionGroup de IEntityListView
            actionGroup.Add(addAction);

            addAction.Activated += delegate
            {
                Window ventana=new Window("Añadir");
                ventana.SetDefaultSize(500,500);

                VBox h=new VBox();
                ventana.Add (h);
                //Label enunciado=new Label("Introduce lo que quieras añadir:");
                //h.Add (enunciado);
                TextView textView = new TextView();
                textView.Buffer.Text = "El texto del textView";
                h.Add (textView);
                Entry caja=new Entry();
                h.Add (caja);
                Button b=new Button("Añadir");
                h.Add (b);
                b.Clicked+=delegate
                {
                    IDbCommand dbCommand=App.Instance.DbConnection.CreateCommand();
                    dbCommand.CommandText =
                    string.Format ("insert into articulo (nombre) values ('{0}')", caja.Text);
                    Console.WriteLine (caja.Text);
                    dbCommand.ExecuteNonQuery ();
                };

                ventana.ShowAll();
            };

            Gtk.Action refreshAction = new Gtk.Action("refreshAction", null, null, Stock.Refresh);
            //tengo acceso al actionGroup de IEntityListView
            actionGroup.Add(refreshAction);
            refreshAction.Activated += delegate {t.Refresh ();};
            Gtk.Action removeAction = new Gtk.Action("removeAction", null, null, Stock.Remove);
            actionGroup.Add(removeAction);
            removeAction.Activated += delegate
            {
                Window ventana=new Window("Borrar");
                ventana.SetDefaultSize(500,500);
                VBox h=new VBox(true,30);
                ventana.Add (h);
                Label enunciado=new Label("Introduce lo que quieras borrar:");
                h.Add (enunciado);
                Entry caja=new Entry();
                h.Add (caja);
                Button b=new Button("Borrar");
                h.Add (b);
                b.Clicked+=delegate
                {
                    IDbCommand dbCommand=App.Instance.DbConnection.CreateCommand();
                    dbCommand.CommandText =
                    string.Format ("delete from articulo where id={0}", caja.Text);
                    dbCommand.ExecuteNonQuery ();
                };

                ventana.ShowAll();

            };

            Gtk.Action editAction = new Gtk.Action("editAction", null, null, Stock.Edit);
            actionGroup.Add(editAction);

            editAction.Activated += delegate {
                Window ventana=new Window("Editar");
                ventana.SetDefaultSize(500,500);
                VBox h=new VBox(true,10);
                ventana.Add (h);
                Label enunciado=new Label("Introduce el nuevo valor:");
                h.Add (enunciado);
                Entry caja=new Entry();
                h.Add (caja);
                Button b=new Button("Editar");
                h.Add (b);
                b.Clicked+=delegate
                {
                    IDbCommand dbCommand=App.Instance.DbConnection.CreateCommand();
                    dbCommand.CommandText =
                    string.Format ("update articulo set nombre='{1}' where id={0}", t.Id,caja.Text);
                    dbCommand.ExecuteNonQuery ();
                };

                ventana.ShowAll();

            };
        }