Esempio n. 1
1
        public CategoriaController(Categoria categoria, CategoriaView categoriaView)
        {
            categoriaView.Nombre = categoria.Nombre;

            categoriaView.SaveActionDelegate = delegate {
                categoria.Nombre = categoriaView.Nombre;
                Categoria.Save(categoria);
            };
        }
Esempio n. 2
0
 public static void Save(Categoria categoria)
 {
     IDbCommand updateDbCommand = App.Instance.DbConnection.CreateCommand ();
     updateDbCommand.CommandText = "update categoria set nombre=@nombre where id=" + categoria.Id;
     DbCommandUtil.AddParameter (updateDbCommand, "nombre", categoria.Nombre);
     updateDbCommand.ExecuteNonQuery ();
 }
Esempio n. 3
0
        public CategoriaController(Categoria categoria, CategoriaView categoriaView)
        {
            this.categoria = categoria;
            this.categoriaView = categoriaView;
            categoriaView.Nombre = categoria.Nombre;

            categoriaView.SaveAction.Activated += delegate{
                saveActionHandler ();
            };
        }
Esempio n. 4
0
        public static Categoria Load(string id)
        {
            IDbCommand selectDbCommand = App.Instance.DbConnection.CreateCommand ();
            selectDbCommand.CommandText = "select nombre from categoria where id=" + id;
            IDataReader dataReader = selectDbCommand.ExecuteReader();
            dataReader.Read(); //lee el primero

            Categoria categoria = new Categoria();
            categoria.Id = int.Parse (id);
            categoria.Nombre = dataReader["nombre"].ToString();
            dataReader.Close ();
            return categoria;
        }
Esempio n. 5
0
        public static Categoria Load(string id)
        {
            IDbCommand select = App.Instance.DbConnection.CreateCommand ();
            select.CommandText = string.Format("select nombre from categoria where id={0}",id);
            IDataReader reader = select.ExecuteReader ();
            reader.Read ();

            Categoria categoria = new Categoria ();
            categoria.Id = int.Parse (id);
            categoria.Nombre = reader ["nombre"].ToString ();
            reader.Close ();

            return categoria;
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            string connectionString="Server=localhost;Database=dbprueba;" +
                                     "User Id=root;Password=sistemas";

            MySqlConnection mySqlConnection = new MySqlConnection(connectionString);

            Categoria cat = new Categoria ();
            cat.Nombre = DateTime.Now.ToString ();

            Categoria.Save (cat);

            App.Instance.DbConnection=mySqlConnection;
            Application.Init ();
            MainWindow win = new MainWindow ();
            win.Show ();
            Application.Run ();
        }