--[[ 54f60bf84d439178 ]] local caption = 'Oprava obratov' if not db.Opened then MessageBox('Otvorte prosím účtovníctvo, v ktorom si želáte opraviť' .. ' obraty a spustite tento skript znovu.', caption, 64) elseif FrmMain.ActiveEvid.TableName ~= 'obrat' and FrmMain.ActiveEvid.TableName ~= 'rozuctovanie' then MessageBox('Nastavte sa do evidencie Obratov alebo Rozúčtovaní,' .. ' označte chybné riadky a spustite tento skript znovu.', caption, 0x30) else local mod = FrmMain.ActiveEvid.TableName == 'obrat' and 1 or 2 local g = FrmMain.ActiveEvid.Table local t = {} g:First() while not g.Eof do if g.Selected then table.insert(t, g:Field'RowID') end g:Next() end if MessageBox('Počet označených ' .. (mod == 1 and 'obratov' or 'rozúčtovaní') .. ': ' .. #t .. '.' .. ' \r\nSkript na týchto ' .. (mod == 1 and 'obratoch' or 'položkách rozúčtovania') .. ' prepočíta ceny a zaokrúhli ich na 2 desatinné miesta.' .. ' \r\nŽeláte si pokračovať?', caption, 0x30 + 0x4) == 6 then local res = false if db:locktable('rozuctovanie') then res = db:exec('UPDATE rozuctovanie SET Suma = round(Cena * Mnozstvo, 2)' .. ' WHERE ' .. (mod == 1 and 'ID_obratu' or 'RowID') .. ' IN (' .. table.concat(t, ',') .. ')') db:finish(res) db:unlocktable('rozuctovanie') end if res then MessageBox('Oprava je hotová.', caption, 64) end return res end end return false