'UPD_SORD - update sales orders

external   messbox() sch scw vloadif() dpath fentrybox() shopmask

public     ptstr

global     x z FindJobNr() jobnr

MAIN
single-step off
screen clear box 1 1 sch scw 0 0 no-border
while true

  x = FindJobNr()
  if x = 1
    continue while
  elseif x = -1
    exit while
  end if

  while true
    data update only-one
    smartpeek $_lastkey z
    if z <> {F10}
      messbox(" Record not saved!! Abandon record for"&jobnr|"? (y/n) ",1,1,1)
      if ptstr == "y"
        exit while
      else
        continue while
      end if
    end if
    write-record
    exit while
  end while

end while
file unload all
transfer "pm_menu.psl" in-memory
END MAIN

FUNCTION FindJobNr()
local l1 c3 c2 c1 ques $reqstr
while true
repaint off
' ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
' º Find Job Nr                                                        º
' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ¼
  x = fentrybox(" Order Nr to Update - {Esc} to finish ",6,shopmask,"")
  if x = -1
    return (-1)
  end if
  jobnr = ptstr

  vloadif(dpath|"upd_sord.vw")
  order change physical
  order change key "[Job_Nr]"
  data find "[Job_Nr]" equal jobnr options "g"   '  find correct JOB
  if cerror
    messbox(" Job NOT entered ",0,0,1)
    return (-2)
  end if

  repaint on		' show screen CUSENT3B and confirm to continue
  repaint
end while
END FUNCTION ' FindJobNr()


