uo_outware.sru 208 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205
  1. $PBExportHeader$uo_outware.sru
  2. forward
  3. global type uo_outware from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_outware from nonvisualobject
  7. end type
  8. global uo_outware uo_outware
  9. type variables
  10. Public ProtectedWrite Long scid = 0 //分部id
  11. Public ProtectedWrite Long outwareid //进仓单表自动增量id
  12. Public ProtectedWrite String outwarecode //单据的唯一编号
  13. Public ProtectedWrite Int billtype = 0 //业务类型
  14. Public ProtectedWrite DateTime opdate //建立时间,自动
  15. Public ProtectedWrite String opemp //建立操作员
  16. Public ProtectedWrite DateTime moddate //修改时间,自动
  17. Public ProtectedWrite String modemp //修改操作员
  18. Public ProtectedWrite Int balcflag = 0 //仓库日结标志
  19. Public ProtectedWrite Int flag = 0 //仓库审核标志
  20. Public ProtectedWrite DateTime auditingdate //审核时间
  21. Public ProtectedWrite String auditingrep //审核操作员
  22. Public ProtectedWrite Int secflag = 0 //财务审核标志
  23. Public ProtectedWrite DateTime secauditingdate //二审核时间
  24. Public ProtectedWrite String secauditingrep //二审核操作员
  25. Public ProtectedWrite Decimal sum_amt = 0 //单据总金额
  26. Public ProtectedWrite Decimal sum_amt_en = 0 //单据总金额(其它单价)
  27. Public ProtectedWrite long balcdateint = 0
  28. Public ProtectedWrite Decimal sum_taxamt = 0 //单据税额
  29. Public ProtectedWrite Decimal sum_taxamt_en = 0 //单据税额(其它单价)
  30. Public ProtectedWrite Int priceflag = 0 //确认标志
  31. Public ProtectedWrite DateTime pricedate //确认时间
  32. Public ProtectedWrite String priceemp //确认操作员
  33. Public ProtectedWrite Long ctmint
  34. Long relid = 0 //关联id
  35. Long storageid = 0 //进仓仓库
  36. DateTime outdate //进仓发生时间
  37. String outrep = '' //经手人
  38. String part = '' //相关号码
  39. String dscrp = '' //备注
  40. Long cusid = 0 //客户id
  41. String cusname = '' //客户名称(不记帐模式使用)
  42. Int thflag = 0 //退货标记
  43. Int ifauto = 0
  44. String relstr_1
  45. String relstr_2
  46. String relstr_3
  47. Long relint_1
  48. Long relint_2
  49. Long relint_3
  50. long relint_4
  51. Decimal otheramt
  52. Decimal damt
  53. Decimal mrate
  54. String rel_address
  55. String rel_tele
  56. String rel_fax
  57. String rel_rep
  58. String upname
  59. DateTime viewdate
  60. Long storagescid = 0 //仓库分部ID
  61. Long deptid = 0
  62. long typeid = 0
  63. String carcode
  64. String transcode
  65. Decimal totalamt
  66. Decimal getamt
  67. Int lsflag
  68. Int pda_flag
  69. DateTime pda_date
  70. long exchangeid
  71. string station_address
  72. Boolean if_getid_ture = True
  73. Transaction commit_transaction //数据commit事务
  74. s_outwaremx outwaremx[], ins_ref_outwaremx[],ins_empty_outwaremx[] //明细结构数组
  75. long ins_ref_mxbt = 0
  76. s_outwaremx_mx outwaremx_mx[]
  77. s_outwaremx_barcode s_mx_barcode[]
  78. s_outware_itemmx outware_itemmx[]
  79. Long it_mxbt = 0 //明细结构数组末指针
  80. Long it_mxbt_mx = 0
  81. Long it_mxbt_barcode = 0
  82. Long it_mxbt_item = 0
  83. Boolean it_newbegin = False //新建标志
  84. Boolean it_updatebegin = False //修改标志
  85. Boolean if_pd_py_check_barcode = False
  86. Int uo_option_autowaste,uo_option_inout_type
  87. Int uo_option_barcode_outwareother_paudit
  88. Int uo_option_confirmaudit_sale,uo_option_sale_use_planqty
  89. Int uo_option_confirmaudit_scll,uo_option_cost_dec
  90. String uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode
  91. Int uo_option_mtrlware_autocmp,uo_option_mtrlware_limit
  92. Int uo_option_scll_limit,uo_option_if_pricetype
  93. Int uo_option_checkprice_native
  94. Int uo_option_if_saleout
  95. Int uo_option_disuse_outware_sale
  96. Int uo_option_sale_ifuse_negativeprice
  97. Int uo_option_pda_sale_lock
  98. Int uo_option_price_rmb
  99. int uo_option_outware_sale_checkprice
  100. int uo_option_scll_use_planqty
  101. int uo_option_barcodelocation_use_inwaremx_location
  102. int uo_option_djqty_check
  103. int uo_option_outware_saleout
  104. int uo_option_scllplan_outware_auto
  105. int uo_option_noauditingqty_mode
  106. int uo_option_outware_pack_save_cmp
  107. int uo_option_pk_notauditqty_check
  108. int uo_option_canpack_ifzanyong
  109. end variables
  110. forward prototypes
  111. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
  112. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  113. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  114. public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg)
  115. public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
  116. public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg)
  117. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  118. public function integer p_clearmx ()
  119. public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
  120. public function integer p_reset ()
  121. public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit)
  122. public function integer del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit)
  123. public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg)
  124. public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg)
  125. public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit)
  126. public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg)
  127. public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg)
  128. public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  129. public function integer uof_check_qty_to_bqty (ref string arg_msg)
  130. public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  131. public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  132. public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg)
  133. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula)
  134. public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg)
  135. public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit)
  136. public function integer uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg)
  137. public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg)
  138. protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg)
  139. public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg)
  140. public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg)
  141. public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg)
  142. end prototypes
  143. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);Int rslt = 1
  144. IF arg_scid < 0 THEN
  145. arg_msg = '请选择分部'
  146. rslt = 0
  147. GOTO ext
  148. END IF
  149. IF Not (arg_billtype = 1 OR &
  150. arg_billtype = 2 OR &
  151. arg_billtype = 3 OR &
  152. arg_billtype = 4 OR &
  153. arg_billtype = 5 OR &
  154. arg_billtype = 6 OR &
  155. arg_billtype = 7 OR &
  156. arg_billtype = 8 OR &
  157. arg_billtype = 9 OR &
  158. arg_billtype = 10 OR &
  159. arg_billtype = 12 OR &
  160. arg_billtype = 15 OR &
  161. arg_billtype = 16 OR &
  162. arg_billtype = 17 or &
  163. arg_billtype = 18 or &
  164. arg_billtype = 19 or &
  165. arg_billtype = 20 or &
  166. arg_billtype = 21 or &
  167. arg_billtype = 22 or &
  168. arg_billtype = 23 or &
  169. arg_billtype = 24 or &
  170. arg_billtype = 25) THEN
  171. rslt = 0
  172. arg_msg = '此单据类型必须为:'
  173. arg_msg = arg_msg+'1-销售出仓单[记帐模式],'
  174. arg_msg = arg_msg+'2-销售出仓单[不记帐模式],'
  175. arg_msg = arg_msg+'3-领料出仓单,'
  176. arg_msg = arg_msg+'4-外协出仓单,'
  177. arg_msg = arg_msg+'5-来料加工发货,'
  178. arg_msg = arg_msg+'6-售后服务出仓单,'
  179. arg_msg = arg_msg+'7-外协销售出仓单,'
  180. arg_msg = arg_msg+'8-其它出仓单,'
  181. arg_msg = arg_msg+'9-盘亏出仓单,'
  182. arg_msg = arg_msg+'10-工具出仓单,'
  183. arg_msg = arg_msg+'12-调拨出仓单'
  184. arg_msg = arg_msg+'15-拆装出仓单'
  185. arg_msg = arg_msg+'16-生产进仓车间自动出仓单(未分配)'
  186. arg_msg = arg_msg+'17-还货出仓单'
  187. arg_msg = arg_msg+'18-自动组装出仓单'
  188. arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)'
  189. arg_msg = arg_msg+'20-车间库存转换自动出仓单'
  190. arg_msg = arg_msg+'21-送货单包件明细自动出仓单'
  191. arg_msg = arg_msg+'22-欠货终止单自动出仓单'
  192. arg_msg = arg_msg+'23-收货单收货明细自动出仓单'
  193. arg_msg = arg_msg+'24-员工物品领用单'
  194. arg_msg = arg_msg+'25-发料损耗自动出仓单'
  195. GOTO ext
  196. END IF
  197. p_reset()
  198. billtype = arg_billtype
  199. scid = arg_scid
  200. it_newbegin = TRUE
  201. it_updatebegin = FALSE
  202. ext:
  203. IF rslt = 0 THEN p_reset()
  204. RETURN rslt
  205. end function
  206. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
  207. Long cnt = 0,i,j
  208. DateTime server_dt
  209. Long ls_newid
  210. Int li_outtype
  211. String ls_storagename
  212. String ls_sccode
  213. Decimal ld_trueoverqty
  214. Int li_ifmrp
  215. Long ll_mtrlid_arr[]
  216. Decimal ld_qty_arr[]
  217. String ls_mtrlcode_arr[]
  218. Long ll_mxcnt = 0
  219. Decimal ld_djqty,ld_noallocqty
  220. Int li_priceflag
  221. Long ll_cnt_billtype21
  222. s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
  223. ins_ref_outwaremx = ins_empty_outwaremx
  224. ins_ref_mxbt = 0
  225. IF uo_option_disuse_outware_sale = -1000 THEN
  226. rslt = 0
  227. arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!'
  228. GOTO ext
  229. END IF
  230. IF uo_option_price_rmb = -1000 THEN
  231. arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!'
  232. rslt = 0
  233. GOTO ext
  234. END IF
  235. IF uo_option_djqty_check = -1000 THEN
  236. rslt = 0
  237. arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!'
  238. GOTO ext
  239. END IF
  240. IF IsNull(relid) THEN relid = 0
  241. IF IsNull(storageid) THEN storageid = 0
  242. IF IsNull(outrep) THEN outrep = ''
  243. IF IsNull(dscrp) THEN dscrp = ''
  244. IF IsNull(part) THEN part = ''
  245. IF IsNull(cusid) THEN cusid = 0
  246. IF IsNull(cusname) THEN cusname = ''
  247. IF IsNull(thflag) THEN thflag = 0
  248. IF IsNull(otheramt) THEN otheramt = 0
  249. IF IsNull(damt) THEN damt = 0
  250. IF IsNull(relstr_1) THEN relstr_1 = ''
  251. IF IsNull(relstr_2) THEN relstr_2 = ''
  252. IF IsNull(relstr_3) THEN relstr_3 = ''
  253. IF IsNull(relint_1) THEN relint_1 = 0
  254. IF IsNull(relint_2) THEN relint_2 = 0
  255. IF IsNull(relint_3) THEN relint_3 = 0
  256. IF IsNull(relint_4) THEN relint_4 = 0
  257. IF IsNull(mrate) THEN mrate = 0
  258. IF IsNull(ifauto) THEN ifauto = 0
  259. IF IsNull(rel_address) THEN rel_address = ''
  260. IF IsNull(rel_tele) THEN rel_tele = ''
  261. IF IsNull(rel_fax) THEN rel_fax = ''
  262. IF IsNull(rel_rep) THEN rel_rep = ''
  263. IF IsNull(upname) THEN upname = ''
  264. IF IsNull(deptid) THEN deptid = 0
  265. IF IsNull(totalamt) THEN totalamt = 0
  266. IF IsNull(getamt) THEN getamt = 0
  267. IF IsNull(lsflag) THEN lsflag = 0
  268. IF IsNull(carcode) THEN carcode = ''
  269. IF IsNull(transcode) THEN transcode = ''
  270. IF IsNull(typeid) THEN typeid = 0
  271. IF IsNull(exchangeid) THEN exchangeid = 0
  272. IF IsNull(station_address) THEN station_address = ''
  273. IF it_newbegin = False And it_updatebegin = False THEN
  274. rslt = 0
  275. arg_msg = "非编辑状态不可以提交"
  276. GOTO ext
  277. END IF
  278. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
  279. //取得系统时间,借用操作员表
  280. IF commit_transaction.SQLCode <> 0 THEN
  281. rslt = 0
  282. arg_msg = "查询操作失败,日期 "
  283. GOTO ext
  284. END IF
  285. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  286. rslt = 0
  287. arg_msg = "没有正确出仓内容"
  288. GOTO ext
  289. END IF
  290. //yyx20150529发货单使用先确认后仓审模式在修改保存操作增加检查单据状态
  291. IF uo_option_confirmaudit_sale = 1 THEN
  292. IF billtype = 1 And outwareid > 0 And priceflag = 0 THEN
  293. SELECT priceflag INTO :li_priceflag
  294. FROM u_outware
  295. WHERE u_outware.outwareid = :outwareid
  296. And u_outware.scid = :scid Using commit_transaction;
  297. IF commit_transaction.SQLCode <> 0 THEN
  298. rslt = 0
  299. arg_msg = "查询单据确认状态操作失败"+"~n"+commit_transaction.SQLErrText
  300. GOTO ext
  301. END IF
  302. IF li_priceflag = 1 THEN
  303. arg_msg = '单据已经确认,不能保存,操作取消'
  304. rslt = 0
  305. GOTO ext
  306. ELSE
  307. SELECT count(*) INTO :ll_cnt_billtype21
  308. FROM u_outware
  309. WHERE u_outware.relid = :outwareid
  310. AND u_outware.scid = :scid
  311. And billtype = 21 Using commit_transaction;
  312. IF commit_transaction.SQLCode <> 0 THEN
  313. rslt = 0
  314. arg_msg = "查询单据是否已确认操作生成销售出仓单失败"+"~n"+commit_transaction.SQLErrText
  315. GOTO ext
  316. END IF
  317. IF ll_cnt_billtype21 > 0 THEN
  318. arg_msg = '单据已确认操作生成销售出仓单,不能保存,操作取消'
  319. rslt = 0
  320. GOTO ext
  321. END IF
  322. END IF
  323. END IF
  324. END IF
  325. //
  326. Int li_mustloca,li_nocheck_bjmx
  327. SELECT storagename,outtype,mustloca,nocheck_bjmx,ifmrp
  328. INTO :ls_storagename,:li_outtype,:li_mustloca,:li_nocheck_bjmx,:li_ifmrp
  329. FROM u_storage
  330. Where storageid = :storageid Using commit_transaction ;
  331. IF commit_transaction.SQLCode <> 0 THEN
  332. rslt = 0
  333. arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText
  334. GOTO ext
  335. END IF
  336. IF li_nocheck_bjmx = 0 THEN
  337. IF li_outtype <> 0 And billtype = 1 And flag = 0 THEN
  338. IF it_mxbt_mx = 0 THEN
  339. rslt = 0
  340. arg_msg = "没有正确包件明细"
  341. GOTO ext
  342. END IF
  343. END IF
  344. END IF
  345. //检查是否有该仓库的建立权限
  346. IF sys_user_storagestr_new <> '0' THEN
  347. IF Pos(sys_user_storagestr_new,','+String(storageid)+',') <= 0 THEN
  348. rslt = 0
  349. arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
  350. GOTO ext
  351. END IF
  352. END IF
  353. //
  354. IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
  355. rslt = 0
  356. arg_msg = "缺少出仓发生时间或不合理"
  357. GOTO ext
  358. END IF
  359. IF flag = 0 THEN
  360. Boolean lb_chk_balc = True
  361. IF sys_option_warebalc_checksale = 0 And billtype = 21 THEN //临时的,详见系统选项152
  362. lb_chk_balc = False
  363. END IF
  364. IF f_check_inoutdate(storageid,outdate,lb_chk_balc,arg_msg) = 0 THEN
  365. rslt = 0
  366. GOTO ext
  367. END IF
  368. END IF
  369. IF billtype = 1 Or billtype = 5 THEN
  370. SELECT name INTO :cusname
  371. FROM u_cust
  372. Where cusid = :cusid Using commit_transaction;
  373. IF commit_transaction.SQLCode <> 0 THEN
  374. rslt = 0
  375. arg_msg = "查询操作失败,客户资料"
  376. GOTO ext
  377. END IF
  378. IF billtype = 1 THEN
  379. IF relint_1 = 0 THEN
  380. arg_msg = '请选择结算方式'
  381. rslt = 0
  382. GOTO ext
  383. END IF
  384. cnt = 0
  385. SELECT count(*) INTO :cnt
  386. FROM cw_currency
  387. Where moneyid = :relint_2;
  388. IF commit_transaction.SQLCode <> 0 THEN
  389. arg_msg = '查询币种失败'
  390. rslt = 0
  391. GOTO ext
  392. END IF
  393. IF cnt = 0 THEN
  394. arg_msg = '币种资料不存在'
  395. rslt = 0
  396. GOTO ext
  397. END IF
  398. IF mrate = 0 THEN
  399. arg_msg = '币种汇率错误'
  400. rslt = 0
  401. GOTO ext
  402. END IF
  403. IF f_moneyid_rate_check(relint_2,mrate,arg_msg) = 0 THEN
  404. rslt = 0
  405. GOTO ext
  406. END IF
  407. END IF
  408. ELSEIF billtype = 4 Or billtype = 7 THEN
  409. SELECT name INTO :cusname
  410. FROM u_spt
  411. Where sptid = :cusid Using commit_transaction;
  412. IF commit_transaction.SQLCode <> 0 THEN
  413. rslt = 0
  414. arg_msg = "查询操作失败,加工商资料"
  415. GOTO ext
  416. END IF
  417. ELSEIF billtype = 3 THEN
  418. IF relid = 0 THEN
  419. arg_msg = '请选择领料工组'
  420. rslt = 0
  421. GOTO ext
  422. END IF
  423. IF relint_1 = 1 Or relint_1 = 2 THEN
  424. IF cusname = '' THEN
  425. arg_msg = '请输入原因'
  426. rslt = 0
  427. GOTO ext
  428. END IF
  429. END IF
  430. ELSEIF billtype = 8 THEN
  431. IF Trim(cusname) = '' Or IsNull(cusname) THEN
  432. rslt = 0
  433. arg_msg = "请输入出仓原因!"
  434. GOTO ext
  435. END IF
  436. END IF
  437. If (thflag = 1 Or (billtype = 3 And relint_1 = 2 )) And li_mustloca = 1 THEN
  438. //
  439. String ls_msg_loca
  440. Long ll_cnt_loca
  441. ll_cnt_loca = 0
  442. FOR i = 1 To it_mxbt
  443. IF Trim(outwaremx[i].Location) = '' THEN
  444. ll_cnt_loca++
  445. IF ll_cnt_loca <= 10 THEN
  446. IF Trim(ls_msg_loca) = '' THEN
  447. ls_msg_loca = ls_msg_loca + String(i)
  448. ELSE
  449. ls_msg_loca = ls_msg_loca + ','+String(i)
  450. END IF
  451. END IF
  452. END IF
  453. NEXT
  454. IF ll_cnt_loca > 0 THEN
  455. rslt = 0
  456. IF ll_cnt_loca <= 10 THEN
  457. arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'明细中第'+ls_msg_loca+'行没有填仓位,请检查'
  458. ELSE
  459. arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'其中第'+ls_msg_loca+'等'+String(ll_cnt_loca)+'行明细没有填仓位,请详细检查'
  460. END IF
  461. GOTO ext
  462. END IF
  463. END IF
  464. IF billtype = 1 And thflag = 0 And outwareid > 0 And uo_option_disuse_outware_sale = 1 THEN
  465. IF uof_disuse(scid,outwareid,0,arg_msg,False) = 0 THEN
  466. rslt = 0
  467. GOTO ext
  468. END IF
  469. END IF
  470. //检查冻结数
  471. IF uo_option_djqty_check = 1 And li_ifmrp = 1 And Not ( billtype = 3 And relint_1 = 4) THEN
  472. FOR i = 1 To it_mxbt
  473. FOR j = 1 To ll_mxcnt
  474. IF outwaremx[i].mtrlid = ll_mtrlid_arr[j] THEN
  475. ld_qty_arr[j] = ld_qty_arr[j] + outwaremx[i].qty
  476. GOTO _next_mx
  477. END IF
  478. NEXT
  479. ll_mxcnt++
  480. ll_mtrlid_arr[ll_mxcnt] = outwaremx[i].mtrlid
  481. ld_qty_arr[ll_mxcnt] = outwaremx[i].qty
  482. ls_mtrlcode_arr[ll_mxcnt] = outwaremx[i].mtrlcode
  483. _next_mx:
  484. NEXT
  485. FOR i = 1 To ll_mxcnt
  486. SELECT SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) )
  487. INTO :ld_djqty
  488. FROM u_OrderRqMtrl_scll INNER JOIN
  489. u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN
  490. uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND
  491. u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND
  492. u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND
  493. u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND
  494. u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND
  495. u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode
  496. WHERE (u_OrderRqMtrl_scll.wareqty <> 0) AND (u_Order_ml.Status NOT IN (3,5,6))
  497. AND u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0
  498. AND u_OrderRqMtrl_scll.MtrlID = :ll_mtrlid_arr[i]
  499. And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction;
  500. IF commit_transaction.SQLCode <> 0 THEN
  501. ld_djqty = 0
  502. END IF
  503. IF IsNull(ld_djqty) THEN ld_djqty = 0
  504. SELECT SUM(u_mtrlware.noallocqty)
  505. INTO :ld_noallocqty
  506. FROM u_mtrlware INNER JOIN
  507. u_storage ON u_mtrlware.storageid = u_storage.storageid
  508. WHERE (u_storage.inuse = 1)
  509. AND u_storage.ifmrp = 1
  510. AND u_mtrlware.mtrlid = :ll_mtrlid_arr[i]
  511. And u_mtrlware.scid = :scid Using commit_transaction;
  512. IF commit_transaction.SQLCode <> 0 THEN
  513. ld_noallocqty = 0
  514. END IF
  515. IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
  516. IF ld_djqty > ld_noallocqty - ld_qty_arr[i] THEN
  517. rslt = 0
  518. arg_msg = '物料['+ls_mtrlcode_arr[i]+']冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########')+',本次出仓数:'+String(ld_qty_arr[i],'#,##0.##########')
  519. GOTO ext
  520. END IF
  521. NEXT
  522. END IF
  523. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  524. IF outwareid = 0 THEN //新建
  525. ls_newid = f_sys_scidentity(scid,"u_outware","outwareid",arg_msg,True,id_sqlca)
  526. IF ls_newid <= 0 THEN
  527. rslt = 0
  528. GOTO ext
  529. END IF
  530. //取分部代号
  531. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  532. rslt = 0
  533. GOTO ext
  534. END IF
  535. //取得新单据编号
  536. CHOOSE CASE billtype
  537. CASE 1,2
  538. IF thflag = 0 THEN
  539. outwarecode = getid(scid,ls_sccode + 'XS',Date(server_dt),if_getid_ture,commit_transaction)
  540. ELSE
  541. IF relid = 0 THEN
  542. outwarecode = getid(scid,ls_sccode + 'XT',Date(server_dt),if_getid_ture,commit_transaction)
  543. ELSEIF relid = 1 THEN
  544. outwarecode = getid(scid,ls_sccode + 'QS',Date(server_dt),if_getid_ture,commit_transaction)
  545. END IF
  546. END IF
  547. CASE 3
  548. IF relint_1 = 0 THEN //生产领料
  549. outwarecode = getid(scid,ls_sccode + 'LL',Date(server_dt),if_getid_ture,commit_transaction)
  550. ELSEIF relint_1 = 1 THEN //超额发料单
  551. outwarecode = getid(scid,ls_sccode + 'BL',Date(server_dt),if_getid_ture,commit_transaction)
  552. ELSEIF relint_1 = 2 THEN //生产还料单
  553. outwarecode = getid(scid,ls_sccode + 'HL',Date(server_dt),if_getid_ture,commit_transaction)
  554. ELSEIF relint_1 = 3 THEN //其他领料
  555. outwarecode = getid(scid,ls_sccode + 'OL',Date(server_dt),if_getid_ture,commit_transaction)
  556. ELSEIF relint_1 = 4 THEN //发料单
  557. outwarecode = getid(scid,ls_sccode + 'FO',Date(server_dt),if_getid_ture,commit_transaction)
  558. ELSEIF relint_1 = 5 THEN //生产补料单
  559. outwarecode = getid(scid,ls_sccode + 'BU',Date(server_dt),if_getid_ture,commit_transaction)
  560. END IF
  561. CASE 4
  562. IF thflag = 0 THEN
  563. outwarecode = getid(scid,ls_sccode + 'KL',Date(server_dt),if_getid_ture,commit_transaction)
  564. ELSE
  565. outwarecode = getid(scid,ls_sccode + 'TL',Date(server_dt),if_getid_ture,commit_transaction)
  566. END IF
  567. CASE 5 //来料加工
  568. IF thflag = 0 THEN
  569. outwarecode = getid(scid,ls_sccode + 'XL',Date(server_dt),if_getid_ture,commit_transaction)
  570. ELSE
  571. outwarecode = getid(scid,ls_sccode + 'LT',Date(server_dt),if_getid_ture,commit_transaction)
  572. END IF
  573. CASE 6
  574. outwarecode = getid(scid,ls_sccode + 'SU',Date(server_dt),if_getid_ture,commit_transaction)
  575. CASE 7
  576. IF thflag = 0 THEN
  577. outwarecode = getid(scid,ls_sccode + 'KW',Date(server_dt),if_getid_ture,commit_transaction)
  578. ELSE
  579. outwarecode = getid(scid,ls_sccode + 'TW',Date(server_dt),if_getid_ture,commit_transaction)
  580. END IF
  581. CASE 8
  582. outwarecode = getid(scid,ls_sccode + 'CC',Date(server_dt),if_getid_ture,commit_transaction)
  583. CASE 9
  584. outwarecode = getid(scid,ls_sccode + 'PQ',Date(server_dt),if_getid_ture,commit_transaction)
  585. CASE 10
  586. outwarecode = getid(scid,ls_sccode + 'KF',Date(server_dt),if_getid_ture,commit_transaction)
  587. CASE 12
  588. outwarecode = getid(scid,ls_sccode + 'OC',Date(server_dt),if_getid_ture,commit_transaction)
  589. CASE 15
  590. outwarecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction)
  591. CASE 16
  592. outwarecode = getid(scid,ls_sccode + 'LC',Date(server_dt),if_getid_ture,commit_transaction)
  593. CASE 17
  594. outwarecode = getid(scid,ls_sccode + 'RO',Date(server_dt),if_getid_ture,commit_transaction)
  595. CASE 18
  596. outwarecode = getid(scid,ls_sccode + 'OA',Date(server_dt),if_getid_ture,commit_transaction)
  597. CASE 19
  598. outwarecode = getid(scid,ls_sccode + 'CO',Date(server_dt),if_getid_ture,commit_transaction)
  599. CASE 20
  600. outwarecode = getid(scid,ls_sccode + 'WO',Date(server_dt),if_getid_ture,commit_transaction)
  601. CASE 21
  602. outwarecode = getid(scid,ls_sccode + 'BO',Date(server_dt),if_getid_ture,commit_transaction)
  603. CASE 22
  604. outwarecode = getid(scid,ls_sccode + 'QO',Date(server_dt),if_getid_ture,commit_transaction)
  605. CASE 23
  606. outwarecode = getid(scid,ls_sccode + 'HO',Date(server_dt),if_getid_ture,commit_transaction)
  607. CASE 24
  608. outwarecode = getid(scid,ls_sccode + 'LY',Date(server_dt),if_getid_ture,commit_transaction)
  609. CASE 25
  610. outwarecode = getid(scid,ls_sccode + 'FW',Date(server_dt),if_getid_ture,commit_transaction)
  611. END CHOOSE
  612. IF outwarecode = "err" Or outwarecode = '' THEN
  613. outwarecode = ''
  614. rslt = 0
  615. arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText
  616. GOTO ext
  617. END IF
  618. INSERT INTO u_outware (
  619. scid,
  620. outwareid,
  621. outwarecode,
  622. billtype,
  623. relid,
  624. storageid,
  625. outdate,
  626. outrep,
  627. part,
  628. dscrp,
  629. cusid,
  630. cusname,
  631. thflag,
  632. opdate,
  633. opemp,
  634. relstr_1,
  635. relstr_2,
  636. relstr_3,
  637. relint_1,
  638. relint_2,
  639. relint_3,
  640. relint_4,
  641. otheramt,
  642. damt,
  643. rel_address,
  644. rel_tele,
  645. rel_fax,
  646. rel_rep,
  647. mrate,
  648. upname,
  649. ifauto,
  650. viewdate,
  651. deptid,
  652. totalamt,
  653. getamt,
  654. lsflag,
  655. carcode,
  656. transcode,
  657. typeid,
  658. exchangeid,
  659. station_address)
  660. VALUES (
  661. :scid,
  662. :ls_newid,
  663. :outwarecode,
  664. :billtype,
  665. :relid,
  666. :storageid,
  667. :outdate,
  668. :outrep,
  669. :part,
  670. :dscrp,
  671. :cusid,
  672. :cusname,
  673. :thflag,
  674. :server_dt,
  675. :publ_operator,
  676. :relstr_1,
  677. :relstr_2,
  678. :relstr_3,
  679. :relint_1,
  680. :relint_2,
  681. :relint_3,
  682. :relint_4,
  683. :otheramt,
  684. :damt,
  685. :rel_address,
  686. :rel_tele,
  687. :rel_fax,
  688. :rel_rep,
  689. :mrate,
  690. :upname,
  691. :ifauto,
  692. :viewdate,
  693. :deptid,
  694. :totalamt,
  695. :getamt,
  696. :lsflag,
  697. :carcode,
  698. :transcode,
  699. :typeid,
  700. :exchangeid,
  701. :station_address) Using commit_transaction ;
  702. IF commit_transaction.SQLCode <> 0 THEN
  703. rslt = 0
  704. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  705. GOTO ext
  706. END IF
  707. //读取新outwareid
  708. outwareid = ls_newid
  709. FOR i = 1 To it_mxbt
  710. //如果是发料单,计算实际超发数量
  711. IF billtype = 3 And relint_1 = 4 THEN
  712. IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN
  713. ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty
  714. ELSE
  715. ld_trueoverqty = 0
  716. END IF
  717. END IF
  718. INSERT INTO u_outwaremx
  719. (scid,
  720. outwareid,
  721. mtrlwareid,
  722. printid,
  723. mtrlid,
  724. plancode,
  725. status,
  726. qty,
  727. fprice,
  728. rebate,
  729. price,
  730. planprice,
  731. mxdscrp,
  732. sptid,
  733. dxflag,
  734. costamt,
  735. ifrel,
  736. relid,
  737. packqty,
  738. olmtrlid,
  739. woodcode,
  740. relcode,
  741. pcode,
  742. enprice,
  743. newpriceamt,
  744. outtypestr,
  745. dftsaleprice,
  746. cost,
  747. planqty,
  748. relprintid,
  749. unit,
  750. rate,
  751. uqty,
  752. storageid,
  753. scidprice,
  754. mtrlcuscode,
  755. location,
  756. pricetype,
  757. formula,
  758. capacity,
  759. saleqty,
  760. saleoutid,
  761. saleoutprintid,
  762. mxdscrp2,
  763. net_weight,
  764. gross_weight,
  765. cubage,
  766. taxrate,
  767. priceformula,
  768. qtyformula,
  769. enacprice,
  770. ifvqty,
  771. trueoverqty,
  772. backtype,
  773. ifnotinout)
  774. VALUES (
  775. :scid,
  776. :ls_newid,
  777. :outwaremx[i].mtrlwareid,
  778. :outwaremx[i].printid,
  779. :outwaremx[i].mtrlid,
  780. :outwaremx[i].plancode,
  781. :outwaremx[i].status,
  782. :outwaremx[i].qty,
  783. :outwaremx[i].fprice,
  784. :outwaremx[i].rebate,
  785. :outwaremx[i].price,
  786. :outwaremx[i].planprice,
  787. :outwaremx[i].mxdscrp,
  788. :outwaremx[i].sptid,
  789. :outwaremx[i].dxflag,
  790. :outwaremx[i].costamt,
  791. :outwaremx[i].ifrel,
  792. :outwaremx[i].relid,
  793. :outwaremx[i].packqty,
  794. :outwaremx[i].olmtrlid,
  795. :outwaremx[i].woodcode,
  796. :outwaremx[i].relcode,
  797. :outwaremx[i].pcode,
  798. :outwaremx[i].enprice,
  799. :outwaremx[i].newpriceamt,
  800. :outwaremx[i].outtype,
  801. :outwaremx[i].dftsaleprice,
  802. :outwaremx[i].cost,
  803. :outwaremx[i].planqty,
  804. :outwaremx[i].relprintid,
  805. :outwaremx[i].unit,
  806. :outwaremx[i].rate,
  807. :outwaremx[i].uqty,
  808. :outwaremx[i].storageid,
  809. :outwaremx[i].scidprice,
  810. :outwaremx[i].mtrlcuscode,
  811. :outwaremx[i].Location,
  812. :outwaremx[i].pricetype,
  813. :outwaremx[i].formula,
  814. :outwaremx[i].capacity,
  815. :outwaremx[i].qty,
  816. :outwaremx[i].saleoutid,
  817. :outwaremx[i].saleoutprintid,
  818. :outwaremx[i].mxdscrp2,
  819. :outwaremx[i].net_weight,
  820. :outwaremx[i].gross_weight,
  821. :outwaremx[i].cubage,
  822. :outwaremx[i].taxrate,
  823. :outwaremx[i].priceformula,
  824. :outwaremx[i].qtyformula,
  825. :outwaremx[i].enacprice,
  826. :outwaremx[i].ifvqty,
  827. :ld_trueoverqty,
  828. :outwaremx[i].backtype,
  829. :outwaremx[i].ifnotinout) Using commit_transaction;
  830. IF commit_transaction.SQLCode <> 0 THEN
  831. outwareid = 0 //还原outwareid
  832. rslt = 0
  833. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  834. GOTO ext
  835. END IF
  836. NEXT
  837. FOR i = 1 To it_mxbt_mx
  838. INSERT INTO u_outwaremx_mx
  839. (scid,
  840. outwareid,
  841. mtrlwareid,
  842. printid,
  843. mxprintid,
  844. mtrlid,
  845. plancode,
  846. status,
  847. qty,
  848. mxdscrp,
  849. sptid,
  850. dxflag,
  851. woodcode,
  852. pcode,
  853. planqty,
  854. storageid,
  855. mtrlcuscode,
  856. location,
  857. ifnotinout)
  858. VALUES (
  859. :scid,
  860. :ls_newid,
  861. :outwaremx_mx[i].mtrlwareid,
  862. :outwaremx_mx[i].printid,
  863. :outwaremx_mx[i].mxprintid,
  864. :outwaremx_mx[i].mtrlid,
  865. :outwaremx_mx[i].plancode,
  866. :outwaremx_mx[i].status,
  867. :outwaremx_mx[i].qty,
  868. :outwaremx_mx[i].mxdscrp,
  869. :outwaremx_mx[i].sptid,
  870. :outwaremx_mx[i].dxflag,
  871. :outwaremx_mx[i].woodcode,
  872. :outwaremx_mx[i].pcode,
  873. :outwaremx_mx[i].planqty,
  874. :outwaremx_mx[i].storageid,
  875. :outwaremx_mx[i].mtrlcuscode,
  876. :outwaremx_mx[i].Location,
  877. :outwaremx_mx[i].ifnotinout) Using commit_transaction;
  878. IF commit_transaction.SQLCode <> 0 THEN
  879. outwareid = 0 //还原outwareid
  880. rslt = 0
  881. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  882. GOTO ext
  883. END IF
  884. NEXT
  885. FOR i = 1 To it_mxbt_item
  886. INSERT INTO u_outware_itemmx
  887. (scid,
  888. outwareid,
  889. printid,
  890. itemid,
  891. amt,
  892. mxdscrp)
  893. VALUES (:scid,
  894. :ls_newid,
  895. :outware_itemmx[i].printid,
  896. :outware_itemmx[i].itemid,
  897. :outware_itemmx[i].amt,
  898. :outware_itemmx[i].mxdscrp) Using commit_transaction;
  899. IF commit_transaction.SQLCode <> 0 THEN
  900. outwareid = 0 //还原taskid
  901. rslt = 0
  902. arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
  903. GOTO ext
  904. END IF
  905. NEXT
  906. //增加已开单数
  907. IF billtype <> 21 And billtype <> 12 THEN
  908. IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
  909. rslt = 0
  910. GOTO ext
  911. END IF
  912. END IF
  913. IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN
  914. FOR i = 1 To it_mxbt
  915. If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN
  916. ins_ref_mxbt++
  917. ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
  918. ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
  919. ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
  920. ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
  921. END IF
  922. NEXT
  923. END IF
  924. ELSE //////////////////////////////////////////////// //更新
  925. // IF (billtype = 1 OR billtype = 5) AND sys_option_autowaste = 1 THEN
  926. // uo_outware_waste uo_waste
  927. // uo_waste = CREATE uo_outware_waste
  928. // uo_waste.commit_transaction = commit_transaction
  929. // IF uo_waste.insertwaste(1,scid,outwareid,arg_msg,FALSE) = 0 THEN
  930. // rslt = 0
  931. // GOTO ext
  932. // END IF
  933. // DESTROY uo_waste
  934. // END IF
  935. IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN
  936. ins_ref_mxbt = 1
  937. DECLARE cur_outwaremx_ori CURSOR FOR
  938. SELECT u_outwaremx.mtrlid,
  939. u_outwaremx.plancode,
  940. u_outwaremx.mtrlcuscode,
  941. u_outwaremx.storageid
  942. FROM u_outwaremx,u_mtrldef
  943. WHERE u_outwaremx.outwareid = :outwareid
  944. AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
  945. AND u_outwaremx.scid = :scid
  946. AND ( u_mtrldef.ifpack = 1 OR u_mtrldef.ifpack = 2 OR u_mtrldef.ifpackpro = 3 OR u_mtrldef.ifpackpro = 4 )
  947. Order By u_outwaremx.printid Using commit_transaction;
  948. OPEN cur_outwaremx_ori;
  949. FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid;
  950. DO WHILE sqlca.SQLCode = 0
  951. ins_ref_mxbt++
  952. FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid;
  953. LOOP
  954. CLOSE cur_outwaremx_ori;
  955. ins_ref_mxbt = ins_ref_mxbt - 1
  956. FOR i = 1 To it_mxbt
  957. If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN
  958. FOR j = 1 To ins_ref_mxbt
  959. IF ins_ref_outwaremx[j].mtrlid = outwaremx[i].mtrlid And ins_ref_outwaremx[j].plancode = outwaremx[i].plancode And ins_ref_outwaremx[j].mtrlcuscode = outwaremx[i].mtrlcuscode And ins_ref_outwaremx[j].storageid = storageid THEN
  960. GOTO _next_mtrl
  961. END IF
  962. NEXT
  963. ins_ref_mxbt++
  964. ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
  965. ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
  966. ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
  967. ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
  968. END IF
  969. _next_mtrl:
  970. NEXT
  971. END IF
  972. If (billtype > 1 And billtype <> 5 ) Or ((billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 0) THEN
  973. UPDATE u_outware
  974. SET billtype = :billtype,
  975. relid = :relid,
  976. storageid = :storageid,
  977. outdate = :outdate,
  978. outrep = :outrep,
  979. part = :part,
  980. dscrp = :dscrp,
  981. cusid = :cusid,
  982. cusname = :cusname,
  983. thflag = :thflag,
  984. moddate = :server_dt,
  985. modemp = :publ_operator,
  986. relstr_1 = :relstr_1,
  987. relstr_2 = :relstr_2,
  988. relstr_3 = :relstr_3,
  989. relint_1 = :relint_1,
  990. relint_2 = :relint_2,
  991. relint_3 = :relint_3,
  992. relint_4 = :relint_4,
  993. otheramt = :otheramt,
  994. damt = :damt,
  995. rel_address = :rel_address,
  996. rel_tele = :rel_tele,
  997. rel_fax = :rel_fax,
  998. rel_rep = :rel_rep,
  999. mrate = :mrate,
  1000. upname = :upname,
  1001. viewdate = :viewdate,
  1002. deptid = :deptid,
  1003. totalamt = :totalamt,
  1004. getamt = :getamt,
  1005. lsflag = :lsflag,
  1006. carcode = :carcode,
  1007. transcode = :transcode,
  1008. typeid = :typeid,
  1009. exchangeid = :exchangeid,
  1010. station_address = :station_address
  1011. WHERE u_outware.outwareid = :outwareid
  1012. AND u_outware.scid = :scid
  1013. And flag = 0 Using commit_transaction;
  1014. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  1015. rslt = 0
  1016. arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText
  1017. GOTO ext
  1018. END IF
  1019. //更新库存已开单数(减)
  1020. IF billtype <> 21 And billtype <> 12 THEN
  1021. IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
  1022. rslt = 0
  1023. GOTO ext
  1024. END IF
  1025. END IF
  1026. //删除原有明细
  1027. DELETE FROM u_outwaremx
  1028. WHERE u_outwaremx.outwareid = :outwareid
  1029. And u_outwaremx.scid = :scid Using commit_transaction;
  1030. IF commit_transaction.SQLCode <> 0 THEN
  1031. rslt = 0
  1032. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  1033. GOTO ext
  1034. END IF
  1035. FOR i = 1 To it_mxbt
  1036. //如果是发料单,计算实际超发数量
  1037. IF billtype = 3 And relint_1 = 4 THEN
  1038. IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN
  1039. ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty
  1040. ELSE
  1041. ld_trueoverqty = 0
  1042. END IF
  1043. END IF
  1044. INSERT INTO u_outwaremx
  1045. (scid,
  1046. outwareid,
  1047. mtrlwareid,
  1048. printid,
  1049. mtrlid,
  1050. plancode,
  1051. status,
  1052. qty,
  1053. fprice,
  1054. rebate,
  1055. price,
  1056. planprice,
  1057. mxdscrp,
  1058. sptid,
  1059. dxflag,
  1060. costamt,
  1061. ifrel,
  1062. relid,
  1063. packqty,
  1064. olmtrlid,
  1065. woodcode,
  1066. relcode,
  1067. pcode,
  1068. enprice,
  1069. newpriceamt,
  1070. outtypestr,
  1071. dftsaleprice,
  1072. cost,
  1073. planqty,
  1074. relprintid,
  1075. unit,
  1076. rate,
  1077. uqty,
  1078. storageid,
  1079. scidprice,
  1080. mtrlcuscode,
  1081. location,
  1082. pricetype,
  1083. formula,
  1084. capacity,
  1085. saleqty,
  1086. saleoutid,
  1087. saleoutprintid,
  1088. mxdscrp2,
  1089. net_weight,
  1090. gross_weight,
  1091. cubage,
  1092. taxrate,
  1093. priceformula,
  1094. qtyformula,
  1095. enacprice,
  1096. ifvqty,
  1097. trueoverqty,
  1098. backtype,
  1099. ifnotinout)
  1100. VALUES (
  1101. :scid,
  1102. :outwareid,
  1103. :outwaremx[i].mtrlwareid,
  1104. :outwaremx[i].printid,
  1105. :outwaremx[i].mtrlid,
  1106. :outwaremx[i].plancode,
  1107. :outwaremx[i].status,
  1108. :outwaremx[i].qty,
  1109. :outwaremx[i].fprice,
  1110. :outwaremx[i].rebate,
  1111. :outwaremx[i].price,
  1112. :outwaremx[i].planprice,
  1113. :outwaremx[i].mxdscrp,
  1114. :outwaremx[i].sptid,
  1115. :outwaremx[i].dxflag,
  1116. :outwaremx[i].costamt,
  1117. :outwaremx[i].ifrel,
  1118. :outwaremx[i].relid,
  1119. :outwaremx[i].packqty,
  1120. :outwaremx[i].olmtrlid,
  1121. :outwaremx[i].woodcode,
  1122. :outwaremx[i].relcode,
  1123. :outwaremx[i].pcode,
  1124. :outwaremx[i].enprice,
  1125. :outwaremx[i].newpriceamt,
  1126. :outwaremx[i].outtype,
  1127. :outwaremx[i].dftsaleprice,
  1128. :outwaremx[i].cost,
  1129. :outwaremx[i].planqty,
  1130. :outwaremx[i].relprintid,
  1131. :outwaremx[i].unit,
  1132. :outwaremx[i].rate,
  1133. :outwaremx[i].uqty,
  1134. :outwaremx[i].storageid,
  1135. :outwaremx[i].scidprice,
  1136. :outwaremx[i].mtrlcuscode,
  1137. :outwaremx[i].Location,
  1138. :outwaremx[i].pricetype,
  1139. :outwaremx[i].formula,
  1140. :outwaremx[i].capacity,
  1141. :outwaremx[i].qty,
  1142. :outwaremx[i].saleoutid,
  1143. :outwaremx[i].saleoutprintid,
  1144. :outwaremx[i].mxdscrp2,
  1145. :outwaremx[i].net_weight,
  1146. :outwaremx[i].gross_weight,
  1147. :outwaremx[i].cubage,
  1148. :outwaremx[i].taxrate,
  1149. :outwaremx[i].priceformula,
  1150. :outwaremx[i].qtyformula,
  1151. :outwaremx[i].enacprice,
  1152. :outwaremx[i].ifvqty,
  1153. :ld_trueoverqty,
  1154. :outwaremx[i].backtype,
  1155. :outwaremx[i].ifnotinout) Using commit_transaction;
  1156. IF commit_transaction.SQLCode <> 0 THEN
  1157. rslt = 0
  1158. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  1159. GOTO ext
  1160. END IF
  1161. NEXT
  1162. //删除原有明细
  1163. DELETE FROM u_outwaremx_mx
  1164. WHERE u_outwaremx_mx.outwareid = :outwareid
  1165. And u_outwaremx_mx.scid = :scid Using commit_transaction;
  1166. IF commit_transaction.SQLCode <> 0 THEN
  1167. rslt = 0
  1168. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  1169. GOTO ext
  1170. END IF
  1171. FOR i = 1 To it_mxbt_mx
  1172. INSERT INTO u_outwaremx_mx
  1173. (scid,
  1174. outwareid,
  1175. mtrlwareid,
  1176. printid,
  1177. mxprintid,
  1178. mtrlid,
  1179. plancode,
  1180. status,
  1181. qty,
  1182. mxdscrp,
  1183. sptid,
  1184. dxflag,
  1185. woodcode,
  1186. pcode,
  1187. planqty,
  1188. storageid,
  1189. mtrlcuscode,
  1190. location,
  1191. ifnotinout)
  1192. VALUES (
  1193. :scid,
  1194. :outwareid,
  1195. :outwaremx_mx[i].mtrlwareid,
  1196. :outwaremx_mx[i].printid,
  1197. :outwaremx_mx[i].mxprintid,
  1198. :outwaremx_mx[i].mtrlid,
  1199. :outwaremx_mx[i].plancode,
  1200. :outwaremx_mx[i].status,
  1201. :outwaremx_mx[i].qty,
  1202. :outwaremx_mx[i].mxdscrp,
  1203. :outwaremx_mx[i].sptid,
  1204. :outwaremx_mx[i].dxflag,
  1205. :outwaremx_mx[i].woodcode,
  1206. :outwaremx_mx[i].pcode,
  1207. :outwaremx_mx[i].planqty,
  1208. :outwaremx_mx[i].storageid,
  1209. :outwaremx_mx[i].mtrlcuscode,
  1210. :outwaremx_mx[i].Location,
  1211. :outwaremx_mx[i].ifnotinout) Using commit_transaction;
  1212. IF commit_transaction.SQLCode <> 0 THEN
  1213. outwareid = 0 //还原outwareid
  1214. rslt = 0
  1215. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  1216. GOTO ext
  1217. END IF
  1218. NEXT
  1219. DELETE FROM u_outware_itemmx
  1220. WHERE u_outware_itemmx.outwareid = :outwareid
  1221. And u_outware_itemmx.scid = :scid Using commit_transaction;
  1222. IF commit_transaction.SQLCode <> 0 THEN
  1223. rslt = 0
  1224. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  1225. GOTO ext
  1226. END IF
  1227. FOR i = 1 To it_mxbt_item
  1228. INSERT INTO u_outware_itemmx
  1229. (scid,
  1230. outwareid,
  1231. printid,
  1232. itemid,
  1233. amt,
  1234. mxdscrp)
  1235. VALUES (:scid,
  1236. :outwareid,
  1237. :outware_itemmx[i].printid,
  1238. :outware_itemmx[i].itemid,
  1239. :outware_itemmx[i].amt,
  1240. :outware_itemmx[i].mxdscrp) Using commit_transaction;
  1241. IF commit_transaction.SQLCode <> 0 THEN
  1242. outwareid = 0 //还原taskid
  1243. rslt = 0
  1244. arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
  1245. GOTO ext
  1246. END IF
  1247. NEXT
  1248. //增加已开单数
  1249. IF billtype <> 21 And billtype <> 12 THEN
  1250. IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
  1251. rslt = 0
  1252. GOTO ext
  1253. END IF
  1254. END IF
  1255. ElseIf (billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 1 THEN
  1256. UPDATE u_outware
  1257. SET billtype = :billtype,
  1258. relid = :relid,
  1259. storageid = :storageid,
  1260. outdate = :outdate,
  1261. outrep = :outrep,
  1262. part = :part,
  1263. dscrp = :dscrp,
  1264. cusid = :cusid,
  1265. cusname = :cusname,
  1266. thflag = :thflag,
  1267. moddate = :server_dt,
  1268. modemp = :publ_operator,
  1269. relstr_1 = :relstr_1,
  1270. relstr_2 = :relstr_2,
  1271. relstr_3 = :relstr_3,
  1272. relint_1 = :relint_1,
  1273. relint_2 = :relint_2,
  1274. otheramt = :otheramt,
  1275. damt = :damt,
  1276. rel_address = :rel_address,
  1277. rel_tele = :rel_tele,
  1278. rel_fax = :rel_fax,
  1279. rel_rep = :rel_rep,
  1280. mrate = :mrate,
  1281. upname = :upname,
  1282. viewdate = :viewdate,
  1283. deptid = :deptid,
  1284. carcode = :carcode,
  1285. transcode = :transcode,
  1286. typeid = :typeid,
  1287. exchangeid = :exchangeid,
  1288. station_address = :station_address
  1289. WHERE u_outware.outwareid = :outwareid
  1290. AND u_outware.scid = :scid
  1291. AND flag = 0
  1292. AND secflag = 0
  1293. And priceflag = 1 Using commit_transaction;
  1294. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  1295. rslt = 0
  1296. arg_msg = "因网络或其它原因导致更新单据操作失败(3)"+"~n"+commit_transaction.SQLErrText
  1297. GOTO ext
  1298. END IF
  1299. //更新库存已开单数(减)
  1300. IF billtype <> 21 And billtype <> 12 THEN
  1301. IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
  1302. rslt = 0
  1303. GOTO ext
  1304. END IF
  1305. END IF
  1306. FOR i = 1 To it_mxbt
  1307. UPDATE u_outWAREmx
  1308. SET qty = :outWAREmx[i].qty,
  1309. saleqty = :outwaremx[i].qty,
  1310. mxdscrp = :outwaremx[I].mxdscrp,
  1311. fprice = :outwaremx[I].fprice,
  1312. rebate = :outwaremx[I].rebate,
  1313. enprice = :outwaremx[I].enprice,
  1314. enacprice = :outwaremx[I].enacprice,
  1315. packqty = :outwaremx[I].packqty,
  1316. outtype = :outwaremx[I].outtype,
  1317. formula = :outwaremx[i].formula,
  1318. capacity = :outwaremx[i].capacity,
  1319. mxdscrp2 = :outwaremx[i].mxdscrp2,
  1320. net_weight = :outwaremx[i].net_weight,
  1321. gross_weight = :outwaremx[i].gross_weight,
  1322. cubage = :outwaremx[i].cubage,
  1323. taxrate = :outwaremx[i].taxrate,
  1324. priceformula = :outwaremx[i].priceformula,
  1325. qtyformula = :outwaremx[i].qtyformula
  1326. WHERE ( scid = :scid AND
  1327. outWAREid = :outwareid AND
  1328. printid = :outwaremx[i].printid);
  1329. IF commit_transaction.SQLCode <> 0 THEN
  1330. rslt = 0
  1331. arg_msg = "因网络或其它原因导致更新明细实发数操作失败"+"~n"+commit_transaction.SQLErrText
  1332. GOTO ext
  1333. END IF
  1334. NEXT
  1335. FOR i = 1 To it_mxbt_mx
  1336. UPDATE u_outwaremx_mx
  1337. SET qty = :outwaremx_mx[i].qty,
  1338. mxdscrp = :outwaremx_mx[I].mxdscrp
  1339. WHERE ( scid = :scid AND
  1340. outWAREid = :outwareid AND
  1341. printid = :outwaremx_mx[i].printid AND
  1342. mxprintid = :outwaremx_mx[i].mxprintid);
  1343. IF commit_transaction.SQLCode <> 0 THEN
  1344. rslt = 0
  1345. arg_msg = "因网络或其它原因导致更新应发明细实发数操作失败"+"~n"+commit_transaction.SQLErrText
  1346. GOTO ext
  1347. END IF
  1348. NEXT
  1349. DELETE FROM u_outware_itemmx
  1350. WHERE u_outware_itemmx.outwareid = :outwareid
  1351. And u_outware_itemmx.scid = :scid Using commit_transaction;
  1352. IF commit_transaction.SQLCode <> 0 THEN
  1353. rslt = 0
  1354. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  1355. GOTO ext
  1356. END IF
  1357. FOR i = 1 To it_mxbt_item
  1358. INSERT INTO u_outware_itemmx
  1359. (scid,
  1360. outwareid,
  1361. printid,
  1362. itemid,
  1363. amt,
  1364. mxdscrp)
  1365. VALUES (:scid,
  1366. :outwareid,
  1367. :outware_itemmx[i].printid,
  1368. :outware_itemmx[i].itemid,
  1369. :outware_itemmx[i].amt,
  1370. :outware_itemmx[i].mxdscrp) Using commit_transaction;
  1371. IF commit_transaction.SQLCode <> 0 THEN
  1372. rslt = 0
  1373. arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
  1374. GOTO ext
  1375. END IF
  1376. NEXT
  1377. //增加已开单数
  1378. IF billtype <> 21 And billtype <> 12 THEN
  1379. IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
  1380. rslt = 0
  1381. GOTO ext
  1382. END IF
  1383. END IF
  1384. ELSE
  1385. UPDATE u_outware
  1386. SET billtype = :billtype,
  1387. relid = :relid,
  1388. storageid = :storageid,
  1389. outdate = :outdate,
  1390. outrep = :outrep,
  1391. part = :part,
  1392. dscrp = :dscrp,
  1393. cusid = :cusid,
  1394. cusname = :cusname,
  1395. thflag = :thflag,
  1396. moddate = :server_dt,
  1397. modemp = :publ_operator,
  1398. relstr_1 = :relstr_1,
  1399. relstr_2 = :relstr_2,
  1400. relstr_3 = :relstr_3,
  1401. relint_1 = :relint_1,
  1402. relint_2 = :relint_2,
  1403. otheramt = :otheramt,
  1404. damt = :damt,
  1405. rel_address = :rel_address,
  1406. rel_tele = :rel_tele,
  1407. rel_fax = :rel_fax,
  1408. rel_rep = :rel_rep,
  1409. mrate = :mrate,
  1410. upname = :upname,
  1411. viewdate = :viewdate,
  1412. deptid = :deptid,
  1413. carcode = :carcode,
  1414. transcode = :transcode,
  1415. typeid = :typeid,
  1416. exchangeid = :exchangeid,
  1417. station_address = :station_address
  1418. WHERE u_outware.outwareid = :outwareid
  1419. AND u_outware.scid = :scid
  1420. AND flag = 1
  1421. And secflag = 0 Using commit_transaction;
  1422. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  1423. rslt = 0
  1424. arg_msg = "因网络或其它原因导致更新单据操作失败(2)"+"~n"+commit_transaction.SQLErrText
  1425. GOTO ext
  1426. END IF
  1427. FOR i = 1 To it_mxbt
  1428. UPDATE u_outWAREmx
  1429. SET price = :outWAREmx[i].price,
  1430. mxdscrp = :outwaremx[I].mxdscrp,
  1431. fprice = :outwaremx[I].fprice,
  1432. rebate = :outwaremx[I].rebate,
  1433. enprice = :outwaremx[I].enprice,
  1434. enacprice = :outwaremx[I].enacprice,
  1435. taxrate = :outwaremx[i].taxrate,
  1436. priceformula = :outwaremx[i].priceformula,
  1437. qtyformula = :outwaremx[i].qtyformula
  1438. WHERE ( scid = :scid AND
  1439. outWAREid = :outwareid AND
  1440. printid = :outwaremx[i].printid);
  1441. IF commit_transaction.SQLCode <> 0 THEN
  1442. rslt = 0
  1443. arg_msg = "因网络或其它原因导致更新明细价格操作失败"+"~n"+commit_transaction.SQLErrText
  1444. GOTO ext
  1445. END IF
  1446. NEXT
  1447. DELETE FROM u_outware_itemmx
  1448. WHERE u_outware_itemmx.outwareid = :outwareid
  1449. And u_outware_itemmx.scid = :scid Using commit_transaction;
  1450. IF commit_transaction.SQLCode <> 0 THEN
  1451. rslt = 0
  1452. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  1453. GOTO ext
  1454. END IF
  1455. FOR i = 1 To it_mxbt_item
  1456. INSERT INTO u_outware_itemmx
  1457. (scid,
  1458. outwareid,
  1459. printid,
  1460. itemid,
  1461. amt,
  1462. mxdscrp)
  1463. VALUES (:scid,
  1464. :outwareid,
  1465. :outware_itemmx[i].printid,
  1466. :outware_itemmx[i].itemid,
  1467. :outware_itemmx[i].amt,
  1468. :outware_itemmx[i].mxdscrp) Using commit_transaction;
  1469. IF commit_transaction.SQLCode <> 0 THEN
  1470. outwareid = 0 //还原taskid
  1471. rslt = 0
  1472. arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
  1473. GOTO ext
  1474. END IF
  1475. NEXT
  1476. END IF
  1477. END IF
  1478. it_newbegin = False
  1479. it_updatebegin = False
  1480. //
  1481. ext:
  1482. IF rslt = 0 THEN
  1483. ROLLBACK Using commit_transaction;
  1484. p_clearmx()
  1485. ELSEIF rslt = 1 And arg_ifcommit THEN
  1486. COMMIT Using commit_transaction;
  1487. END IF
  1488. RETURN rslt
  1489. end function
  1490. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1491. Long cnt = 0,i,j,mx_barcode_cnt
  1492. String ls_storagename
  1493. Int li_outtype,li_storagetype,li_if_pd_usebarcode
  1494. Decimal ld_sumnotoutqty,ld_sumnotoutqty_bill
  1495. s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
  1496. ins_ref_outwaremx = ins_empty_outwaremx
  1497. ins_ref_mxbt = 0
  1498. Long ll_taskid,ll_taskprintid
  1499. Decimal ld_assign_outqty,ld_outmx_qty
  1500. uo_sqlpro uo_pro
  1501. uo_pro = Create uo_sqlpro
  1502. uo_pro.commit_transaction = commit_transaction
  1503. uo_cmpl_packpro uo_cmpl_p
  1504. uo_cmpl_p = Create uo_cmpl_packpro
  1505. uo_cmpl_p.commit_transaction = commit_transaction
  1506. If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
  1507. rslt = 0
  1508. Goto ext
  1509. End If
  1510. If uo_option_inout_type = -1000 Then
  1511. rslt = 0
  1512. arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
  1513. Goto ext
  1514. End If
  1515. If uo_option_barcode_outwareother_paudit = -1000 Then
  1516. rslt = 0
  1517. arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!'
  1518. Goto ext
  1519. End If
  1520. uo_mtrlware_assign uo_ma
  1521. uo_ma = Create uo_mtrlware_assign
  1522. uo_ma.commit_transaction = commit_transaction
  1523. //库存分配ds
  1524. datastore ds_out_assign
  1525. ds_out_assign = Create datastore
  1526. If thflag = 0 Then
  1527. ds_out_assign.DataObject = 'ds_outwaremx_assign'
  1528. Else
  1529. ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
  1530. End If
  1531. ds_out_assign.SetTransObject(commit_transaction)
  1532. If outwareid = 0 Then
  1533. rslt = 0
  1534. arg_msg = "没有出仓审核对象"
  1535. Goto ext
  1536. End If
  1537. If storageid = 0 Then
  1538. rslt = 0
  1539. arg_msg = '没有正确的仓库'
  1540. Goto ext
  1541. End If
  1542. If billtype <> 9 Then
  1543. If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
  1544. rslt = 0
  1545. Goto ext
  1546. End If
  1547. End If
  1548. Select storagename,outtype,storagetype,if_pd_usebarcode
  1549. Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode
  1550. From u_storage
  1551. Where storageid = :storageid Using commit_transaction ;
  1552. If commit_transaction.SQLCode <> 0 Then
  1553. rslt = 0
  1554. arg_msg = "查询操作失败,仓库"
  1555. Goto ext
  1556. End If
  1557. //检查是否有该仓库的建立权限
  1558. If sys_user_storagestr_audit <> '0' Then
  1559. If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
  1560. rslt = 0
  1561. arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据'
  1562. Goto ext
  1563. End If
  1564. End If
  1565. //
  1566. If uo_option_inout_type = 2 And li_outtype = 2 And &
  1567. ( uo_option_barcode_outwareother_paudit = 1 And billtype = 8 ) Then
  1568. If priceflag = 0 Then
  1569. arg_msg = '单据未确认,不能审核'
  1570. rslt = 0
  1571. Goto ext
  1572. End If
  1573. End If
  1574. If flag = 1 Then
  1575. rslt = 0
  1576. arg_msg = "单据已经审核"
  1577. Goto ext
  1578. End If
  1579. If li_outtype = 2 Then
  1580. For i = 1 To it_mxbt
  1581. If outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
  1582. Next
  1583. If mx_barcode_cnt > 0 And ( billtype = 8 Or billtype = 9 And &
  1584. ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
  1585. If uof_check_qty_to_bqty(arg_msg) = 0 Then
  1586. rslt = 0
  1587. Goto ext
  1588. End If
  1589. End If
  1590. End If
  1591. Update u_outware
  1592. Set Auditingrep = :publ_operator,
  1593. Auditingdate = getdate(),
  1594. flag = 1
  1595. Where u_outware.outwareid = :outwareid
  1596. And flag = 0
  1597. And scid = :scid Using commit_transaction;
  1598. If commit_transaction.SQLCode <> 0 Then
  1599. rslt = 0
  1600. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1601. Goto ext
  1602. ElseIf commit_transaction.SQLNRows = 0 Then
  1603. rslt = 0
  1604. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1605. Goto ext
  1606. End If
  1607. For i = 1 To it_mxbt
  1608. Decimal ld_ref_costamt
  1609. // ld_ref_costamt = 0
  1610. If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,&
  1611. outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then
  1612. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  1613. rslt = 0
  1614. Goto ext
  1615. End If
  1616. If billtype <> 19 Then
  1617. //先取消分配再扣库存
  1618. //更新库存分配(销售出仓单包件出仓)
  1619. If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then
  1620. ll_taskid = 0
  1621. ll_taskprintid = 0
  1622. ld_assign_outqty = 0
  1623. Select u_outwaremx.relid,
  1624. u_outwaremx.relprintid
  1625. Into :ll_taskid,
  1626. :ll_taskprintid
  1627. From u_outwaremx
  1628. Where u_outwaremx.scid = :scid
  1629. And u_outwaremx.outwareid = :relid //发货单id
  1630. And u_outwaremx.printid = :outwaremx[i].olmtrlid
  1631. Using commit_transaction;
  1632. If commit_transaction.SQLCode <> 0 Then
  1633. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  1634. rslt = 0
  1635. Goto ext
  1636. End If
  1637. If ll_taskid > 0 Then
  1638. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  1639. If ds_out_assign.RowCount() > 0 Then
  1640. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  1641. Else
  1642. ld_sumnotoutqty = 0
  1643. End If
  1644. ld_sumnotoutqty_bill = 0
  1645. ld_sumnotoutqty_bill = outwaremx[i].qty
  1646. ds_out_assign.AcceptText()
  1647. If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
  1648. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细'
  1649. rslt = 0
  1650. Goto ext
  1651. Else
  1652. ld_assign_outqty = 0
  1653. For j = 1 To ds_out_assign.RowCount()
  1654. If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then
  1655. ld_assign_outqty = ld_sumnotoutqty_bill
  1656. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
  1657. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg
  1658. rslt = 0
  1659. Goto ext
  1660. End If
  1661. Exit
  1662. Else
  1663. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  1664. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
  1665. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg
  1666. rslt = 0
  1667. Goto ext
  1668. End If
  1669. ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j]
  1670. End If
  1671. Next
  1672. End If
  1673. End If
  1674. End If
  1675. If sys_option_inout_procedure = 0 Then
  1676. If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  1677. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  1678. outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  1679. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  1680. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
  1681. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  1682. rslt = 0
  1683. Goto ext
  1684. End If
  1685. Else
  1686. If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  1687. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  1688. outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  1689. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  1690. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  1691. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  1692. rslt = 0
  1693. Goto ext
  1694. End If
  1695. End If
  1696. //更新库存分配销售退货单
  1697. If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then
  1698. ll_taskid = 0
  1699. ll_taskprintid = 0
  1700. ld_assign_outqty = 0
  1701. Select u_outwaremx.relid,
  1702. u_outwaremx.relprintid
  1703. Into :ll_taskid,
  1704. :ll_taskprintid
  1705. From u_outwaremx
  1706. Where u_outwaremx.scid = :scid
  1707. And u_outwaremx.outwareid = :relid
  1708. And u_outwaremx.printid = :outwaremx[i].olmtrlid
  1709. Using commit_transaction;
  1710. If commit_transaction.SQLCode <> 0 Then
  1711. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  1712. rslt = 0
  1713. Goto ext
  1714. End If
  1715. If ll_taskid > 0 Then
  1716. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  1717. If ds_out_assign.RowCount() > 0 Then
  1718. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  1719. Else
  1720. ld_sumnotoutqty = 0
  1721. End If
  1722. ds_out_assign.AcceptText()
  1723. ld_outmx_qty = Abs(outwaremx[i].qty)
  1724. If ld_outmx_qty > ld_sumnotoutqty And ll_taskid > 0 Then
  1725. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细'
  1726. rslt = 0
  1727. Goto ext
  1728. Else
  1729. ld_assign_outqty = 0
  1730. For j = 1 To ds_out_assign.RowCount()
  1731. If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then
  1732. ld_assign_outqty = ld_outmx_qty
  1733. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
  1734. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
  1735. rslt = 0
  1736. Goto ext
  1737. End If
  1738. Exit
  1739. Else
  1740. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  1741. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
  1742. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
  1743. rslt = 0
  1744. Goto ext
  1745. End If
  1746. ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j]
  1747. End If
  1748. Next
  1749. End If
  1750. End If
  1751. End If
  1752. Else
  1753. If sys_option_inout_procedure = 0 Then
  1754. If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  1755. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  1756. outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  1757. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  1758. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  1759. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  1760. rslt = 0
  1761. Goto ext
  1762. End If
  1763. Else
  1764. If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  1765. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  1766. outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  1767. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  1768. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  1769. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  1770. rslt = 0
  1771. Goto ext
  1772. End If
  1773. End If
  1774. End If
  1775. //yyx2012-9-29返回计算可装数库存id数组
  1776. If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
  1777. If uo_option_noauditingqty_mode = 0 Then
  1778. If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
  1779. rslt = 0
  1780. Goto ext
  1781. End If
  1782. Else
  1783. ins_ref_mxbt++
  1784. ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
  1785. ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
  1786. ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
  1787. ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
  1788. End If
  1789. End If
  1790. //
  1791. Next
  1792. //更新条码
  1793. If li_outtype = 2 And &
  1794. mx_barcode_cnt > 0 And &
  1795. ( billtype <> 9 Or billtype = 9 And &
  1796. ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
  1797. If uof_p_barcode(1,arg_msg) = 0 Then
  1798. rslt = 0
  1799. Goto ext
  1800. End If
  1801. End If
  1802. //更新库存已开单数(减)
  1803. If billtype <> 21 And billtype <> 12 Then
  1804. If uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 Then
  1805. rslt = 0
  1806. Goto ext
  1807. End If
  1808. End If
  1809. //yyx2012-9-29返回计算可装数库存id数组计算可装数
  1810. If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
  1811. If uo_option_noauditingqty_mode = 0 Then
  1812. If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
  1813. rslt = 0
  1814. Goto ext
  1815. End If
  1816. End If
  1817. End If
  1818. //
  1819. flag = 1
  1820. ext:
  1821. If rslt = 0 Then
  1822. Rollback Using commit_transaction;
  1823. ElseIf rslt = 1 And arg_ifcommit Then
  1824. Commit Using commit_transaction;
  1825. End If
  1826. Destroy uo_ma
  1827. Destroy ds_out_assign
  1828. Destroy uo_pro
  1829. Destroy uo_cmpl_p
  1830. Return rslt
  1831. end function
  1832. public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1
  1833. IF uo_option_inout_type = -1000 THEN
  1834. rslt = 0
  1835. arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
  1836. GOTO ext
  1837. END IF
  1838. IF uo_option_barcode_outwareother_paudit= -1000 THEN
  1839. rslt = 0
  1840. arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!'
  1841. GOTO ext
  1842. END IF
  1843. IF uo_option_confirmaudit_sale = -1000 THEN
  1844. rslt = 0
  1845. arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
  1846. GOTO ext
  1847. END IF
  1848. IF uo_option_sale_use_planqty = -1000 THEN
  1849. rslt = 0
  1850. arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!'
  1851. GOTO ext
  1852. END IF
  1853. IF arg_scid < 0 THEN
  1854. arg_msg = '请选择分部'
  1855. rslt = 0
  1856. GOTO ext
  1857. END IF
  1858. IF arg_outwareid <= 0 THEN
  1859. rslt = 0
  1860. GOTO ext
  1861. END IF
  1862. IF Not (arg_billtype = 1 OR &
  1863. arg_billtype = 2 OR &
  1864. arg_billtype = 3 OR &
  1865. arg_billtype = 4 OR &
  1866. arg_billtype = 5 OR &
  1867. arg_billtype = 6 OR &
  1868. arg_billtype = 7 OR &
  1869. arg_billtype = 8 OR &
  1870. arg_billtype = 9 OR &
  1871. arg_billtype = 10 OR &
  1872. arg_billtype = 12 OR &
  1873. arg_billtype = 15 OR &
  1874. arg_billtype = 16 OR &
  1875. arg_billtype = 17 or &
  1876. arg_billtype = 18 or &
  1877. arg_billtype = 19 or &
  1878. arg_billtype = 20 or &
  1879. arg_billtype = 21 or &
  1880. arg_billtype = 22 or &
  1881. arg_billtype = 23 or &
  1882. arg_billtype = 24 or &
  1883. arg_billtype = 25) THEN
  1884. rslt = 0
  1885. arg_msg = '此单据类型必须为:'
  1886. arg_msg = arg_msg+'1-销售单[记帐模式],'
  1887. arg_msg = arg_msg+'2-销售单[不记帐模式],'
  1888. arg_msg = arg_msg+'3-领料出仓单,'
  1889. arg_msg = arg_msg+'4-外加工出仓单,'
  1890. arg_msg = arg_msg+'5-来料加工发货,'
  1891. arg_msg = arg_msg+'6-售后服务出仓单,'
  1892. arg_msg = arg_msg+'7-外协销售出仓单,'
  1893. arg_msg = arg_msg+'8-其他出仓单,'
  1894. arg_msg = arg_msg+'9-盘亏出仓单,'
  1895. arg_msg = arg_msg+'10-工具出仓单,'
  1896. arg_msg = arg_msg+'12-调拨出仓单,'
  1897. arg_msg = arg_msg+'15-拆装出仓单,'
  1898. arg_msg = arg_msg+'16-生产进仓车间自动出仓(未分配),'
  1899. arg_msg = arg_msg+'17-还货出仓单,'
  1900. arg_msg = arg_msg+'18-自动组装出仓单,'
  1901. arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)'
  1902. arg_msg = arg_msg+'20-车间库存转换自动出仓单'
  1903. arg_msg = arg_msg+'21-销售发货单包件明细自动出仓单'
  1904. arg_msg = arg_msg+'22-欠货终止单自动出仓单'
  1905. arg_msg = arg_msg+'23-采购收货单收货明细自动出仓单'
  1906. arg_msg = arg_msg+'24-员工物品领用单'
  1907. arg_msg = arg_msg+'25-发料损耗自动出仓单'
  1908. GOTO ext
  1909. END IF
  1910. IF arg_billtype = 12 THEN
  1911. rslt = 0
  1912. arg_msg = '单据类型:12-调拨出仓>>不能修改'
  1913. GOTO ext
  1914. END IF
  1915. IF arg_billtype = 17 THEN
  1916. rslt = 0
  1917. arg_msg = '单据类型:17-还货出仓单>>不能修改'
  1918. GOTO ext
  1919. END IF
  1920. IF arg_billtype = 18 THEN
  1921. rslt = 0
  1922. arg_msg = '单据类型:18-自动组装出仓单>>不能修改'
  1923. GOTO ext
  1924. END IF
  1925. rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
  1926. IF rslt = 0 THEN GOTO ext
  1927. IF uo_option_inout_type = 2 AND &
  1928. ( uo_option_barcode_outwareother_paudit = 1 AND arg_billtype = 8 ) THEN
  1929. IF priceflag = 1 THEN
  1930. arg_msg = '单据已确认,不能修改'
  1931. rslt = 0
  1932. GOTO ext
  1933. END IF
  1934. END IF
  1935. String ls_storagename
  1936. SELECT storagename
  1937. INTO :ls_storagename
  1938. FROM u_storage
  1939. Where storageid = :storageid USING commit_transaction ;
  1940. IF commit_transaction.SQLCode <> 0 THEN
  1941. rslt = 0
  1942. arg_msg = "查询操作失败,仓库"
  1943. GOTO ext
  1944. END IF
  1945. //检查是否有该仓库的建立权限
  1946. IF sys_user_storagestr_new <> '0' THEN
  1947. IF Pos(sys_user_storagestr_new,','+String(storageid)+',') <= 0 THEN
  1948. rslt = 0
  1949. arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许修改该仓库的单据'
  1950. GOTO ext
  1951. END IF
  1952. END IF
  1953. //
  1954. IF arg_billtype = 1 THEN
  1955. IF uo_option_confirmaudit_sale = 1 AND uo_option_sale_use_planqty = 1 THEN
  1956. IF priceflag = 1 AND flag = 1 AND secflag = 1 THEN
  1957. rslt = 0
  1958. arg_msg = '单据已经过仓库及财务审核,不可以修改'
  1959. GOTO ext
  1960. ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
  1961. rslt = 0
  1962. arg_msg = '单据已经确认,仓审前不可以修改'
  1963. GOTO ext
  1964. END IF
  1965. ELSE
  1966. IF flag = 1 AND secflag = 1 THEN
  1967. rslt = 0
  1968. arg_msg = '单据已经过仓库及财务审核,不可以修改'
  1969. GOTO ext
  1970. ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
  1971. rslt = 0
  1972. arg_msg = '单据已经确认,仓审前不可以修改'
  1973. GOTO ext
  1974. END IF
  1975. END IF
  1976. ELSEIF arg_billtype = 5 THEN
  1977. IF flag = 1 AND secflag = 1 THEN
  1978. rslt = 0
  1979. arg_msg = '单据已经过仓库及财务审核,不可以修改'
  1980. GOTO ext
  1981. ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
  1982. rslt = 0
  1983. arg_msg = '单据已经确认,仓审前不可以修改,不可以修改'
  1984. GOTO ext
  1985. END IF
  1986. ELSE
  1987. IF flag = 1 THEN
  1988. rslt = 0
  1989. arg_msg = '单据已经审核,不可以修改'
  1990. GOTO ext
  1991. END IF
  1992. END IF
  1993. outwareid = arg_outwareid
  1994. billtype = arg_billtype
  1995. scid = arg_scid
  1996. it_newbegin = FALSE
  1997. it_updatebegin = TRUE
  1998. p_clearmx() //清除明细
  1999. ext:
  2000. IF rslt = 0 THEN p_reset()
  2001. RETURN rslt
  2002. end function
  2003. public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg)
  2004. //0 失败 1成功
  2005. Int rslt = 1
  2006. Long i = 1,no_mxcheck = 0,j = 1,no_mxcheck_barcode = 0,k = 1,l = 1,ll_i
  2007. Int li_outtype
  2008. Decimal ld_planprice
  2009. sum_amt = 0
  2010. sum_amt_en = 0
  2011. sum_taxamt = 0
  2012. sum_taxamt_en = 0
  2013. IF arg_outwareid <= 0 THEN
  2014. rslt = 0
  2015. arg_msg = "非法出仓单唯一码"
  2016. GOTO ext
  2017. END IF
  2018. rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
  2019. IF rslt = 0 THEN GOTO ext
  2020. SELECT outtype
  2021. INTO :li_outtype
  2022. FROM u_storage
  2023. Where storageid = :storageid Using commit_transaction ;
  2024. IF commit_transaction.SQLCode <> 0 THEN
  2025. rslt = 0
  2026. arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText
  2027. GOTO ext
  2028. END IF
  2029. //用游标读取明细
  2030. DECLARE cur_outwaremx CURSOR FOR
  2031. SELECT u_outwaremx.printid,
  2032. u_outwaremx.mtrlid,
  2033. u_outwaremx.plancode,
  2034. u_outwaremx.status,
  2035. u_outwaremx.qty,
  2036. u_outwaremx.fprice,
  2037. u_outwaremx.rebate,
  2038. u_outwaremx.price,
  2039. u_outwaremx.mxdscrp,
  2040. u_mtrldef.mtrlcode,
  2041. u_outwaremx.sptid,
  2042. u_outwaremx.dxflag,
  2043. u_outwaremx.mtrlwareid,
  2044. u_outwaremx.storageid,
  2045. u_outwaremx.costamt,
  2046. u_outwaremx.ifrel,
  2047. u_outwaremx.relid,
  2048. u_outwaremx.olmtrlid,
  2049. u_outwaremx.packqty,
  2050. u_outwaremx.woodcode,
  2051. u_outwaremx.pcode,
  2052. u_outwaremx.enprice,
  2053. u_outwaremx.newpriceamt,
  2054. u_outwaremx.outtypestr,
  2055. u_outwaremx.dftsaleprice,
  2056. u_outwaremx.cost,
  2057. u_outwaremx.planqty,
  2058. u_outwaremx.relprintid,
  2059. u_outwaremx.relcode,
  2060. u_outwaremx.unit,
  2061. u_outwaremx.rate,
  2062. u_outwaremx.uqty,
  2063. u_outwaremx.overqty,
  2064. u_outwaremx.mtrlcuscode,
  2065. u_outwaremx.location,
  2066. u_outwaremx.pricetype,
  2067. u_outwaremx.formula,
  2068. u_outwaremx.capacity,
  2069. u_mtrldef.ifpackpro,
  2070. u_mtrldef.ifpack,
  2071. u_mtrldef.outtype,
  2072. u_outwaremx.saleqty,
  2073. u_outwaremx.saleoutid,
  2074. u_outwaremx.saleoutprintid,
  2075. u_outwaremx.mxdscrp2,
  2076. u_outwaremx.net_weight,
  2077. u_outwaremx.gross_weight,
  2078. u_outwaremx.cubage,
  2079. u_outwaremx.taxrate,
  2080. u_outwaremx.priceformula,
  2081. u_outwaremx.qtyformula,
  2082. u_mtrldef.iffp,
  2083. u_outwaremx.enacprice,
  2084. u_outwaremx.ifvqty,
  2085. u_outwaremx.backtype,
  2086. u_outwaremx.ifnotinout
  2087. FROM u_outwaremx,u_mtrldef,u_outware
  2088. WHERE u_outware.outwareid = :arg_outwareid AND
  2089. u_outwaremx.mtrlid = u_mtrldef.mtrlid AND
  2090. u_outware.scid = :arg_scid AND
  2091. u_outware.outwareid = u_outwaremx.outwareid AND
  2092. u_outware.scid = u_outwaremx.scid
  2093. Order By u_outwaremx.printid Using commit_transaction;
  2094. OPEN cur_outwaremx;
  2095. FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
  2096. :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
  2097. :outwaremx[i].rebate,:outwaremx[i].price,
  2098. :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
  2099. :outwaremx[i].sptid,:outwaremx[i].dxflag,
  2100. :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
  2101. :outwaremx[i].costamt,:outwaremx[i].ifrel,
  2102. :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
  2103. :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
  2104. :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
  2105. :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode,
  2106. :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty,
  2107. :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula,
  2108. :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl,
  2109. :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid,
  2110. :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage,
  2111. :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp,
  2112. :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout;
  2113. DO WHILE commit_transaction.SQLCode = 0
  2114. sum_amt = sum_amt + Round( (outwaremx[i].saleqty * outwaremx[i].price) / ( 1 + outwaremx[i].taxrate) ,2) //计算单据总金额
  2115. sum_amt_en = sum_amt_en + Round((outwaremx[i].saleqty * outwaremx[i].enacprice) / ( 1 + outwaremx[i].taxrate),2) //计算单据总金额
  2116. sum_taxamt = sum_taxamt + Round( ( outwaremx[i].saleqty * outwaremx[i].price * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate) ,2)
  2117. sum_taxamt_en = sum_taxamt_en + Round( (outwaremx[i].saleqty * outwaremx[i].enacprice * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate),2)
  2118. i++
  2119. FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
  2120. :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
  2121. :outwaremx[i].rebate,:outwaremx[i].price,
  2122. :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
  2123. :outwaremx[i].sptid,:outwaremx[i].dxflag,
  2124. :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
  2125. :outwaremx[i].costamt,:outwaremx[i].ifrel,
  2126. :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
  2127. :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
  2128. :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
  2129. :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode,
  2130. :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty,
  2131. :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula,
  2132. :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl,
  2133. :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid,
  2134. :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage,
  2135. :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp,
  2136. :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout;
  2137. LOOP
  2138. CLOSE cur_outwaremx;
  2139. //检验明细是否读入完整
  2140. SELECT count(*) INTO :no_mxcheck
  2141. FROM u_outwaremx
  2142. WHERE u_outwaremx.outwareid = :arg_outwareid
  2143. And scid = :arg_scid Using commit_transaction;
  2144. IF commit_transaction.SQLCode <> 0 THEN
  2145. rslt = 0
  2146. arg_msg = "查询操作失败,出仓单明细数量"
  2147. GOTO ext
  2148. END IF
  2149. IF i <> (no_mxcheck+1) THEN
  2150. rslt = 0
  2151. arg_msg = "查询操作失败,出仓单明细"
  2152. GOTO ext
  2153. END IF
  2154. //取计划价
  2155. FOR ll_i = 1 To i - 1
  2156. ld_planprice = 0
  2157. f_get_planprice_mtrl(outwaremx[ll_i].mtrlid,outwaremx[ll_i].status,outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode,ld_planprice)
  2158. IF IsNull(ld_planprice) THEN ld_planprice = 0
  2159. outwaremx[ll_i].planprice = ld_planprice
  2160. NEXT
  2161. DECLARE cur_outwaremx_mx CURSOR FOR
  2162. SELECT u_outwaremx_mx.printid, u_outwaremx_mx.mxprintid,
  2163. u_outwaremx_mx.mtrlwareid, u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid,
  2164. u_outwaremx_mx.plancode, u_outwaremx_mx.status, u_outwaremx_mx.woodcode,
  2165. u_outwaremx_mx.pcode, u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location,
  2166. u_outwaremx_mx.sptid, u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty,
  2167. u_outwaremx_mx.qty, u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ifnotinout,
  2168. u_mtrldef.ifpackpro, u_mtrldef.ifpack,u_mtrldef.mtrlcode
  2169. FROM u_outwaremx_mx INNER JOIN
  2170. u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
  2171. WHERE u_outwaremx_mx.scid = :arg_scid
  2172. AND u_outwaremx_mx.outwareid = :arg_outwareid
  2173. Order By u_outwaremx_mx.mxprintid Using commit_transaction;
  2174. OPEN cur_outwaremx_mx;
  2175. FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid,
  2176. :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid,
  2177. :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode,
  2178. :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location,
  2179. :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty,
  2180. :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout,
  2181. :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode;
  2182. DO WHILE commit_transaction.SQLCode = 0
  2183. j++
  2184. FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid,
  2185. :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid,
  2186. :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode,
  2187. :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location,
  2188. :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty,
  2189. :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout,
  2190. :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode;
  2191. LOOP
  2192. CLOSE cur_outwaremx_mx;
  2193. SELECT count(*) INTO :no_mxcheck
  2194. FROM u_outwaremx_mx
  2195. WHERE u_outwaremx_mx.outwareid = :arg_outwareid
  2196. And scid = :arg_scid Using commit_transaction;
  2197. IF commit_transaction.SQLCode <> 0 THEN
  2198. rslt = 0
  2199. arg_msg = "查询操作失败,出仓单应发明细数量"
  2200. GOTO ext
  2201. END IF
  2202. IF j <> (no_mxcheck+1) THEN
  2203. rslt = 0
  2204. arg_msg = "查询操作失败,出仓单应发明细"
  2205. GOTO ext
  2206. END IF
  2207. //用游标读取条码明细
  2208. IF li_outtype = 2 THEN
  2209. DECLARE cur_outwaremx_barcode CURSOR FOR
  2210. SELECT u_outwaremx_mx_barcode.barcode,
  2211. u_outwaremx_mx_barcode.qty,
  2212. u_mtrlware_mx.packqty,
  2213. u_mtrlware_mx.mtrlwareid,
  2214. u_outwaremx_mx_barcode.qty * u_mtrlware_mx.packqty
  2215. FROM u_outwaremx_mx_barcode,u_mtrlware_mx
  2216. WHERE u_outwaremx_mx_barcode.barcode = u_mtrlware_mx.barcode AND
  2217. u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
  2218. u_outwaremx_mx_barcode.scid = :arg_scid AND
  2219. u_outwaremx_mx_barcode.billtype = :billtype
  2220. Order By u_outwaremx_mx_barcode.barcode Using commit_transaction;
  2221. OPEN cur_outwaremx_barcode;
  2222. FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,
  2223. :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty;
  2224. DO WHILE commit_transaction.SQLCode = 0
  2225. k++
  2226. FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,
  2227. :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty;
  2228. LOOP
  2229. CLOSE cur_outwaremx_barcode;
  2230. //检验明细是否读入完整
  2231. SELECT count(*) INTO :no_mxcheck_barcode
  2232. FROM u_outwaremx_mx_barcode
  2233. WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  2234. AND u_outwaremx_mx_barcode.scid = :arg_scid
  2235. And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction;
  2236. IF commit_transaction.SQLCode <> 0 THEN
  2237. rslt = 0
  2238. arg_msg = "查询操作失败,出仓单明细数量"
  2239. GOTO ext
  2240. END IF
  2241. IF k <> (no_mxcheck_barcode+1) THEN
  2242. rslt = 0
  2243. arg_msg = "查询操作失败,出仓单条码明细"
  2244. GOTO ext
  2245. END IF
  2246. it_mxbt_barcode = k - 1
  2247. END IF
  2248. //读取来料加工订单费用明细
  2249. DECLARE cur_outware_itemmx CURSOR FOR
  2250. SELECT scid, outwareid, printid, itemid, amt, mxdscrp,IsCusAmt
  2251. FROM u_outware_itemmx
  2252. WHERE outwareid = :arg_outwareid
  2253. AND scid = :arg_scid
  2254. Using commit_transaction;
  2255. OPEN cur_outware_itemmx;
  2256. FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid,
  2257. :outware_itemmx[l].printid,:outware_itemmx[l].itemid,
  2258. :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp,
  2259. :outware_itemmx[l].IsCusAmt;
  2260. DO WHILE commit_transaction.SQLCode = 0
  2261. l++
  2262. FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid,
  2263. :outware_itemmx[l].printid,:outware_itemmx[l].itemid,
  2264. :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp,
  2265. :outware_itemmx[l].IsCusAmt;
  2266. LOOP
  2267. CLOSE cur_outware_itemmx;
  2268. //检验明细是否读入完整
  2269. SELECT count(*) INTO :no_mxcheck
  2270. FROM u_outware_itemmx
  2271. Where outwareid = :arg_outwareid And scid = :arg_scid Using commit_transaction;
  2272. IF commit_transaction.SQLCode <> 0 THEN
  2273. rslt = 0
  2274. arg_msg = "查询操作失败,费用明细数量"
  2275. GOTO ext
  2276. END IF
  2277. IF l <> (no_mxcheck+1) THEN
  2278. rslt = 0
  2279. arg_msg = "查询操作失败,费用明细"
  2280. GOTO ext
  2281. END IF
  2282. it_mxbt_item = l - 1
  2283. outwareid = arg_outwareid
  2284. scid = arg_scid
  2285. it_mxbt = i - 1
  2286. it_mxbt_mx = j - 1
  2287. it_mxbt_barcode = k - 1
  2288. it_newbegin = False
  2289. it_updatebegin = False
  2290. ext:
  2291. IF rslt = 0 THEN p_reset()
  2292. RETURN rslt
  2293. end function
  2294. public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
  2295. IF uo_option_confirmaudit_sale = -1000 THEN
  2296. rslt = 0
  2297. arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
  2298. GOTO ext
  2299. END IF
  2300. arg_newdescppart = Trim(arg_newdescppart)
  2301. IF it_updatebegin OR it_newbegin THEN
  2302. rslt = 0
  2303. arg_msg = "编辑状态下不可用"
  2304. GOTO ext
  2305. END IF
  2306. IF arg_newdescppart = '' THEN
  2307. rslt = 0
  2308. arg_msg = "要添加内容为空,操作取消"
  2309. GOTO ext
  2310. END IF
  2311. rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
  2312. IF rslt = 0 THEN GOTO ext
  2313. IF billtype = 1 and uo_option_confirmaudit_sale = 1 THEN
  2314. IF priceflag = 0 THEN
  2315. rslt = 0
  2316. arg_msg = "单据未确认,不能增备注"
  2317. GOTO ext
  2318. END IF
  2319. ELSE
  2320. IF flag = 0 THEN
  2321. rslt = 0
  2322. arg_msg = "非审核状态下不可用"
  2323. GOTO ext
  2324. END IF
  2325. END IF
  2326. UPDATE u_outware
  2327. SET dscrp = dscrp+' '+:arg_newdescppart
  2328. WHERE outwareid = :outwareid
  2329. AND scid = :scid USING commit_transaction;
  2330. IF commit_transaction.SQLCode <> 0 THEN
  2331. ROLLBACK ;
  2332. rslt = 0
  2333. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  2334. GOTO ext
  2335. END IF
  2336. COMMIT USING commit_transaction;
  2337. dscrp = dscrp+' '+arg_newdescppart
  2338. ext: Return (rslt)
  2339. end function
  2340. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  2341. Long cnt = 0,i,j,mx_barcode_cnt
  2342. String ls_storagename
  2343. Int li_outtype,li_storagetype,li_if_pd_usebarcode
  2344. Decimal ld_sumnotoutqty
  2345. Decimal ld_assign_outqty,ld_outmx_qty,ld_sumnotoutqty_bill
  2346. Long ll_taskid,ll_taskprintid
  2347. DateTime null_dt
  2348. SetNull(null_dt)
  2349. s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
  2350. uo_sqlpro uo_pro
  2351. uo_pro = Create uo_sqlpro
  2352. uo_pro.commit_transaction = commit_transaction
  2353. uo_cmpl_packpro uo_cmpl_p
  2354. uo_cmpl_p = Create uo_cmpl_packpro
  2355. uo_cmpl_p.commit_transaction = commit_transaction
  2356. ins_ref_outwaremx = ins_empty_outwaremx
  2357. ins_ref_mxbt = 0
  2358. If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
  2359. rslt = 0
  2360. Goto ext
  2361. End If
  2362. uo_mtrlware_assign uo_ma
  2363. uo_ma = Create uo_mtrlware_assign
  2364. uo_ma.commit_transaction = commit_transaction
  2365. //库存分配ds
  2366. datastore ds_out_assign
  2367. ds_out_assign = Create datastore
  2368. If thflag = 0 Then
  2369. ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
  2370. Else
  2371. ds_out_assign.DataObject = 'ds_outwaremx_assign'
  2372. End If
  2373. ds_out_assign.SetTransObject(commit_transaction)
  2374. If storageid = 0 Then
  2375. rslt = 0
  2376. arg_msg = '没有正确的仓库'
  2377. Goto ext
  2378. End If
  2379. If billtype <> 9 And Not (billtype = 3 And Pos(dscrp,'电脑生成的') > 0 And Pos(dscrp,'的领料单') > 0) Then
  2380. If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
  2381. rslt = 0
  2382. Goto ext
  2383. End If
  2384. End If
  2385. Select storagename,outtype,storagetype,if_pd_usebarcode
  2386. Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode
  2387. From u_storage
  2388. Where storageid = :storageid Using commit_transaction ;
  2389. If commit_transaction.SQLCode <> 0 Then
  2390. rslt = 0
  2391. arg_msg = "查询操作失败,仓库"
  2392. Goto ext
  2393. End If
  2394. //检查是否有该仓库的建立权限
  2395. If sys_user_storagestr_audit <> '0' Then
  2396. If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
  2397. rslt = 0
  2398. arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据'
  2399. Goto ext
  2400. End If
  2401. End If
  2402. //
  2403. If outwareid = 0 Then
  2404. rslt = 0
  2405. arg_msg = "没有出仓撤审对象"
  2406. Goto ext
  2407. End If
  2408. If ctmint > 0 Then
  2409. arg_msg = '单据已截数,不能操作'
  2410. rslt = 0
  2411. Goto ext
  2412. End If
  2413. If flag = 0 Then
  2414. rslt = 0
  2415. arg_msg = "单据还未审核"
  2416. Goto ext
  2417. End If
  2418. If balcflag = 1 Then
  2419. rslt = 0
  2420. arg_msg = "单据已经日结,不能撤审"
  2421. Goto ext
  2422. End If
  2423. Update u_outware
  2424. Set Auditingrep = '',
  2425. Auditingdate = :null_dt,
  2426. flag = 0
  2427. Where u_outware.outwareid = :outwareid
  2428. And flag = 1
  2429. And secflag = 0
  2430. And scid = :scid Using commit_transaction;
  2431. If commit_transaction.SQLCode <> 0 Then
  2432. rslt = 0
  2433. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  2434. Goto ext
  2435. ElseIf commit_transaction.SQLNRows = 0 Then
  2436. rslt = 0
  2437. arg_msg = "单据正在撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  2438. Goto ext
  2439. End If
  2440. For i = 1 To it_mxbt
  2441. If billtype <> 19 Then
  2442. //销售退货单更新分配明细
  2443. If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then
  2444. ll_taskid = 0
  2445. ll_taskprintid = 0
  2446. ld_assign_outqty = 0
  2447. Select u_outwaremx.relid,
  2448. u_outwaremx.relprintid
  2449. Into :ll_taskid,
  2450. :ll_taskprintid
  2451. From u_outwaremx
  2452. Where u_outwaremx.scid = :scid
  2453. And u_outwaremx.outwareid = :relid //发货单id
  2454. And u_outwaremx.printid = :outwaremx[i].olmtrlid
  2455. Using commit_transaction;
  2456. If commit_transaction.SQLCode <> 0 Then
  2457. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  2458. rslt = 0
  2459. Goto ext
  2460. End If
  2461. If ll_taskid > 0 Then
  2462. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  2463. If ds_out_assign.RowCount() > 0 Then
  2464. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  2465. Else
  2466. ld_sumnotoutqty = 0
  2467. End If
  2468. ld_sumnotoutqty_bill = 0
  2469. ld_sumnotoutqty_bill = Abs(outwaremx[i].qty)
  2470. ds_out_assign.AcceptText()
  2471. If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
  2472. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细'
  2473. rslt = 0
  2474. Goto ext
  2475. Else
  2476. ld_assign_outqty = 0
  2477. For j = 1 To ds_out_assign.RowCount()
  2478. If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then
  2479. ld_assign_outqty = ld_sumnotoutqty_bill
  2480. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
  2481. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
  2482. rslt = 0
  2483. Goto ext
  2484. End If
  2485. Exit
  2486. Else
  2487. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  2488. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
  2489. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
  2490. rslt = 0
  2491. Goto ext
  2492. End If
  2493. ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j]
  2494. End If
  2495. Next
  2496. End If
  2497. End If
  2498. End If
  2499. If sys_option_inout_procedure = 0 Then
  2500. If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  2501. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  2502. outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  2503. outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
  2504. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
  2505. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2506. rslt = 0
  2507. Goto ext
  2508. End If
  2509. Else
  2510. If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  2511. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  2512. 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  2513. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  2514. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  2515. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2516. rslt = 0
  2517. Goto ext
  2518. End If
  2519. End If
  2520. //发货单更新库存分配
  2521. If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then
  2522. ll_taskid = 0
  2523. ll_taskprintid = 0
  2524. ld_assign_outqty = 0
  2525. Select u_outwaremx.relid,
  2526. u_outwaremx.relprintid
  2527. Into :ll_taskid,
  2528. :ll_taskprintid
  2529. From u_outwaremx
  2530. Where u_outwaremx.scid = :scid
  2531. And u_outwaremx.outwareid = :relid
  2532. And u_outwaremx.printid = :outwaremx[i].olmtrlid
  2533. Using commit_transaction;
  2534. If commit_transaction.SQLCode <> 0 Then
  2535. arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售出仓单明细行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  2536. rslt = 0
  2537. Goto ext
  2538. End If
  2539. If ll_taskid > 0 Then
  2540. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  2541. If ds_out_assign.RowCount() > 0 Then
  2542. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  2543. Else
  2544. ld_sumnotoutqty = 0
  2545. End If
  2546. ds_out_assign.AcceptText()
  2547. ld_outmx_qty = outwaremx[i].qty
  2548. If ld_outmx_qty > ld_sumnotoutqty Then
  2549. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细'
  2550. rslt = 0
  2551. Goto ext
  2552. Else
  2553. ld_assign_outqty = 0
  2554. For j = 1 To ds_out_assign.RowCount()
  2555. If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then
  2556. ld_assign_outqty = ld_outmx_qty
  2557. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
  2558. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2559. rslt = 0
  2560. Goto ext
  2561. End If
  2562. Exit
  2563. Else
  2564. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  2565. If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
  2566. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2567. rslt = 0
  2568. Goto ext
  2569. End If
  2570. ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j]
  2571. End If
  2572. Next
  2573. End If
  2574. End If
  2575. End If
  2576. Else
  2577. If sys_option_inout_procedure = 0 Then
  2578. If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  2579. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  2580. outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  2581. outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
  2582. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  2583. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2584. rslt = 0
  2585. Goto ext
  2586. End If
  2587. Else
  2588. If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  2589. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  2590. 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  2591. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  2592. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
  2593. arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
  2594. rslt = 0
  2595. Goto ext
  2596. End If
  2597. End If
  2598. End If
  2599. If li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
  2600. //yyx2012-9-29返回计算可装数库存id数组
  2601. If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
  2602. If uo_option_noauditingqty_mode = 0 Then
  2603. If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
  2604. rslt = 0
  2605. Goto ext
  2606. End If
  2607. Else
  2608. ins_ref_mxbt++
  2609. ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
  2610. ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
  2611. ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
  2612. ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
  2613. End If
  2614. End If
  2615. //
  2616. Next
  2617. //更新条码
  2618. If li_outtype = 2 And &
  2619. mx_barcode_cnt > 0 And &
  2620. ( billtype <> 9 Or billtype = 9 And &
  2621. ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
  2622. If uof_p_barcode(0,arg_msg) = 0 Then
  2623. rslt = 0
  2624. Goto ext
  2625. End If
  2626. End If
  2627. //增加已开单数
  2628. If billtype <> 21 And billtype <> 12 Then
  2629. If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then
  2630. rslt = 0
  2631. Goto ext
  2632. End If
  2633. End If
  2634. //yyx2012-9-29返回计算可装数库存id数组计算可装数
  2635. If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
  2636. If uo_option_noauditingqty_mode = 0 Then
  2637. If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
  2638. rslt = 0
  2639. Goto ext
  2640. End If
  2641. End If
  2642. End If
  2643. //
  2644. flag = 0
  2645. ext:
  2646. If rslt = 0 Then
  2647. Rollback Using commit_transaction;
  2648. ElseIf rslt = 1 And arg_ifcommit Then
  2649. Commit Using commit_transaction;
  2650. End If
  2651. Destroy uo_ma
  2652. Destroy ds_out_assign
  2653. Destroy uo_pro
  2654. Destroy uo_cmpl_p
  2655. Return rslt
  2656. end function
  2657. public function integer p_clearmx ();//int p_clearmx()
  2658. //清除明细
  2659. it_mxbt = 0
  2660. it_mxbt_mx = 0
  2661. it_mxbt_barcode = 0
  2662. it_mxbt_item = 0
  2663. RETURN 1
  2664. end function
  2665. public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  2666. //0 失败 1成功
  2667. Int rslt = 1
  2668. IF arg_outwareid <= 0 THEN
  2669. rslt = 0
  2670. arG_MSG = "非法出仓单唯一码"
  2671. GOTO ext
  2672. END IF
  2673. SELECT u_outware.outwarecode,
  2674. u_outware.billtype,
  2675. u_outware.relid,
  2676. u_outware.storageid,
  2677. u_outware.outdate,
  2678. u_outware.outrep,
  2679. u_outware.part,
  2680. u_outware.cusid,
  2681. u_outware.cusname,
  2682. u_outware.dscrp,
  2683. u_outware.thflag,
  2684. u_outware.flag,
  2685. u_outware.secflag,
  2686. u_outware.balcflag,
  2687. u_outware.relstr_1,
  2688. u_outware.relstr_2,
  2689. u_outware.relstr_3,
  2690. u_outware.relint_1,
  2691. u_outware.relint_2,
  2692. u_outware.relint_3,
  2693. u_outware.priceflag,
  2694. u_outware.otheramt,
  2695. u_outware.damt,
  2696. u_outware.rel_address,
  2697. u_outware.rel_tele,
  2698. u_outware.rel_fax,
  2699. u_outware.rel_rep,
  2700. u_outware.mrate,
  2701. u_outware.upname,
  2702. u_outware.ctmint,
  2703. u_outware.ifauto,
  2704. u_outware.viewdate,
  2705. u_outware.deptid,
  2706. u_outware.carcode,
  2707. u_outware.transcode,
  2708. u_outware.pda_flag,
  2709. u_outware.pda_date,
  2710. u_outware.typeid,
  2711. u_outware.exchangeid,
  2712. u_outware.balcdateint,
  2713. u_outware.relint_4,
  2714. u_outware.station_address
  2715. INTO :outwarecode,
  2716. :billtype,
  2717. :relid,
  2718. :storageid,
  2719. :outdate,
  2720. :outrep,
  2721. :part,
  2722. :cusid,
  2723. :cusname,
  2724. :dscrp,
  2725. :thflag,
  2726. :flag,
  2727. :secflag,
  2728. :balcflag,
  2729. :relstr_1,
  2730. :relstr_2,
  2731. :relstr_3,
  2732. :relint_1,
  2733. :relint_2,
  2734. :relint_3,
  2735. :priceflag,
  2736. :otheramt,
  2737. :damt,
  2738. :rel_address,
  2739. :rel_tele,
  2740. :rel_fax,
  2741. :rel_rep,
  2742. :mrate,
  2743. :upname,
  2744. :ctmint,
  2745. :ifauto,
  2746. :viewdate,
  2747. :deptid,
  2748. :carcode,
  2749. :transcode,
  2750. :pda_flag,
  2751. :pda_date,
  2752. :typeid,
  2753. :exchangeid,
  2754. :balcdateint,
  2755. :relint_4,
  2756. :station_address
  2757. FROM u_outware
  2758. WHERE u_outware.outwareid = :arg_outwareid
  2759. AND scid = :arg_scid USING commit_transaction;
  2760. IF commit_transaction.SQLCode <> 0 THEN
  2761. rslt = 0
  2762. arG_MSG = "查询操作失败(错误出仓单唯一码),出仓单,"+string(arg_outwareid)+','+string(commit_transaction.SQLCode)+'~n'+commit_transaction.SQLErrText
  2763. GOTO ext
  2764. END IF
  2765. outwareid = arg_outwareid
  2766. scid = arg_scid
  2767. ext:
  2768. IF rslt = 0 THEN p_reset()
  2769. RETURN rslt
  2770. end function
  2771. public function integer p_reset ();//int p_reset()
  2772. //清除对象及其明细
  2773. scid = 0
  2774. outwareid = 0
  2775. outwarecode = ''
  2776. billtype = 0
  2777. opemp = ''
  2778. modemp = ''
  2779. auditingrep = ''
  2780. secauditingrep = ''
  2781. flag = 0
  2782. secflag = 0
  2783. relid = 0
  2784. storageid = 0
  2785. outrep = ''
  2786. part = ''
  2787. dscrp = ''
  2788. cusid = 0
  2789. cusname = ''
  2790. thflag = 0
  2791. otheramt = 0
  2792. damt = 0
  2793. rel_address = ''
  2794. rel_tele = ''
  2795. rel_fax = ''
  2796. rel_rep= ''
  2797. deptid = 0
  2798. station_address = ''
  2799. exchangeid = 0
  2800. balcdateint = 0
  2801. relint_4 = 0
  2802. carcode = ''
  2803. transcode = ''
  2804. typeid = 0
  2805. it_newbegin = FALSE
  2806. it_updatebegin = FALSE
  2807. //清除明细
  2808. p_clearmx()
  2809. RETURN 1
  2810. end function
  2811. public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  2812. Decimal ld_cost,ld_cost_cmpl,ld_noallocqty,ld_wareamt
  2813. Long ll_storagescid
  2814. SELECT scid INTO :ll_storagescid
  2815. FROM u_storage
  2816. Where storageid = :storageid Using commit_transaction;
  2817. IF commit_transaction.SQLCode <> 0 THEN
  2818. rslt = 0
  2819. arg_msg = '查询仓库分部失败'+ commit_transaction.SQLErrText
  2820. GOTO ext
  2821. END IF
  2822. //yyx2012-9-21 storageid = :storageid 这个无用
  2823. //SELECT cost INTO :ld_cost
  2824. // FROM u_mtrlware
  2825. // WHERE storageid = :storageid
  2826. // AND mtrlwareid = :arg_mtrlwareid
  2827. // AND scid = :ll_storagescid USING commit_transaction;
  2828. //IF commit_transaction.SQLCode <> 0 THEN
  2829. // arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
  2830. // rslt = 0
  2831. // GOTO ext
  2832. //END IF
  2833. SELECT u_mtrlware.cost,u_mtrlware.noallocqty,u_mtrlware.wareamt
  2834. INTO :ld_cost,:ld_noallocqty,:ld_wareamt
  2835. FROM u_mtrlware
  2836. WHERE u_mtrlware.mtrlwareid = :arg_mtrlwareid
  2837. And u_mtrlware.scid = :ll_storagescid Using commit_transaction;
  2838. IF commit_transaction.SQLCode <> 0 THEN
  2839. arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
  2840. rslt = 0
  2841. GOTO ext
  2842. END IF
  2843. //yyx2013-8-31
  2844. IF ld_noallocqty = 0 THEN
  2845. ld_cost = ld_cost
  2846. ELSE
  2847. ld_cost_cmpl = Round(ld_wareamt/ld_noallocqty,uo_option_cost_dec)
  2848. IF ld_cost <> ld_cost_cmpl THEN
  2849. ld_cost = ld_cost_cmpl
  2850. END IF
  2851. END IF
  2852. //yyx2013-8-31_end
  2853. arg_ref_costamt = Round(ld_cost * arg_qty ,2)
  2854. UPDATE u_outwaremx
  2855. SET costamt = :arg_ref_costamt,
  2856. cost = :ld_cost
  2857. WHERE scid = :scid
  2858. AND outwareid = :outwareid
  2859. And printid = :arg_printid Using commit_transaction;
  2860. IF commit_transaction.SQLCode <> 0 THEN
  2861. arg_msg = '更新'+arg_mtrlcode+'出仓成本价失败,'+commit_transaction.SQLErrText
  2862. rslt = 0
  2863. GOTO ext
  2864. END IF
  2865. IF billtype = 3 Or &
  2866. billtype = 4 Or &
  2867. billtype = 8 Or &
  2868. billtype = 9 Or &
  2869. billtype = 12 Or &
  2870. billtype = 24 THEN
  2871. UPDATE u_outwaremx
  2872. SET u_outwaremx.fprice = :ld_cost,
  2873. u_outwaremx.price = :ld_cost
  2874. WHERE scid = :scid
  2875. AND outwareid = :outwareid
  2876. And printid = :arg_printid Using commit_transaction;
  2877. IF commit_transaction.SQLCode <> 0 THEN
  2878. arg_msg = '更新'+arg_mtrlcode+'出仓面价失败,'+commit_transaction.SQLErrText
  2879. rslt = 0
  2880. GOTO ext
  2881. END IF
  2882. END IF
  2883. ext:
  2884. IF rslt = 0 THEN
  2885. ROLLBACK Using commit_transaction;
  2886. ELSEIF rslt = 1 And arg_ifcommit THEN
  2887. COMMIT Using commit_transaction;
  2888. END IF
  2889. RETURN rslt
  2890. end function
  2891. public function integer del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
  2892. //0 FAIL, 1 SUCCESS
  2893. Int rslt = 1
  2894. Long i
  2895. s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
  2896. ins_ref_outwaremx = ins_empty_outwaremx
  2897. ins_ref_mxbt = 0
  2898. If uo_option_disuse_outware_sale = -1000 Then
  2899. rslt = 0
  2900. arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!'
  2901. Goto ext
  2902. End If
  2903. If uo_option_confirmaudit_sale = -1000 Then
  2904. rslt = 0
  2905. arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
  2906. Goto ext
  2907. End If
  2908. If uo_option_confirmaudit_scll = -1000 Then
  2909. rslt = 0
  2910. arg_msg = '选项:[006]生产领料单先确认后审核,读取初始默认值失败,操作取消!'
  2911. Goto ext
  2912. End If
  2913. If arg_outwareid <= 0 Then
  2914. rslt = 0
  2915. arg_msg = "没有删除对象,操作取消"
  2916. Goto ext
  2917. End If
  2918. If getinfo(arg_scid,arg_outwareid,arg_msg) = 0 Then
  2919. rslt = 0
  2920. Goto ext
  2921. End If
  2922. //IF ( billtype = 1 or billtype = 5 ) AND uo_option_autowaste = 1 THEN
  2923. // uo_outware_waste uo_waste
  2924. // uo_waste = CREATE uo_outware_waste
  2925. // uo_waste.commit_transaction = commit_transaction
  2926. // IF uo_waste.insertwaste(0,arg_scid,arg_outwareid,arG_MSG,FALSE) = 0 THEN
  2927. // rslt = 0
  2928. // GOTO ext
  2929. // END IF
  2930. //
  2931. // DESTROY uo_waste
  2932. //END IF
  2933. If ( billtype = 1 Or billtype = 5 ) And uo_option_confirmaudit_sale = 1 Then
  2934. If priceflag = 1 Then
  2935. arg_msg = '单据已确认,不能删除'
  2936. rslt = 0
  2937. Goto ext
  2938. End If
  2939. End If
  2940. If billtype = 3 And relint_1 = 0 And uo_option_confirmaudit_scll = 1 Then
  2941. If priceflag = 1 Then
  2942. arg_msg = '单据已确认,不能删除'
  2943. rslt = 0
  2944. Goto ext
  2945. End If
  2946. End If
  2947. If flag = 1 Then
  2948. rslt = 0
  2949. arg_msg = "单据已经审核,不可以删除"
  2950. Goto ext
  2951. End If
  2952. If arg_ifcheck_auto = 1 Then
  2953. If ifauto = 1 Then
  2954. rslt = 0
  2955. arg_msg = '单据为动建立的单据,不可以删除'
  2956. Goto ext
  2957. End If
  2958. End If
  2959. If billtype = 1 And thflag = 0 And uo_option_disuse_outware_sale = 1 Then
  2960. If uof_disuse(arg_scid,arg_outwareid,1,arg_msg,False) = 0 Then
  2961. rslt = 0
  2962. Goto ext
  2963. End If
  2964. End If
  2965. If uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 Then
  2966. For i = 1 To it_mxbt
  2967. If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) Then
  2968. ins_ref_mxbt++
  2969. ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
  2970. ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
  2971. ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
  2972. ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
  2973. End If
  2974. Next
  2975. End If
  2976. //更新库存已开单数(减)
  2977. If billtype <> 21 And billtype <> 12 Then
  2978. If uof_noauditingqty_del(arg_scid,arg_outwareid,arg_msg) = 0 Then
  2979. rslt = 0
  2980. Goto ext
  2981. End If
  2982. End If
  2983. Delete From u_outware
  2984. Where u_outware.outwareid = :arg_outwareid
  2985. And u_outware.scid = :arg_scid
  2986. Using commit_transaction;
  2987. If commit_transaction.SQLCode <> 0 Then
  2988. rslt = 0
  2989. arg_msg = "删除出仓单操作失败"+"~n"+commit_transaction.SQLErrText
  2990. Goto ext
  2991. End If
  2992. Delete From u_outwaremx
  2993. Where u_outwaremx.outwareid = :arg_outwareid
  2994. And u_outwaremx.scid = :arg_scid Using commit_transaction;
  2995. If commit_transaction.SQLCode <> 0 Then
  2996. rslt = 0
  2997. arg_msg = "删除出仓单明细操作失败"+"~n"+commit_transaction.SQLErrText
  2998. Goto ext
  2999. End If
  3000. Delete From u_outwaremx_mx
  3001. Where u_outwaremx_mx.outwareid = :arg_outwareid
  3002. And u_outwaremx_mx.scid = :arg_scid Using commit_transaction;
  3003. If commit_transaction.SQLCode <> 0 Then
  3004. rslt = 0
  3005. arg_msg = "删除出仓单应发明细操作失败"+"~n"+commit_transaction.SQLErrText
  3006. Goto ext
  3007. End If
  3008. Delete From u_outwaremx_mx_barcode
  3009. Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  3010. And u_outwaremx_mx_barcode.scid = :arg_scid
  3011. And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction;
  3012. If commit_transaction.SQLCode <> 0 Then
  3013. rslt = 0
  3014. arg_msg = "删除出仓单条码明细操作失败"+"~n"+commit_transaction.SQLErrText
  3015. Goto ext
  3016. End If
  3017. Delete From u_outware_itemmx
  3018. Where u_outware_itemmx.outwareid = :arg_outwareid
  3019. And u_outware_itemmx.scid = :arg_scid Using commit_transaction;
  3020. If commit_transaction.SQLCode <> 0 Then
  3021. rslt = 0
  3022. arg_msg = "删除出仓单费用明细操作失败"+"~n"+commit_transaction.SQLErrText
  3023. Goto ext
  3024. End If
  3025. it_newbegin = False
  3026. it_updatebegin = False
  3027. ext:
  3028. If rslt = 0 Then
  3029. Rollback Using commit_transaction;
  3030. p_reset()
  3031. ElseIf rslt = 1 And arg_ifcommit Then
  3032. Commit Using commit_transaction;
  3033. End If
  3034. Return (rslt)
  3035. end function
  3036. public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg);Int rslt = 1
  3037. Long ls_newid
  3038. Decimal ld_cost
  3039. Int li_storMtrlprp
  3040. Long ll_storagescid
  3041. Int li_ifunit
  3042. Int li_statusflag
  3043. Decimal ld_capacity,ld_capacity_zj
  3044. s_mtrlcfg_expr s_pz[]
  3045. String ls_status_zj
  3046. Long ll_i
  3047. Int li_ifpack
  3048. Int if_recmp_balc
  3049. Int li_ifcost
  3050. IF sys_if_recmp_balc < 0 THEN
  3051. SELECT if_recmp_balc
  3052. INTO :if_recmp_balc
  3053. From sys_msg Using commit_transaction ;
  3054. IF commit_transaction.SQLCode <> 0 THEN
  3055. arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText
  3056. rslt = 0
  3057. GOTO ext
  3058. END IF
  3059. IF if_recmp_balc = 0 THEN
  3060. rslt = 0
  3061. arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
  3062. GOTO ext
  3063. END IF
  3064. ELSE
  3065. IF sys_if_recmp_balc = 0 THEN
  3066. rslt = 0
  3067. arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
  3068. GOTO ext
  3069. END IF
  3070. END IF
  3071. IF uo_option_change_status = '-1000' THEN
  3072. rslt = 0
  3073. arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
  3074. GOTO ext
  3075. END IF
  3076. IF uo_option_change_woodcode = '-1000' THEN
  3077. rslt = 0
  3078. arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
  3079. GOTO ext
  3080. END IF
  3081. IF uo_option_change_pcode = '-1000' THEN
  3082. rslt = 0
  3083. arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
  3084. GOTO ext
  3085. END IF
  3086. IF uo_option_cost_dec = -1000 THEN
  3087. rslt = 0
  3088. arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!'
  3089. GOTO ext
  3090. END IF
  3091. SELECT Mtrlprp,scid,ifcost INTO :li_storMtrlprp,:ll_storagescid,:li_ifcost
  3092. FROM u_storage
  3093. Where storageid = :arg_storageid Using commit_transaction ;
  3094. IF commit_transaction.SQLCode <> 0 THEN
  3095. arg_msg = '查询仓库信息失败'
  3096. rslt = 0
  3097. GOTO ext
  3098. END IF
  3099. SELECT ifunit,ifpack,capacity,statusflag
  3100. INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag
  3101. FROM u_mtrldef
  3102. Where mtrlid = :arg_mtrlid Using commit_transaction ;
  3103. IF commit_transaction.SQLCode <> 0 THEN
  3104. arg_msg = '查询物料信息失败'
  3105. rslt = 0
  3106. GOTO ext
  3107. END IF
  3108. IF li_statusflag = 2 THEN
  3109. ld_capacity = 0
  3110. f_checkpz(arg_status,s_pz[])
  3111. FOR ll_i = 1 To UpperBound(s_pz)
  3112. ls_status_zj = s_pz[ll_i].cfgname
  3113. SELECT capacity
  3114. INTO :ld_capacity_zj
  3115. FROM u_mtrl_configure
  3116. WHERE mtrlid = :arg_mtrlid
  3117. And Name = :ls_status_zj;
  3118. IF commit_transaction.SQLCode <> 0 THEN
  3119. ld_capacity_zj = 0
  3120. END IF
  3121. ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
  3122. NEXT
  3123. END IF
  3124. Int li_ifupdate_date
  3125. String ls_str
  3126. String or_err_part
  3127. IF billtype = 1 Or &
  3128. billtype = 2 Or &
  3129. billtype = 3 Or &
  3130. billtype = 4 Or &
  3131. billtype = 5 Or &
  3132. billtype = 7 Or &
  3133. billtype = 8 Or &
  3134. billtype = 10 THEN
  3135. li_ifupdate_date = 1
  3136. ELSE
  3137. li_ifupdate_date = 0
  3138. END IF
  3139. IF li_ifunit = 0 THEN arg_uqty = 0
  3140. IF li_ifcost = 1 THEN
  3141. UPDATE u_mtrlware
  3142. SET noallocqty = noallocqty - :arg_qty ,
  3143. wsallocqty = wsallocqty - :arg_qty,
  3144. unoallocqty = unoallocqty - :arg_uqty,
  3145. capacity = capacity + :ld_capacity * :arg_qty,
  3146. wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END ,
  3147. cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END ,
  3148. saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
  3149. WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
  3150. ( scid = :ll_storagescid ) Using commit_transaction ;
  3151. IF commit_transaction.SQLCode = 0 THEN
  3152. IF commit_transaction.SQLNRows = 0 THEN
  3153. ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
  3154. IF ls_newid <= 0 THEN
  3155. rslt = 0
  3156. GOTO ext
  3157. END IF
  3158. ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec)
  3159. INSERT INTO u_mtrlware
  3160. ( scid,
  3161. mtrlwareid,
  3162. mtrlid,
  3163. storageid,
  3164. plancode,
  3165. status,
  3166. noallocqty,
  3167. unoallocqty,
  3168. wareamt,
  3169. planprice,
  3170. sptid,
  3171. dxflag,
  3172. woodcode,
  3173. pcode,
  3174. cost,
  3175. storMtrlprp,
  3176. mtrlcuscode,
  3177. location,
  3178. capacity,
  3179. wsallocqty)
  3180. VALUES (
  3181. :ll_storagescid,
  3182. :ls_newid,
  3183. :arg_mtrlid,
  3184. :arg_storageid,
  3185. :arg_plancode,
  3186. :arg_status,
  3187. :arg_qty,
  3188. :arg_uqty,
  3189. :arg_costamt,
  3190. :arg_planprice,
  3191. :arg_sptid,
  3192. :arg_dxflag,
  3193. :arg_woodcode,
  3194. :arg_pcode,
  3195. :ld_cost,
  3196. :li_storMtrlprp,
  3197. :arg_mtrlcuscode,
  3198. :arg_location,
  3199. :ld_capacity * :arg_qty,
  3200. :arg_qty) Using commit_transaction ;
  3201. IF commit_transaction.SQLCode <> 0 THEN
  3202. rslt = 0
  3203. IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  3204. IF arg_status <> '' THEN
  3205. ls_str = ' '+uo_option_change_status+':'+arg_status
  3206. END IF
  3207. IF arg_pcode <> '' THEN
  3208. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  3209. END IF
  3210. IF arg_woodcode <> '' THEN
  3211. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  3212. END IF
  3213. arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
  3214. ELSE
  3215. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
  3216. END IF
  3217. GOTO ext
  3218. END IF
  3219. END IF
  3220. ELSE
  3221. rslt = 0
  3222. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  3223. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  3224. arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减"
  3225. ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  3226. IF arg_status <> '' THEN
  3227. ls_str = ' '+uo_option_change_status+':'+arg_status
  3228. END IF
  3229. IF arg_pcode <> '' THEN
  3230. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  3231. END IF
  3232. IF arg_woodcode <> '' THEN
  3233. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  3234. END IF
  3235. arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
  3236. ELSE
  3237. arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
  3238. END IF
  3239. GOTO ext
  3240. END IF
  3241. ELSE
  3242. UPDATE u_mtrlware
  3243. SET noallocqty = noallocqty - :arg_qty ,
  3244. wsallocqty = wsallocqty - :arg_qty,
  3245. unoallocqty = unoallocqty - :arg_uqty,
  3246. capacity = capacity + :ld_capacity * :arg_qty,
  3247. wareamt = 0 ,
  3248. cost = 0 ,
  3249. saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
  3250. WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
  3251. ( scid = :ll_storagescid ) Using commit_transaction ;
  3252. IF commit_transaction.SQLCode = 0 THEN
  3253. IF commit_transaction.SQLNRows = 0 THEN
  3254. ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
  3255. IF ls_newid <= 0 THEN
  3256. rslt = 0
  3257. GOTO ext
  3258. END IF
  3259. INSERT INTO u_mtrlware
  3260. ( scid,
  3261. mtrlwareid,
  3262. mtrlid,
  3263. storageid,
  3264. plancode,
  3265. status,
  3266. noallocqty,
  3267. unoallocqty,
  3268. wareamt,
  3269. planprice,
  3270. sptid,
  3271. dxflag,
  3272. woodcode,
  3273. pcode,
  3274. cost,
  3275. storMtrlprp,
  3276. mtrlcuscode,
  3277. location,
  3278. capacity,
  3279. wsallocqty)
  3280. VALUES (
  3281. :ll_storagescid,
  3282. :ls_newid,
  3283. :arg_mtrlid,
  3284. :arg_storageid,
  3285. :arg_plancode,
  3286. :arg_status,
  3287. :arg_qty,
  3288. :arg_uqty,
  3289. 0,
  3290. 0,
  3291. :arg_sptid,
  3292. :arg_dxflag,
  3293. :arg_woodcode,
  3294. :arg_pcode,
  3295. 0,
  3296. :li_storMtrlprp,
  3297. :arg_mtrlcuscode,
  3298. :arg_location,
  3299. :ld_capacity * :arg_qty,
  3300. :arg_qty) Using commit_transaction ;
  3301. IF commit_transaction.SQLCode <> 0 THEN
  3302. rslt = 0
  3303. IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  3304. IF arg_status <> '' THEN
  3305. ls_str = ' '+uo_option_change_status+':'+arg_status
  3306. END IF
  3307. IF arg_pcode <> '' THEN
  3308. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  3309. END IF
  3310. IF arg_woodcode <> '' THEN
  3311. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  3312. END IF
  3313. arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
  3314. ELSE
  3315. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
  3316. END IF
  3317. GOTO ext
  3318. END IF
  3319. END IF
  3320. ELSE
  3321. rslt = 0
  3322. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  3323. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  3324. arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减"
  3325. ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  3326. IF arg_status <> '' THEN
  3327. ls_str = ' '+uo_option_change_status+':'+arg_status
  3328. END IF
  3329. IF arg_pcode <> '' THEN
  3330. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  3331. END IF
  3332. IF arg_woodcode <> '' THEN
  3333. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  3334. END IF
  3335. arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
  3336. ELSE
  3337. arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
  3338. END IF
  3339. GOTO ext
  3340. END IF
  3341. END IF
  3342. ext:
  3343. IF rslt = 0 THEN
  3344. ROLLBACK Using commit_transaction ;
  3345. END IF
  3346. RETURN rslt
  3347. end function
  3348. public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg);Int rslt = 1
  3349. Long i
  3350. Long ll_scid,ll_mtrlwareid
  3351. Int li_storagetype_storage
  3352. String ls_location_top1
  3353. IF billtype <> 1 And billtype <> 8 And billtype <> 9 And billtype <> 12 And billtype <> 17 THEN
  3354. rslt = 1
  3355. GOTO ext
  3356. END IF
  3357. uo_getbar uo_gb
  3358. uo_gb = Create uo_getbar
  3359. IF it_mxbt_barcode = 0 THEN
  3360. arg_msg = '没有条码明细,请检查'
  3361. rslt = 0
  3362. GOTO ext
  3363. END IF
  3364. IF f_rst_storage_storagetype(storageid,li_storagetype_storage) = 0 THEN
  3365. arg_msg = '查询仓库库存策略失败,请检查'
  3366. rslt = 0
  3367. GOTO ext
  3368. END IF
  3369. FOR i = 1 To it_mxbt_barcode
  3370. IF thflag = 0 THEN
  3371. IF uo_gb.uof_barcode_out(s_mx_barcode[i].barcode,arg_audittype,False,arg_msg) = 0 THEN
  3372. rslt = 0
  3373. GOTO ext
  3374. END IF
  3375. ELSE
  3376. IF arg_audittype = 1 THEN
  3377. IF uo_option_barcodelocation_use_inwaremx_location = 0 THEN
  3378. ls_location_top1 = ''
  3379. ELSE
  3380. SELECT top 1 u_outwaremx.location
  3381. INTO :ls_location_top1
  3382. FROM u_outwaremx
  3383. WHERE u_outwaremx.scid = :scid
  3384. AND u_outwaremx.outwareid = :outwareid
  3385. Using commit_transaction;
  3386. IF commit_transaction.SQLCode <> 0 THEN
  3387. arg_msg = '查询出仓单明细仓位信息失败,'+commit_transaction.SQLErrText
  3388. rslt = 0
  3389. GOTO ext
  3390. END IF
  3391. END IF
  3392. SELECT u_mtrlware.scid,u_mtrlware.mtrlwareid
  3393. INTO :ll_scid,:ll_mtrlwareid
  3394. FROM u_mtrlware,u_mtrlware_mx,u_mtrldef
  3395. WHERE u_mtrlware.storageid = :storageid
  3396. AND u_mtrlware_mx.barcode = :s_mx_barcode[i].barcode
  3397. AND u_mtrlware.mtrlid = u_mtrlware_mx.mtrlid
  3398. AND u_mtrlware.mtrlid = u_mtrldef.mtrlid
  3399. AND ( u_mtrlware.sptid = u_mtrlware_mx.sptid AND :li_storagetype_storage = 0 OR
  3400. u_mtrlware.sptid = 0 AND :li_storagetype_storage = 1 )
  3401. AND u_mtrlware.status = u_mtrlware_mx.status
  3402. AND u_mtrlware.woodcode = u_mtrlware_mx.woodcode
  3403. AND u_mtrlware.pcode = u_mtrlware_mx.pcode
  3404. AND u_mtrlware.plancode = u_mtrlware_mx.plancode
  3405. AND ( u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND :li_storagetype_storage = 0 OR
  3406. :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND (u_mtrldef.ifpackpro = 4 OR u_mtrldef.ifpack = 2) OR
  3407. :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = '' AND u_mtrldef.ifpackpro <> 4 AND u_mtrldef.ifpack <> 2 )
  3408. AND (u_mtrlware.Location = u_mtrlware_mx.Location AND :uo_option_barcodelocation_use_inwaremx_location = 0 OR
  3409. u_mtrlware.Location = :ls_location_top1 And :uo_option_barcodelocation_use_inwaremx_location = 1 ) Using commit_transaction;
  3410. IF commit_transaction.SQLCode <> 0 THEN
  3411. arg_msg = '条码:'+s_mx_barcode[i].barcode+',查询库存资料失败,请检查对应条码单与库存资料,'+commit_transaction.SQLErrText
  3412. rslt = 0
  3413. GOTO ext
  3414. END IF
  3415. ELSE
  3416. ll_scid = 0
  3417. ll_mtrlwareid = 0
  3418. END IF
  3419. IF uo_gb.uof_barcode_in(s_mx_barcode[i].barcode,&
  3420. ll_scid,ll_mtrlwareid,'',0,0,arg_audittype,0,False,arg_msg) = 0 THEN
  3421. rslt = 0
  3422. GOTO ext
  3423. END IF
  3424. END IF
  3425. NEXT
  3426. ext:
  3427. IF rslt = 0 THEN
  3428. ROLLBACK;
  3429. END IF
  3430. Destroy uo_getbar
  3431. RETURN rslt
  3432. end function
  3433. public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  3434. INSERT INTO u_outwaremx_mx_barcode
  3435. (billtype,scid,outwareid,barcode,qty)
  3436. VALUES
  3437. (:arg_billtype,
  3438. :arg_scid,:arg_outwareid,:arg_barcode,:arg_qty);
  3439. IF sqlca.SQLCode <> 0 THEN
  3440. arg_msg = '出仓明细保存条码失败,条码:'+arg_barcode+','+sqlca.SQLErrText
  3441. rslt = 0
  3442. GOTO ext
  3443. END IF
  3444. ext:
  3445. IF rslt = 0 THEN
  3446. ROLLBACK;
  3447. ELSEIF rslt = 1 AND arg_ifcommit THEN
  3448. COMMIT;
  3449. END IF
  3450. RETURN rslt
  3451. end function
  3452. public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
  3453. IF priceflag = 1 THEN
  3454. rslt = 0
  3455. arg_msg = "单据已经确认"
  3456. GOTO ext
  3457. END IF
  3458. UPDATE u_outware
  3459. SET priceemp = :publ_operator,
  3460. pricedate = getdate(),
  3461. priceflag = 1
  3462. WHERE u_outware.outwareid = :outwareid
  3463. AND priceflag = 0
  3464. AND scid = :scid USING commit_transaction;
  3465. IF commit_transaction.SQLCode <> 0 THEN
  3466. rslt = 0
  3467. arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  3468. GOTO ext
  3469. ELSEIF commit_transaction.SQLNRows = 0 THEN
  3470. rslt = 0
  3471. arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  3472. GOTO ext
  3473. END IF
  3474. priceflag = 1
  3475. ext:
  3476. IF rslt = 0 THEN
  3477. ROLLBACK USING commit_transaction;
  3478. ELSEIF rslt = 1 AND arg_ifcommit THEN
  3479. COMMIT USING commit_transaction;
  3480. END IF
  3481. RETURN rslt
  3482. end function
  3483. public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
  3484. DateTime null_dt
  3485. SetNull(null_dt)
  3486. IF priceflag = 0 THEN
  3487. rslt = 0
  3488. arg_msg = "单据还未确认,不能反确认"
  3489. GOTO ext
  3490. END IF
  3491. IF flag = 1 THEN
  3492. rslt = 0
  3493. arg_msg = "单据已仓审,不能反确认"
  3494. GOTO ext
  3495. END IF
  3496. IF it_mxbt_barcode > 0 THEN
  3497. arg_msg = '单据已扫描条码,不能反确认,如果要反确认,请先清除条码'
  3498. rslt = 0
  3499. GOTO ext
  3500. END IF
  3501. UPDATE u_outware
  3502. SET priceemp = '',
  3503. pricedate = :null_dt,
  3504. priceflag = 0
  3505. WHERE u_outware.outwareid = :outwareid
  3506. AND priceflag = 1
  3507. AND scid = :scid USING commit_transaction;
  3508. IF commit_transaction.SQLCode <> 0 THEN
  3509. rslt = 0
  3510. arg_msg = "因网络或其它原因导致反确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  3511. GOTO ext
  3512. ELSEIF commit_transaction.SQLNRows = 0 THEN
  3513. rslt = 0
  3514. arg_msg = "单据正在反确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  3515. GOTO ext
  3516. END IF
  3517. priceflag = 0
  3518. ext:
  3519. IF rslt = 0 THEN
  3520. ROLLBACK USING commit_transaction;
  3521. ELSEIF rslt = 1 AND arg_ifcommit THEN
  3522. COMMIT USING commit_transaction;
  3523. END IF
  3524. RETURN rslt
  3525. end function
  3526. public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  3527. Int li_ref_outtype
  3528. Long ll_i,ll_j,ll_k
  3529. Long ll_f,ll_arr
  3530. Long ll_mtrlware_arr[]
  3531. Decimal ld_outqty_arr[],ld_updateqty
  3532. IF arg_outwareid <= 0 THEN
  3533. arg_msg = '错误的单据id'
  3534. rslt = 0
  3535. GOTO ext
  3536. END IF
  3537. IF getinfo(arg_scid,arg_outwareid,arg_msg) = 0 THEN
  3538. rslt = 0
  3539. GOTO ext
  3540. END IF
  3541. IF f_rst_storage_outtype(storageid,li_ref_outtype) = 0 THEN
  3542. arg_msg = '查询仓库出仓策略失败,请检查仓库资料'
  3543. rslt = 0
  3544. GOTO ext
  3545. END IF
  3546. IF li_ref_outtype <> 2 THEN
  3547. arg_msg = '仓库出仓策略不是使用条码出仓,操作取消,请检查仓库资料'
  3548. rslt = 0
  3549. GOTO ext
  3550. END IF
  3551. IF priceflag = 0 THEN
  3552. arg_msg = '单据未确认,操作取消'
  3553. rslt = 0
  3554. GOTO ext
  3555. END IF
  3556. IF flag = 1 THEN
  3557. arg_msg = '单据已仓审,操作取消'
  3558. rslt = 0
  3559. GOTO ext
  3560. END IF
  3561. //计算条码出仓数
  3562. FOR ll_j = 1 TO it_mxbt_barcode
  3563. ll_f = 0
  3564. ll_arr = UpperBound(ll_mtrlware_arr)
  3565. FOR ll_k = 1 TO ll_arr
  3566. IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN
  3567. ll_f = ll_k
  3568. EXIT
  3569. END IF
  3570. NEXT
  3571. IF ll_f > 0 THEN
  3572. ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty
  3573. ELSE
  3574. ll_arr++
  3575. ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid
  3576. ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty
  3577. END IF
  3578. NEXT
  3579. UPDATE u_outwaremx
  3580. SET u_outwaremx.uqty = 0,
  3581. u_outwaremx.qty = 0
  3582. FROM u_outwaremx,u_mtrldef
  3583. WHERE u_outwaremx.scid = :arg_scid
  3584. AND u_outwaremx.outwareid = :arg_outwareid
  3585. AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
  3586. AND u_mtrldef.outtype = 2 USING commit_transaction;
  3587. IF commit_transaction.SQLCode <> 0 THEN
  3588. arg_msg = '清除出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText
  3589. rslt = 0
  3590. GOTO ext
  3591. END IF
  3592. FOR ll_i = 1 TO it_mxbt
  3593. ld_updateqty = 0
  3594. IF outwaremx[ll_i].outtype_mtrl <> 2 THEN CONTINUE
  3595. FOR ll_k = 1 TO UpperBound(ll_mtrlware_arr)
  3596. IF ld_outqty_arr[ll_k] = 0 THEN CONTINUE
  3597. IF outwaremx[ll_i].mtrlwareid = ll_mtrlware_arr[ll_k] THEN
  3598. IF outwaremx[ll_i].qty >= ld_outqty_arr[ll_k] THEN
  3599. ld_updateqty = ld_outqty_arr[ll_k]
  3600. ld_outqty_arr[ll_k] = 0
  3601. ELSE
  3602. ld_updateqty = outwaremx[ll_i].qty
  3603. ld_outqty_arr[ll_k] = ld_outqty_arr[ll_k] - outwaremx[ll_i].qty
  3604. END IF
  3605. EXIT
  3606. END IF
  3607. NEXT
  3608. IF ld_updateqty > 0 THEN
  3609. UPDATE u_outwaremx
  3610. SET u_outwaremx.uqty = :ld_updateqty,
  3611. u_outwaremx.qty = :ld_updateqty
  3612. WHERE u_outwaremx.scid = :arg_scid
  3613. AND u_outwaremx.outwareid = :arg_outwareid
  3614. AND u_outwaremx.printid = :outwaremx[ll_i].printid USING commit_transaction;
  3615. IF commit_transaction.SQLCode <> 0 THEN
  3616. arg_msg = '行:'+String(ll_i)+',更新出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText
  3617. rslt = 0
  3618. GOTO ext
  3619. END IF
  3620. END IF
  3621. NEXT
  3622. ext:
  3623. IF rslt = 0 THEN
  3624. ROLLBACK USING commit_transaction;
  3625. ELSEIF rslt = 1 AND arg_ifcommit THEN
  3626. COMMIT USING commit_transaction;
  3627. END IF
  3628. RETURN rslt
  3629. end function
  3630. public function integer uof_check_qty_to_bqty (ref string arg_msg);Int rslt = 1
  3631. Long ll_j,ll_k
  3632. Long ll_f,ll_arr,ll_find
  3633. String ls_mtrlcode_array[],ls_mtrlcode
  3634. Long ll_mtrlware_arr[]
  3635. Decimal ld_outqty_arr[]
  3636. Long ll_mtrlware_arr_bill[]
  3637. Decimal ld_outqty_arr_bill[]
  3638. Boolean lb_equal = False
  3639. //计算条码出仓数
  3640. FOR ll_j = 1 To it_mxbt_barcode
  3641. ll_f = 0
  3642. ll_arr = UpperBound(ll_mtrlware_arr)
  3643. FOR ll_k = 1 To ll_arr
  3644. IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN
  3645. ll_f = ll_k
  3646. EXIT
  3647. END IF
  3648. NEXT
  3649. IF ll_f > 0 THEN
  3650. ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty
  3651. ELSE
  3652. ll_arr++
  3653. ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid
  3654. ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty
  3655. END IF
  3656. NEXT
  3657. //计算出仓明细出仓数
  3658. IF billtype = 1 THEN
  3659. FOR ll_j = 1 To it_mxbt_mx
  3660. ll_f = 0
  3661. ll_arr = UpperBound(ll_mtrlware_arr_bill)
  3662. FOR ll_k = 1 To ll_arr
  3663. IF ll_mtrlware_arr_bill[ll_k] = outwaremx_mx[ll_j].mtrlwareid THEN
  3664. ll_f = ll_k
  3665. EXIT
  3666. END IF
  3667. NEXT
  3668. IF ll_f > 0 THEN
  3669. ld_outqty_arr_bill[ll_f] += outwaremx_mx[ll_j].qty
  3670. ELSE
  3671. ll_arr++
  3672. ls_mtrlcode_array[ll_arr] = outwaremx_mx[ll_j].mtrlcode
  3673. ll_mtrlware_arr_bill[ll_arr] = outwaremx_mx[ll_j].mtrlwareid
  3674. ld_outqty_arr_bill[ll_arr] = outwaremx_mx[ll_j].qty
  3675. END IF
  3676. NEXT
  3677. ELSE
  3678. FOR ll_j = 1 To it_mxbt
  3679. IF outwaremx[ll_j].outtype_mtrl <> 2 THEN CONTINUE
  3680. ll_f = 0
  3681. ll_arr = UpperBound(ll_mtrlware_arr_bill)
  3682. FOR ll_k = 1 To ll_arr
  3683. IF ll_mtrlware_arr_bill[ll_k] = outwaremx[ll_j].mtrlwareid THEN
  3684. ll_f = ll_k
  3685. EXIT
  3686. END IF
  3687. NEXT
  3688. IF ll_f > 0 THEN
  3689. ld_outqty_arr_bill[ll_f] += outwaremx[ll_j].qty
  3690. ELSE
  3691. ll_arr++
  3692. ls_mtrlcode_array[ll_arr] = outwaremx[ll_j].mtrlcode
  3693. ll_mtrlware_arr_bill[ll_arr] = outwaremx[ll_j].mtrlwareid
  3694. ld_outqty_arr_bill[ll_arr] = outwaremx[ll_j].qty
  3695. END IF
  3696. NEXT
  3697. END IF
  3698. //检查1
  3699. FOR ll_j = 1 To UpperBound(ll_mtrlware_arr_bill)
  3700. lb_equal = False
  3701. IF ld_outqty_arr_bill[ll_j] = 0 THEN CONTINUE
  3702. ll_find = 0
  3703. FOR ll_k = 1 To UpperBound(ll_mtrlware_arr)
  3704. IF ll_mtrlware_arr_bill[ll_j] = ll_mtrlware_arr[ll_k] THEN
  3705. ll_find = ll_k
  3706. IF ld_outqty_arr_bill[ll_j] = ld_outqty_arr[ll_k] THEN
  3707. lb_equal = True
  3708. EXIT
  3709. END IF
  3710. END IF
  3711. NEXT
  3712. IF Not lb_equal THEN
  3713. IF ll_find = 0 THEN
  3714. arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:0,不相等请检查'
  3715. ELSE
  3716. arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:'+String( ld_outqty_arr[ll_find],'#0.##########')+',不相等请检查'
  3717. END IF
  3718. rslt = 0
  3719. GOTO ext
  3720. END IF
  3721. NEXT
  3722. //检查2
  3723. FOR ll_j = 1 To UpperBound(ll_mtrlware_arr)
  3724. lb_equal = False
  3725. IF ld_outqty_arr[ll_j] = 0 THEN CONTINUE
  3726. ll_find = 0
  3727. FOR ll_k = 1 To UpperBound(ll_mtrlware_arr_bill)
  3728. IF ll_mtrlware_arr[ll_j] = ll_mtrlware_arr_bill[ll_k] THEN
  3729. ll_find = ll_k
  3730. IF ld_outqty_arr[ll_j] = ld_outqty_arr_bill[ll_k] THEN
  3731. lb_equal = True
  3732. EXIT
  3733. END IF
  3734. END IF
  3735. NEXT
  3736. IF Not lb_equal THEN
  3737. ls_mtrlcode = ''
  3738. SELECT u_mtrldef.mtrlcode INTO :ls_mtrlcode
  3739. FROM u_mtrlware,u_mtrldef
  3740. WHERE u_mtrlware.mtrlid = u_mtrldef.mtrlid
  3741. AND u_mtrlware.scid = :scid
  3742. And u_mtrlware.mtrlwareid = :ll_mtrlware_arr[ll_j] Using commit_transaction;
  3743. IF commit_transaction.SQLCode <> 0 THEN
  3744. arg_msg = '查询条码库存id:'+String(ll_mtrlware_arr[ll_j])+',查询物料编码失败,'+commit_transaction.SQLErrText
  3745. rslt = 0
  3746. GOTO ext
  3747. END IF
  3748. IF ll_find = 0 THEN
  3749. arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:0,不相等,请检查'
  3750. ELSE
  3751. arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_find],'#0.##########')+',不相等,请检查'
  3752. END IF
  3753. rslt = 0
  3754. GOTO ext
  3755. END IF
  3756. NEXT
  3757. ext:
  3758. RETURN rslt
  3759. end function
  3760. public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i
  3761. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  3762. rslt = 0
  3763. GOTO ext
  3764. END IF
  3765. IF secflag = 1 THEN
  3766. rslt = 0
  3767. arg_msg = "单据已经财审,不能再财审"
  3768. GOTO ext
  3769. END IF
  3770. UPDATE u_outware
  3771. SET secauditingrep = :publ_operator,
  3772. secauditingdate = getdate(),
  3773. secflag = 1
  3774. WHERE outwareid = :outwareid
  3775. AND secflag = 0
  3776. AND scid = :scid USING commit_transaction;
  3777. IF commit_transaction.SQLCode <> 0 THEN
  3778. rslt = 0
  3779. arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  3780. GOTO ext
  3781. ELSEIF commit_transaction.SQLNRows = 0 THEN
  3782. rslt = 0
  3783. arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  3784. GOTO ext
  3785. END IF
  3786. secflag = 1
  3787. ext:
  3788. IF rslt = 0 THEN
  3789. ROLLBACK USING commit_transaction;
  3790. ELSEIF rslt = 1 AND arg_ifcommit THEN
  3791. COMMIT USING commit_transaction;
  3792. END IF
  3793. RETURN rslt
  3794. end function
  3795. public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i
  3796. DateTime null_dt
  3797. SetNull(null_dt)
  3798. Int li_StoreBalcType,li_AmtAuditFlag
  3799. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  3800. rslt = 0
  3801. GOTO ext
  3802. END IF
  3803. IF secflag = 0 THEN
  3804. rslt = 0
  3805. arg_msg = "单据不在财审状态,不能执行财撤"
  3806. GOTO ext
  3807. END IF
  3808. //检查仓库是否分开结存
  3809. IF balcdateint <> 0 THEN
  3810. SELECT StoreBalcType
  3811. INTO :li_StoreBalcType
  3812. FROM u_storage
  3813. Where storageid = :storageid;
  3814. IF sqlca.SQLCode <> 0 THEN
  3815. li_StoreBalcType = 0
  3816. END IF
  3817. //如果分开结存,检查结存表是否已金额结存
  3818. IF li_StoreBalcType = 1 THEN
  3819. SELECT top 1 AmtAuditFlag
  3820. INTO :li_AmtAuditFlag
  3821. FROM u_warebalc
  3822. WHERE storageid = :storageid
  3823. And balcdateint = :balcdateint;
  3824. IF sqlca.SQLCode <> 0 THEN
  3825. li_AmtAuditFlag = 0
  3826. END IF
  3827. IF li_AmtAuditFlag = 1 THEN
  3828. rslt = 0
  3829. arg_msg = '仓库结存日期段已执行过金额结存,不能财撤单据'
  3830. GOTO ext
  3831. END IF
  3832. END IF
  3833. END IF
  3834. UPDATE u_outware
  3835. SET secauditingrep = '',
  3836. secauditingdate = :null_dt,
  3837. secflag = 0
  3838. WHERE outwareid = :outwareid
  3839. AND secflag = 1
  3840. And scid = :scid Using commit_transaction;
  3841. IF commit_transaction.SQLCode <> 0 THEN
  3842. rslt = 0
  3843. arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  3844. GOTO ext
  3845. ELSEIF commit_transaction.SQLNRows = 0 THEN
  3846. rslt = 0
  3847. arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  3848. GOTO ext
  3849. END IF
  3850. secflag = 0
  3851. ext:
  3852. IF rslt = 0 THEN
  3853. ROLLBACK Using commit_transaction;
  3854. ELSEIF rslt = 1 And arg_ifcommit THEN
  3855. COMMIT Using commit_transaction;
  3856. END IF
  3857. RETURN rslt
  3858. end function
  3859. public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg);Int rslt = 1
  3860. Long cnt
  3861. cnt = 0
  3862. IF it_newbegin = False And it_updatebegin = False THEN
  3863. rslt = 0
  3864. arg_msg = "非编辑状态不可以使用,操作取消"
  3865. GOTO ext
  3866. END IF
  3867. IF IsNull(arg_printid) THEN arg_printid = 0
  3868. IF IsNull(arg_itemid) THEN arg_itemid = 0
  3869. IF IsNull(arg_amt) THEN arg_amt = 0
  3870. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  3871. IF arg_itemid = 0 Or arg_amt = 0 THEN
  3872. rslt = 1
  3873. GOTO ext
  3874. END IF
  3875. SELECT count(*)
  3876. INTO :cnt
  3877. FROM u_itemdef
  3878. Where itemid = :arg_itemid;
  3879. IF commit_transaction.SQLCode <> 0 THEN
  3880. rslt = 0
  3881. arg_msg = '查询收支项目是否存在失败,'+commit_transaction.SQLErrText
  3882. GOTO ext
  3883. END IF
  3884. IF cnt = 0 THEN
  3885. rslt = 0
  3886. arg_msg = '第'+String(arg_printid)+'行,收支项目不存在,请检查'
  3887. GOTO ext
  3888. END IF
  3889. it_mxbt_item++
  3890. outware_itemmx[it_mxbt_item].printid = arg_printid
  3891. outware_itemmx[it_mxbt_item].itemid = arg_itemid
  3892. outware_itemmx[it_mxbt_item].amt = arg_amt
  3893. outware_itemmx[it_mxbt_item].mxdscrp = arg_mxdscrp
  3894. ext:
  3895. IF rslt = 0 THEN p_clearmx()
  3896. RETURN rslt
  3897. end function
  3898. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula);
  3899. s_outwaremx s_mx
  3900. s_mx.mtrlwareid = arg_mtrlwareid
  3901. s_mx.qty = arg_qty
  3902. s_mx.fprice = arg_fprice
  3903. s_mx.rebate = arg_rebate
  3904. s_mx.mxdscrp = arg_mxdscrp
  3905. s_mx.printid = arg_printid
  3906. s_mx.ifrel = arg_ifrel
  3907. s_mx.relid = arg_relid
  3908. s_mx.olmtrlid = arg_olmtrlid
  3909. s_mx.packqty = arg_packqty
  3910. s_mx.outtype = arg_outtype
  3911. s_mx.planqty = arg_planqty
  3912. s_mx.relprintid = arg_relprintid
  3913. s_mx.unit = arg_unit
  3914. s_mx.uqty = arg_uqty
  3915. s_mx.rate = arg_rate
  3916. s_mx.pricetype = arg_pricetype
  3917. s_mx.formula = arg_formula
  3918. s_mx.saleoutid = arg_saleoutid
  3919. s_mx.saleoutprintid = arg_saleoutprintid
  3920. s_mx.mxdscrp2 = arg_mxdscrp2
  3921. s_mx.net_weight = arg_net_weight
  3922. s_mx.gross_weight = arg_gross_weight
  3923. s_mx.cubage = arg_cubage
  3924. s_mx.taxrate = arg_taxrate
  3925. s_mx.priceformula = arg_priceformula
  3926. s_mx.qtyformula = arg_qtyformula
  3927. return acceptmx(s_mx, arg_msg)
  3928. end function
  3929. public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg);Int rslt = 1
  3930. Long cnt
  3931. SELECT count(*)
  3932. INTO :cnt
  3933. FROM u_warepdb
  3934. WHERE storageid = :arg_storageid
  3935. And flag = 0 Using commit_transaction;
  3936. IF commit_transaction.SQLCode <> 0 THEN
  3937. rslt = 0
  3938. arg_msg = '查询仓库是否有盘点表未审核失败,'+commit_transaction.SQLErrText
  3939. GOTO ext
  3940. END IF
  3941. IF cnt > 0 THEN
  3942. rslt = 0
  3943. arg_msg = '仓库有盘点表未审核,不能仓审或仓撤单据,请检查'
  3944. GOTO ext
  3945. END IF
  3946. ext:
  3947. RETURN rslt
  3948. end function
  3949. public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  3950. Long ll_disuseid
  3951. //arg_disusetype 0 - 修改, 1-删除
  3952. Select max(disuseid) Into :ll_disuseid
  3953. From u_outware_disuse
  3954. Where scid = :arg_scid
  3955. And outwareid = :arg_outwareid Using commit_transaction;
  3956. If commit_transaction.SQLCode = -1 Then
  3957. rslt = 0
  3958. arg_msg = '获取销售发货单废弃单序号失败,'+ commit_transaction.SQLErrText
  3959. Goto ext
  3960. ElseIf commit_transaction.SQLCode = 100 Then
  3961. ll_disuseid = 0
  3962. End If
  3963. if isnull(ll_disuseid) then ll_disuseid = 0
  3964. ll_disuseid++
  3965. Insert Into u_outware_disuse
  3966. (scid, outwareid, outwarecode, billtype, relid, StorageID, opdate, opemp, Modemp,
  3967. moddate, flag, auditingdate, auditingrep, outdate, outrep, part, dscrp, cusid, cusname,
  3968. balcflag, balcdateint, thflag, secflag, secauditingdate, secauditingrep, ctmint,
  3969. printnum, wagemth, otheramt, relstr_1, relstr_2, relstr_3, relint_1, relint_2, relint_3,
  3970. priceflag, pricedate, priceemp, rel_address, rel_tele, rel_fax, rel_rep, mrate, damt,
  3971. upname, ifauto, viewdate, deptid, senduser, sendcnt, sendtime, pda_flag, pda_date,
  3972. carcode, transcode, lsflag, totalamt, getamt, moneyname, banktypename,
  3973. storagename, disuseemp, disusedate, disusetype, disuseid)
  3974. Select u_outware.scid, u_outware.outwareid, u_outware.outwarecode, u_outware.billtype,
  3975. u_outware.relid, u_outware.StorageID, u_outware.opdate, u_outware.opemp,
  3976. u_outware.Modemp, u_outware.moddate, u_outware.flag, u_outware.auditingdate,
  3977. u_outware.auditingrep, u_outware.outdate, u_outware.outrep, u_outware.part,
  3978. u_outware.dscrp, u_outware.cusid, u_outware.cusname, u_outware.balcflag,
  3979. u_outware.balcdateint, u_outware.thflag, u_outware.secflag,
  3980. u_outware.secauditingdate, u_outware.secauditingrep, u_outware.ctmint,
  3981. u_outware.printnum, u_outware.wagemth, u_outware.otheramt, u_outware.relstr_1,
  3982. u_outware.relstr_2, u_outware.relstr_3, u_outware.relint_1, u_outware.relint_2,
  3983. u_outware.relint_3, u_outware.priceflag, u_outware.pricedate, u_outware.priceemp,
  3984. u_outware.rel_address, u_outware.rel_tele, u_outware.rel_fax, u_outware.rel_rep,
  3985. u_outware.mrate, u_outware.damt, u_outware.upname, u_outware.ifauto,
  3986. u_outware.viewdate, u_outware.deptid, u_outware.senduser, u_outware.sendcnt,
  3987. u_outware.sendtime, u_outware.pda_flag, u_outware.pda_date, u_outware.carcode,
  3988. u_outware.transcode, u_outware.lsflag, u_outware.totalamt, u_outware.getamt,
  3989. cw_currency.name, cw_banktype.banktypename, u_storage.storagename,
  3990. :publ_operator,getdate(),:arg_disusetype,:ll_disuseid
  3991. From u_outware LEFT Outer JOIN
  3992. u_storage ON u_outware.StorageID = u_storage.storageid LEFT Outer JOIN
  3993. cw_banktype ON u_outware.relint_1 = cw_banktype.banktypeid LEFT Outer JOIN
  3994. cw_currency ON u_outware.relint_2 = cw_currency.moneyid
  3995. Where u_outware.scid = :arg_scid
  3996. And u_outware.outwareid = :arg_outwareid Using commit_transaction;
  3997. If commit_transaction.SQLCode <> 0 Then
  3998. rslt = 0
  3999. arg_msg = '插入销售发货单废弃单失败,'+commit_transaction.SQLErrText
  4000. Goto ext
  4001. End If
  4002. Insert Into u_outwaremx_disuse
  4003. (scid, outwareid, printid, mtrlwareid, mtrlid, storageid, plancode, status, qty, fprice,
  4004. rebate, price, costamt, planprice, mxdscrp, Sptid, Dxflag, ifrel, olmtrlid, relid, packqty,
  4005. woodcode, relcode, pcode, enprice, newpriceamt, ctmint, outtype, dftsaleprice, cost,
  4006. planqty, relprintid, uqty, rate, unit, scidprice, outtypestr, overqty, mtrlcuscode,
  4007. location, pricetype, formula, capacity, saleqty, saleoutid, saleoutprintid, net_weight,
  4008. gross_weight, cubage, mxdscrp2, taxrate, priceformula, qtyformula, mtrlwareprintid,
  4009. mtrlcode, mtrlname,disuseid)
  4010. Select u_outwaremx.scid, u_outwaremx.outwareid, u_outwaremx.printid,
  4011. u_outwaremx.mtrlwareid, u_outwaremx.mtrlid, u_outwaremx.storageid,
  4012. u_outwaremx.plancode, u_outwaremx.status, u_outwaremx.qty, u_outwaremx.fprice,
  4013. u_outwaremx.rebate, u_outwaremx.price, u_outwaremx.costamt,
  4014. u_outwaremx.planprice, u_outwaremx.mxdscrp, u_outwaremx.Sptid,
  4015. u_outwaremx.Dxflag, u_outwaremx.ifrel, u_outwaremx.olmtrlid, u_outwaremx.relid,
  4016. u_outwaremx.packqty, u_outwaremx.woodcode, u_outwaremx.relcode,
  4017. u_outwaremx.pcode, u_outwaremx.enprice, u_outwaremx.newpriceamt,
  4018. u_outwaremx.ctmint, u_outwaremx.outtype, u_outwaremx.dftsaleprice,
  4019. u_outwaremx.cost, u_outwaremx.planqty, u_outwaremx.relprintid, u_outwaremx.uqty,
  4020. u_outwaremx.rate, u_outwaremx.unit, u_outwaremx.scidprice,
  4021. u_outwaremx.outtypestr, u_outwaremx.overqty, u_outwaremx.mtrlcuscode,
  4022. u_outwaremx.location, u_outwaremx.pricetype, u_outwaremx.formula,
  4023. u_outwaremx.capacity, u_outwaremx.saleqty, u_outwaremx.saleoutid,
  4024. u_outwaremx.saleoutprintid, u_outwaremx.net_weight, u_outwaremx.gross_weight,
  4025. u_outwaremx.cubage, u_outwaremx.mxdscrp2, u_outwaremx.taxrate,
  4026. u_outwaremx.priceformula, u_outwaremx.qtyformula, u_outwaremx.mtrlwareprintid,
  4027. u_mtrldef.mtrlcode, u_mtrldef.mtrlname,:ll_disuseid
  4028. From u_outwaremx LEFT Outer JOIN
  4029. u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
  4030. Where u_outwaremx.scid = :arg_scid
  4031. And u_outwaremx.outwareid = :arg_outwareid Using commit_transaction;
  4032. If commit_transaction.SQLCode <> 0 Then
  4033. rslt = 0
  4034. arg_msg = '插入销售发货单废弃单明细失败,'+commit_transaction.SQLErrText
  4035. Goto ext
  4036. End If
  4037. Insert Into u_outwaremx_mx_disuse
  4038. (scid, outwareid, printid, mxprintid, mtrlwareid, storageid, mtrlid, plancode, status,
  4039. woodcode, pcode, mtrlcuscode, location, sptid, dxflag, planqty, qty, mxdscrp, ctmint,
  4040. mtrlcode, mtrlname, disuseid)
  4041. Select u_outwaremx_mx.scid, u_outwaremx_mx.outwareid, u_outwaremx_mx.printid,
  4042. u_outwaremx_mx.mxprintid, u_outwaremx_mx.mtrlwareid,
  4043. u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid, u_outwaremx_mx.plancode,
  4044. u_outwaremx_mx.status, u_outwaremx_mx.woodcode, u_outwaremx_mx.pcode,
  4045. u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location, u_outwaremx_mx.sptid,
  4046. u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty, u_outwaremx_mx.qty,
  4047. u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ctmint, u_mtrldef.mtrlcode,
  4048. u_mtrldef.mtrlname,:ll_disuseid
  4049. From u_outwaremx_mx LEFT Outer JOIN
  4050. u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
  4051. Where u_outwaremx_mx.scid = :arg_scid
  4052. And u_outwaremx_mx.outwareid = :arg_outwareid Using commit_transaction;
  4053. If commit_transaction.SQLCode <> 0 Then
  4054. rslt = 0
  4055. arg_msg = '插入销售发货单废弃单包件明细失败,'+commit_transaction.SQLErrText
  4056. Goto ext
  4057. End If
  4058. Insert Into u_outwaremx_mx_barcode_disuse
  4059. (billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, disuseid)
  4060. Select billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, :ll_disuseid
  4061. From u_outwaremx_mx_barcode
  4062. Where u_outwaremx_mx_barcode.scid = :arg_scid
  4063. And u_outwaremx_mx_barcode.outwareid = :arg_outwareid Using commit_transaction;
  4064. If commit_transaction.SQLCode <> 0 Then
  4065. rslt = 0
  4066. arg_msg = '插入销售发货单废弃单条码明细失败,'+commit_transaction.SQLErrText
  4067. Goto ext
  4068. End If
  4069. Insert Into u_outware_itemmx_disuse
  4070. (scid, outwareid, printid, itemid, amt, mxdscrp, itemcode, itemname, itemtype,
  4071. disuseid)
  4072. Select u_outware_itemmx.scid, u_outware_itemmx.outwareid, u_outware_itemmx.printid,
  4073. u_outware_itemmx.itemid, u_outware_itemmx.amt, u_outware_itemmx.mxdscrp,
  4074. u_itemdef.itemcode, u_itemdef.itemname, u_itemdef.itemtype,:ll_disuseid
  4075. From u_outware_itemmx LEFT Outer JOIN
  4076. u_itemdef ON u_outware_itemmx.itemid = u_itemdef.itemid
  4077. Where u_outware_itemmx.scid = :arg_scid
  4078. And u_outware_itemmx.outwareid = :arg_outwareid Using commit_transaction;
  4079. If commit_transaction.SQLCode <> 0 Then
  4080. rslt = 0
  4081. arg_msg = '插入销售发货单废弃单费用明细失败,'+commit_transaction.SQLErrText
  4082. Goto ext
  4083. End If
  4084. ext:
  4085. If rslt = 0 Then
  4086. Rollback Using commit_transaction;
  4087. ElseIf rslt = 1 And arg_ifcommit Then
  4088. Commit Using commit_transaction;
  4089. End If
  4090. Return rslt
  4091. end function
  4092. public function integer uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg);if sys_option_if_saleout = 0 then return 1
  4093. Int rslt = 1
  4094. Long i
  4095. Long ll_scid, ll_taskid, ll_printid
  4096. uo_bgtr_timer uo_tr
  4097. uo_tr = Create uo_bgtr_timer
  4098. IF getinfo(arg_scid, arg_outwareid, arg_msg) = 0 THEN
  4099. rslt = 0
  4100. GOTO ext
  4101. END IF
  4102. FOR i = 1 To it_mxbt
  4103. ll_taskid = outwaremx[i].relid
  4104. ll_printid = outwaremx[i].relprintid
  4105. IF ll_taskid > 0 And ll_printid > 0 THEN
  4106. IF uo_tr.uf_update_saleoutcodestr(arg_scid, ll_taskid, ll_printid, arg_msg) = 0 THEN
  4107. rslt = 0
  4108. GOTO ext
  4109. END IF
  4110. END IF
  4111. NEXT
  4112. ext:
  4113. Destroy uo_tr
  4114. RETURN rslt
  4115. end function
  4116. public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i
  4117. Long i_mtrlid,i_storageid,i_sptid
  4118. Int i_dxflag,li_mtrlkind
  4119. String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
  4120. Decimal i_planprice,ld_dftsaleprice
  4121. Double i_cost,i_newprice
  4122. Decimal i_notauditqty,i_allouseqty
  4123. String ls_relcode,ls_relcode_saleout
  4124. Decimal lde_noconqty,lde_notauditqty,lde_mx_qty
  4125. Decimal ld_saletqty_task,ld_fpqty_task,ld_consignedqty_task
  4126. Decimal lde_notauditqty_plan
  4127. Long ll_storagescid
  4128. String ls_unit
  4129. Int li_ifunit
  4130. Decimal ld_scllrate
  4131. String i_mtrlcuscode,i_location
  4132. Decimal ld_viewqty
  4133. Int li_if_cus_mtrlware
  4134. Int ls_noallocflag
  4135. Long ll_storagetype,ll_storagetype_storage,ll_outtype_storage
  4136. Int li_statusflag
  4137. Decimal ld_capacity,ld_capacity_zj
  4138. s_mtrlcfg_expr s_pz[]
  4139. String ls_status_zj
  4140. Long ll_i
  4141. Long li_storagetype
  4142. Decimal ld_upsalerate,ld_upsaleqty
  4143. String ls_status_task,ls_woodcode_task,ls_pcode_task
  4144. Long ll_mtrlid_task
  4145. Decimal ld_scllqty
  4146. Int li_status_ck,li_woodcode_ck,li_pcode_ck
  4147. Decimal ld_noaudit_planqty
  4148. Int i_ifpackpro,li_outtype,i_ifpack
  4149. Decimal i_packqty_fp,ld_pack_noauditqty
  4150. //uo_option_confirmaudit_sale
  4151. //uo_option_sale_use_planqty
  4152. //uo_option_mtrlware_limit
  4153. //uo_option_inout_type
  4154. //uo_option_if_pricetype
  4155. //uo_option_checkprice_native
  4156. uo_cusprice uo_price
  4157. uo_price = Create uo_cusprice
  4158. If uo_option_confirmaudit_sale = -1000 Then
  4159. rslt = 0
  4160. arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
  4161. Goto ext
  4162. End If
  4163. If uo_option_sale_use_planqty = -1000 Then
  4164. rslt = 0
  4165. arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!'
  4166. Goto ext
  4167. End If
  4168. If uo_option_mtrlware_limit = -1000 Then
  4169. rslt = 0
  4170. arg_msg = '选项:[037]客户库存选择限制,读取初始默认值失败,操作取消!'
  4171. Goto ext
  4172. End If
  4173. If uo_option_inout_type = -1000 Then
  4174. rslt = 0
  4175. arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
  4176. Goto ext
  4177. End If
  4178. If uo_option_if_pricetype = -1000 Then
  4179. rslt = 0
  4180. arg_msg = '选项:[154]启用价格分类,读取初始默认值失败,操作取消!'
  4181. Goto ext
  4182. End If
  4183. If uo_option_checkprice_native = -1000 Then
  4184. rslt = 0
  4185. arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!'
  4186. Goto ext
  4187. End If
  4188. If uo_option_if_saleout = -1000 Then
  4189. rslt = 0
  4190. arg_msg = '选项:[200]使用发货通知单,读取初始默认值失败,操作取消!'
  4191. Goto ext
  4192. End If
  4193. If uo_option_outware_sale_checkprice = -1000 Then
  4194. rslt = 0
  4195. arg_msg = '选项:[320]销售发货单保存时检查实价是否与销售订单一致,读取初始默认值失败,操作取消!'
  4196. Goto ext
  4197. End If
  4198. If uo_option_scll_use_planqty = -1000 Then
  4199. rslt = 0
  4200. arg_msg = '选项:[123]领料单使用计划领料数,读取初始默认值失败,操作取消!'
  4201. Goto ext
  4202. End If
  4203. If uo_option_price_rmb = -1000 Then
  4204. rslt = 0
  4205. arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!'
  4206. Goto ext
  4207. End If
  4208. If uo_option_pk_notauditqty_check = -1000 Then
  4209. rslt = 0
  4210. arg_msg = '选项:[397]盘亏单保存时检查库存未开单数,读取初始默认值失败,操作取消!'
  4211. Goto ext
  4212. End If
  4213. If it_newbegin = False And it_updatebegin = False Then
  4214. rslt = 0
  4215. arg_msg = "非编辑状态不可以使用,操作取消"
  4216. Goto ext
  4217. End If
  4218. If uo_option_canpack_ifzanyong = -1000 Then
  4219. rslt = 0
  4220. arg_msg = '选项:[417]通用包件产品可装数选项,读取初始默认值失败,操作取消!'
  4221. Goto ext
  4222. End If
  4223. Select scid,
  4224. storagetype,
  4225. outtype,
  4226. balctype,
  4227. noallocflag
  4228. Into :ll_storagescid,
  4229. :ll_storagetype_storage,
  4230. :ll_outtype_storage,
  4231. :li_if_cus_mtrlware,
  4232. :ls_noallocflag
  4233. From u_storage
  4234. Where storageid = :storageid Using commit_transaction;
  4235. If commit_transaction.SQLCode <> 0 Then
  4236. rslt = 0
  4237. arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText
  4238. Goto ext
  4239. End If
  4240. //清除空值
  4241. If IsNull(s_mx.mtrlwareid) Then s_mx.mtrlwareid = 0
  4242. If IsNull(s_mx.printid) Then s_mx.printid = 0
  4243. If IsNull(s_mx.qty) Then s_mx.qty = 0
  4244. If IsNull(s_mx.fprice) Then s_mx.fprice = 0
  4245. If IsNull(s_mx.rebate) Then s_mx.rebate = 0
  4246. If IsNull(s_mx.mxdscrp) Then s_mx.mxdscrp = ''
  4247. If IsNull(s_mx.ifrel) Then s_mx.ifrel = 0
  4248. If IsNull(s_mx.relid) Then s_mx.relid = 0
  4249. If IsNull(s_mx.olmtrlid) Then s_mx.olmtrlid = 0
  4250. If IsNull(s_mx.packqty) Then s_mx.packqty = 0
  4251. If IsNull(s_mx.outtype) Then s_mx.outtype = ''
  4252. If IsNull(s_mx.planqty) Then s_mx.planqty = 0
  4253. If IsNull(s_mx.relprintid) Then s_mx.relprintid = 0
  4254. If IsNull(s_mx.unit) Then s_mx.unit = ''
  4255. If IsNull(s_mx.uqty) Then s_mx.uqty = 0
  4256. If IsNull(s_mx.rate) Then s_mx.rate = 1
  4257. If IsNull(s_mx.pricetype) Then s_mx.pricetype = ''
  4258. If IsNull(s_mx.formula) Then s_mx.formula = ''
  4259. If IsNull(s_mx.saleoutid) Then s_mx.saleoutid = 0
  4260. If IsNull(s_mx.saleoutprintid) Then s_mx.saleoutprintid = 0
  4261. If IsNull(s_mx.mxdscrp2) Then s_mx.mxdscrp2 = ''
  4262. If IsNull(s_mx.net_weight) Then s_mx.net_weight = 0
  4263. If IsNull(s_mx.gross_weight) Then s_mx.gross_weight = 0
  4264. If IsNull(s_mx.cubage) Then s_mx.cubage = 0
  4265. If IsNull(s_mx.taxrate) Then s_mx.taxrate = 0
  4266. If IsNull(s_mx.priceformula) Then s_mx.priceformula = ''
  4267. If IsNull(s_mx.qtyformula) Then s_mx.qtyformula = ''
  4268. If IsNull(s_mx.ifvqty) Then s_mx.ifvqty = 0
  4269. If IsNull(s_mx.backtype) Then s_mx.backtype = 0
  4270. If IsNull(s_mx.ifnotinout) Then s_mx.ifnotinout = 0
  4271. If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then
  4272. rslt = 1
  4273. Goto ext
  4274. End If
  4275. If billtype <> 9 Then
  4276. If s_mx.uqty = 0 And s_mx.rate = 0 Then
  4277. rslt = 1
  4278. Goto ext
  4279. End If
  4280. End If
  4281. If s_mx.uqty = 0 Then
  4282. s_mx.rate = 1
  4283. Else
  4284. If billtype = 1 Then
  4285. s_mx.rate = s_mx.planqty / s_mx.uqty
  4286. Else
  4287. s_mx.rate = s_mx.qty / s_mx.uqty
  4288. End If
  4289. End If
  4290. If s_mx.rebate < 0 Then
  4291. arg_msg = '折扣错误,请检查'
  4292. rslt = 0
  4293. Goto ext
  4294. End If
  4295. //检查物料库存ID
  4296. Select u_mtrlware.mtrlid,
  4297. u_mtrlware.storageid,
  4298. u_mtrlware.plancode,
  4299. u_mtrlware.status,
  4300. u_mtrlware.cost,
  4301. u_mtrldef.mtrlcode,
  4302. u_mtrlware.sptid,
  4303. u_mtrlware.dxflag,
  4304. u_mtrlware.woodcode,
  4305. u_mtrlware.pcode,
  4306. u_mtrlware.noauditingqty,
  4307. u_mtrlware.noallocqty,
  4308. u_mtrldef.unit,
  4309. u_mtrlware.mtrlcuscode,
  4310. u_mtrlware.location,
  4311. u_mtrldef.storagetype,
  4312. u_mtrldef.statusflag,
  4313. u_mtrldef.capacity * u_mtrldef.capaparm,
  4314. u_mtrldef.storagetype,
  4315. u_mtrldef.upsalerate,
  4316. u_mtrldef.upsaleqty,
  4317. u_mtrldef.ifunit,
  4318. u_mtrldef.outtype,
  4319. u_mtrldef.ifpackpro,
  4320. u_mtrldef.ifpack,
  4321. u_mtrlware.packqty_fp
  4322. Into :i_mtrlid,
  4323. :i_storageid,
  4324. :i_plancode,
  4325. :i_status,
  4326. :i_cost,
  4327. :i_mtrlcode,
  4328. :i_sptid,
  4329. :i_dxflag,
  4330. :i_woodcode,
  4331. :i_pcode,
  4332. :i_notauditqty,
  4333. :i_allouseqty,
  4334. :ls_unit,
  4335. :i_mtrlcuscode,
  4336. :i_location,
  4337. :ll_storagetype,
  4338. :li_statusflag,
  4339. :ld_capacity,
  4340. :li_storagetype,
  4341. :ld_upsalerate,
  4342. :ld_upsaleqty,
  4343. :li_ifunit,
  4344. :li_outtype,
  4345. :i_ifpackpro,
  4346. :i_ifpack,
  4347. :i_packqty_fp
  4348. From u_mtrlware Inner JOIN
  4349. u_mtrldef ON u_mtrlware.mtrlid = u_mtrldef.mtrlid
  4350. Where ( u_mtrlware.mtrlwareid = :s_mx.mtrlwareid )
  4351. And ( u_mtrlware.scid = :ll_storagescid ) Using commit_transaction;
  4352. If commit_transaction.SQLCode <> 0 Then
  4353. rslt = 0
  4354. arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText
  4355. Goto ext
  4356. End If
  4357. If IsNull(ld_dftsaleprice) Then ld_dftsaleprice = 0
  4358. If IsNull(i_cost) Then i_cost = 0
  4359. If IsNull(i_plancode) Then i_plancode = ''
  4360. If IsNull(i_status) Then i_status = ''
  4361. If IsNull(i_mtrlid) Then i_mtrlid = 0
  4362. If IsNull(i_storageid) Then i_storageid = 0
  4363. If IsNull(i_sptid) Then i_sptid = 0
  4364. If IsNull(i_dxflag) Then i_dxflag = 0
  4365. If IsNull(i_woodcode) Then i_woodcode = ''
  4366. If IsNull(i_pcode) Then i_pcode = ''
  4367. If IsNull(i_mtrlcuscode) Then i_mtrlcuscode = ''
  4368. If IsNull(i_location) Then i_location = ''
  4369. If IsNull(ll_storagetype) Then ll_storagetype = 0
  4370. If IsNull(li_statusflag) Then li_statusflag = 0
  4371. If IsNull(ld_capacity) Then ld_capacity = 0
  4372. If IsNull(ld_upsalerate) Then ld_upsalerate = 0
  4373. If IsNull(ld_upsaleqty) Then ld_upsaleqty = 0
  4374. If IsNull(i_packqty_fp) Then i_packqty_fp = 0
  4375. If billtype = 1 And thflag = 0 Then
  4376. If uo_option_confirmaudit_sale = 0 Or uo_option_sale_use_planqty = 0 Then
  4377. If ll_outtype_storage = 0 Then //And ll_storagetype_storage = 0 THEN // // dyy edit 2012-02-23
  4378. s_mx.qty = s_mx.planqty
  4379. End If
  4380. If li_ifunit = 0 And s_mx.rate <> 0 Then
  4381. s_mx.uqty = s_mx.qty / s_mx.rate
  4382. End If
  4383. End If
  4384. End If
  4385. //销售发货单检查高级进出仓属性
  4386. If billtype = 1 Then
  4387. If uo_option_inout_type <> 0 And ll_outtype_storage <> 0 And i_ifpackpro <> 0 And li_outtype = 0 Then
  4388. rslt = 0
  4389. arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",仓库使用包件出仓或条码出仓,发货明细物料资料是包件产品,但产品资料没设为包件出仓或条码出仓,不能保存"
  4390. Goto ext
  4391. End If
  4392. End If
  4393. If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then
  4394. rslt = 1
  4395. Goto ext
  4396. End If
  4397. //IF billtype <> 9 THEN
  4398. // IF li_ifunit = 1 THEN
  4399. // IF s_mx.uqty = s_mx.qty And s_mx.uqty > 0 And s_mx.qty > 0 And s_mx.unit <> ls_unit THEN
  4400. // rslt = 0
  4401. // arg_msg = "第"+String(s_mx.printid)+"行,物料使用库存双数量核算,但录入的计量单位数量与库存单位数量相同,操作取消"
  4402. // GOTO ext
  4403. // END IF
  4404. // END IF
  4405. //END IF
  4406. //
  4407. f_get_planprice_mtrl(i_mtrlid,i_status,i_woodcode,i_pcode,i_planprice)
  4408. If IsNull(i_planprice) Then i_planprice = 0
  4409. If li_statusflag = 2 Then
  4410. ld_capacity = 0
  4411. f_checkpz(i_status,s_pz[])
  4412. For ll_i = 1 To UpperBound(s_pz)
  4413. ls_status_zj = s_pz[ll_i].cfgname
  4414. Select capacity * capaparm
  4415. Into :ld_capacity_zj
  4416. From u_mtrl_configure
  4417. Where mtrlid = :i_mtrlid
  4418. And Name = :ls_status_zj Using commit_transaction;
  4419. If commit_transaction.SQLCode <> 0 Then
  4420. rslt = 0
  4421. arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",查询子件 "+ls_status_zj+" 折算套数参数操作失败"
  4422. Goto ext
  4423. End If
  4424. ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
  4425. Next
  4426. End If
  4427. Select sum(qty) Into :ld_viewqty
  4428. From u_mtrlware_view
  4429. Where scid = :ll_storagescid
  4430. And mtrlwareid = :s_mx.mtrlwareid
  4431. And inuse = 1
  4432. And cusid = :cusid Using commit_transaction;
  4433. If commit_transaction.SQLCode <> 0 Then
  4434. rslt = 0
  4435. arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存虚拟数量,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText
  4436. Goto ext
  4437. End If
  4438. If IsNull(ld_viewqty) Then ld_viewqty = 0
  4439. If billtype = 1 Or billtype = 5 Then
  4440. If ll_storagetype = 0 Then
  4441. If li_if_cus_mtrlware = 1 And uo_option_mtrlware_limit = 0 And flag = 0 Then
  4442. If cusid <> i_sptid Then
  4443. rslt = 0
  4444. arg_msg = "查询操作失败,明细纪录对应的库存不是该客户的库存!"
  4445. Goto ext
  4446. End If
  4447. End If
  4448. End If
  4449. End If
  4450. If billtype = 1 Then
  4451. f_get_defsaleprice(cusid,i_mtrlid,i_status,i_pcode,i_woodcode,relint_2,ld_dftsaleprice)
  4452. Else
  4453. ld_dftsaleprice = 0
  4454. mrate = 1
  4455. End If
  4456. If billtype <> 9 Then
  4457. // IF Trim(ls_unit) <> Trim(s_mx.unit) And s_mx.rate = 1 THEN
  4458. // arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'不同,但转换率为1,请检查'
  4459. // rslt = 0
  4460. // GOTO ext
  4461. // END IF
  4462. If Trim(ls_unit) = Trim(s_mx.unit) And s_mx.rate <> 1 Then
  4463. arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'相同,但转换率不为1,请检查'
  4464. rslt = 0
  4465. Goto ext
  4466. End If
  4467. End If
  4468. //*****检查大于未开数不可以开单
  4469. If (flag = 0 And billtype <> 12 And billtype <> 21 And billtype <> 23 And billtype <> 17 And billtype <> 4 And billtype <> 7 ) And thflag = 0 Then
  4470. If uo_option_pk_notauditqty_check = 0 And billtype = 9 Then
  4471. Goto _end_check_qty
  4472. End If
  4473. If Not (billtype = 3 And relint_1 = 4 And it_newbegin) Then
  4474. Decimal ol_mtrl_qty = 0,ld_mx_qty = 0,ld_ref_qty = 0
  4475. Decimal ol_mtrl_qty_plan = 0,ol_mtrl_qty_sf = 0
  4476. String ls_msg
  4477. Boolean lb_ifplan = False
  4478. If billtype = 1 And uo_option_confirmaudit_sale = 1 And uo_option_sale_use_planqty = 1 Then lb_ifplan = True
  4479. If billtype = 1 And ll_outtype_storage = 2 Then lb_ifplan = True
  4480. If billtype = 3 And relint_1 <> 4 And relint_1 <> 5 And uo_option_scll_use_planqty = 1 Then lb_ifplan = True
  4481. If ls_noallocflag = 1 Then
  4482. If it_updatebegin Then
  4483. Select sum(u_outwaremx.qty),sum(u_outwaremx.planqty)
  4484. Into :ol_mtrl_qty_sf,:ol_mtrl_qty_plan
  4485. From u_outwaremx
  4486. Where u_outwaremx.outwareid = :outwareid
  4487. And u_outwaremx.mtrlwareid = :s_mx.mtrlwareid
  4488. And scid = :scid Using commit_transaction;
  4489. If commit_transaction.SQLCode = -1 Then
  4490. rslt = 0
  4491. arg_msg = "物料编码:"+i_mtrlcode+',查询原开单数量失败'
  4492. Goto ext
  4493. End If
  4494. End If
  4495. For LS_i = 1 To it_mxbt
  4496. If s_mx.mtrlwareid = outwaremx[LS_i].mtrlwareid Then
  4497. If lb_ifplan Then
  4498. ld_mx_qty = ld_mx_qty + outwaremx[LS_i].planqty
  4499. Else
  4500. ld_mx_qty = ld_mx_qty + outwaremx[LS_i].qty
  4501. End If
  4502. End If
  4503. Next
  4504. If lb_ifplan Then
  4505. ld_mx_qty = ld_mx_qty + s_mx.planqty
  4506. Else
  4507. ld_mx_qty = ld_mx_qty + s_mx.qty
  4508. End If
  4509. If IsNull(i_allouseqty) Then i_allouseqty = 0
  4510. If IsNull(i_notauditqty) Then i_notauditqty = 0
  4511. If IsNull(ol_mtrl_qty_sf) Then ol_mtrl_qty_sf = 0
  4512. If IsNull(ol_mtrl_qty_plan) Then ol_mtrl_qty_plan = 0
  4513. If IsNull(ld_mx_qty) Then ld_mx_qty = 0
  4514. Select ifpackpro Into :i_ifpackpro
  4515. From u_mtrldef
  4516. Where mtrlid = :i_mtrlid Using commit_transaction ;
  4517. If commit_transaction.SQLCode <> 0 Then
  4518. arg_msg = "物料编码:"+i_mtrlcode+',查询物料是否包件产品失败,'+commit_transaction.SQLErrText
  4519. rslt = 0
  4520. Goto ext
  4521. End If
  4522. ld_ref_qty = 0
  4523. If i_ifpackpro > 0 Then
  4524. If f_cmp_di_qty_outware(scid,outwareid,i_mtrlid,storageid,i_status,i_woodcode,i_pcode,i_plancode,i_mtrlcuscode,cusid,ld_ref_qty,ls_msg,arg_msg) = 0 Then
  4525. ld_ref_qty = 0
  4526. // arg_msg = '第'+String(s_mx.printid)+'行,计算可装数失败,'+arg_msg
  4527. // rslt = 0
  4528. // GOTO ext
  4529. End If
  4530. If uo_option_inout_type = 0 Then
  4531. If lb_ifplan Then
  4532. ol_mtrl_qty = ol_mtrl_qty_plan
  4533. Else
  4534. ol_mtrl_qty = ol_mtrl_qty_sf
  4535. End If
  4536. Else
  4537. ol_mtrl_qty = 0
  4538. End If
  4539. Else
  4540. If lb_ifplan Then
  4541. ol_mtrl_qty = ol_mtrl_qty_plan
  4542. Else
  4543. ol_mtrl_qty = ol_mtrl_qty_sf
  4544. End If
  4545. End If
  4546. If ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty + ld_ref_qty + ld_viewqty ) Then
  4547. rslt = 0
  4548. arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00#######')+"}" + "可组装数{"+String(ld_ref_qty,'#####,0.00#######')+"}"+ "库存虚拟数量{"+String(ld_viewqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######')
  4549. Goto ext
  4550. End If
  4551. //如果包件产品使用占用数流程, 直接开单发包件,要检查数量不能超出未分配占用数(盘亏单除外)
  4552. If i_ifpack = 1 And uo_option_canpack_ifzanyong = 1 And billtype <> 9 Then
  4553. Select SUM(Case u_outwaremx.qty WHEN 0 Then u_outwaremx.planqty Else u_outwaremx.qty End)
  4554. Into :ld_pack_noauditqty
  4555. From u_outwaremx Inner JOIN
  4556. u_outware On u_outwaremx.scid = u_outware.scid And
  4557. u_outwaremx.outwareid = u_outware.outwareid
  4558. Where (u_outware.flag = 0)
  4559. And (u_outware.thflag = 0)
  4560. And ( u_outwaremx.mtrlwareid = :s_mx.mtrlwareid )
  4561. And ( u_outwaremx.scid = :scid )
  4562. and (u_outware.outwareid <> :outwareid) Using commit_transaction;
  4563. If commit_transaction.SQLCode = -1 Then
  4564. rslt = 0
  4565. arg_msg = "物料编码:"+i_mtrlcode+',查询包件直接开单数量失败'
  4566. Goto ext
  4567. End If
  4568. If IsNull(ld_pack_noauditqty) Then ld_pack_noauditqty = 0
  4569. If ld_mx_qty - ol_mtrl_qty + ld_pack_noauditqty > i_allouseqty - i_packqty_fp Then
  4570. rslt = 0
  4571. arg_msg = String(i_mtrlcode)+"库存未分配数不够,不能开单.未分配占用数{"+String(i_allouseqty - i_packqty_fp + ol_mtrl_qty,'#####,0.00#######')+"}" + "包件已直接开单数{"+string(ld_pack_noauditqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######')
  4572. Goto ext
  4573. End If
  4574. End If
  4575. End If
  4576. End If
  4577. _end_check_qty:
  4578. End If
  4579. //***********************************************
  4580. If uo_option_sale_ifuse_negativeprice = 0 Then
  4581. If s_mx.fprice * s_mx.rebate < 0 Then //检查单价
  4582. rslt = 0
  4583. arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 单价错误"
  4584. Goto ext
  4585. End If
  4586. End If
  4587. If s_mx.rebate < 0 Then
  4588. rslt = 0
  4589. arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 折扣错误"
  4590. Goto ext
  4591. End If
  4592. Choose Case billtype
  4593. Case 1
  4594. If s_mx.ifrel > 0 Then
  4595. If flag = 0 Then
  4596. //检查订单
  4597. If s_mx.relid = 0 Then
  4598. arg_msg = '请先择相应的订单'
  4599. rslt = 0
  4600. Goto ext
  4601. End If
  4602. Select u_saletask.taskcode,
  4603. u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty - u_saletaskmx.consignedqty ,
  4604. u_saletaskmx.mtrlid,
  4605. u_saletaskmx.status,
  4606. u_saletaskmx.woodcode,
  4607. u_saletaskmx.pcode,
  4608. u_saletaskmx.fpqty,
  4609. u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty,
  4610. u_saletaskmx.consignedqty
  4611. Into :ls_relcode,
  4612. :lde_noconqty,
  4613. :ll_mtrlid_task,
  4614. :ls_status_task,
  4615. :ls_woodcode_task,
  4616. :ls_pcode_task,
  4617. :ld_fpqty_task,
  4618. :ld_saletqty_task,
  4619. :ld_consignedqty_task
  4620. From u_saletaskmx,u_saletask
  4621. Where u_saletaskmx.taskid = :s_mx.relid
  4622. And u_saletaskmx.scid = :scid
  4623. And u_saletaskmx.scid = u_saletask.scid
  4624. And u_saletaskmx.printid = :s_mx.relprintid
  4625. And u_saletaskmx.taskid = u_saletask.taskid
  4626. Using commit_transaction;
  4627. If commit_transaction.SQLCode <> 0 Then
  4628. arg_msg = '查询销售订单是否有订购产品:'+i_mtrlcode+'失败'
  4629. rslt = 0
  4630. Goto ext
  4631. End If
  4632. If ll_mtrlid_task <> i_mtrlid Then
  4633. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息(物料id)不匹配,不允许保存,请检查相关订单信息与库存信息'
  4634. rslt = 0
  4635. Goto ext
  4636. End If
  4637. Select Top 1 Case WHEN ltrim(rtrim(:i_status)) = ltrim(rtrim(:ls_status_task)) Then 0 Else 1 End,
  4638. Case WHEN ltrim(rtrim(:i_woodcode)) = ltrim(rtrim(:ls_woodcode_task)) Then 0 Else 1 End,
  4639. Case WHEN ltrim(rtrim(:i_pcode)) = ltrim(rtrim(:ls_pcode_task)) Then 0 Else 1 End
  4640. Into :li_status_ck,:li_woodcode_ck,:li_pcode_ck
  4641. From u_user Using commit_transaction;
  4642. If commit_transaction.SQLCode <> 0 Then
  4643. arg_msg = '查询订单:'+ls_relcode+' 产品:'+i_mtrlcode+',3个配置信息与库存3个配置信息是否相同失败,'+commit_transaction.SQLErrText
  4644. rslt = 0
  4645. Goto ext
  4646. End If
  4647. If li_status_ck + li_woodcode_ck + li_pcode_ck > 0 Then
  4648. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息不匹配,不允许保存,请检查相关订单信息与库存信息'
  4649. rslt = 0
  4650. Goto ext
  4651. End If
  4652. lde_mx_qty = 0
  4653. For LS_i = 1 To it_mxbt
  4654. If i_mtrlid = outwaremx[LS_i].mtrlid And &
  4655. s_mx.relid = outwaremx[LS_i].relid And &
  4656. i_status = outwaremx[LS_i].status And &
  4657. i_woodcode = outwaremx[LS_i].woodcode And &
  4658. i_pcode = outwaremx[LS_i].pcode And &
  4659. (i_plancode = outwaremx[LS_i].plancode Or li_storagetype = 1) And &
  4660. s_mx.relprintid = outwaremx[LS_i].relprintid Then
  4661. If lb_ifplan Then
  4662. lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty
  4663. Else
  4664. lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty
  4665. End If
  4666. End If
  4667. Next
  4668. If lb_ifplan Then
  4669. lde_mx_qty = lde_mx_qty + s_mx.planqty
  4670. Else
  4671. lde_mx_qty = lde_mx_qty + s_mx.qty
  4672. End If
  4673. //查询相关订单已开发货单未审核数量
  4674. Select isnull(sum(qty),0),isnull(sum(planqty),0)
  4675. Into :lde_notauditqty,:lde_notauditqty_plan
  4676. From u_outwaremx,u_outware
  4677. Where u_outwaremx.relid = :s_mx.relid
  4678. And u_outwaremx.relprintid = :s_mx.relprintid
  4679. And u_outware.flag = 0
  4680. And u_outware.billtype = 1
  4681. And u_outwaremx.outwareid = u_outware.outwareid
  4682. And u_outwaremx.scid = u_outware.scid
  4683. And u_outware.outwareid <> :outwareid
  4684. And u_outware.scid = :scid
  4685. Using commit_transaction;
  4686. If commit_transaction.SQLCode <> 0 Then
  4687. arg_msg = '查询销售订单:'+ls_relcode+'产品:'+i_mtrlcode+'已开发货单未审核数量失败'
  4688. rslt = 0
  4689. Goto ext
  4690. End If
  4691. If lb_ifplan Then
  4692. If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then
  4693. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4694. rslt = 0
  4695. Goto ext
  4696. End If
  4697. If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then
  4698. If lde_notauditqty_plan + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then
  4699. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4700. rslt = 0
  4701. Goto ext
  4702. End If
  4703. End If
  4704. Else
  4705. If lde_notauditqty + lde_mx_qty > lde_noconqty Then
  4706. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4707. rslt = 0
  4708. Goto ext
  4709. End If
  4710. If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then
  4711. If lde_notauditqty + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then
  4712. arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4713. rslt = 0
  4714. Goto ext
  4715. End If
  4716. End If
  4717. End If
  4718. //检查发货通知单
  4719. If uo_option_if_saleout = 1 And thflag = 0 Then
  4720. If s_mx.saleoutid = 0 Then
  4721. arg_msg = '请先择相应的发货通知单'
  4722. rslt = 0
  4723. Goto ext
  4724. End If
  4725. Select u_saleoutmx.saleqty - u_saleoutmx.consignedqty - u_saleoutmx.stopqty,
  4726. u_saleout.taskcode
  4727. Into :lde_noconqty,:ls_relcode_saleout
  4728. From u_saleoutmx,u_saleout
  4729. Where u_saleoutmx.taskid = :s_mx.saleoutid
  4730. And u_saleoutmx.printid = :s_mx.saleoutprintid
  4731. And u_saleoutmx.taskid = u_saleout.taskid
  4732. And u_saleout.scid = :scid
  4733. Using commit_transaction;
  4734. If commit_transaction.SQLCode <> 0 Then
  4735. arg_msg = '查询发货通知单是否有产品:'+i_mtrlcode+'失败,'+commit_transaction.SQLErrText
  4736. rslt = 0
  4737. Goto ext
  4738. End If
  4739. lde_mx_qty = 0
  4740. For LS_i = 1 To it_mxbt
  4741. If s_mx.saleoutid = outwaremx[LS_i].saleoutid And &
  4742. s_mx.saleoutprintid = outwaremx[LS_i].saleoutprintid Then
  4743. If lb_ifplan Then
  4744. lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty
  4745. Else
  4746. lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty
  4747. End If
  4748. End If
  4749. Next
  4750. If lb_ifplan Then
  4751. lde_mx_qty = lde_mx_qty + s_mx.planqty
  4752. Else
  4753. lde_mx_qty = lde_mx_qty + s_mx.qty
  4754. End If
  4755. //查询相关订单已开发货单未审核数量
  4756. Select isnull(sum(qty),0),isnull(sum(planqty),0)
  4757. Into :lde_notauditqty,:lde_notauditqty_plan
  4758. From u_outwaremx,u_outware
  4759. Where u_outwaremx.saleoutid = :s_mx.saleoutid
  4760. And u_outwaremx.saleoutprintid = :s_mx.saleoutprintid
  4761. And u_outware.flag = 0
  4762. And u_outware.billtype = 1
  4763. And u_outwaremx.outwareid = u_outware.outwareid
  4764. And u_outwaremx.scid = u_outware.scid
  4765. And u_outware.outwareid <> :outwareid
  4766. And u_outware.scid = :scid
  4767. Using commit_transaction;
  4768. If commit_transaction.SQLCode <> 0 Then
  4769. arg_msg = '查询发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'已开发货单未审核数量失败,'+commit_transaction.SQLErrText
  4770. rslt = 0
  4771. Goto ext
  4772. End If
  4773. If lb_ifplan Then
  4774. If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then
  4775. arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4776. rslt = 0
  4777. Goto ext
  4778. End If
  4779. Else
  4780. If lde_notauditqty + lde_mx_qty > lde_noconqty Then
  4781. arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  4782. rslt = 0
  4783. Goto ext
  4784. End If
  4785. End If
  4786. End If
  4787. End If
  4788. End If
  4789. Case 3
  4790. // IF uo_option_scll_limit = 0 AND NOT relint_1 = 3 THEN
  4791. If Not (relint_1 = 3 Or relint_1 = 4 ) Then
  4792. Select u_mtrldef.mtrlkind,
  4793. u_mtrldef.scllrate,
  4794. u_mtrldef.scllqty
  4795. Into :li_mtrlkind,
  4796. :ld_scllrate,
  4797. :ld_scllqty
  4798. From u_mtrldef,u_mtrlware
  4799. Where u_mtrldef.mtrlid = u_mtrlware.mtrlid And
  4800. u_mtrlware.mtrlwareid = :s_mx.mtrlwareid And
  4801. u_mtrlware.scid = :ll_storagescid
  4802. Using commit_transaction;
  4803. If commit_transaction.SQLCode <> 0 Then
  4804. arg_msg = '查询物料:'+i_mtrlcode+'分摊属性失败'
  4805. rslt = 0
  4806. Goto ext
  4807. End If
  4808. // If li_mtrlkind = 0 And Not f_power_ind(119,sys_msg_pow) And ( s_mx.ifrel = 0 Or s_mx.relid = 0 ) Then
  4809. // arg_msg = '请先选择计划,第'+String(s_mx.printid)+'行'
  4810. // rslt = 0
  4811. // Goto ext
  4812. // End If
  4813. //
  4814. // If li_mtrlkind = 1 And ( s_mx.ifrel = 1 Or s_mx.relid > 0 ) Then
  4815. // arg_msg = '不能选择计划,第'+String(s_mx.printid)+'行'
  4816. // rslt = 0
  4817. // Goto ext
  4818. // End If
  4819. If (li_mtrlkind = 0 Or (li_mtrlkind = 2 And ld_scllrate > 0)) And (relint_1 = 0 Or relint_1 = 5) And s_mx.relid > 0 Then
  4820. Decimal ld_RqQty,ld_DstrQty,ld_noaudit_DstrQty
  4821. Decimal ld_allowqty
  4822. Long ll_wrkGrpid
  4823. Decimal ld_backqty,ld_backbuqty
  4824. Select u_OrderRqMtrl_scll.trueRqQty,
  4825. u_OrderRqMtrl_scll.DstrQty,
  4826. u_OrderRqMtrl_scll.wrkGrpid,
  4827. isnull(uv_outware_scll_back.qty,0)
  4828. Into :ld_RqQty,
  4829. :ld_DstrQty,
  4830. :ll_wrkGrpid,
  4831. :ld_backqty
  4832. From u_OrderRqMtrl_scll Inner JOIN
  4833. u_workgroup ON
  4834. u_OrderRqMtrl_scll.wrkGrpid = u_workgroup.wrkGrpid LEFT Outer JOIN
  4835. uv_outware_scll_back ON
  4836. u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid And
  4837. u_OrderRqMtrl_scll.status = uv_outware_scll_back.status And
  4838. u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode And
  4839. u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode And
  4840. u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid And
  4841. u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid
  4842. Where u_OrderRqMtrl_scll.scid = :scid
  4843. And u_OrderRqMtrl_scll.orderid = :s_mx.relid
  4844. And u_OrderRqMtrl_scll.MtrlID = :i_mtrlid
  4845. And u_OrderRqMtrl_scll.status = :i_status
  4846. And u_OrderRqMtrl_scll.woodcode = :i_woodcode
  4847. And u_OrderRqMtrl_scll.pcode = :i_pcode
  4848. And u_workgroup.workgroupid = :relid
  4849. Using commit_transaction;
  4850. If commit_transaction.SQLCode <> 0 Then
  4851. arg_msg = '查询物料'+i_mtrlcode+'计划领料数和已领料数失败,'+sqlca.SQLErrText
  4852. rslt = 0
  4853. Goto ext
  4854. End If
  4855. If relint_1 = 5 Then
  4856. Select sum(u_Outwaremx.qty) Into :ld_backbuqty
  4857. From u_outware,u_Outwaremx,u_workgroup
  4858. Where u_outware.scid = u_Outwaremx.scid
  4859. And u_outware.outwareid = u_Outwaremx.outwareid
  4860. And u_outware.billtype = 3
  4861. And u_outware.relint_1 = 5
  4862. And u_outware.outwareid <> :outwareid
  4863. And u_Outwaremx.scid = :scid
  4864. And u_Outwaremx.mtrlid = :i_mtrlid
  4865. And u_outware.relid = u_workgroup.workgroupid
  4866. And u_workgroup.wrkGrpid = :ll_wrkGrpid
  4867. And u_Outwaremx.relid = :s_mx.relid
  4868. Using commit_transaction;
  4869. If commit_transaction.SQLCode <> 0 Then
  4870. arg_msg = '查询物料'+i_mtrlcode+'已补料单数失败,'+sqlca.SQLErrText
  4871. rslt = 0
  4872. Goto ext
  4873. End If
  4874. If IsNull(ld_backbuqty) Then ld_backbuqty = 0
  4875. If 0 - ld_backqty < s_mx.qty + ld_backbuqty Then
  4876. arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可补料总数:'+String(0 - ld_backqty,'#,#0.0#########')+',已补料数:'+String(ld_backbuqty,'#,#0.0#########')+',不可再补料:'+String(s_mx.qty,'#,#0.0#########')
  4877. rslt = 0
  4878. Goto ext
  4879. End If
  4880. End If
  4881. Select sum(u_Outwaremx.qty),sum(u_Outwaremx.planqty) Into :ld_noaudit_DstrQty,:ld_noaudit_planqty
  4882. From u_outware,u_Outwaremx,u_workgroup
  4883. Where u_outware.scid = u_Outwaremx.scid
  4884. And u_outware.outwareid = u_Outwaremx.outwareid
  4885. And u_outware.billtype = 3
  4886. And u_outware.flag = 0
  4887. And u_outware.outwareid <> :outwareid
  4888. And u_Outwaremx.scid = :scid
  4889. And u_Outwaremx.mtrlid = :i_mtrlid
  4890. And u_outware.relid = u_workgroup.workgroupid
  4891. And u_workgroup.wrkGrpid = :ll_wrkGrpid
  4892. And u_Outwaremx.relid = :s_mx.relid
  4893. Using commit_transaction;
  4894. If commit_transaction.SQLCode <> 0 Then
  4895. arg_msg = '查询物料'+i_mtrlcode+'已开单领料数失败,'+sqlca.SQLErrText
  4896. rslt = 0
  4897. Goto ext
  4898. End If
  4899. If IsNull(ld_RqQty) Then ld_RqQty = 0
  4900. If IsNull(ld_DstrQty) Then ld_DstrQty = 0
  4901. If IsNull(ld_noaudit_DstrQty) Then ld_noaudit_DstrQty = 0
  4902. // IF li_mtrlkind = 0 THEN
  4903. // ld_scllrate = 0
  4904. // ld_scllqty
  4905. ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_DstrQty
  4906. If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_DstrQty + s_mx.qty Then
  4907. arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单数:'+String(ld_noaudit_DstrQty,'#,#0.0####')
  4908. rslt = 0
  4909. Goto ext
  4910. End If
  4911. If uo_option_scll_use_planqty = 1 And Not f_power_ind(3863,sys_msg_pow) Then
  4912. ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_planqty
  4913. If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_planqty + s_mx.planqty Then
  4914. arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单计划数:'+String(ld_noaudit_planqty,'#,#0.0####')
  4915. rslt = 0
  4916. Goto ext
  4917. End If
  4918. End If
  4919. End If
  4920. End If
  4921. If s_mx.ifrel > 0 And relint_1 <> 4 Then
  4922. If s_mx.relid = 0 Then
  4923. arg_msg = '请先择相应的计划'
  4924. rslt = 0
  4925. Goto ext
  4926. End If
  4927. Select ordercode Into :ls_relcode
  4928. From u_order_ml
  4929. Where u_order_ml.orderid = :s_mx.relid
  4930. And u_order_ml.scid = :scid
  4931. Using commit_transaction;
  4932. If commit_transaction.SQLCode <> 0 Then
  4933. arg_msg = '查询生产计划是否有生产产品失败'
  4934. rslt = 0
  4935. Goto ext
  4936. End If
  4937. End If
  4938. If relint_1 = 4 Then
  4939. Select outwarecode
  4940. Into :ls_relcode
  4941. From u_outware_scllplan
  4942. Where outwareid = :s_mx.relid
  4943. And scid = :scid
  4944. Using commit_transaction;
  4945. If commit_transaction.SQLCode <> 0 Then
  4946. arg_msg = '查询相关发料通知单失败'
  4947. rslt = 0
  4948. Goto ext
  4949. End If
  4950. End If
  4951. End Choose
  4952. //销售发货单要取分部结算价
  4953. Decimal ld_scidprice,ld_price_task
  4954. If flag = 0 Then
  4955. If billtype = 1 Or billtype = 5 Then
  4956. If s_mx.ifrel = 1 Then
  4957. Select scidprice,price
  4958. Into :ld_scidprice,:ld_price_task
  4959. From u_saletaskmx
  4960. Where scid = :scid
  4961. And u_saletaskmx.printid = :s_mx.relprintid
  4962. And u_saletaskmx.taskid = :s_mx.relid Using commit_transaction;
  4963. If commit_transaction.SQLCode <> 0 Then
  4964. arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询相关销售订单分部结算价失败'+commit_transaction.SQLErrText
  4965. rslt = 0
  4966. Goto ext
  4967. End If
  4968. Else
  4969. Select scidprice
  4970. Into :ld_scidprice
  4971. From u_mtrldef
  4972. Where mtrlid = :i_mtrlid Using commit_transaction;
  4973. If commit_transaction.SQLCode <> 0 Then
  4974. arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询物料分部结算价失败'+commit_transaction.SQLErrText
  4975. rslt = 0
  4976. Goto ext
  4977. End If
  4978. End If
  4979. End If
  4980. End If
  4981. //**取最新价
  4982. Select price
  4983. Into :i_newprice
  4984. From v_maxprice_sptprice
  4985. Where mtrlid = :i_mtrlid Using commit_transaction;
  4986. If commit_transaction.SQLCode <> 0 Or IsNull(i_newprice) Then i_newprice = 0
  4987. If billtype = 1 Then
  4988. // IF uo_option_if_pricetype = 1 And s_mx.pricetype <> '' THEN
  4989. Int li_ifcheckprice
  4990. If s_mx.pricetype <> '' Then
  4991. Select ifcheckprice
  4992. Into :li_ifcheckprice
  4993. From u_pricetype
  4994. Where pricetype = :s_mx.pricetype Using commit_transaction;
  4995. If commit_transaction.SQLCode <> 0 Then
  4996. arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询价格分类是否属于赠送类型失败,'+commit_transaction.SQLErrText
  4997. rslt = 0
  4998. Goto ext
  4999. End If
  5000. Else
  5001. li_ifcheckprice = 1
  5002. End If
  5003. If li_ifcheckprice = 2 Then s_mx.rebate = 0
  5004. If li_ifcheckprice = 1 And s_mx.ifrel = 0 Then
  5005. If uo_option_checkprice_native = 1 Then
  5006. If uo_price.uof_check_price (cusid,i_mtrlid,&
  5007. i_mtrlcode,i_status,i_pcode,&
  5008. i_woodcode,relint_2,s_mx.fprice * mrate * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then
  5009. rslt = 0
  5010. Goto ext
  5011. End If
  5012. Else
  5013. If uo_price.uof_check_price (cusid,i_mtrlid,&
  5014. i_mtrlcode,i_status,i_pcode,&
  5015. i_woodcode,relint_2,s_mx.fprice * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then
  5016. rslt = 0
  5017. Goto ext
  5018. End If
  5019. End If
  5020. End If
  5021. // END IF
  5022. End If
  5023. //写入内容
  5024. it_mxbt++
  5025. outwaremx[it_mxbt].dftsaleprice = ld_dftsaleprice
  5026. outwaremx[it_mxbt].mtrlwareid = s_mx.mtrlwareid
  5027. outwaremx[it_mxbt].mtrlid = i_mtrlid
  5028. outwaremx[it_mxbt].status = i_status
  5029. outwaremx[it_mxbt].qty = s_mx.qty
  5030. outwaremx[it_mxbt].planqty = s_mx.planqty
  5031. outwaremx[it_mxbt].storageid = i_storageid
  5032. outwaremx[it_mxbt].cost = i_cost
  5033. outwaremx[it_mxbt].costamt = Round(i_cost * s_mx.qty,2)
  5034. outwaremx[it_mxbt].newpriceamt = Round(i_newprice * s_mx.qty,2)
  5035. outwaremx[it_mxbt].plancode = i_plancode
  5036. outwaremx[it_mxbt].planprice = i_planprice
  5037. outwaremx[it_mxbt].mtrlcode = i_mtrlcode
  5038. outwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
  5039. outwaremx[it_mxbt].printid = s_mx.printid
  5040. outwaremx[it_mxbt].outtype = s_mx.outtype
  5041. outwaremx[it_mxbt].enprice = s_mx.fprice
  5042. outwaremx[it_mxbt].rebate = s_mx.rebate
  5043. If uo_option_price_rmb = 1 And billtype = 1 Then
  5044. outwaremx[it_mxbt].fprice = Round(s_mx.fprice * mrate,2)
  5045. outwaremx[it_mxbt].price = Round(outwaremx[it_mxbt].fprice * s_mx.rebate,2)
  5046. Else
  5047. outwaremx[it_mxbt].fprice = s_mx.fprice * mrate
  5048. outwaremx[it_mxbt].price = outwaremx[it_mxbt].fprice * s_mx.rebate
  5049. End If
  5050. If billtype = 1 And s_mx.ifrel = 1 And uo_option_outware_sale_checkprice = 1 Then
  5051. If Abs(outwaremx[it_mxbt].price - ld_price_task) > 0.02 Then
  5052. arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+',销售发货单实价:'+String(outwaremx[it_mxbt].price,'#,##0.00')+' 与对应销售订单实价:'+String(ld_price_task,'#,##0.00')+' 不一致,请检查'
  5053. rslt = 0
  5054. Goto ext
  5055. End If
  5056. End If
  5057. If billtype = 1 Then
  5058. If uo_option_price_rmb = 1 Then
  5059. outwaremx[it_mxbt].enacprice = Round(outwaremx[it_mxbt].fprice * s_mx.rebate/mrate,2)
  5060. Else
  5061. outwaremx[it_mxbt].enacprice = outwaremx[it_mxbt].fprice * s_mx.rebate/mrate
  5062. End If
  5063. Else
  5064. outwaremx[it_mxbt].enacprice = 0
  5065. End If
  5066. outwaremx[it_mxbt].sptid = i_sptid
  5067. outwaremx[it_mxbt].dxflag = i_dxflag
  5068. outwaremx[it_mxbt].ifrel = s_mx.ifrel
  5069. outwaremx[it_mxbt].relid = s_mx.relid
  5070. outwaremx[it_mxbt].olmtrlid = s_mx.olmtrlid
  5071. outwaremx[it_mxbt].packqty = s_mx.packqty
  5072. outwaremx[it_mxbt].woodcode = i_woodcode
  5073. outwaremx[it_mxbt].pcode = i_pcode
  5074. outwaremx[it_mxbt].relcode = ls_relcode
  5075. outwaremx[it_mxbt].relprintid = s_mx.relprintid
  5076. outwaremx[it_mxbt].unit = s_mx.unit
  5077. outwaremx[it_mxbt].rate = s_mx.rate
  5078. outwaremx[it_mxbt].uqty = s_mx.uqty
  5079. outwaremx[it_mxbt].mtrlcuscode = i_mtrlcuscode
  5080. outwaremx[it_mxbt].Location = i_location
  5081. outwaremx[it_mxbt].scidprice = ld_scidprice
  5082. outwaremx[it_mxbt].pricetype = s_mx.pricetype
  5083. outwaremx[it_mxbt].formula = s_mx.formula
  5084. outwaremx[it_mxbt].capacity = ld_capacity * s_mx.qty
  5085. outwaremx[it_mxbt].saleoutid = s_mx.saleoutid
  5086. outwaremx[it_mxbt].saleoutprintid = s_mx.saleoutprintid
  5087. outwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2
  5088. outwaremx[it_mxbt].net_weight = s_mx.net_weight
  5089. outwaremx[it_mxbt].gross_weight = s_mx.gross_weight
  5090. outwaremx[it_mxbt].cubage = s_mx.cubage
  5091. outwaremx[it_mxbt].taxrate = s_mx.taxrate
  5092. outwaremx[it_mxbt].priceformula = s_mx.priceformula
  5093. outwaremx[it_mxbt].qtyformula = s_mx.qtyformula
  5094. outwaremx[it_mxbt].ifvqty = s_mx.ifvqty
  5095. outwaremx[it_mxbt].backtype = s_mx.backtype
  5096. outwaremx[it_mxbt].ifnotinout = s_mx.ifnotinout
  5097. outwaremx[it_mxbt].ifpackpro = i_ifpackpro
  5098. outwaremx[it_mxbt].ifpack = i_ifpack
  5099. ext:
  5100. If rslt = 0 Then p_clearmx()
  5101. Destroy uo_price
  5102. Return rslt
  5103. end function
  5104. protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg);Int rslt = 1
  5105. Long ls_newid
  5106. Decimal ld_cost
  5107. Int li_storMtrlprp,li_storagetype,li_outtype_storage
  5108. Long ll_storagescid
  5109. Int li_ifunit,li_ifpack,li_ifpackpro
  5110. Int li_statusflag
  5111. Decimal ld_capacity,ld_capacity_zj
  5112. s_mtrlcfg_expr s_pz[]
  5113. String ls_status_zj
  5114. Long ll_i
  5115. Decimal ld_noallocqty,ld_allocqty
  5116. String ls_storagename
  5117. Int li_ifcost
  5118. Int if_recmp_balc
  5119. String or_err_part
  5120. Decimal ld_pypkqty,ld_pypkamt
  5121. Decimal ld_saleoutqty,ld_saleoutamt
  5122. Decimal ld_saleoutqty_pack,ld_saleoutamt_pack
  5123. Decimal ld_buyoutqty_packpro,ld_buyoutamt_packpro
  5124. Decimal ld_cpoutqty,ld_cpoutamt
  5125. Decimal ld_jgoutqty,ld_jgoutamt
  5126. Decimal ld_dioutqty,ld_dioutamt
  5127. Decimal ld_mvoutqty,ld_mvoutamt
  5128. Decimal ld_otoutqty,ld_otoutamt
  5129. Decimal ld_pkoutqty,ld_pkoutamt
  5130. int li_ifmrp
  5131. IF sys_if_recmp_balc < 0 THEN
  5132. SELECT if_recmp_balc
  5133. INTO :if_recmp_balc
  5134. From sys_msg Using commit_transaction ;
  5135. IF commit_transaction.SQLCode <> 0 THEN
  5136. arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText
  5137. rslt = 0
  5138. GOTO ext
  5139. END IF
  5140. IF if_recmp_balc = 0 THEN
  5141. rslt = 0
  5142. arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
  5143. GOTO ext
  5144. END IF
  5145. ELSE
  5146. IF sys_if_recmp_balc = 0 THEN
  5147. rslt = 0
  5148. arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
  5149. GOTO ext
  5150. END IF
  5151. END IF
  5152. IF uo_option_change_status = '-1000' THEN
  5153. rslt = 0
  5154. arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
  5155. GOTO ext
  5156. END IF
  5157. IF uo_option_change_woodcode = '-1000' THEN
  5158. rslt = 0
  5159. arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
  5160. GOTO ext
  5161. END IF
  5162. IF uo_option_change_pcode = '-1000' THEN
  5163. rslt = 0
  5164. arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
  5165. GOTO ext
  5166. END IF
  5167. IF uo_option_cost_dec = -1000 THEN
  5168. rslt = 0
  5169. arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!'
  5170. GOTO ext
  5171. END IF
  5172. IF uo_option_mtrlware_autocmp = -1000 THEN
  5173. rslt = 0
  5174. arg_msg = '选项:[158]自动计算库存包件可装数,读取初始默认值失败,操作取消!'
  5175. GOTO ext
  5176. END IF
  5177. If uo_option_djqty_check = -1000 Then
  5178. rslt = 0
  5179. arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!'
  5180. Goto ext
  5181. End If
  5182. uo_cmpl_packpro uo_cmpl_p
  5183. uo_cmpl_p = Create uo_cmpl_packpro
  5184. uo_cmpl_p.commit_transaction = commit_transaction
  5185. SELECT Mtrlprp,scid,storagetype,outtype,storagename,ifcost,ifmrp
  5186. INTO :li_storMtrlprp,:ll_storagescid,:li_storagetype,:li_outtype_storage,:ls_storagename,:li_ifcost,:li_ifmrp
  5187. FROM u_storage
  5188. Where storageid = :arg_storageid Using commit_transaction ;
  5189. IF commit_transaction.SQLCode <> 0 THEN
  5190. arg_msg = '查询仓库信息失败,'+commit_transaction.SQLErrText
  5191. rslt = 0
  5192. GOTO ext
  5193. END IF
  5194. IF li_storagetype = 1 THEN
  5195. IF billtype <> 1 And billtype <> 23 Or billtype = 1 And li_outtype_storage = 0 THEN
  5196. SELECT noallocqty,allocqty INTO :ld_noallocqty,:ld_allocqty
  5197. FROM u_mtrlware
  5198. WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
  5199. ( scid = :ll_storagescid ) Using commit_transaction ;
  5200. IF commit_transaction.SQLCode <> 0 THEN
  5201. arg_msg = '仓库:'+ls_storagename+',查询库存信息失败,'+commit_transaction.SQLErrText
  5202. rslt = 0
  5203. GOTO ext
  5204. END IF
  5205. IF ld_noallocqty - arg_qty < ld_allocqty THEN
  5206. arg_msg = '仓库:'+ls_storagename+',库存数小于已分配数,请检查库存,库存id:'+string(arg_mtrlwareid)+',库存数:'+String(ld_noallocqty - arg_qty,'#0.##########')+',已分配数:'+String(ld_allocqty,'#0.##########')
  5207. rslt = 0
  5208. GOTO ext
  5209. END IF
  5210. END IF
  5211. END IF
  5212. SELECT ifunit,ifpack,capacity,statusflag,ifpackpro
  5213. INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag,:li_ifpackpro
  5214. FROM u_mtrldef
  5215. Where mtrlid = :arg_mtrlid Using commit_transaction ;
  5216. IF commit_transaction.SQLCode <> 0 THEN
  5217. arg_msg = '查询物料信息失败,'+commit_transaction.SQLErrText
  5218. rslt = 0
  5219. GOTO ext
  5220. END IF
  5221. IF li_statusflag = 2 THEN
  5222. ld_capacity = 0
  5223. f_checkpz(arg_status,s_pz[])
  5224. FOR ll_i = 1 To UpperBound(s_pz)
  5225. ls_status_zj = s_pz[ll_i].cfgname
  5226. SELECT capacity
  5227. INTO :ld_capacity_zj
  5228. FROM u_mtrl_configure
  5229. WHERE mtrlid = :arg_mtrlid
  5230. And Name = :ls_status_zj;
  5231. IF commit_transaction.SQLCode <> 0 THEN
  5232. ld_capacity_zj = 0
  5233. END IF
  5234. ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
  5235. NEXT
  5236. END IF
  5237. Int li_ifupdate_date
  5238. String ls_str
  5239. IF billtype = 1 Or &
  5240. billtype = 2 Or &
  5241. billtype = 3 Or &
  5242. billtype = 4 Or &
  5243. billtype = 5 Or &
  5244. billtype = 7 Or &
  5245. billtype = 8 Or &
  5246. billtype = 10 Or &
  5247. billtype = 12 Or &
  5248. billtype = 17 Or &
  5249. billtype = 21 Or &
  5250. billtype = 24 THEN
  5251. li_ifupdate_date = 1
  5252. ELSE
  5253. li_ifupdate_date = 0
  5254. END IF
  5255. IF li_ifunit = 0 THEN arg_uqty = 0
  5256. IF li_ifcost = 1 THEN
  5257. UPDATE u_mtrlware
  5258. SET noallocqty = noallocqty - :arg_qty ,
  5259. unoallocqty = unoallocqty - :arg_uqty,
  5260. capacity = capacity + :ld_capacity * :arg_qty ,
  5261. wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END ,
  5262. cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END ,
  5263. saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
  5264. WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
  5265. ( scid = :ll_storagescid ) Using commit_transaction ;
  5266. IF commit_transaction.SQLCode = 0 THEN
  5267. IF commit_transaction.SQLNRows = 0 THEN
  5268. ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
  5269. IF ls_newid <= 0 THEN
  5270. rslt = 0
  5271. GOTO ext
  5272. END IF
  5273. ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec)
  5274. INSERT INTO u_mtrlware
  5275. ( scid,
  5276. mtrlwareid,
  5277. mtrlid,
  5278. storageid,
  5279. plancode,
  5280. status,
  5281. noallocqty,
  5282. unoallocqty,
  5283. allocqty,
  5284. wareamt,
  5285. planprice,
  5286. sptid,
  5287. dxflag,
  5288. woodcode,
  5289. pcode,
  5290. cost,
  5291. storMtrlprp,
  5292. mtrlcuscode,
  5293. location,
  5294. capacity)
  5295. VALUES (
  5296. :ll_storagescid,
  5297. :ls_newid,
  5298. :arg_mtrlid,
  5299. :arg_storageid,
  5300. :arg_plancode,
  5301. :arg_status,
  5302. :arg_qty,
  5303. :arg_uqty,
  5304. 0,
  5305. :arg_costamt,
  5306. :arg_planprice,
  5307. :arg_sptid,
  5308. :arg_dxflag,
  5309. :arg_woodcode,
  5310. :arg_pcode,
  5311. :ld_cost,
  5312. :li_storMtrlprp,
  5313. :arg_mtrlcuscode,
  5314. :arg_location,
  5315. :ld_capacity * :arg_qty) Using commit_transaction ;
  5316. IF arg_status <> '' THEN
  5317. ls_str = ' '+uo_option_change_status+':'+arg_status
  5318. END IF
  5319. IF arg_pcode <> '' THEN
  5320. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  5321. END IF
  5322. IF arg_woodcode <> '' THEN
  5323. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  5324. END IF
  5325. IF commit_transaction.SQLCode <> 0 THEN
  5326. rslt = 0
  5327. IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  5328. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText
  5329. ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
  5330. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText
  5331. ELSE
  5332. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
  5333. END IF
  5334. GOTO ext
  5335. END IF
  5336. END IF
  5337. ELSE
  5338. rslt = 0
  5339. IF arg_status <> '' THEN
  5340. ls_str = ' '+uo_option_change_status+':'+arg_status
  5341. END IF
  5342. IF arg_pcode <> '' THEN
  5343. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  5344. END IF
  5345. IF arg_woodcode <> '' THEN
  5346. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  5347. END IF
  5348. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  5349. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  5350. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
  5351. ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  5352. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
  5353. ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
  5354. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减"
  5355. ELSE
  5356. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
  5357. END IF
  5358. GOTO ext
  5359. END IF
  5360. //-----------------------------------更新结存
  5361. CHOOSE CASE billtype
  5362. CASE 1,2,5,6
  5363. ld_saleoutqty = arg_qty
  5364. ld_saleoutamt = arg_costamt
  5365. CASE 3
  5366. ld_cpoutqty = arg_qty
  5367. ld_cpoutamt = arg_costamt
  5368. CASE 4,7
  5369. ld_jgoutqty = arg_qty
  5370. ld_jgoutamt = arg_costamt
  5371. CASE 8
  5372. ld_otoutqty = arg_qty
  5373. ld_otoutamt = arg_costamt
  5374. CASE 9
  5375. ld_pkoutqty = arg_qty
  5376. ld_pkoutamt = arg_costamt
  5377. ld_pypkqty = arg_qty
  5378. ld_pypkamt = arg_costamt
  5379. CASE 12
  5380. ld_mvoutqty = arg_qty
  5381. ld_mvoutamt = arg_costamt
  5382. CASE 15
  5383. ld_dioutqty = arg_qty
  5384. ld_dioutamt = arg_costamt
  5385. CASE 21
  5386. ld_saleoutqty_pack = arg_qty
  5387. ld_saleoutamt_pack = arg_costamt
  5388. CASE 23
  5389. ld_buyoutqty_packpro = arg_qty
  5390. ld_buyoutamt_packpro = arg_costamt
  5391. CASE ELSE
  5392. ld_otoutqty = arg_qty
  5393. ld_otoutamt = arg_costamt
  5394. END CHOOSE
  5395. UPDATE u_warebalc
  5396. SET desqty = desqty + :arg_qty ,
  5397. udesqty = udesqty + :arg_uqty,
  5398. desamt = desamt + :arg_costamt,
  5399. vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END ,
  5400. uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END ,
  5401. vdesamt = case :arg_ifvqty when 0 then vdesamt else vdesamt + :arg_costamt END ,
  5402. balcqty = balcqty - :arg_qty,
  5403. ubalcqty = ubalcqty - :arg_uqty,
  5404. balcamt = case balcqty - :arg_qty when 0 then 0 else balcamt - :arg_costamt END,
  5405. pypk = pypk - :ld_pypkqty,
  5406. pypkamt = pypkamt - :ld_pypkamt,
  5407. saleoutqty = saleoutqty + :ld_saleoutqty,
  5408. saleoutamt = saleoutamt + :ld_saleoutamt,
  5409. saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack,
  5410. saleoutamt_pack = saleoutamt_pack + :ld_saleoutamt_pack,
  5411. buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro,
  5412. buyoutamt_packpro = buyoutamt_packpro + :ld_buyoutamt_packpro,
  5413. cpoutqty = cpoutqty + :ld_cpoutqty,
  5414. cpoutamt = cpoutamt + :ld_cpoutamt,
  5415. jgoutqty = jgoutqty + :ld_jgoutqty,
  5416. jgoutamt = jgoutamt + :ld_jgoutamt,
  5417. otoutqty = otoutqty + :ld_otoutqty,
  5418. otoutamt = otoutamt + :ld_otoutamt,
  5419. mvoutqty = mvoutqty + :ld_mvoutqty,
  5420. mvoutamt = mvoutamt + :ld_mvoutamt,
  5421. dioutqty = dioutqty + :ld_dioutqty,
  5422. dioutamt = dioutamt + :ld_dioutamt,
  5423. pkoutqty = pkoutqty + :ld_pkoutqty,
  5424. pkoutamt = pkoutamt + :ld_pkoutamt
  5425. WHERE ( balcdateint = 0 ) AND
  5426. ( scid = :ll_storagescid) AND
  5427. ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ;
  5428. IF commit_transaction.SQLCode = 0 THEN
  5429. IF commit_transaction.SQLNRows = 0 THEN
  5430. INSERT INTO u_warebalc
  5431. ( balcdateint,
  5432. mtrlid,
  5433. storageid,
  5434. bgqty,
  5435. bgamt,
  5436. incqty,
  5437. incamt,
  5438. desqty,
  5439. desamt,
  5440. balcqty,
  5441. balcamt,
  5442. pypk,
  5443. pypkamt,
  5444. status,
  5445. scid ,
  5446. saleoutqty,
  5447. saleoutamt,
  5448. saleoutqty_pack,
  5449. saleoutamt_pack,
  5450. buyoutqty_packpro,
  5451. buyoutamt_packpro,
  5452. cpoutqty,
  5453. cpoutamt,
  5454. jgoutqty,
  5455. jgoutamt,
  5456. dioutqty,
  5457. dioutamt,
  5458. mvoutqty,
  5459. mvoutamt,
  5460. otoutqty,
  5461. otoutamt,
  5462. pkoutqty,
  5463. pkoutamt,
  5464. woodcode,
  5465. pcode,
  5466. ubgqty,
  5467. uincqty,
  5468. udesqty,
  5469. ubalcqty,
  5470. plancode,
  5471. sptid,
  5472. dxflag,
  5473. mtrlcuscode,
  5474. location,
  5475. mtrlwareid)
  5476. VALUES (
  5477. 0,
  5478. :arg_mtrlid,
  5479. :arg_storageid,
  5480. 0,
  5481. 0,
  5482. 0,
  5483. 0,
  5484. :arg_qty,
  5485. :arg_costamt,
  5486. 0 - :arg_qty,
  5487. 0 - :arg_costamt,
  5488. 0 - :ld_pypkqty,
  5489. 0 - :ld_pypkamt,
  5490. :arg_status,
  5491. :ll_storagescid,
  5492. :ld_saleoutqty,
  5493. :ld_saleoutamt,
  5494. :ld_saleoutqty_pack,
  5495. :ld_saleoutamt_pack,
  5496. :ld_buyoutqty_packpro,
  5497. :ld_buyoutamt_packpro,
  5498. :ld_cpoutqty,
  5499. :ld_cpoutamt,
  5500. :ld_jgoutqty,
  5501. :ld_jgoutamt,
  5502. :ld_dioutqty,
  5503. :ld_dioutamt,
  5504. :ld_mvoutqty,
  5505. :ld_mvoutamt,
  5506. :ld_otoutqty,
  5507. :ld_otoutamt,
  5508. :ld_pkoutqty,
  5509. :ld_pkoutamt,
  5510. :arg_woodcode,
  5511. :arg_pcode,
  5512. 0,
  5513. 0,
  5514. :arg_uqty,
  5515. 0 - :arg_uqty,
  5516. :arg_plancode,
  5517. :arg_sptid,
  5518. :arg_dxflag,
  5519. :arg_mtrlcuscode,
  5520. :arg_location,
  5521. :arg_mtrlwareid) Using commit_transaction ;
  5522. IF commit_transaction.SQLCode <> 0 THEN
  5523. rslt = 0
  5524. arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
  5525. GOTO ext
  5526. END IF
  5527. END IF
  5528. ELSE
  5529. rslt = 0
  5530. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  5531. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  5532. arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减"
  5533. ELSE
  5534. arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText
  5535. END IF
  5536. GOTO ext
  5537. END IF
  5538. ELSE
  5539. UPDATE u_mtrlware
  5540. SET noallocqty = noallocqty - :arg_qty ,
  5541. unoallocqty = unoallocqty - :arg_uqty,
  5542. capacity = capacity + :ld_capacity * :arg_qty ,
  5543. wareamt = 0 ,
  5544. cost = 0 ,
  5545. saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
  5546. WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
  5547. ( scid = :ll_storagescid ) Using commit_transaction ;
  5548. IF commit_transaction.SQLCode = 0 THEN
  5549. IF commit_transaction.SQLNRows = 0 THEN
  5550. ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
  5551. IF ls_newid <= 0 THEN
  5552. rslt = 0
  5553. GOTO ext
  5554. END IF
  5555. INSERT INTO u_mtrlware
  5556. ( scid,
  5557. mtrlwareid,
  5558. mtrlid,
  5559. storageid,
  5560. plancode,
  5561. status,
  5562. noallocqty,
  5563. unoallocqty,
  5564. allocqty,
  5565. wareamt,
  5566. planprice,
  5567. sptid,
  5568. dxflag,
  5569. woodcode,
  5570. pcode,
  5571. cost,
  5572. storMtrlprp,
  5573. mtrlcuscode,
  5574. location,
  5575. capacity)
  5576. VALUES (
  5577. :ll_storagescid,
  5578. :ls_newid,
  5579. :arg_mtrlid,
  5580. :arg_storageid,
  5581. :arg_plancode,
  5582. :arg_status,
  5583. :arg_qty,
  5584. :arg_uqty,
  5585. 0,
  5586. 0,
  5587. 0,
  5588. :arg_sptid,
  5589. :arg_dxflag,
  5590. :arg_woodcode,
  5591. :arg_pcode,
  5592. 0,
  5593. :li_storMtrlprp,
  5594. :arg_mtrlcuscode,
  5595. :arg_location,
  5596. :ld_capacity * :arg_qty) Using commit_transaction ;
  5597. IF arg_status <> '' THEN
  5598. ls_str = ' '+uo_option_change_status+':'+arg_status
  5599. END IF
  5600. IF arg_pcode <> '' THEN
  5601. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  5602. END IF
  5603. IF arg_woodcode <> '' THEN
  5604. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  5605. END IF
  5606. IF commit_transaction.SQLCode <> 0 THEN
  5607. rslt = 0
  5608. IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  5609. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText
  5610. ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
  5611. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText
  5612. ELSE
  5613. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
  5614. END IF
  5615. GOTO ext
  5616. END IF
  5617. END IF
  5618. ELSE
  5619. rslt = 0
  5620. IF arg_status <> '' THEN
  5621. ls_str = ' '+uo_option_change_status+':'+arg_status
  5622. END IF
  5623. IF arg_pcode <> '' THEN
  5624. ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
  5625. END IF
  5626. IF arg_woodcode <> '' THEN
  5627. ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
  5628. END IF
  5629. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  5630. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  5631. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
  5632. ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
  5633. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
  5634. ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
  5635. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减"
  5636. ELSE
  5637. arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
  5638. END IF
  5639. GOTO ext
  5640. END IF
  5641. //-----------------------------------更新结存
  5642. CHOOSE CASE billtype
  5643. CASE 1,2,5,6
  5644. ld_saleoutqty = arg_qty
  5645. CASE 3
  5646. ld_cpoutqty = arg_qty
  5647. CASE 4,7
  5648. ld_jgoutqty = arg_qty
  5649. CASE 8
  5650. ld_otoutqty = arg_qty
  5651. CASE 9
  5652. ld_pkoutqty = arg_qty
  5653. ld_pypkqty = arg_qty
  5654. CASE 12
  5655. ld_mvoutqty = arg_qty
  5656. CASE 15
  5657. ld_dioutqty = arg_qty
  5658. CASE 21
  5659. ld_saleoutqty_pack = arg_qty
  5660. CASE 23
  5661. ld_buyoutqty_packpro = arg_qty
  5662. CASE ELSE
  5663. ld_otoutqty = arg_qty
  5664. END CHOOSE
  5665. UPDATE u_warebalc
  5666. SET desqty = desqty + :arg_qty ,
  5667. udesqty = udesqty + :arg_uqty,
  5668. desamt = 0,
  5669. vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END ,
  5670. uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END ,
  5671. vdesamt = 0 ,
  5672. balcqty = balcqty - :arg_qty,
  5673. ubalcqty = ubalcqty - :arg_uqty,
  5674. balcamt = 0,
  5675. pypk = pypk - :ld_pypkqty,
  5676. pypkamt = 0,
  5677. saleoutqty = saleoutqty + :ld_saleoutqty,
  5678. saleoutamt = 0,
  5679. saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack,
  5680. saleoutamt_pack = 0,
  5681. buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro,
  5682. buyoutamt_packpro = 0,
  5683. cpoutqty = cpoutqty + :ld_cpoutqty,
  5684. cpoutamt = 0,
  5685. jgoutqty = jgoutqty + :ld_jgoutqty,
  5686. jgoutamt = 0,
  5687. otoutqty = otoutqty + :ld_otoutqty,
  5688. otoutamt = 0,
  5689. mvoutqty = mvoutqty + :ld_mvoutqty,
  5690. mvoutamt = 0,
  5691. dioutqty = dioutqty + :ld_dioutqty,
  5692. dioutamt = 0,
  5693. pkoutqty = pkoutqty + :ld_pkoutqty,
  5694. pkoutamt = 0
  5695. WHERE ( balcdateint = 0 ) AND
  5696. ( scid = :ll_storagescid) AND
  5697. ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ;
  5698. IF commit_transaction.SQLCode = 0 THEN
  5699. IF commit_transaction.SQLNRows = 0 THEN
  5700. INSERT INTO u_warebalc
  5701. ( balcdateint,
  5702. mtrlid,
  5703. storageid,
  5704. bgqty,
  5705. bgamt,
  5706. incqty,
  5707. incamt,
  5708. desqty,
  5709. desamt,
  5710. balcqty,
  5711. balcamt,
  5712. pypk,
  5713. pypkamt,
  5714. status,
  5715. scid ,
  5716. saleoutqty,
  5717. saleoutamt,
  5718. saleoutqty_pack,
  5719. saleoutamt_pack,
  5720. buyoutqty_packpro,
  5721. buyoutamt_packpro,
  5722. cpoutqty,
  5723. cpoutamt,
  5724. jgoutqty,
  5725. jgoutamt,
  5726. dioutqty,
  5727. dioutamt,
  5728. mvoutqty,
  5729. mvoutamt,
  5730. otoutqty,
  5731. otoutamt,
  5732. pkoutqty,
  5733. pkoutamt,
  5734. woodcode,
  5735. pcode,
  5736. ubgqty,
  5737. uincqty,
  5738. udesqty,
  5739. ubalcqty,
  5740. plancode,
  5741. sptid,
  5742. dxflag,
  5743. mtrlcuscode,
  5744. location,
  5745. mtrlwareid)
  5746. VALUES (
  5747. 0,
  5748. :arg_mtrlid,
  5749. :arg_storageid,
  5750. 0,
  5751. 0,
  5752. 0,
  5753. 0,
  5754. :arg_qty,
  5755. 0,
  5756. 0 - :arg_qty,
  5757. 0,
  5758. 0 - :ld_pypkqty,
  5759. 0,
  5760. :arg_status,
  5761. :ll_storagescid,
  5762. :ld_saleoutqty,
  5763. 0,
  5764. :ld_saleoutqty_pack,
  5765. 0,
  5766. :ld_buyoutqty_packpro,
  5767. 0,
  5768. :ld_cpoutqty,
  5769. 0,
  5770. :ld_jgoutqty,
  5771. 0,
  5772. :ld_dioutqty,
  5773. 0,
  5774. :ld_mvoutqty,
  5775. 0,
  5776. :ld_otoutqty,
  5777. 0,
  5778. :ld_pkoutqty,
  5779. 0,
  5780. :arg_woodcode,
  5781. :arg_pcode,
  5782. 0,
  5783. 0,
  5784. :arg_uqty,
  5785. 0 - :arg_uqty,
  5786. :arg_plancode,
  5787. :arg_sptid,
  5788. :arg_dxflag,
  5789. :arg_mtrlcuscode,
  5790. :arg_location,
  5791. :arg_mtrlwareid) Using commit_transaction ;
  5792. IF commit_transaction.SQLCode <> 0 THEN
  5793. rslt = 0
  5794. arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
  5795. GOTO ext
  5796. END IF
  5797. END IF
  5798. ELSE
  5799. rslt = 0
  5800. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  5801. IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  5802. arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减"
  5803. ELSE
  5804. arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText
  5805. END IF
  5806. GOTO ext
  5807. END IF
  5808. END IF
  5809. //自动计算包件产品可装数yyx20100414
  5810. //yyx2012-9-28取消
  5811. //IF ( li_ifpack = 1 or li_ifpack = 2 Or li_ifpackpro = 3 Or li_ifpackpro = 4 ) AND uo_option_mtrlware_autocmp = 1 THEN
  5812. // IF uo_cmpl_p.uof_cmpl(arg_mtrlid,arg_plancode,arg_mtrlcuscode,arg_storageid,arg_msg) = 0 THEN
  5813. // rslt = 0
  5814. // GOTO ext
  5815. // END IF
  5816. //END IF
  5817. If uo_option_djqty_check = 1 and not (billtype = 3 And relint_1 = 2 ) and li_ifmrp = 1 and not ( billtype = 3 And relint_1 = 4) Then
  5818. Decimal ld_djqty
  5819. Select SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0))
  5820. Into :ld_djqty
  5821. FROM u_OrderRqMtrl_scll INNER JOIN
  5822. u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN
  5823. uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND
  5824. u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND
  5825. u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND
  5826. u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND
  5827. u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND
  5828. u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode
  5829. Where (u_OrderRqMtrl_scll.wareqty <> 0) And (u_Order_ml.Status Not In (3,5,6))
  5830. And u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0
  5831. And u_OrderRqMtrl_scll.MtrlID = :arg_mtrlid
  5832. And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction;
  5833. If commit_transaction.SQLCode <> 0 Then
  5834. ld_djqty = 0
  5835. End If
  5836. If IsNull(ld_djqty) Then ld_djqty = 0
  5837. Select SUM(u_mtrlware.noallocqty)
  5838. Into :ld_noallocqty
  5839. From u_mtrlware Inner JOIN
  5840. u_storage ON u_mtrlware.storageid = u_storage.storageid
  5841. Where (u_storage.inuse = 1)
  5842. And u_storage.ifmrp = 1
  5843. And u_mtrlware.mtrlid = :arg_mtrlid
  5844. And u_mtrlware.scid = :scid Using commit_transaction;
  5845. If commit_transaction.SQLCode <> 0 Then
  5846. ld_noallocqty = 0
  5847. End If
  5848. If IsNull(ld_noallocqty) Then ld_noallocqty = 0
  5849. If ld_djqty > ld_noallocqty Then
  5850. rslt = 0
  5851. arg_msg = '冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########')
  5852. Goto ext
  5853. End If
  5854. End If
  5855. ext:
  5856. IF rslt = 0 THEN
  5857. ROLLBACK Using commit_transaction ;
  5858. END IF
  5859. Destroy uo_cmpl_p
  5860. RETURN rslt
  5861. end function
  5862. public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i
  5863. String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
  5864. Long ll_storagescid
  5865. Long i_mtrlid,i_storageid,i_sptid
  5866. Int i_dxflag
  5867. string i_mtrlcuscode,i_location
  5868. int i_ifpackpro,i_ifpack
  5869. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  5870. rslt = 0
  5871. arg_msg = "非编辑状态不可以使用,操作取消"
  5872. GOTO ext
  5873. END IF
  5874. SELECT scid INTO :ll_storagescid
  5875. FROM u_storage
  5876. Where storageid = :storageid USING commit_transaction;
  5877. IF commit_transaction.SQLCode <> 0 THEN
  5878. rslt = 0
  5879. arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText
  5880. GOTO ext
  5881. END IF
  5882. //清除空值
  5883. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  5884. IF IsNull(arg_printid) THEN arg_printid = 0
  5885. IF IsNull(arg_qty) THEN arg_qty = 0
  5886. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  5887. IF IsNull(arg_planqty) THEN arg_planqty = 0
  5888. IF IsNull(arg_mxprintid) THEN arg_mxprintid = 0
  5889. IF arg_mtrlwareid = 0 Or ( arg_qty = 0 AND arg_planqty = 0 ) THEN
  5890. rslt = 1
  5891. GOTO ext
  5892. END IF
  5893. //检查物料库存ID
  5894. SELECT u_mtrlware.mtrlid,
  5895. u_mtrlware.storageid,
  5896. u_mtrlware.plancode,
  5897. u_mtrlware.status,
  5898. u_mtrldef.mtrlcode,
  5899. u_mtrlware.sptid,
  5900. u_mtrlware.dxflag,
  5901. u_mtrlware.woodcode,
  5902. u_mtrlware.pcode,
  5903. u_mtrlware.mtrlcuscode,
  5904. u_mtrlware.location,
  5905. u_mtrldef.ifpackpro,
  5906. u_mtrldef.ifpack
  5907. INTO :i_mtrlid,
  5908. :i_storageid,
  5909. :i_plancode,
  5910. :i_status,
  5911. :i_mtrlcode,
  5912. :i_sptid,
  5913. :i_dxflag,
  5914. :i_woodcode,
  5915. :i_pcode,
  5916. :i_mtrlcuscode,
  5917. :i_location,
  5918. :i_ifpackpro,
  5919. :i_ifpack
  5920. FROM u_mtrlware ,u_mtrldef
  5921. WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
  5922. AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
  5923. And ( u_mtrlware.scid = :ll_storagescid ) USING commit_transaction;
  5924. IF commit_transaction.SQLCode <> 0 THEN
  5925. rslt = 0
  5926. arg_msg = "第"+String(arg_printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(arg_mtrlwareid)+',~n'+commit_transaction.SQLErrText
  5927. GOTO ext
  5928. END IF
  5929. IF IsNull(i_plancode) THEN i_plancode = ''
  5930. IF IsNull(i_status) THEN i_status = ''
  5931. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  5932. IF IsNull(i_storageid) THEN i_storageid = 0
  5933. IF IsNull(i_sptid) THEN i_sptid = 0
  5934. IF IsNull(i_dxflag) THEN i_dxflag = 0
  5935. IF IsNull(i_woodcode) THEN i_woodcode = ''
  5936. IF IsNull(i_pcode) THEN i_pcode = ''
  5937. IF IsNull(i_mtrlcuscode) THEN i_mtrlcuscode = ''
  5938. IF IsNull(i_location) THEN i_location = ''
  5939. IF IsNull(i_ifpackpro) THEN i_ifpackpro = 0
  5940. IF IsNull(i_ifpack) THEN i_ifpack = 0
  5941. //写入内容
  5942. it_mxbt_mx++
  5943. outwaremx_mx[it_mxbt_mx].mtrlwareid = arg_mtrlwareid
  5944. outwaremx_mx[it_mxbt_mx].mtrlid = i_mtrlid
  5945. outwaremx_mx[it_mxbt_mx].status = i_status
  5946. outwaremx_mx[it_mxbt_mx].qty = arg_qty
  5947. outwaremx_mx[it_mxbt_mx].planqty = arg_planqty
  5948. outwaremx_mx[it_mxbt_mx].storageid = i_storageid
  5949. outwaremx_mx[it_mxbt_mx].plancode = i_plancode
  5950. outwaremx_mx[it_mxbt_mx].mtrlcode = i_mtrlcode
  5951. outwaremx_mx[it_mxbt_mx].mxdscrp = arg_mxdscrp
  5952. outwaremx_mx[it_mxbt_mx].printid = arg_printid
  5953. outwaremx_mx[it_mxbt_mx].mxprintid = arg_mxprintid
  5954. outwaremx_mx[it_mxbt_mx].sptid = i_sptid
  5955. outwaremx_mx[it_mxbt_mx].dxflag = i_dxflag
  5956. outwaremx_mx[it_mxbt_mx].woodcode = i_woodcode
  5957. outwaremx_mx[it_mxbt_mx].pcode = i_pcode
  5958. outwaremx_mx[it_mxbt_mx].mtrlcuscode = i_mtrlcuscode
  5959. outwaremx_mx[it_mxbt_mx].location = i_location
  5960. outwaremx_mx[it_mxbt_mx].ifnotinout = arg_ifnotinout
  5961. outwaremx_mx[it_mxbt_mx].ifpackpro = i_ifpackpro
  5962. outwaremx_mx[it_mxbt_mx].ifpack = i_ifpack
  5963. ext:
  5964. IF rslt = 0 THEN p_clearmx()
  5965. RETURN rslt
  5966. end function
  5967. public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
  5968. Int rslt = 1
  5969. Long i
  5970. Decimal ld_qty,ld_uqty
  5971. If thflag = 1 Then
  5972. rslt = 1
  5973. Goto ext
  5974. End If
  5975. For i = 1 To it_mxbt
  5976. ld_qty = 0
  5977. ld_uqty = 0
  5978. If arg_billtype <> 1 And arg_billtype <> 3 Then
  5979. ld_qty = outwaremx[i].qty
  5980. ld_uqty = outwaremx[i].uqty
  5981. ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then
  5982. ld_qty = outwaremx[i].qty
  5983. ld_uqty = outwaremx[i].uqty
  5984. ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then
  5985. ld_qty = outwaremx[i].qty
  5986. ld_uqty = outwaremx[i].uqty
  5987. ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then
  5988. If outwaremx[i].qty = 0 Then
  5989. ld_qty = outwaremx[i].planqty
  5990. Else
  5991. ld_qty = outwaremx[i].qty
  5992. End If
  5993. ld_uqty = outwaremx[i].uqty
  5994. ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And outwaremx[i].ifpack = 0 And outwaremx[i].ifpackpro = 0 Then
  5995. If outwaremx[i].qty = 0 Then
  5996. ld_qty = outwaremx[i].planqty
  5997. Else
  5998. ld_qty = outwaremx[i].qty
  5999. End If
  6000. ld_uqty = outwaremx[i].uqty
  6001. End If
  6002. Update u_mtrlware
  6003. Set noauditingqty = noauditingqty + :ld_qty,
  6004. noauditinguqty = noauditingqty + :ld_uqty
  6005. Where scid = :arg_scid
  6006. And mtrlwareid = :outwaremx[i].mtrlwareid;
  6007. If sqlca.SQLCode <> 0 Then
  6008. rslt = 0
  6009. arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  6010. Goto ext
  6011. End If
  6012. Next
  6013. For i = 1 To it_mxbt_mx
  6014. ld_qty = 0
  6015. ld_uqty = 0
  6016. If uo_option_inout_type > 0 Then
  6017. If outwaremx_mx[i].ifpack = 1 Or outwaremx_mx[i].ifpackpro = 4 Or outwaremx_mx[i].ifpackpro = 3 Then
  6018. If outwaremx_mx[i].qty = 0 Then
  6019. ld_qty = outwaremx_mx[i].planqty
  6020. Else
  6021. ld_qty = outwaremx_mx[i].qty
  6022. End If
  6023. ld_uqty = ld_qty
  6024. Update u_mtrlware
  6025. Set noauditingqty = noauditingqty + :ld_qty,
  6026. noauditinguqty = noauditingqty + :ld_uqty
  6027. Where scid = :arg_scid
  6028. And mtrlwareid = :outwaremx_mx[i].mtrlwareid;
  6029. If sqlca.SQLCode <> 0 Then
  6030. rslt = 0
  6031. arg_msg = '物料:'+String(outwaremx_mx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  6032. Goto ext
  6033. End If
  6034. End If
  6035. End If
  6036. Next
  6037. ext:
  6038. Return rslt
  6039. end function
  6040. public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
  6041. Int rslt = 1
  6042. Long i,ll_i,j
  6043. Decimal ld_qty,ld_uqty
  6044. Int arg_billtype,arg_relint_1
  6045. If thflag = 1 Then
  6046. rslt = 1
  6047. Goto ext
  6048. End If
  6049. i = 1
  6050. j = 1
  6051. s_outwaremx arg_s_mx[]
  6052. s_outwaremx_mx arg_s_mxmx[]
  6053. Select billtype,relint_1
  6054. Into :arg_billtype,:arg_relint_1
  6055. From u_outware
  6056. Where scid = :arg_scid
  6057. And outwareid = :arg_outwareid Using commit_transaction;
  6058. If commit_transaction.SQLCode <> 0 Then
  6059. rslt = 0
  6060. arg_msg = '查询单据信息失败,'+commit_transaction.SQLErrText
  6061. Goto ext
  6062. End If
  6063. Declare cur_outwaremx Cursor For
  6064. Select u_outwaremx.mtrlwareid,
  6065. u_outwaremx.planqty,
  6066. u_outwaremx.qty,
  6067. u_outwaremx.uqty,
  6068. u_mtrldef.mtrlcode,
  6069. u_mtrldef.ifpackpro,
  6070. u_mtrldef.ifpack
  6071. From u_outwaremx,u_mtrldef
  6072. Where u_outwaremx.outwareid = :arg_outwareid And
  6073. u_outwaremx.mtrlid = u_mtrldef.mtrlid And
  6074. u_outwaremx.scid = :arg_scid
  6075. Order By u_outwaremx.printid Using commit_transaction;
  6076. Open cur_outwaremx;
  6077. Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,
  6078. :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack;
  6079. Do While sqlca.SQLCode = 0
  6080. i++
  6081. Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,
  6082. :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack;
  6083. Loop
  6084. Close cur_outwaremx;
  6085. Declare cur_outwaremx_mx Cursor For
  6086. Select u_outwaremx_mx.mtrlwareid,
  6087. u_outwaremx_mx.planqty,
  6088. u_outwaremx_mx.qty,
  6089. u_mtrldef.ifpackpro,
  6090. u_mtrldef.ifpack,
  6091. u_mtrldef.mtrlcode
  6092. From u_outwaremx_mx Inner JOIN
  6093. u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
  6094. Where u_outwaremx_mx.scid = :arg_scid
  6095. And u_outwaremx_mx.outwareid = :arg_outwareid
  6096. Order By u_outwaremx_mx.mxprintid Using commit_transaction;
  6097. Open cur_outwaremx_mx;
  6098. Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty,
  6099. :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode;
  6100. Do While sqlca.SQLCode = 0
  6101. j++
  6102. Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty,
  6103. :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode;
  6104. Loop
  6105. Close cur_outwaremx_mx;
  6106. For ll_i = 1 To i - 1
  6107. ld_qty = 0
  6108. ld_uqty = 0
  6109. If arg_billtype <> 1 And arg_billtype <> 3 Then
  6110. ld_qty = arg_s_mx[ll_i].qty
  6111. ld_uqty = arg_s_mx[ll_i].uqty
  6112. ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then
  6113. ld_qty = arg_s_mx[ll_i].qty
  6114. ld_uqty = arg_s_mx[ll_i].uqty
  6115. ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then
  6116. ld_qty = arg_s_mx[ll_i].qty
  6117. ld_uqty = arg_s_mx[ll_i].uqty
  6118. ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then
  6119. If arg_s_mx[ll_i].qty = 0 Then
  6120. ld_qty = arg_s_mx[ll_i].planqty
  6121. Else
  6122. ld_qty = arg_s_mx[ll_i].qty
  6123. End If
  6124. ld_uqty = arg_s_mx[ll_i].uqty
  6125. ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And arg_s_mx[ll_i].ifpack = 0 And arg_s_mx[ll_i].ifpackpro = 0 Then
  6126. If arg_s_mx[ll_i].qty = 0 Then
  6127. ld_qty = arg_s_mx[ll_i].planqty
  6128. Else
  6129. ld_qty = arg_s_mx[ll_i].qty
  6130. End If
  6131. ld_uqty = arg_s_mx[ll_i].uqty
  6132. End If
  6133. Update u_mtrlware
  6134. Set noauditingqty = noauditingqty - :ld_qty,
  6135. noauditinguqty = noauditingqty - :ld_uqty
  6136. Where scid = :arg_scid
  6137. And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid;
  6138. If sqlca.SQLCode <> 0 Then
  6139. rslt = 0
  6140. arg_msg = '物料:'+String(arg_s_mx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  6141. Goto ext
  6142. End If
  6143. Next
  6144. For ll_i = 1 To j - 1
  6145. ld_qty = 0
  6146. ld_uqty = 0
  6147. If uo_option_inout_type > 0 Then
  6148. If arg_s_mxmx[ll_i].ifpack = 1 Or arg_s_mxmx[ll_i].ifpackpro = 4 Or arg_s_mxmx[ll_i].ifpackpro = 3 Then
  6149. If arg_s_mxmx[ll_i].qty = 0 Then
  6150. ld_qty = arg_s_mxmx[ll_i].planqty
  6151. Else
  6152. ld_qty = arg_s_mxmx[ll_i].qty
  6153. End If
  6154. ld_uqty = ld_qty
  6155. Update u_mtrlware
  6156. Set noauditingqty = noauditingqty - :ld_qty,
  6157. noauditinguqty = noauditingqty - :ld_uqty
  6158. Where scid = :arg_scid
  6159. And mtrlwareid = :arg_s_mxmx[ll_i].mtrlwareid;
  6160. If sqlca.SQLCode <> 0 Then
  6161. rslt = 0
  6162. arg_msg = '物料:'+String(arg_s_mxmx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  6163. Goto ext
  6164. End If
  6165. End If
  6166. End If
  6167. Next
  6168. ext:
  6169. Return rslt
  6170. end function
  6171. on uo_outware.create
  6172. call super::create
  6173. TriggerEvent( this, "constructor" )
  6174. end on
  6175. on uo_outware.destroy
  6176. TriggerEvent( this, "destructor" )
  6177. call super::destroy
  6178. end on
  6179. event constructor;String str_optionvalue,arg_msg
  6180. //f_get_sys_option_value('030',str_optionvalue,arg_msg)
  6181. //uo_option_autowaste = Long(str_optionvalue)
  6182. //
  6183. f_get_sys_option_value('142',str_optionvalue,arg_msg)
  6184. uo_option_inout_type = Long(str_optionvalue)
  6185. f_get_sys_option_value('205',str_optionvalue,arg_msg)
  6186. uo_option_barcode_outwareother_paudit = Long(str_optionvalue)
  6187. f_get_sys_option_value('025',str_optionvalue,arg_msg)
  6188. uo_option_confirmaudit_sale = Long(str_optionvalue)
  6189. f_get_sys_option_value('115',str_optionvalue,arg_msg)
  6190. uo_option_sale_use_planqty = Long(str_optionvalue)
  6191. f_get_sys_option_value('006',str_optionvalue,arg_msg)
  6192. uo_option_confirmaudit_scll = Long(str_optionvalue)
  6193. f_get_sys_option_value('022',str_optionvalue,arg_msg)
  6194. uo_option_cost_dec = Long(str_optionvalue)
  6195. f_get_sys_option_value('029',str_optionvalue,arg_msg)
  6196. uo_option_change_status = str_optionvalue
  6197. f_get_sys_option_value('027',str_optionvalue,arg_msg)
  6198. uo_option_change_woodcode = str_optionvalue
  6199. f_get_sys_option_value('028',str_optionvalue,arg_msg)
  6200. uo_option_change_pcode = str_optionvalue
  6201. f_get_sys_option_value('158',str_optionvalue,arg_msg)
  6202. uo_option_mtrlware_autocmp = Long(str_optionvalue)
  6203. f_get_sys_option_value('037',str_optionvalue,arg_msg)
  6204. uo_option_mtrlware_limit = Long(str_optionvalue)
  6205. f_get_sys_option_value('200',str_optionvalue,arg_msg)
  6206. uo_option_if_saleout = Long(str_optionvalue)
  6207. f_get_sys_option_value('154',str_optionvalue,arg_msg)
  6208. uo_option_if_pricetype = Long(str_optionvalue)
  6209. f_get_sys_option_value('056',str_optionvalue,arg_msg)
  6210. uo_option_checkprice_native = Long(str_optionvalue)
  6211. f_get_sys_option_value('292',str_optionvalue,arg_msg)
  6212. uo_option_disuse_outware_sale = Long(str_optionvalue)
  6213. f_get_sys_option_value('300',str_optionvalue,arg_msg)
  6214. uo_option_sale_ifuse_negativeprice = Long(str_optionvalue)
  6215. f_get_sys_option_value('310',str_optionvalue,arg_msg)
  6216. uo_option_pda_sale_lock = Long(str_optionvalue)
  6217. f_get_sys_option_value('238',str_optionvalue,arg_msg)
  6218. uo_option_price_rmb = Long(str_optionvalue)
  6219. f_get_sys_option_value('320',str_optionvalue,arg_msg)
  6220. uo_option_outware_sale_checkprice = Long(str_optionvalue)
  6221. f_get_sys_option_value('123',str_optionvalue,arg_msg)
  6222. uo_option_scll_use_planqty = Long(str_optionvalue)
  6223. f_get_sys_option_value('287',str_optionvalue,arg_msg)
  6224. uo_option_barcodelocation_use_inwaremx_location = Long(str_optionvalue)
  6225. f_get_sys_option_value('378',str_optionvalue,arg_msg)
  6226. uo_option_djqty_check = long(str_optionvalue)
  6227. f_get_sys_option_value('147',str_optionvalue,arg_msg)
  6228. uo_option_outware_saleout = Long(str_optionvalue)
  6229. f_get_sys_option_value('248',str_optionvalue,arg_msg)
  6230. uo_option_scllplan_outware_auto = Long(str_optionvalue)
  6231. f_get_sys_option_value('390',str_optionvalue,arg_msg)
  6232. uo_option_noauditingqty_mode = Long(str_optionvalue)
  6233. f_get_sys_option_value('395',str_optionvalue,arg_msg)
  6234. uo_option_outware_pack_save_cmp = Long(str_optionvalue)
  6235. f_get_sys_option_value('397',str_optionvalue,arg_msg)
  6236. uo_option_pk_notauditqty_check = Long(str_optionvalue)
  6237. f_get_sys_option_value('417',str_optionvalue,arg_msg)
  6238. uo_option_canpack_ifzanyong = Long(str_optionvalue)
  6239. end event