if thisform.frm_mode="A" headtype=thisform.mdoch =sqlexec(posqlconn,"select current_no from icount where doc_type='"+ headtype +"' ","c_currhkey") =sqlexec(posqlconn,"update icount set current_no=current_no+1 WHERE DOC_TYPE='"+ headtype +"'") =sqlcommit(posqlconn) SELECT c_currhkey replace fheader.hkey with c_currhkey.current_no+1 thisform.m_filldetail(c_currhkey.current_no+1) IF USED('c_currhkey') USE IN c_currhkey endif endif if thisform.frm_mode="A" m.dettype=thisform.mdocd sele fdetail go top do while !eof() =SQLEXEC(posqlconn,"select a.doc_type, a.current_no from icount a where a.doc_type='ND'", “c_currdkey") SELECT c_currdkey =sqlexec(posqlconn,"update icount set icount.current_no=icount.current_no+1 where icount.doc_type='"+ALLTRIM(m.dettype)+"'") =sqlcommit(posqlconn) replace fdetail.dkey with c_currdkey.current_no+1 IF USED('c_currdkey') USE IN c_currdkey endif SELE FDETAIL SKIP enddo endif wait window "Processing..." nowait do case case thisform.frm_mode="A" =SQLSETPROP(posqlconn, 'Transactions', 2) && Manual transactions BEGIN TRANSACTION IF thisform.m_saveheader() select fheader if (thisform.m_savedetail()) if thisform.m_saveother() && Detail file is updated if thisform.m_savestk() && Fire posting trigger if thisform.m_savegl() IF sqlcommit(posqlconn)<= 0 =SQLROLLBACK(posqlconn) ROLLBACK thisform.o_busrules.m_messbox("Cannot Commit Transaction!") ELSE end transaction llupdate=.t. ENDIF ELSE =SQLROLLBACK(posqlconn) ROLLBACK thisform.o_busrules.m_messbox("Cannot Update GL!") ENDIF ELSE =SQLROLLBACK(posqlconn) rollback thisform.o_busrules.m_messbox("Cannot Update Stock!") ENDIF ELSE =SQLROLLBACK(posqlconn) rollback thisform.o_busrules.m_messbox("Cannot Update Postings!") ENDIF ELSE =SQLROLLBACK(posqlconn) rollback thisform.o_busrules.m_messbox("Cannot Update Detail File!") ENDIF ELSE =SQLROLLBACK(posqlconn) ROLLBACK thisform.o_busrules.m_messbox("Cannot Update Header File!") ENDIF IF llupdate thisform.lockscreen=.f. wait clear thisform.o_busrules.m_messbox(thisform.name+" "+"Number "; +allTRIM(thisform.firstfield.value)+" Saved!",64) thisform.m_printdoc() ELSE thisform.o_busrules.m_messbox("Unable to save Transaction! Try again later!") thisform.m_reverttable ENDIF WAIT CLEAR thisform.lockscreen=.t. thisform.lcreckey=0 thisform.frm_doc_no=" " append blank in fheader thisform.lockscreen=.f. thisform.refresh if !thisform.autonum thisform.firstfield.setfocus else thisform.secondfield.setfocus endif return