示例#1
0
        public ArticuloListView(IDbConnection dbConnection)
            : base(dbConnection)
        {
            App.Instance.SQL="select * from articulo";

            helper=new TreeViewHelper(TreeView,dbConnection,App.Instance.SQL);
        }
示例#2
0
        public ArticuloListView()
        {
            string sql="select * from articulo";
             helper=new TreeViewHelper(treeView,sql);

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

            Gtk.Action deleteAction=new Gtk.Action("deleteAction",null,null, Stock.Delete);
            actionGroup.Add(deleteAction);

            deleteAction.Activated+=delegate{
                executeNonQuery(string.Format("delete from articulo where id={0}",helper.Id));
            };

            Gtk.Action newAction=new Gtk.Action("newAction",null,null, Stock.New);
            actionGroup.Add(newAction);

            newAction.Activated+=delegate{

                executeNonQuery(string.Format("insert into articulo (nombre) values ('{0}')",DateTime.Now));
            };

            treeView.Selection.Changed += delegate {
                editAction.Sensitive=treeView.Selection.CountSelectedRows() >0;
                string id=getId();
                Console.WriteLine(id);
            };
        }
示例#3
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();

            };
        }
示例#4
0
        public CategoriaListView(IDbConnection dbConnection)
            : base(dbConnection)
        {
            App.Instance.SQL="select * from categoria";

            helper=new TreeViewHelper(TreeView,dbConnection,App.Instance.SQL);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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;
        }
示例#8
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;
            };
        }
示例#9
0
        public CategoriaListview()
        {
            TreeViewHelper treeViewHelper = new TreeViewHelper (treeView, App.Instance.DbConnection, "select id,nombre from categoria");

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

                treeViewHelper.refresh();
            };

            ActionGroup.Add (actionRefresh);

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

                Categoria categoria=(Categoria)ModelHelper.Load(typeof(Categoria),treeViewHelper.Id);

                Console.WriteLine ("id=[{0}, nombre={1} ",categoria.Id,categoria.Nombre);

            };

            ActionGroup.Add (actionEdit);
        }
示例#10
0
 public CategoriaListView()
 {
     helper=new TreeViewHelper(treeView,"select * from categoria");
     setAction();
     refresh();
 }
示例#11
0
 public ArticuloListView()
 {
     helper=new TreeViewHelper(treeView,"select * from articulo");
     setActions();
 }
示例#12
0
 public CategoriaListView()
 {
     string sql="select * from categoria";
     helper=new TreeViewHelper(treeView,sql);
 }
示例#13
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();

            };
        }