public CategoriaController(Categoria categoria, CategoriaView categoriaView) { categoriaView.Nombre = categoria.Nombre; categoriaView.SaveActionDelegate = delegate { categoria.Nombre = categoriaView.Nombre; Categoria.Save(categoria); }; }
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 (); }
public CategoriaController(Categoria categoria, CategoriaView categoriaView) { this.categoria = categoria; this.categoriaView = categoriaView; categoriaView.Nombre = categoria.Nombre; categoriaView.SaveAction.Activated += delegate{ saveActionHandler (); }; }
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; }
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; }
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 (); }