Esempio n. 1
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();


        treeView.AppendColumn("id", new CellRendererText(), "text", 0);
        treeView.AppendColumn("nombre", new CellRendererText(), "text", 1);

        ListStore listStore = new ListStore(typeof(long), typeof(string));

        treeView.Model = listStore;

        //liststore.AppendValues (33L, "Treinta y tres");

        App.Instance.DbConnection = new MySqlConnection("Database=dbprueba;user=root;password=sistemas");
        App.Instance.DbConnection.Open();

        fillListStore(listStore);


        newAction.Activated += delegate {
            CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
        };

        deleteAction.Activated += delegate {
            if (!WindowHelper.Confirm(this, "Quieres eliminar el registro?"))
            {
                return;
            }

            TreeIter treeIter;
            treeView.Selection.GetSelected(out treeIter);
            object id = listStore.GetValue(treeIter, 0);

            Console.WriteLine("deleteAction Activated id = {0}", id);
            IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand();
            //TODO usar dbParameters para el id
            deleteDbCommand.CommandText = "delete from categoria where id = @id";
            DbHelper.DbCommandAddParameter(deleteDbCommand, "id", id);
            deleteDbCommand.ExecuteNonQuery();
        };

        refreshActions.Activated += delegate {
            fillListStore(listStore);
        };

        treeView.Selection.Changed += delegate {
            Console.WriteLine("treeView  Selection Changed CountSelectedRows()={0}",
                              treeView.Selection.CountSelectedRows());

            refreshAction();
        };
        //dbConnection.Close ();
    }
Esempio n. 2
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
        treeView.AppendColumn ("nombre", new CellRendererText(), "text", 1);

        ListStore listStore = new ListStore(typeof(long), typeof(string));
        treeView.Model = listStore;

        //liststore.AppendValues (33L, "Treinta y tres");

        App.Instance.DbConnection = new MySqlConnection ("Database=dbprueba;user=root;password=sistemas");
        App.Instance.DbConnection.Open ();

        fillListStore (listStore);

        newAction.Activated += delegate {
            CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
        };

        deleteAction.Activated += delegate {

            if (!WindowHelper.Confirm(this, "Quieres eliminar el registro?")){
                return;
            }

            TreeIter treeIter;
            treeView.Selection.GetSelected(out treeIter);
            object id = listStore.GetValue(treeIter,0);

            Console.WriteLine ("deleteAction Activated id = {0}" , id);
            IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand();
            //TODO usar dbParameters para el id
            deleteDbCommand.CommandText = "delete from categoria where id = @id";
            DbHelper.DbCommandAddParameter(deleteDbCommand, "id", id);
            deleteDbCommand.ExecuteNonQuery();

        };

        refreshActions.Activated += delegate {
            fillListStore (listStore);
        };

        treeView.Selection.Changed += delegate {
            Console.WriteLine ("treeView  Selection Changed CountSelectedRows()={0}",
                               treeView.Selection.CountSelectedRows());

            refreshAction();

        };
        //dbConnection.Close ();
    }
Esempio n. 3
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
        treeView.AppendColumn ("nombre", new CellRendererText(), "text", 1);

        ListStore liststore = new ListStore(typeof(long), typeof(string));
        treeView.Model = liststore;

        //liststore.AppendValues (33L, "Treinta y tres");

        App.Instance.DbConnection = new MySqlConnection ("Database=dbprueba;user=root;password=sistemas");
        App.Instance.DbConnection.Open ();

        //operaciones (insert, select...)

        //IDbCommand insertDbCommand = dbConnection.CreateCommand ();
        //insertDbCommand.CommandText = "insert into categoria (nombre) values ('categoria 2')";
        //insertDbCommand.ExecuteNonQuery ();

        //Las operaciones que toquen

        IDbCommand dbcommand = App.Instance.DbConnection.CreateCommand ();
        dbcommand.CommandText = "select * from categoria";
        IDataReader dataReader = dbcommand.ExecuteReader ();
        while (dataReader.Read()) {
            //Console.WriteLine ("id={0} nombre={1}", dataReader ["id"], dataReader ["nombre"]);
            liststore.AppendValues (dataReader ["id"], dataReader ["nombre"]);
        }
        dataReader.Close ();
        newAction.Activated += delegate {
            CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
        };
        //dbConnection.Close ();
    }
Esempio n. 4
0
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		Build ();


		//Crear treeview categorias
		treeView.AppendColumn ("Id", new CellRendererText (), "text", 0);
		treeView.AppendColumn ("Nombre", new CellRendererText (), "text", 1);
		ListStore listStore = new ListStore (typeof(long), typeof(string));
		treeView.Model = listStore;

	
		//mysql
		App.Instance.DbConnection = new MySqlConnection (
			"Database=dbprueba;User=root;Password=sistemas");
		App.Instance.DbConnection.Open ();


		//operaciones
