Example #1
0
        private void update()
        {
            IDbCommand dbcommand = APP.Instance.Dbconection.CreateCommand();

            dbcommand.CommandText = "update articulo set nombre=@nombre, categoria=@categoria, precio=@precio where id=@id";
            nombre    = entry1.Text;
            categoria = ComboBoxHelper.GetId(combobox1);
            precio    = Convert.ToDecimal(spinbutton1.Value);

            DbCommandHelper.AddParameter(dbcommand, "nombre", nombre);
            DbCommandHelper.AddParameter(dbcommand, "categoria", categoria);
            DbCommandHelper.AddParameter(dbcommand, "precio", precio);
            DbCommandHelper.AddParameter(dbcommand, "id", id);
            dbcommand.ExecuteNonQuery();
            Destroy();
        }
Example #2
0
        //boton guardar
        //		private void save(){
        //			if (id == null)
        //				insert ();
        //			else
        //				update();
        //		}

        private void insert()
        {
            IDbCommand dbcommand = APP.Instance.Dbconection.CreateCommand();

            dbcommand.CommandText = "insert into articulo (nombre, categoria, precio)" +
                                    "values (@nombre, @categoria, @precio)";

            nombre    = entry1.Text;
            categoria = ComboBoxHelper.GetId(combobox1);
            precio    = Convert.ToDecimal(spinbutton1.Value);

            DbCommandHelper.AddParameter(dbcommand, "nombre", nombre);
            DbCommandHelper.AddParameter(dbcommand, "categoria", categoria);
            DbCommandHelper.AddParameter(dbcommand, "precio", precio);
            dbcommand.ExecuteNonQuery();
            Destroy();
        }