コード例 #1
0
ファイル: CategoriaListView.cs プロジェクト: ruben206/ad
        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();

            };
        }
コード例 #2
0
ファイル: ArticuloListView.cs プロジェクト: javidam/Ad
        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);
        }
コード例 #3
0
ファイル: CategoriaListView.cs プロジェクト: ruben206/ad
        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);
        }
コード例 #4
0
ファイル: CategoriaListView.cs プロジェクト: ruben206/ad
        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;
        }
コード例 #5
0
ファイル: CategoriaListView.cs プロジェクト: CarlosColoma/AD
        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;
            };
        }
コード例 #6
0
ファイル: ArticuloListView.cs プロジェクト: ruben206/ad
        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();

            };
        }