//		IDbCommand insertdbCommand = dbConnection.CreateCommand ();
//		insertdbCommand.CommandText =
//			"insert into categoria (nombre) values ('categoria 4')";
//		insertdbCommand.ExecuteNonQuery ();


		//App.Instance.DbConnection.Close ();

		CategoriaView categoriaView = new CategoriaView ();

		deleteAction.Activated += delegate {
//			Confirmar el borrado
//			MessageDialog messageDialog= new MessageDialog(
//				this,
//				DialogFlags.Modal,
//				MessageType.Question,
//				ButtonsType.YesNo,
//				"¿Deseas eliminar el registro?"
//				);
//			messageDialog.Title=Title;
//			ResponseType response=(ResponseType)messageDialog.Run();
//			messageDialog.Destroy();
//			if(response!=ResponseType.Yes)
//				return;
			if (!WindowHelper.Confirm (this, "¿Deseas eliminar el registro?"))
				return;



			Console.WriteLine ("delete activated");
			TreeIter treeIter;
			treeView.Selection.GetSelected (out treeIter);
			object id = listStore.GetValue (treeIter, 0);

			Console.WriteLine ("deleteAction Activated id={0}", id);
			IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand ();
			deleteDbCommand.CommandText = "delete from categoria where id= " + id;

		};
		treeView.Selection.Changed += delegate {
			Console.WriteLine ("Selection changed CountSelectedRows()={0}",
			                   treeView.Selection.CountSelectedRows ());
			updateActions ();

		};
		refreshAction.Activated += delegate {
			fillListstore (listStore);
		};
		deleteAction.Activated += delegate {
			MessageDialog messageDialog = new MessageDialog(
				this,
				DialogFlags.Modal,
				MessageType.Question,
				ButtonsType.YesNo,
				"¿Quieres eliminar el registro?"

			);
			ResponseType response = (ResponseType)messageDialog.Run();
			messageDialog.Destroy();
			if (response == ResponseType.Yes)
				Console.WriteLine ("ResponseType.Yes");;//lo que toque
		updateActions ();
 
	}
Esempio n. 5
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        treeView.AppendColumn ("id", new CellRendererText (), "text", 0);
        treeView.AppendColumn ("nombre", new CellRendererText(), "text", 1);

        ListStore liststore = new ListStore(typeof(long), typeof(string));
        treeView.Model = liststore;

        //liststore.AppendValues (33L, "Treinta y tres");

        App.Instance.DbConnection = new MySqlConnection
            ("Database=dbprueba;user=root;password=sistema");
        App.Instance.DbConnection.Open ();

        filListstore (liststore);

        newAction.Activated += delegate {
            CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
        };

        deleteAction.Activated += delegate {

            //confirmar
        //			MessageDialog messagedialog =new MessageDialog(
        //				this,
        //				DialogFlags.Modal,
        //				MessageType.Question,
        //				ButtonsType.YesNo,
        //				"¿QUIERES ELMINAR EL REGISTRO?"
        //			);
        //			messagedialog.Title=Title;
        //			ResponseType response = (ResponseType)messagedialog.Run();
        //			messagedialog.Destroy();
        //
        //			if (response!=ResponseType.Yes)
        //				return;

            if (!WindowHelper.Confirm(this,"¿QUIERES ELMINAR EL REGISTRO?"))
                return;

            TreeIter treeIter;
            treeView.Selection.GetSelected(out treeIter);
            object id = liststore.GetValue(treeIter,0);

            Console.WriteLine ("deleteAction Activated id = {0}" , id);
            IDbCommand deletedbcommand =App.Instance.DbConnection.CreateCommand();

            deletedbcommand.CommandText = "delete from categoria where id=  @id";
            DBHelper.DbCommandAddParameter(deletedbcommand, "id", id);
            deletedbcommand.ExecuteNonQuery();

        };

        treeView.Selection.Changed += delegate {
            Console.WriteLine ("treeView  Selection Changed CountSelectedRows()={0}",
                               treeView.Selection.CountSelectedRows());
            updateActions();

        };

        refreshAction.Activated += delegate {
            filListstore (liststore);

        };

        updateActions();
        //dbConnection.Close ();
    }
Esempio n. 6
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();


        treeView.AppendColumn("id", new CellRendererText(), "text", 0);
        treeView.AppendColumn("nombre", new CellRendererText(), "text", 1);

        ListStore liststore = new ListStore(typeof(long), typeof(string));

        treeView.Model = liststore;

        //liststore.AppendValues (33L, "Treinta y tres");

        App.Instance.DbConnection = new MySqlConnection
                                        ("Database=dbprueba;user=root;password=sistema");
        App.Instance.DbConnection.Open();

        filListstore(liststore);

        newAction.Activated += delegate {
            CCategoria.CategoriaView categoriaView = new CCategoria.CategoriaView();
        };

        deleteAction.Activated += delegate {
            //confirmar
//			MessageDialog messagedialog =new MessageDialog(
//				this,
//				DialogFlags.Modal,
//				MessageType.Question,
//				ButtonsType.YesNo,
//				"¿QUIERES ELMINAR EL REGISTRO?"
//			);
//			messagedialog.Title=Title;
//			ResponseType response = (ResponseType)messagedialog.Run();
//			messagedialog.Destroy();
//
//			if (response!=ResponseType.Yes)
//				return;

            if (!WindowHelper.Confirm(this, "¿QUIERES ELMINAR EL REGISTRO?"))
            {
                return;
            }

            TreeIter treeIter;
            treeView.Selection.GetSelected(out treeIter);
            object id = liststore.GetValue(treeIter, 0);

            Console.WriteLine("deleteAction Activated id = {0}", id);
            IDbCommand deletedbcommand = App.Instance.DbConnection.CreateCommand();


            deletedbcommand.CommandText = "delete from categoria where id=  @id";
            DBHelper.DbCommandAddParameter(deletedbcommand, "id", id);
            deletedbcommand.ExecuteNonQuery();
        };

        treeView.Selection.Changed += delegate {
            Console.WriteLine("treeView  Selection Changed CountSelectedRows()={0}",
                              treeView.Selection.CountSelectedRows());
            updateActions();
        };


        refreshAction.Activated += delegate {
            filListstore(liststore);
        };

        updateActions();
        //dbConnection.Close ();
    }