// перекодировка штрихкодов

var

  FIRSTBARCODE :integer= 1;

  table :TTable;
  Query :TQuery;

begin

  Table := tTAble.create(nil);
  Query := TQuery.Create(NIl);
  try
    Table.databasename := 'dbkassa';
    Query.databasename := table.databasename;
    table.tablename := 'tovar.db';

    Query.sql.text := 'update pr_tovar set barcode = :p_barcode where nn = :p_nn and ostat >0';

    table.open;
    table.filter := 'floatbarcode = 1';
    table.filtered := true;
    table.first;
    with TMyWait.create('Идет замена кодов') do
    try
        Progressbarmax := table.recordcount;
        Progressbarpos := 0;
        while not table.eof do
        begin
          incprogress;
          table.edit;
          table.fieldbyname('barcode').asstring := inttostr(FirstBarcode);
          table.post;
          Query.parambyname('p_nn').asstring := table.fieldbyname('nn').asstring;
          Query.parambyname('p_barcode').asstring := inttostr(FirstBarcode);
          Query.execsql;

          inc(FirstBarcode);
          table.next;
        end;
    finally
      free
    end;
  finally
    Query.free;
    Table.free;
  end;
end.

