123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455 |
- $PBExportHeader$uo_oppose.sru
- forward
- global type uo_oppose from nonvisualobject
- end type
- type s_opposemx_mtrl from structure within uo_oppose
- end type
- type s_opposemx_dept from structure within uo_oppose
- end type
- end forward
- type s_opposemx_mtrl from structure
- long mtrlid
- string status
- decimal { 10 } qty
- string mxdscrp
- string status_mode
- string woodcode
- string pcode
- end type
- type s_opposemx_dept from structure
- long deptid
- string wkpname
- string productieda
- end type
- global type uo_oppose from nonvisualobject
- end type
- global uo_oppose uo_oppose
- type variables
- public protectedwrite long billid
- public protectedwrite string billcode
- public protectedwrite int billtype
- public protectedwrite datetime opdate
- public protectedwrite string opemp
- public protectedwrite datetime moddate
- public protectedwrite string modemp
- public protectedwrite int flag
- public protectedwrite datetime auditingdate
- public protectedwrite string auditingrep
- public protectedwrite int secflag
- long relid
- datetime billdate
- string opposedept
- datetime thdate
- datetime fhdate
- string threason
- string custdscrp
- string saleidea
- string productieda
- string qualityidea
- string manageridea
- string improveidea
- string wkpdscrp
- decimal opposeamt
- decimal selfamt
- long itemid
- string opposetype
- string dealdscrp
- string relcode
- boolean if_getid_ture=true
- transaction commit_transaction
- private:
- long it_mxbt=0
- s_opposemx_mtrl opposemx_mtrl[]
- long it_depmxbt=0
- s_opposemx_dept opposemx_dept[]
- boolean it_newbegin=false
- boolean it_updatebegin=false
-
- end variables
- forward prototypes
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer p_reset ()
- public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer updatebegin (long arg_billid, ref string arg_msg)
- public function integer p_getinfo (long arg_billid, ref string arg_msg)
- public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer newbegin (integer arg_billtype, ref string arg_msg)
- public function integer add_qualityidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_manageridea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_improveidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_productieda (long arg_billid, long arg_deptid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer secauditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer c_secauditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function long acceptdeptid (long arg_deptid, string arg_productieda, ref string arg_msg)
- public function integer acceptmx (long arg_mtrlid, string arg_status, decimal arg_qty, string arg_status_mode, string arg_woodcode, string arg_pcode, string arg_mxdscrp, ref string arg_msg)
- public function integer update_saleamt (long arg_billid, decimal arg_opposeamt, decimal arg_selfamt, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
- Long cnt = 0,i,ll_i
- DateTime server_dt
- Long ls_newid
- String ls_wkpdscrp,ls_opposedept
- IF IsNull(opposedept) THEN opposedept = ""
- IF IsNull(threason) THEN threason = ""
- IF IsNull(custdscrp) THEN custdscrp = ""
- IF IsNull(saleidea) THEN saleidea = ""
- IF IsNull(productieda) THEN productieda = ""
- IF IsNull(manageridea) THEN manageridea = ""
- IF IsNull(qualityidea) THEN qualityidea = ""
- IF IsNull(relid) THEN relid = 0
- IF IsNull(opposeamt) THEN opposeamt = 0
- IF IsNull(itemid) THEN itemid = 0
- IF IsNull(opposetype) THEN opposetype = ""
- IF IsNull(dealdscrp) THEN dealdscrp = ""
- IF IsNull(selfamt) THEN selfamt = 0
- IF IsNull(relcode) THEN relcode = ''
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- ////2015-03-30 取消限制 (youshi)
- //IF selfamt > opposeamt THEN
- // rslt = 0
- // arg_msg = '个人金额不能大于总金额'
- // GOTO ext
- //END IF
- SELECT count(*) INTO :cnt
- FROM u_oppose_item
- Where itemid = :itemid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询投拆项目资料失败'
- rslt = 0
- GOTO ext
- END IF
- IF cnt = 0 THEN
- arg_msg = '系统不存在项目资料'
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 0 OR billtype = 2 THEN
- IF billtype = 0 THEN
- IF opposedept = '' THEN
- arg_msg = '请输入投诉部门'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- SELECT name INTO :ls_opposedept
- FROM u_cust
- Where cusid = :relid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败,可能客户资料不存在'
- rslt = 0
- GOTO ext
- END IF
- opposedept = ls_opposedept
- END IF
-
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确产品明细内容"
- GOTO ext
- END IF
-
- IF it_depmxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确部门明细内容"
- GOTO ext
- END IF
- //***************************
- FOR ll_i = 1 TO it_depmxbt
- ls_wkpdscrp = ls_wkpdscrp + opposemx_dept[ll_i].wkpname +','
- NEXT
-
- IF Len(ls_wkpdscrp) > 0 THEN
- ls_wkpdscrp = Left(ls_wkpdscrp,Len(ls_wkpdscrp) - 1)
- END IF
- //****************************
- ELSE
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_spt
- Where sptid = :relid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 OR cnt = 0 THEN
- arg_msg = '查询供应商资料失败,可能供应商资料不存在'
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt <> 1 THEN
- arg_msg = '供应商资料不存在或重复,请检查'
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF billtype <> 2 THEN
- IF f_check_inoutdate(0,billdate,FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF billid = 0 THEN //新建
- ls_newid = f_sys_scidentity(0,"u_oppose","billid",arg_msg,TRUE,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- IF billtype = 0 THEN
- billcode = getid(0,'TS',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF billtype = 1 THEN
- billcode = getid(0,'SS',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF billtype = 2 THEN
- billcode = getid(0,'CS',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
-
- IF billcode = "err" THEN
- billcode = ''
- rslt = 0
- arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_oppose(billid,
- billdate,
- opposedept,
- thdate,
- fhdate,
- threason,
- custdscrp,
- saleidea,
- productieda,
- qualityidea,
- manageridea,
- improveidea,
- billcode,
- opdate,
- opemp,
- billtype,
- relid,
- wkpdscrp,
- opposeamt,
- itemid,
- opposetype,
- dealdscrp,
- selfamt,
- relcode
- )
- VALUES(:ls_newid,
- :billdate,
- :opposedept,
- :thdate,
- :fhdate,
- :threason,
- :custdscrp,
- :saleidea,
- :productieda,
- :qualityidea,
- :manageridea,
- :improveidea,
- :billcode,
- getdate(),
- :publ_operator,
- :billtype,
- :relid,
- :ls_wkpdscrp,
- :opposeamt,
- :itemid,
- :opposetype,
- :dealdscrp,
- :selfamt,
- :relcode
- ) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_depmxbt
- INSERT INTO u_opposemx_dept(deptid,
- billid,
- productieda,
- opemp,
- opdate)
- Values (:opposemx_dept[i].deptid,
- :ls_newid,
- :opposemx_dept[i].productieda,
- :publ_operator,
- getdate()) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //读取新inwareid
- billid = ls_newid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_opposemx_mtrl(
- mtrlid,
- status,
- qty,
- mxdscrp ,
- billid,
- status_mode,
- woodcode,
- pcode)
- VALUES ( :opposemx_mtrl[i].mtrlid,
- :opposemx_mtrl[i].status,
- :opposemx_mtrl[i].qty,
- :opposemx_mtrl[i].mxdscrp,
- :ls_newid,
- :opposemx_mtrl[i].status_mode,
- :opposemx_mtrl[i].woodcode,
- :opposemx_mtrl[i].pcode
- ) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0 //还原inwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_oppose
- SET billid = :billid,
- billdate = :billdate,
- opposedept = :opposedept,
- thdate = :thdate,
- fhdate = :fhdate,
- threason = :threason,
- custdscrp = :custdscrp,
- saleidea = :saleidea,
- productieda = :productieda,
- qualityidea = :qualityidea,
- manageridea = :manageridea,
- improveidea = :improveidea,
- billcode = :billcode,
- moddate = getdate(),
- modemp = :publ_operator,
- relid = :relid,
- wkpdscrp = :ls_wkpdscrp,
- opposeamt = :opposeamt,
- itemid = :itemid,
- opposetype = :opposetype,
- dealdscrp = :dealdscrp,
- selfamt = :selfamt,
- relcode = :relcode
- WHERE u_oppose.billid = :billid
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- //删除原有明细
- DELETE FROM u_opposemx_dept
- Where u_opposemx_dept.billid = :billid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_depmxbt
- INSERT INTO u_opposemx_dept(deptid,
- productieda,
- billid,
- opemp,
- opdate)
- Values (:opposemx_dept[i].deptid,
- :opposemx_dept[i].productieda,
- :billid,:publ_operator,getdate()) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //删除原有明细
- DELETE FROM u_opposemx_mtrl
- Where u_opposemx_mtrl.billid = :billid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_opposemx_mtrl(
- mtrlid,
- status,
- qty,
- mxdscrp ,
- billid,
- status_mode,
- woodcode,
- pcode)
- VALUES ( :opposemx_mtrl[i].mtrlid,
- :opposemx_mtrl[i].status,
- :opposemx_mtrl[i].qty,
- :opposemx_mtrl[i].mxdscrp,
- :billid,
- :opposemx_mtrl[i].status_mode,
- :opposemx_mtrl[i].woodcode,
- :opposemx_mtrl[i].pcode
- ) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- it_depmxbt=0
- return 1
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
-
- billid = 0
- billcode = ''
- opemp = ''
- modemp = ''
- auditingrep = ''
- flag = 0
- opposedept = ''
- threason = ''
- custdscrp = ''
- saleidea = ''
- productieda = ''
- qualityidea = ''
- manageridea = ''
- improveidea = ''
- opposeamt = 0
- itemid = 0
- opposetype = ''
- dealdscrp = ''
- it_newbegin = false
- it_updatebegin = false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
- Long i = 1,no_mxcheck = 0,j = 1
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = "非法单据唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_billid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_inwaermx CURSOR FOR
- SELECT u_opposemx_mtrl.mtrlid,
- u_opposemx_mtrl.status,
- u_opposemx_mtrl.qty,
- u_opposemx_mtrl.mxdscrp,
- u_opposemx_mtrl.status_mode,
- u_opposemx_mtrl.woodcode,
- u_opposemx_mtrl.pcode
- FROM u_opposemx_mtrl
- Where u_opposemx_mtrl.billid = :arg_billid Using commit_transaction;
-
- OPEN cur_inwaermx;
- FETCH cur_inwaermx INTO :opposemx_mtrl[i].mtrlid,
- :opposemx_mtrl[i].status,:opposemx_mtrl[i].qty ,
- :opposemx_mtrl[i].mxdscrp ,:opposemx_mtrl[i].status_mode,
- :opposemx_mtrl[i].woodcode,:opposemx_mtrl[i].pcode;
-
- DO WHILE commit_transaction.SQLCode = 0
- i++
- FETCH cur_inwaermx INTO :opposemx_mtrl[i].mtrlid,
- :opposemx_mtrl[i].status,:opposemx_mtrl[i].qty ,
- :opposemx_mtrl[i].mxdscrp ,:opposemx_mtrl[i].status_mode,
- :opposemx_mtrl[i].woodcode,:opposemx_mtrl[i].pcode;
-
- LOOP
- CLOSE cur_inwaermx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_opposemx_mtrl
- WHERE u_opposemx_mtrl.billid = :arg_billid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,进仓单明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,投诉单产品明细"
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_depmx CURSOR FOR
- SELECT u_opposemx_dept.deptid
- FROM u_opposemx_dept
- Where u_opposemx_dept.billid = :arg_billid Using commit_transaction;
-
- OPEN cur_depmx;
- FETCH cur_depmx Into :opposemx_dept[i].deptid ;
- DO WHILE commit_transaction.SQLCode = 0
- j++
- FETCH cur_depmx Into :opposemx_dept[i].deptid ;
- LOOP
- CLOSE cur_depmx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_opposemx_dept
- WHERE u_opposemx_dept.billid = :arg_billid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,投诉单部门明细"
- GOTO ext
- END IF
- IF j <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,进仓单明细"
- GOTO ext
- END IF
- billid = arg_billid
- it_mxbt = i - 1
- it_depmxbt = j - 1
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer updatebegin (long arg_billid, ref string arg_msg);long rslt = 1
- if arg_billid <= 0 then
- rslt = 0
- goto ext
- end if
- rslt = p_getinfo(arg_billid,arg_msg)
- if rslt = 0 then goto ext
- if flag = 1 then
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- goto ext
- end if
- billid = arg_billid
- it_newbegin = false
- it_updatebegin = true
- p_clearmx() //清除明细
- ext:
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer p_getinfo (long arg_billid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- INT rslt=1
- IF arg_billid<=0 THEN
- rslt=0
- arG_MSG="非法单据唯一码"
- goto ext
- end if
-
- SELECT u_oppose.billid,
- u_oppose.billdate,
- u_oppose.billtype,
- u_oppose.relid,
- u_oppose.opposedept,
- u_oppose.thdate,
- u_oppose.fhdate,
- u_oppose.threason,
- u_oppose.custdscrp,
- u_oppose.saleidea,
- u_oppose.productieda,
- u_oppose.qualityidea,
- u_oppose.manageridea,
- u_oppose.improveidea,
- u_oppose.billcode,
- u_oppose.opdate,
- u_oppose.opemp,
- u_oppose.moddate,
- u_oppose.modemp,
- u_oppose.flag,
- u_oppose.secflag,
- u_oppose.auditdate,
- u_oppose.auditemp ,
- u_oppose.wkpdscrp,
- u_oppose.opposeamt,
- u_oppose.selfamt,
- u_oppose.itemid,
- u_oppose.opposetype,
- u_oppose.dealdscrp,
- u_oppose.relcode
- into :billid,
- :billdate,
- :billtype,
- :relid,
- :opposedept,
- :thdate,
- :fhdate,
- :threason,
- :custdscrp,
- :saleidea,
- :productieda,
- :qualityidea,
- :manageridea,
- :improveidea,
- :billcode,
- :opdate,
- :opemp,
- :moddate,
- :modemp,
- :flag,
- :secflag,
- :auditingdate,
- :auditingrep,
- :wkpdscrp,
- :opposeamt,
- :selfamt,
- :itemid,
- :opposetype,
- :dealdscrp,
- :relcode
- FROM u_oppose
- WHERE u_oppose.billid =:arg_billid using commit_transaction;
-
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误单据唯一码)"+commit_transaction.sqlerrtext
- goto ext
- end if
- billid = arg_billid
-
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);
- int rslt = 1
- if arg_billid = 0 then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- goto ext
- end if
- rslt = p_getinfo(arg_billid,arg_msg)
- if rslt = 0 then goto ext
- if flag = 1 then
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- goto ext
- end if
- delete from u_opposemx_mtrl
- where u_opposemx_mtrl.billid = :arg_billid using commit_transaction;
- if commit_transaction.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除客户投诉单明细操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- delete from u_opposemx_dept
- where u_opposemx_dept.billid = :arg_billid using commit_transaction;
- if commit_transaction.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除客户投诉单部门明细操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- delete from u_oppose
- where u_oppose.billid = :arg_billid using commit_transaction;
- if commit_transaction.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除客户投诉单操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- it_newbegin = false
- it_updatebegin = false
- ext:
- if rslt=0 then
- rollback using commit_transaction;
- elseif rslt=1 and arg_ifcommit then
- commit using commit_transaction;
- end if
- p_reset()
- return rslt
- end function
- public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- IF billtype = 2 THEN
- UPDATE u_oppose
- SET auditemp = :publ_operator,
- auditdate = getdate(),
- flag = 1
- WHERE u_oppose.billid = :billid
- AND flag = 0
- AND secflag = 0 USING commit_transaction;
- ELSE
- UPDATE u_oppose
- SET auditemp = :publ_operator,
- auditdate = getdate(),
- flag = 1,
- secflag = 1,
- secauditdate = getdate(),
- secauditemp = :publ_operator
- WHERE u_oppose.billid = :billid
- AND flag = 0 USING commit_transaction;
- END IF
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
- DateTime null_dt
- SetNull(null_dt)
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- //IF it_newbegin OR it_updatebegin THEN
- // rslt = 0
- // arg_msg = "编辑状态下不可以执行审核"
- // GOTO ext
- //END IF
- IF p_getinfo(arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未审核"
- GOTO ext
- END IF
- IF billtype = 2 THEN
- IF secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已终审,不能撤审"
- GOTO ext
- END IF
- END IF
- IF billtype = 2 THEN
- UPDATE u_oppose
- SET auditemp = '',
- auditdate = :null_dt,
- flag = 0
- WHERE u_oppose.billid = :billid
- AND flag = 1
- AND secflag = 0 USING commit_transaction;
- ELSE
- UPDATE u_oppose
- SET auditemp = '',
- auditdate = :null_dt,
- flag = 0,
- secauditemp = '',
- secauditdate = :null_dt,
- secflag = 0
- WHERE u_oppose.billid = :billid
- AND flag = 1
- AND secflag = 1 USING commit_transaction;
- END IF
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- flag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer newbegin (integer arg_billtype, ref string arg_msg);int rslt=1
- if arg_billtype <> 0 and arg_billtype <> 1 and arg_billtype <> 2 then
- arg_msg = '错误的单据类型:0-内部投诉单,1-供应商投诉单,2-客户/部门投诉单'
- rslt = 0
- goto ext
- end if
- p_reset()
- it_newbegin=true
- it_updatebegin=false
- billtype =arg_billtype
- ext :
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer add_qualityidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arG_MSG = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arG_MSG = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_oppose
- SET qualityidea = qualityidea+' '+:arg_newdescppart
- Where u_oppose.billid = :arg_billid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- qualityidea = qualityidea+' '+arg_newdescppart
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- Return (rslt)
- end function
- public function integer add_manageridea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arG_MSG = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arG_MSG = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_oppose
- SET manageridea = manageridea+' '+:arg_newdescppart
- Where u_oppose.billid = :arg_billid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- manageridea = manageridea+' '+arg_newdescppart
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- Return (rslt)
- end function
- public function integer add_improveidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arG_MSG = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arG_MSG = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_oppose
- SET improveidea = improveidea+' '+:arg_newdescppart
- Where u_oppose.billid = :arg_billid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- improveidea = improveidea+' '+arg_newdescppart
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- Return (rslt)
- end function
- public function integer add_productieda (long arg_billid, long arg_deptid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arG_MSG = "编辑状态下不可用"
- GOTO ext
- END IF
- //IF arg_newdescppart = '' THEN
- // rslt = 0
- // arG_MSG = "要添加内容为空,操作取消"
- // GOTO ext
- //END IF
- IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_opposemx_dept
- SET productieda = :arg_newdescppart,
- opemp = :publ_operator,
- opdate = getdate()
- WHERE u_opposemx_dept.billid = :arg_billid
- AND u_opposemx_dept.deptid = :arg_deptid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- Return (rslt)
- end function
- public function integer secauditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype <> 2 THEN
- arg_msg = '不是客户投诉单,不能终审'
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据未初审,不能终审"
- GOTO ext
- END IF
- IF secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已终审,不能终审"
- GOTO ext
- END IF
- UPDATE u_oppose
- SET secauditemp = :publ_operator,
- secauditdate = getdate(),
- secflag = 1
- WHERE u_oppose.billid = :billid
- AND flag = 1
- AND secflag = 0 USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- secflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_secauditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
- DateTime null_dt
- SetNull(null_dt)
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- //IF it_newbegin OR it_updatebegin THEN
- // rslt = 0
- // arg_msg = "编辑状态下不可以执行审核"
- // GOTO ext
- //END IF
- IF p_getinfo(arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype <> 2 THEN
- arg_msg = '不是客户投诉单,不能终审撤审'
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 0 THEN
- rslt = 0
- arg_msg = "单据还未终审"
- GOTO ext
- END IF
- UPDATE u_oppose
- SET secauditemp = '',
- secauditdate = :null_dt,
- secflag = 0
- WHERE u_oppose.billid = :billid
- AND secflag = 1 USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- secflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function long acceptdeptid (long arg_deptid, string arg_productieda, ref string arg_msg);int rslt = 1
- long i
- string ls_wrkGrpName
- if isnull(arg_deptid) then arg_deptid = 0
- if arg_deptid = 0 then
- rslt = 1
- goto ext
- end if
- select wrkGrpName into :ls_wrkGrpName
- from u_sc_workgroup
- where wrkGrpid = :arg_deptid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询责任部门资料失败'
- rslt = 0
- goto ext
- end if
- for i = 1 to it_depmxbt
- if opposemx_dept[i].deptid = arg_deptid then
- rslt = 1
- goto ext
- end if
- next
- it_depmxbt++
- opposemx_dept[it_depmxbt].deptid = arg_deptid
- opposemx_dept[it_depmxbt].wkpname = ls_wrkGrpName
- opposemx_dept[it_depmxbt].productieda = arg_productieda
- ext:
- if rslt = 0 then p_clearmx()
- return rslt
- end function
- public function integer acceptmx (long arg_mtrlid, string arg_status, decimal arg_qty, string arg_status_mode, string arg_woodcode, string arg_pcode, string arg_mxdscrp, ref string arg_msg);Int rslt = 1
- Long cnt = 0,ls_i
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
- IF IsNull(arg_status) THEN arg_status = ''
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- // 如果进仓数量为 0,或物料编号为空,则不作任何处理
- IF arg_mtrlid = 0 Or arg_qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- FOR ls_i = 1 To it_mxbt
- IF opposemx_mtrl[ls_i].mtrlid = arg_mtrlid And opposemx_mtrl[ls_i].status = arg_status THEN
- rslt = 1
- GOTO ext
- END IF
- NEXT
- //写入内容
- it_mxbt++
- opposemx_mtrl[it_mxbt].mtrlid = arg_mtrlid
- opposemx_mtrl[it_mxbt].status = arg_status
- opposemx_mtrl[it_mxbt].qty = arg_qty
- opposemx_mtrl[it_mxbt].mxdscrp = arg_mxdscrp
- opposemx_mtrl[it_mxbt].status_mode = arg_status_mode
- opposemx_mtrl[it_mxbt].woodcode = arg_woodcode
- opposemx_mtrl[it_mxbt].pcode = arg_pcode
- ext:
- IF rslt = 0 THEN p_clearmx()
- Return(rslt)
- end function
- public function integer update_saleamt (long arg_billid, decimal arg_opposeamt, decimal arg_selfamt, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arG_MSG = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_selfamt < 0 THEN
- rslt = 0
- arG_MSG = "个人金额不能为负数,操作取消"
- GOTO ext
- END IF
- IF arg_opposeamt < 0 THEN
- rslt = 0
- arG_MSG = "总金额不能为负数,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arG_MSG = "待审核状态下不可用"
- GOTO ext
- END IF
- ////2015-03-30 取消限制 (youshi)
- //IF arg_selfamt > arg_opposeamt THEN
- // rslt = 0
- // arG_MSG = '个人金额不能大于总金额'
- // GOTO ext
- //END IF
- UPDATE u_oppose
- SET opposeamt = :arg_opposeamt,
- selfamt = :arg_selfamt
- Where u_oppose.billid = :arg_billid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- opposeamt = arg_opposeamt
- selfamt = arg_selfamt
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- Return (rslt)
- end function
- on uo_oppose.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_oppose.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|