12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349 |
- $PBExportHeader$uo_saleplan.sru
- forward
- global type uo_saleplan from nonvisualobject
- end type
- type s_saleplanmx from structure within uo_saleplan
- end type
- type s_saleplanmx_mx from structure within uo_saleplan
- end type
- end forward
- type s_saleplanmx from structure
- long mtrlid
- string mtrlcode
- long printid
- decimal { 10 } planqty
- string mxdscrp
- decimal { 10 } price
- decimal { 2 } planamt
- string status
- string woodcode
- string pcode
- end type
- type s_saleplanmx_mx from structure
- long mtrlid
- string mtrlcode
- long printid
- decimal{10} planqty
- decimal{10} price
- decimal{2} planamt
- string mxdscrp
- end type
- global type uo_saleplan from nonvisualobject
- end type
- global uo_saleplan uo_saleplan
- type variables
- PUBLIC PROTECTEDWRITE Long scid = 0
- PUBLIC PROTECTEDWRITE Long billID = 0
- PUBLIC PROTECTEDWRITE String billCode = ''
- PUBLIC PROTECTEDWRITE DateTime opdate
- PUBLIC PROTECTEDWRITE String opemp = ''
- public protectedwrite datetime moddate //修改时间,自动
- public protectedwrite string modemp ='' //修改操作员
- public protectedwrite int flag=0 //审核标志
- public protectedwrite datetime auditingdate //审核时间
- PUBLIC PROTECTEDWRITE String auditingrep = ''//审核操作员
- public protectedwrite int secflag=0 //审核标志
- public protectedwrite datetime secauditingdate //审核时间
- PUBLIC PROTECTEDWRITE String secauditingrep = ''//审核操作员
- string outrep = ''
- decimal salemth = 0
- DateTime billdate
- String dscrp = ''
- string relcode = ''
- long cusid = 0
- Transaction commit_transaction
- PRIVATE:
- s_saleplanmx saleplanmx[] //明细结构数组
- s_saleplanmx_mx saleplanmx_mx[]
- Long it_MXBT = 0 //明细结构数组末指针
- long it_mxbt_mx = 0
- Boolean IT_NEWBEGIN = FALSE //新建标志
- Boolean IT_UPDATEBEGIN = FALSE//修改标志
- end variables
- forward prototypes
- public function integer p_reset ()
- public function integer p_clearmx ()
- public function integer newbegin (long arg_scid, ref string arg_msg)
- public function integer save (ref string arg_msg, boolean arg_ifcommit)
- public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer getinfo (integer arg_scid, long arg_billid, ref string arg_msg)
- public function integer cancel (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer audit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer caudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer csecaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer updatesaleqty (long arg_salemth, string arg_outrep, ref string arg_msg, boolean arg_ifcommit)
- public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_planqty, decimal arg_price, string arg_mxdscrp, ref string arg_msg, long arg_printid)
- end prototypes
- public function integer p_reset ();//INT p_RESET()
- //清除对象及其明细
- billid=0
- billcode=''
- outrep = ''
- salemth = 0
- relcode = ''
- cusid = 0
- it_newbegin=FALSE
- it_updatebegin=FALSE
- //清除明细
- P_CLEARMX()
- RETURN 1
- end function
- public function integer p_clearmx ();//INT p_clearmx()
- //清除明细
- it_mxbt = 0
- it_mxbt_mx = 0
- RETURN 1
- end function
- public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单
- //0 fail 1 success
- long rslt=1,CNT=0
- if arg_scid < 0 then
- arg_msg = '请选择分部'
- rslt = 0
- goto ext
- end if
- p_reset()
- it_newbegin=TRUE
- it_updatebegin=FALSE
- scid=arg_scid
- ext:
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i,j
- DateTime server_dt
- Long ll_billid
- String ls_sccode
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(relcode) THEN relcode = ''
- IF IsNull(salemth) THEN salemth = 0
- IF IsNull(outrep) THEN outrep = ''
- IF IsNull(cusid) THEN cusid = 0
- //IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arG_MSG = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF Trim(outrep) = '' THEN
- rslt = 0
- arG_MSG = "请输入业务员"
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_saleplan
- WHERE outrep = :outrep
- AND salemth = :salemth
- AND billid <> :billid
- USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = '查询该业务当月是否已开销售计划失败'+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arG_MSG = '该业务员当月已开销售计划,不能重复开单'
- GOTO ext
- END IF
- IF cusid > 0 THEN
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :cusid;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询客户是否存在失败 "
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arG_MSG = '客户资料不存在,请检查'
- GOTO ext
- END IF
- 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
- IF f_check_inoutdate(0,billdate,FALSE,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arG_MSG = "没有正确单据明细内容"
- GOTO ext
- END IF
- //////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF billid = 0 THEN //新建
- ll_billid = f_sys_scidentity(scid,"u_saleplan","billid",arG_MSG,TRUE,id_sqlca) //数据commit事务)
- IF ll_billid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- billCode = getid(scid,ls_sccode + 'XP',Date(server_dt),FALSE,commit_transaction)
- IF billCode = "err" THEN
- billCode = ''
- rslt = 0
- arG_MSG = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_saleplan
- ( scid,
- billid,
- billcode,
- outrep,
- billdate,
- salemth,
- relcode,
- Dscrp,
- opemp,
- opdate,
- cusid
- )
- VALUES (:scid,
- :ll_billid,
- :billCode,
- :outrep,
- :billdate,
- :salemth,
- :relcode,
- :Dscrp,
- :publ_operator,
- :server_dt,
- :cusid) USING commit_transaction ;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致插入单据操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
-
- //读取新billid
- billid = ll_billid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_saleplanmx
- ( scid,
- billid,
- mtrlid,
- planqty,
- mxdscrp,
- printid,
- price,
- planamt,
- status,
- woodcode,
- pcode,
- mxtype)
- VALUES (:scid,
- :ll_billid,
- :saleplanmx[i].mtrlid,
- :saleplanmx[i].planqty,
- :saleplanmx[i].mxdscrp,
- :saleplanmx[i].printid,
- :saleplanmx[i].price,
- :saleplanmx[i].planamt,
- :saleplanmx[i].status,
- :saleplanmx[i].woodcode,
- :saleplanmx[i].pcode,
- 0) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0 //还原billID
- rslt = 0
- arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- NEXT
-
- FOR j = 1 TO it_mxbt_mx
- INSERT INTO u_saleplanmx
- ( scid,
- billid,
- mtrlid,
- planqty,
- mxdscrp,
- printid,
- price,
- planamt,
- mxtype)
- VALUES (:scid,
- :ll_billid,
- :saleplanmx_mx[j].mtrlid,
- :saleplanmx_mx[j].planqty,
- :saleplanmx_mx[j].mxdscrp,
- :saleplanmx_mx[j].printid,
- :saleplanmx_mx[j].price,
- :saleplanmx_mx[j].planamt,
- 1) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0 //还原billID
- rslt = 0
- arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- NEXT
-
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_saleplan
- SET outrep = :outrep,
- salemth = :salemth,
- billdate = :billdate,
- relcode = :relcode,
- Dscrp = :Dscrp,
- moddate = getdate(),
- Modemp = :publ_operator,
- cusid = :cusid
- WHERE u_saleplan.billid = :billID
- AND scid = :scid
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致更新销售计划操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_saleplanmx
- Where u_saleplanmx.billid = :billid AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_saleplanmx
- ( scid,
- billid,
- mtrlid,
- planqty,
- mxdscrp,
- printid,
- price,
- planamt,
- status,
- woodcode,
- pcode,
- mxtype)
- VALUES (:scid,
- :billid,
- :saleplanmx[i].mtrlid,
- :saleplanmx[i].planqty,
- :saleplanmx[i].mxdscrp,
- :saleplanmx[i].printid,
- :saleplanmx[i].price,
- :saleplanmx[i].planamt,
- :saleplanmx[i].status,
- :saleplanmx[i].woodcode,
- :saleplanmx[i].pcode,
- 0) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- NEXT
-
-
-
- FOR j = 1 TO it_mxbt_mx
- INSERT INTO u_saleplanmx
- ( scid,
- billid,
- mtrlid,
- planqty,
- mxdscrp,
- printid,
- price,
- planamt,
- mxtype)
- VALUES (:scid,
- :billid,
- :saleplanmx_mx[j].mtrlid,
- :saleplanmx_mx[j].planqty,
- :saleplanmx_mx[j].mxdscrp,
- :saleplanmx_mx[j].printid,
- :saleplanmx_mx[j].price,
- :saleplanmx_mx[j].planamt,
- 1) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0 //还原billID
- rslt = 0
- arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- NEXT
-
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- p_clearmx()
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit AND rslt = 1 THEN
- COMMIT USING commit_transaction;
- END IF
- Return(rslt)
- end function
- public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
- SELECT
- billid,
- billcode,
- outrep,
- salemth,
- billdate,
- relcode,
- dscrp,
- opemp,
- opdate,
- flag,
- secflag
- INTO :billid,
- :billcode,
- :outrep,
- :salemth,
- :billdate,
- :relcode,
- :dscrp,
- :opemp,
- :opdate,
- :flag,
- :secflag
- FROM u_saleplan
- Where u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = '查询单据内容失败(错误单据唯一码)'+sqlca.SQLErrText
- GOTO ext
- END IF
- scid = arg_scid
- billid = arg_billid
- ext:
- RETURN rslt
- end function
- public function integer getinfo (integer arg_scid, long arg_billid, ref string arg_msg);
- Int rslt = 1,i = 1,no_mxcheck = 0
- Int j = 1
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_saleplanmx CURSOR FOR
- SELECT
- mtrlid,
- planqty,
- printid,
- mxdscrp,
- price,
- planamt,
- status,
- woodcode,
- pcode
- FROM u_saleplanmx
- WHERE u_saleplanmx.billid = :arg_billid AND
- u_saleplanmx.scid = :arg_scid AND
- u_saleplanmx.mxtype = 0
- Order By u_saleplanmx.printid USING commit_transaction;
-
- OPEN cur_saleplanmx;
- FETCH cur_saleplanmx INTO :saleplanmx[i].mtrlid,:saleplanmx[i].planqty,
- :saleplanmx[i].printid,:saleplanmx[i].mxdscrp,
- :saleplanmx[i].price,:saleplanmx[i].planamt,
- :saleplanmx[i].status,:saleplanmx[i].woodcode,:saleplanmx[i].pcode;
-
- DO WHILE commit_transaction.SQLCode = 0
- i++
- FETCH cur_saleplanmx INTO :saleplanmx[i].mtrlid,:saleplanmx[i].planqty,
- :saleplanmx[i].printid,:saleplanmx[i].mxdscrp,
- :saleplanmx[i].price,:saleplanmx[i].planamt,
- :saleplanmx[i].status,:saleplanmx[i].woodcode,:saleplanmx[i].pcode;
- LOOP
- CLOSE cur_saleplanmx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_saleplanmx
- WHERE u_saleplanmx.billid = :arg_billid AND
- u_saleplanmx.scid = :arg_scid AND
- u_saleplanmx.mxtype = 0 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
- it_mxbt = i - 1
- //
- //用游标读取明细
- DECLARE cur_saleplanmx_mx CURSOR FOR
- SELECT
- mtrlid,
- planqty,
- printid,
- mxdscrp,
- price,
- planamt
- FROM u_saleplanmx
- WHERE u_saleplanmx.billid = :arg_billid AND
- u_saleplanmx.scid = :arg_scid AND
- u_saleplanmx.mxtype = 1
- Order By u_saleplanmx.printid USING commit_transaction;
-
- OPEN cur_saleplanmx_mx;
- FETCH cur_saleplanmx_mx INTO :saleplanmx[j].mtrlid,:saleplanmx[j].planqty,
- :saleplanmx[j].printid,:saleplanmx[j].mxdscrp,
- :saleplanmx[j].price,:saleplanmx[j].planamt;
-
- DO WHILE commit_transaction.SQLCode = 0
- j++
- FETCH cur_saleplanmx_mx INTO :saleplanmx[j].mtrlid,:saleplanmx[j].planqty,
- :saleplanmx[j].printid,:saleplanmx[j].mxdscrp,
- :saleplanmx[j].price,:saleplanmx[j].planamt;
- LOOP
- CLOSE cur_saleplanmx_mx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_saleplanmx
- WHERE u_saleplanmx.billid = :arg_billid AND
- u_saleplanmx.scid = :arg_scid AND
- u_saleplanmx.mxtype = 1 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
- it_mxbt_mx = j - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer cancel (long arg_scid, 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
- IF p_getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- ARG_MSG = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- DELETE FROM u_saleplan
- WHERE u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "删除销售计划操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- DELETE FROM u_saleplanmx
- Where u_saleplanmx.billid = :arg_billid AND u_saleplanmx.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "删除单据明细操作失败"+"~n"+SQLCA.SQLErrText
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- ext:
- p_reset()
- Return (rslt)
- end function
- public function integer audit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);
- Int rslt = 1,cnt = 0
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF getinfo(arg_scid,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 it_MXBT <= 0 THEN
- rslt = 0
- ARG_MSG = "单据明细错误,操作取消"
- GOTO ext
- END IF
- //更新审核标记
- UPDATE u_saleplan
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- Where u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid
- AND u_saleplan.flag = 0 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 add_dscrp (long arg_scid, 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_scid,arg_billid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arG_MSG = "待审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_saleplan
- SET DSCRP = DSCRP+' '+:arg_newdescppart
- WHERE u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- DSCRP = DSCRP+' '+arg_newdescppart
- 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 updatebegin (long arg_scid, long arg_billid, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg)
- //从置对象,设定业务类型与关联ID,准备更新进仓单
- //0 fail 1 success
- Long rslt = 1,CNT = 0
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误销售计划唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '已经处于审核状态,不可以修改,要修改请先撤销审核'
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- scid = arg_scid
- billid = arg_billid
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer caudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
- DateTime ls_auditingdate
- SetNull(ls_auditingdate)
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误销售计划唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,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 secflag = 1 THEN
- rslt = 0
- ARG_MSG = "单据已经确认,不可以执行取消审核,请核对"
- GOTO ext
- END IF
- UPDATE u_saleplan
- SET flag = 0,auditingrep = '',auditingdate = :ls_auditingdate
- WHERE u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid
- AND u_saleplan.flag = 1 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 secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);
- Int rslt = 1,cnt = 0
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF getinfo(arg_scid,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 secflag = 1 THEN
- rslt = 0
- ARG_MSG = "单据已经二审,操作取消"
- GOTO ext
- END IF
- IF it_MXBT <= 0 THEN
- rslt = 0
- ARG_MSG = "单据明细错误,操作取消"
- GOTO ext
- END IF
- //更新审核标记
- UPDATE u_saleplan
- SET secauditingrep = :publ_operator, secauditingdate = getdate(),
- secflag = 1
- Where u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid
- AND u_saleplan.secflag = 0 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 csecaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
- datetime ls_secauditingdate
- setnull(ls_secauditingdate)
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 0 THEN
- rslt = 0
- ARG_MSG = "单据未二审,操作取消"
- GOTO ext
- END IF
- IF it_MXBT <= 0 THEN
- rslt = 0
- ARG_MSG = "单据明细错误,操作取消"
- GOTO ext
- END IF
- //更新审核标记
- UPDATE u_saleplan
- SET secauditingrep = '', secauditingdate = :ls_secauditingdate,
- secflag = 0
- Where u_saleplan.billid = :arg_billid
- AND u_saleplan.scid = :arg_scid
- AND u_saleplan.secflag = 1 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 updatesaleqty (long arg_salemth, string arg_outrep, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt = 0
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_saleplan
- WHERE salemth = :arg_salemth
- AND outrep = :arg_outrep
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询业务员:'+arg_outrep+',本月是否有未审单据失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF cnt > 0 THEN
- arg_msg = '业务员:'+arg_outrep+',本月有未审单据,请检查'
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_saleplan
- WHERE salemth = :arg_salemth
- AND outrep = :arg_outrep
- AND secflag = 1 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询业务员:'+arg_outrep+',本月是否有终审单据失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF cnt > 0 THEN
- arg_msg = '业务员:'+arg_outrep+',本月有终审单据,请检查'
- rslt = 0
- GOTO ext
- END IF
- //计算当月实际销售数
- Int li_year,li_month
- li_year = Integer(Left(String(arg_salemth),4))
- IF Mid(String(arg_salemth),5,1) = '0' THEN
- li_month = Integer(Mid(String(arg_salemth),6,1))
- ELSE
- li_month = Integer(Mid(String(arg_salemth),5,2))
- END IF
- Long l,ll_ant_arr = 1
- Long ll_mtrlid_arr[],ll_scid_arr[]
- Decimal ld_saleqty_arr[],ld_saleamt_arr[]
- String ls_mtrlcode_arr[]
- Long ll_max_saleplanid
- DECLARE cur_sale CURSOR FOR
- SELECT isnull(sum(qty),0),
- isnull(sum(round(qty * price,2)),0),
- u_outwaremx.scid,
- u_outwaremx.mtrlid,
- u_mtrldef.mtrlcode
- FROM u_outwaremx,u_outware,u_mtrldef
- WHERE u_outwaremx.outwareid = u_outware.outwareid
- AND u_outwaremx.scid = u_outware.scid
- AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
- AND u_outware.outrep = :arg_outrep
- AND datepart(yyyy,u_outware.outdate) = :li_year
- AND datepart(mm,u_outware.outdate) = :li_month
- AND u_outware.billtype = 1
- AND u_outware.flag = 1
- AND u_outware.secflag = 1
- AND u_outwaremx.outtypestr = ''
- GROUP BY u_outwaremx.scid,
- u_outwaremx.mtrlid,
- u_mtrldef.mtrlcode
- USING commit_transaction;
-
- OPEN cur_sale;
- FETCH cur_sale INTO :ld_saleqty_arr[ll_ant_arr],
- :ld_saleamt_arr[ll_ant_arr],
- :ll_scid_arr[ll_ant_arr],
- :ll_mtrlid_arr[ll_ant_arr],
- :ls_mtrlcode_arr[ll_ant_arr];
-
- DO WHILE commit_transaction.SQLCode = 0
- ll_ant_arr++
- FETCH cur_sale INTO :ld_saleqty_arr[ll_ant_arr],
- :ld_saleamt_arr[ll_ant_arr],
- :ll_scid_arr[ll_ant_arr],
- :ll_mtrlid_arr[ll_ant_arr],
- :ls_mtrlcode_arr[ll_ant_arr];
- LOOP
- CLOSE cur_sale;
- ll_ant_arr = ll_ant_arr - 1
- IF ll_ant_arr = 0 THEN
- arg_msg = '业务员:'+arg_outrep+',没有实际销售数,请检查'
- rslt = 0
- GOTO ext
- END IF
- DELETE u_saleplanmx
- FROM u_saleplan,u_saleplanmx
- WHERE u_saleplan.scid = u_saleplanmx.scid
- AND u_saleplan.billid = u_saleplanmx.billid
- AND u_saleplan.salemth = :arg_salemth
- AND u_saleplan.outrep = :arg_outrep
- AND u_saleplanmx.planqty = 0
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '清除业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
- GOTO ext
- END IF
- //Open(w_sys_wait_jdt) //初始化进度条
- //w_sys_wait_jdt.Show()
- //w_sys_wait_jdt.wf_accepttol(ll_ant_arr) //初始化进度条1
- //
- FOR l = 1 TO ll_ant_arr
- // w_sys_wait_jdt.wf_inc(l) //进度
- // w_sys_wait_jdt.st_msg.Text = "处理:"+ls_mtrlcode_arr[l] //进度信息
-
-
- UPDATE u_saleplanmx
- SET saleqty = :ld_saleqty_arr[l],
- saleamt = :ld_saleamt_arr[l]
- FROM u_saleplan,u_saleplanmx
- WHERE u_saleplan.scid = u_saleplanmx.scid
- AND u_saleplan.billid = u_saleplanmx.billid
- AND u_saleplan.salemth = :arg_salemth
- AND u_saleplan.outrep = :arg_outrep
- AND u_saleplanmx.scid = :ll_scid_arr[l]
- AND u_saleplanmx.mtrlid = :ll_mtrlid_arr[l]
- and u_saleplanmx.mxtype = 1
- USING commit_transaction;
-
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- SELECT max(billid) INTO :ll_max_saleplanid
- FROM u_saleplan
- WHERE u_saleplan.salemth = :arg_salemth
- AND u_saleplan.outrep = :arg_outrep
- AND u_saleplan.scid = :ll_scid_arr[l]
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询业务员:'+arg_outrep+',单据ID失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF IsNull(ll_max_saleplanid) THEN ll_max_saleplanid = 0
- IF ll_max_saleplanid = 0 THEN
- arg_msg = '业务员:'+arg_outrep+',单据ID错误'
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_saleplanmx
- (scid,
- billid,
- mtrlid,
- saleqty,
- saleamt,
- mxtype)
- VALUES
- (:ll_scid_arr[l],
- :ll_max_saleplanid,
- :ll_mtrlid_arr[l],
- :ld_saleqty_arr[l],
- :ld_saleamt_arr[l],
- 1)
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '新增业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
- arg_msg = '更新业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ext:
- //Close(w_sys_wait_jdt)
- 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 acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_planqty, decimal arg_price, string arg_mxdscrp, ref string arg_msg, long arg_printid);Int rslt = 1
- Long cnt = 0,LS_i,ls_j
- 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_mtrlcode) THEN arg_mtrlcode = ''
- IF IsNull(arg_planqty) THEN arg_planqty = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_price) THEN arg_price = 0
- IF IsNull(arg_status) THEN arg_status = ''
- IF IsNull(arg_woodcode) THEN arg_woodcode = ''
- IF IsNull(arg_pcode) THEN arg_pcode = ''
- IF arg_mtrlid = 0 OR arg_planqty = 0 THEN // 如果物料编号为空,则不作任何处理
- rslt = 1
- GOTO ext
- END IF
- //检查物料id
- SELECT count(*)
- INTO :cnt
- FROM u_mtrldef
- WHERE u_mtrldef.mtrlid = :arg_mtrlid
- USING commit_transaction;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败,产品编号,"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arG_MSG = "错误的产品编号: "+String(arg_mtrlcode)
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_saleplanmx,u_saleplan
- WHERE u_saleplanmx.scid = u_saleplan.scid
- AND u_saleplanmx.billid = u_saleplan.billid
- AND u_saleplan.outrep = :outrep
- AND u_saleplan.salemth = :salemth
- AND u_saleplanmx.mtrlid = :arg_mtrlid
- AND u_saleplanmx.status = :arg_status
- AND u_saleplanmx.woodcode = :arg_woodcode
- AND u_saleplanmx.pcode = :arg_pcode
- AND u_saleplanmx.billid <> :billid
- USING commit_transaction;
- IF sqlca.SQLCode <> 0 THEN
- arG_MSG = '查询业务员:'+outrep+',产品:'+arg_mtrlcode+',本月是否在其它计件单已做计划失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF cnt > 0 THEN
- arG_MSG = '查询业务员:'+outrep+',产品:'+arg_mtrlcode+',本月在其它计件单已做计划失败'
- rslt = 0
- GOTO ext
- END IF
- FOR LS_i = 1 TO it_mxbt //合并重复项(产品,配置)
- IF saleplanmx[LS_i].mtrlid = arg_mtrlid AND &
- saleplanmx[LS_i].status = arg_status AND &
- saleplanmx[LS_i].woodcode = arg_woodcode AND &
- saleplanmx[LS_i].pcode = arg_pcode THEN
- saleplanmx[LS_i].planqty = saleplanmx[LS_i].planqty + arg_planqty
- rslt = 1
- GOTO _next
- END IF
- NEXT
- //写入内容
- it_mxbt++
- saleplanmx[it_mxbt].mtrlid = arg_mtrlid
- saleplanmx[it_mxbt].mtrlcode = arg_mtrlcode
- saleplanmx[it_mxbt].planqty = arg_planqty
- saleplanmx[it_mxbt].price = arg_price
- saleplanmx[it_mxbt].planamt = Round(arg_price * arg_planqty,2)
- saleplanmx[it_mxbt].mxdscrp = arg_mxdscrp
- saleplanmx[it_mxbt].printid = arg_printid
- saleplanmx[it_mxbt].status = arg_status
- saleplanmx[it_mxbt].woodcode = arg_woodcode
- saleplanmx[it_mxbt].pcode = arg_pcode
- _next:
- FOR ls_j = 1 TO it_mxbt_mx //合并重复项(产品)
- IF saleplanmx_mx[ls_j].mtrlid = arg_mtrlid THEN
- saleplanmx_mx[ls_j].planqty = saleplanmx_mx[ls_j].planqty + arg_planqty
- rslt = 1
- GOTO ext
- END IF
- NEXT
- it_mxbt_mx++
- saleplanmx_mx[it_mxbt_mx].mtrlid = arg_mtrlid
- saleplanmx_mx[it_mxbt_mx].mtrlcode = arg_mtrlcode
- saleplanmx_mx[it_mxbt_mx].planqty = arg_planqty
- saleplanmx_mx[it_mxbt_mx].price = arg_price
- saleplanmx_mx[it_mxbt_mx].planamt = Round(arg_price * arg_planqty,2)
- saleplanmx_mx[it_mxbt_mx].mxdscrp = arg_mxdscrp
- saleplanmx_mx[it_mxbt_mx].printid = arg_printid
- ext:
- IF rslt = 0 THEN p_clearmx()
- Return(rslt)
- end function
- on uo_saleplan.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_saleplan.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- global type uo_incase from nonvisualobject
- end type
|