Example #1
0
 public ArticuloView()
     : base(Gtk.WindowType.Toplevel)
 {
     articulo = new Articulo();
     init ();
     saveAction.Activated +=delegate {insert();}
 }
Example #2
0
 public ArticuloView(object id)
     : base(Gtk.WindowType.Toplevel)
 {
     articulo = ArticuloPersister.Load(id);
     init ();
     saveAction.Activated +=delegate {update();}
 }
Example #3
0
        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 ();
        }
Example #4
0
        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 ();
        }
Example #5
0
        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;
        }
Example #6
0
 public static int Save(Articulo articulo)
 {
     return(articulo.Id == null?Insert(articulo) : Update(articulo));
 }
Example #7
0
 public static int save(Articulo articulo)
 {
     return articulo.Id == null ? Insert (articulo) : Update (articulo);
 }
Example #8
0
 public ArticuloView(object id) : base(WindowType.Toplevel)
 {
     articulo = ArticuloPersister.Load(id);
     init();
     saveAction.Activated += delegate { update(); };
 }
Example #9
0
 public ArticuloView() : base(Gtk.WindowType.Toplevel)
 {
     articulo = new Articulo();
     init();
     saveAction.Activated += delegate { insert(); };
 }
Example #10
0
 public static void Update(Articulo articulo)
 {
 }
Example #11
0
 public static void Insert(Articulo articulo)
 {
 }