public ArticuloView() : base(Gtk.WindowType.Toplevel) { articulo = new Articulo(); init (); saveAction.Activated +=delegate {insert();} }
public ArticuloView(object id) : base(Gtk.WindowType.Toplevel) { articulo = ArticuloPersister.Load(id); init (); saveAction.Activated +=delegate {update();} }
public static int Insert(Articulo articulo) { IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand (); dbCommand.CommandText = "insert into articulo (nombre, categoria, precio) " + "values (@nombre, @categoria, @precio)"; DbCommandHelper.AddParameter (dbCommand, "nombre", articulo.Nombre); DbCommandHelper.AddParameter (dbCommand, "categoria", articulo.Categoria); DbCommandHelper.AddParameter (dbCommand, "precio", articulo.Precio); return dbCommand.ExecuteNonQuery (); }
public static int Update(Articulo articulo) { IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand (); dbCommand.CommandText = "update articulo set nombre=@nombre, categoria=@categoria,"+ "precio=@precio where id=@id"; DbCommandHelper.AddParameter (dbCommand, "nombre", articulo.Nombre); DbCommandHelper.AddParameter (dbCommand, "categoria", articulo.Categoria); DbCommandHelper.AddParameter (dbCommand, "precio", articulo.Precio); DbCommandHelper.AddParameter (dbCommand, "id", articulo.Id); return dbCommand.ExecuteNonQuery (); }
public static Articulo Load(object id) { Articulo articulo = new Articulo (); articulo.Id = id; IDbCommand dbCommand = App.Instance.DbConnection.CreateCommand (); dbCommand.CommandText = "select * from articulo where id = @id"; DbCommandHelper.AddParameter (dbCommand, "id", id); IDataReader datareader = dbCommand.ExecuteReader(); if (!datareader.Read ()) ; articulo.Nombre = (string)datareader ["nombre"]; articulo.Categoria = get(datareader["categoria"],null); articulo.Precio = (decimal)get(datareader["precio"],decimal.Zero); datareader.Close (); return articulo; }
public static int Save(Articulo articulo) { return(articulo.Id == null?Insert(articulo) : Update(articulo)); }
public static int save(Articulo articulo) { return articulo.Id == null ? Insert (articulo) : Update (articulo); }
public ArticuloView(object id) : base(WindowType.Toplevel) { articulo = ArticuloPersister.Load(id); init(); saveAction.Activated += delegate { update(); }; }
public ArticuloView() : base(Gtk.WindowType.Toplevel) { articulo = new Articulo(); init(); saveAction.Activated += delegate { insert(); }; }
public static void Update(Articulo articulo) { }
public static void Insert(Articulo articulo) { }