12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049 |
- $PBExportHeader$uo_incase.sru
- forward
- global type uo_incase from nonvisualobject
- end type
- type s_incasemx_array from structure within uo_incase
- end type
- type s_incasemx from structure within uo_incase
- end type
- end forward
- type s_incasemx from structure
- long mtrlid
- string mtrlstatus
- string pfcode
- string mtrlmode
- string packunit
- long printid
- decimal { 4 } qty
- decimal { 4 } packqty
- decimal { 4 } grossweight
- string mxdscrp
- decimal { 4 } netweight
- decimal { 4 } cubage
- integer ifson_flag
- long fathermtrlid
- string packsize
- string packcode
- decimal { 5 } packqty_1
- decimal { 5 } Sonscale
- long cusid
- long relid_outware
- string relcode_outware
- int discard
- end type
- global type uo_incase from nonvisualobject
- end type
- global uo_incase uo_incase
- type variables
- PUBLIC PROTECTEDWRITE Long scid = 0
- PUBLIC PROTECTEDWRITE Long incaseID = 0
- PUBLIC PROTECTEDWRITE String incaseCode = ''
- PUBLIC PROTECTEDWRITE DateTime opdate
- PUBLIC PROTECTEDWRITE String operator = ''
- PUBLIC PROTECTEDWRITE String Permit_emp = ''//审核操作员
- public protectedwrite datetime moddate //修改时间,自动
- public protectedwrite string modemp //修改操作员
- public protectedwrite int flag=0 //审核标志
- public protectedwrite datetime auditingdate //审核时间
- Long relid = 0
- Long custID = 0
- String Assign_emp
- DateTime incasedate
- String dscrp
- string relcode
- string prdship
- Transaction commit_transaction
- PRIVATE:
- s_incasemx incasemx[] //明细结构数组
- Long it_MXBT = 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 (string arg_operator, ref string arg_msg, boolean arg_ifcommit)
- public function integer updatebegin (long arg_scid, long arg_incased, ref string arg_msg)
- public function integer p_getinfo (long arg_scid, long arg_incaseid, ref string arg_msg)
- public function integer cancel (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_incaseid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
- public function integer audit (long arg_scid, long arg_incaseid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
- public function integer cancelaudit (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit)
- public function integer getinfo (integer arg_scid, long arg_incaseid, ref string arg_msg)
- public function integer acceptmx (long arg_mtrlid, string arg_mtrlstatus, string arg_pfcode, decimal arg_qty, string arg_packunit, string arg_packcode, string arg_packsize, string arg_mxdscrp, decimal arg_packqty, ref string arg_msg, long arg_printid, decimal arg_grossweight, decimal arg_netweight, decimal arg_cubage, integer arg_ifson_flag, integer arg_fathermtrlid, long arg_packqty_1, long arg_cusid, long arg_relid_outware, string arg_relcode_outware, integer arg_discard, decimal arg_sonscale)
- end prototypes
- public function integer p_reset ();//INT p_RESET()
- //清除对象及其明细
- incaseID=0
- incaseCode=''
- operator=''
- relcode = ''
- flag=0
- it_newbegin=FALSE
- it_updatebegin=FALSE
- //清除明细
- P_CLEARMX()
- RETURN 1
- end function
- public function integer p_clearmx ();//INT p_clearmx()
- //清除明细
- it_mxbt=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 (string arg_operator, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
- DateTime server_dt
- Long ll_incaseid
- String ls_sccode
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(assign_emp) THEN assign_emp = ''
- IF IsNull(arg_operator) THEN arg_operator = ''
- //====================================================================
- // Script - save ( ref string arg_msg, boolean arg_ifcommit )
- // Reason:
- //--------------------------------------------------------------------
- // Modified By: yyx Date: 2004.02.20
- //--------------------------------------------------------------------
- IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp
- //====================================================================
- operator = arg_operator
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arG_MSG = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF Trim(assign_emp) = '' 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
- IF Year(Date(incasedate)) < 2000 OR IsNull(incasedate) THEN
- rslt = 0
- arG_MSG = "缺少装箱发生时间或不合理"
- GOTO ext
- END IF
- IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(incasedate,'yyyy-mm-dd'))) > 30 THEN
- rslt = 0
- arG_MSG = '装箱单日期错误,日期不能超前系统日期'
- GOTO ext
- END IF
- IF DaysAfter(Date(String(incasedate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > 30 THEN
- rslt = 0
- arG_MSG = '装箱单日期错误,日期不能落后系统日期'
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arG_MSG = "没有正确装箱单单明细内容"
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :operator USING commit_transaction ;
- 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
- opdate = server_dt //填写单据建立时间(最近修改时间)
- //////////////////////////////////////////////////开始区分:新建/更新 处理
- IF incaseID = 0 THEN //新建
-
- ll_incaseid = f_sys_scidentity(scid,"u_incase","incaseid",arG_MSG,FALSE, commit_transaction) //数据commit事务)
- IF ll_incaseid <= 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
-
- incaseCode = getid(scid,ls_sccode + 'ZX',Date(server_dt),FALSE,commit_transaction)
- IF incaseCode = "err" THEN
- incaseCode = ''
- rslt = 0
- arG_MSG = "无法获取装箱单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_incase
- ( scid,
- incaseid,
- incaseCode,
- cusID,
- incasedate,
- Assign_Emp,
- relcode,
- Dscrp,
- opemp,
- opdate,
- relid,
- prdship
- )
- VALUES ( :scid,
- :ll_incaseid,
- :incaseCode,
- :custID,
- :incasedate,
- :Assign_Emp,
- :relcode,
- :Dscrp,
- :operator,
- :server_dt,
- :relid,
- :prdship) USING commit_transaction ;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_incase') > 0 THEN
- arG_MSG = '插入装箱单操作失败,关键字单据ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_incase') > 0 THEN
- arG_MSG = '插入装箱单操作失败,单据编号重复'
- ELSE
- arG_MSG = "因网络或其它原因导致插入装箱单操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
-
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
-
- //读取新incaseid
- incaseID = ll_incaseid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_incasemx
- ( scid,
- incaseid,
- mtrlid,
- mtrlstatus,
- pfcode,
- printid,
- packunit,
- packcode,
- packsize,
- qty,
- packqty,
- grossweight,
- netweight,
- cubage,
- ifson_flag,
- fathermtrlid,
- mxdscrp,
- packqty_1,
- cusid,
- relid_outware,
- relcode_outware,
- discard,
- Sonscale
- )
- VALUES (:scid,
- :ll_incaseid,
- :incasemx[i].mtrlid,
- :incasemx[i].mtrlstatus,
- :incasemx[i].pfcode,
- :incasemx[i].printid,
- :incasemx[i].packunit ,
- :incasemx[i].packcode,
- :incasemx[i].packsize ,
- :incasemx[i].qty,
- :incasemx[i].packqty,
- :incasemx[i].grossweight,
- :incasemx[i].netweight,
- :incasemx[i].cubage,
- :incasemx[i].ifson_flag,
- :incasemx[i].fathermtrlid,
- :incasemx[i].mxdscrp,
- :incasemx[i].packqty_1,
- :incasemx[i].cusid,
- :incasemx[i].relid_outware,
- :incasemx[i].relcode_outware,
- :incasemx[i].discard,
- :incasemx[i].Sonscale
- ) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- incaseID = 0 //还原incaseID
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_incasemx') > 0 THEN
- arG_MSG = '插入装箱单明细操作失败,关键字单据ID,分部ID,序号重复'
- ELSE
- arG_MSG = "因网络或其它原因导致插入装箱单明细操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
- NEXT
-
- ELSE //////////////////////////////////////////////////更新
- UPDATE u_incase
- SET cusID = :custID,
- incasedate = :incasedate,
- Assign_Emp = :Assign_Emp,
- Dscrp = :Dscrp,
- moddate = getdate(),
- Modemp = :publ_operator,
- relcode = :relcode,
- prdship = :prdship
- WHERE u_incase.incaseid = :incaseID
- AND scid = :scid
- 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
- ROLLBACK USING commit_transaction;
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_incasemx
- Where u_incasemx.incaseID = :incaseID 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_incasemx
- ( scid,
- incaseid,
- mtrlid,
- mtrlstatus,
- pfcode,
- printid,
- packunit,
- packcode,
- packsize,
- qty,
- packqty,
- grossweight,
- netweight,
- cubage,
- ifson_flag,
- fathermtrlid,
- mxdscrp,
- packqty_1,
- cusid,
- relid_outware,
- relcode_outware,
- discard,
- Sonscale)
- VALUES (:scid,
- :incaseID,
- :incasemx[i].mtrlid,
- :incasemx[i].mtrlstatus,
- :incasemx[i].pfcode,
- :incasemx[i].printid,
- :incasemx[i].packunit ,
- :incasemx[i].packcode,
- :incasemx[i].packsize ,
- :incasemx[i].qty,
- :incasemx[i].packqty,
- :incasemx[i].grossweight,
- :incasemx[i].netweight,
- :incasemx[i].cubage,
- :incasemx[i].ifson_flag,
- :incasemx[i].fathermtrlid,
- :incasemx[i].mxdscrp,
- :incasemx[i].packqty_1,
- :incasemx[i].cusid,
- :incasemx[i].relid_outware,
- :incasemx[i].relcode_outware,
- :incasemx[i].discard,
- :incasemx[i].Sonscale
- ) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_incasemx') > 0 THEN
- arG_MSG = '插入装箱单明细操作失败,关键字单据ID,分部ID,序号重复'
- ELSE
- arG_MSG = "因网络或其它原因导致插入装箱单明细操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- 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 updatebegin (long arg_scid, long arg_incased, 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_incased<=0 THEN
- rslt=0
- ARG_MSG='错误装箱单唯一码'
- goto ext
- end if
- if p_getinfo(arg_scid,arg_incased,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
- incaseID=arg_incased
- ext:
- if rslt=0 then p_reset()
- return rslt
- end function
- public function integer p_getinfo (long arg_scid, long arg_incaseid, ref string arg_msg);Int rslt = 1
-
- SELECT
- incaseid,
- incasecode,
- cusid,
- incasedate,
- assign_emp,
- relcode,
- dscrp,
- opemp,
- opdate,
- flag,
- prdship
- INTO :incaseid,
- :incasecode,
- :custid,
- :incasedate,
- :assign_emp,
- :relcode,
- :dscrp,
- :operator,
- :opdate,
- :flag,
- :prdship
- FROM u_incase
- Where u_incase.incaseid = :arg_incaseid AND
- u_incase.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
- incaseID= arg_incaseid
- ext:
- RETURN rslt
- end function
- public function integer cancel (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit);//删除未审核的装箱单
- //0 FAIL, 1 SUCCESS
- INT rslt=1
- IF arg_incaseid<=0 THEN
- rslt=0
- ARG_MSG='错误装箱单唯一码'
- goto ext
- end if
- if p_getinfo(arg_scid,arg_incaseid,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_incase
- WHERE u_incase.incaseid = :arg_incaseid and u_incase.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_incasemx
- WHERE u_incasemx.incaseid = :arg_incaseid and u_incasemx.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 arg_ifcommit and rslt = 1 then
- COMMIT using commit_transaction;
- end if
- EXT:
- p_reset()
- return (rslt)
- end function
- public function integer add_dscrp (long arg_scid, long arg_incaseid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//add_dscrp(string arg_newdescppart)
- //0 fail 1 SUCCESS
- 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_incaseid,arg_msg)=0 then
- rslt=0
- goto ext
- end if
- IF flag=0 THEN
- rslt=0
- arG_MSG="待审核状态下不可用"
- goto ext
- END IF
- UPDATE u_incase
- SET DSCRP = DSCRP+' '+:arg_newdescppart
- WHERE u_incase.incaseid = :arg_incaseid 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
- DSCRP = DSCRP+' '+arg_newdescppart
- it_newbegin=FALSE
- it_updatebegin=FALSE
- EXT:
- if arg_ifcommit and rslt=1 then
- COMMIT using commit_transaction;
- end if
- p_reset()
- return (rslt)
- end function
- public function integer audit (long arg_scid, long arg_incaseid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
- Int rslt = 1,cnt = 0
- IF arg_incaseid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误装箱单唯一码'
- GOTO ext
- END IF
- IF getinfo(arg_scid,arg_incaseid,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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :arg_emp USING commit_transaction;
- 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
- //更新审核标记
- UPDATE u_incase
- SET auditingrep = :arg_emp, auditingdate = getdate(),
- flag = 1
- Where u_incase.incaseid = :arg_incaseid AND u_incase.scid = :arg_scid AND u_incase.flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- long ll_relid_outware
- int ls_j,ls_k
- boolean if_find
- long ll_relid_incase
- if it_MXBT<1 then
- rslt = 0
- ARG_MSG = "没有正确的明细内容"
- GOTO ext
- END IF
- for ls_j=1 to it_MXBT
-
- ll_relid_outware=incasemx[ls_j].relid_outware
- if_find=false
- for ls_k=1 to ls_j - 1
- if ll_relid_outware=incasemx[ls_k].relid_outware then
- if_find=true
- exit
- end if
- next
-
- if not if_find then
-
- select relid_incase
- into :ll_relid_incase
- from u_outware
- where u_outware.outwareid=:ll_relid_outware and scid=:scid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "因网络或其它原因导致查询操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- if ll_relid_incase<>0 then
- rslt = 0
- ARG_MSG = "装箱明细单据中有相关销售已经装箱"
- GOTO ext
- END IF
-
- update u_outware
- set relid_incase=:incaseID
- where u_outware.outwareid=:ll_relid_outware and scid=:scid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- end if
- next
- 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 cancelaudit (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit);INT rslt=1,cnt=0
- datetime ls_auditingdate
- setnull(ls_auditingdate)
- IF arg_incaseid<=0 THEN
- rslt=0
- ARG_MSG='错误装箱单唯一码'
- goto ext
- end if
- if getinfo(arg_scid,arg_incaseid,arg_msg)=0 then
- rslt=0
- goto ext
- end if
- IF flag = 0 THEN
- rslt=0
- arG_MSG="装箱只有在已审核状态才可以执行撤消审核,请核对"
- goto ext
- END IF
- UPDATE u_incase
- SET flag = 0,auditingrep='',auditingdate=:ls_auditingdate
- WHERE u_incase.incaseid = :arg_incaseid and u_incase.scid=:arg_scid and u_incase.flag=1 using commit_transaction ;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="因网络或其它原因导致装箱单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
- goto ext
- end if
- long ll_relid_outware
- int ls_j,ls_k
- boolean if_find
- if it_MXBT<1 then
- rslt = 0
- ARG_MSG = "没有正确的明细内容"
- GOTO ext
- END IF
- for ls_j=1 to it_MXBT
-
- ll_relid_outware=incasemx[ls_j].relid_outware
- if_find=false
- for ls_k=1 to ls_j - 1
- if ll_relid_outware=incasemx[ls_k].relid_outware then
- if_find=true
- exit
- end if
- next
-
- if not if_find then
-
- update u_outware
- set relid_incase=0
- where u_outware.outwareid=:ll_relid_outware and scid=:scid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- ARG_MSG = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- end if
- next
- 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 getinfo (integer arg_scid, long arg_incaseid, ref string arg_msg);//getinfo(long arg_taskid,string arg_msg)
- //0 失败 1成功
- Int rslt = 1,I = 1,NO_MXCHECK = 0
- IF arg_incaseid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误采购订单唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_incaseid,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE CUR_INCASEMX CURSOR FOR
- SELECT
- mtrlid,
- mtrlstatus,
- printid,
- packunit,
- pfcode,
- packcode,
- packsize,
- qty,
- packqty,
- grossweight,
- netweight,
- cubage,
- ifson_flag,
- fathermtrlid,
- mxDscrp,
- packqty_1,
- cusid,
- relid_outware,
- relcode_outware,
- discard,
- Sonscale
- FROM u_incasemx
- WHERE u_incasemx.INCASEid = :arg_incaseid AND
- u_incasemx.scid = :arg_scid
- order by u_incasemx.printid USING commit_transaction;
-
- OPEN CUR_INCASEMX;
- FETCH CUR_INCASEMX INTO :incasemx[I].mtrlid,:incasemx[I].mtrlstatus,:incasemx[I].printid,
- :incasemx[I].packunit,:incasemx[I].pfcode,
- :incasemx[I].packcode,:incasemx[I].packsize,:incasemx[I].qty,
- :incasemx[I].packqty,:incasemx[I].grossweight,:incasemx[I].netweight,
- :incasemx[I].cubage,:incasemx[I].ifson_flag,:incasemx[I].fathermtrlid,:incasemx[I].mxDscrp,
- :incasemx[I].packqty_1,:incasemx[I].cusid,:incasemx[I].relid_outware,:incasemx[I].relcode_outware
- ,:incasemx[I].discard,:incasemx[I].Sonscale;
- DO WHILE commit_transaction.SQLCode = 0
- I++
- FETCH CUR_INCASEMX INTO :incasemx[I].mtrlid,:incasemx[I].mtrlstatus,:incasemx[I].printid,
- :incasemx[I].packunit,:incasemx[I].pfcode,
- :incasemx[I].packcode,:incasemx[I].packsize,:incasemx[I].qty,
- :incasemx[I].packqty,:incasemx[I].grossweight,:incasemx[I].netweight,
- :incasemx[I].cubage,:incasemx[I].ifson_flag,:incasemx[I].fathermtrlid,:incasemx[I].mxDscrp,
- :incasemx[I].packqty_1,:incasemx[I].cusid,:incasemx[I].relid_outware,:incasemx[I].relcode_outware
- ,:incasemx[I].discard,:incasemx[I].Sonscale;
- LOOP
- CLOSE CUR_INCASEMX;
- //检验明细是否读入完整
- SELECT COUNT(*) INTO :NO_MXCHECK
- FROM u_incasemx
- WHERE u_incasemx.incaseid = :arg_incaseid AND
- u_incasemx.scid = :arg_scid 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
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer acceptmx (long arg_mtrlid, string arg_mtrlstatus, string arg_pfcode, decimal arg_qty, string arg_packunit, string arg_packcode, string arg_packsize, string arg_mxdscrp, decimal arg_packqty, ref string arg_msg, long arg_printid, decimal arg_grossweight, decimal arg_netweight, decimal arg_cubage, integer arg_ifson_flag, integer arg_fathermtrlid, long arg_packqty_1, long arg_cusid, long arg_relid_outware, string arg_relcode_outware, integer arg_discard, decimal arg_sonscale);Long rslt = 1,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_fathermtrlid) THEN arg_fathermtrlid = 0
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_packqty) THEN arg_packqty = 0
- IF IsNull(arg_mtrlstatus) THEN arg_mtrlstatus = ''
- IF IsNull(arg_packunit) THEN arg_packunit = ''
- IF IsNull(arg_packcode) THEN arg_packcode = ''
- IF IsNull(arg_packsize) THEN arg_packsize = ''
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_ifson_flag) THEN arg_ifson_flag = 0
- IF IsNull(arg_grossweight) THEN arg_grossweight = 0
- IF IsNull(arg_netweight) THEN arg_netweight = 0
- IF IsNull(arg_cubage) THEN arg_cubage = 0
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_pfcode) THEN arg_pfcode = ''
- IF IsNull(arg_packqty_1) THEN arg_packqty_1 = 0
- IF IsNull(arg_relid_outware) THEN arg_relid_outware = 0
- IF IsNull(arg_relcode_outware) THEN arg_relcode_outware = ''
- IF IsNull(arg_discard) THEN arg_discard = 0
- IF IsNull(ARG_Sonscale) THEN ARG_Sonscale = 0
- IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理
- rslt = 1
- GOTO ext
- END IF
- IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理
- rslt = 1
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_cusid USING commit_transaction;
- 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
- //检查相关销售单
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_outware
- Where scid = :scid AND outwareid = :arg_relid_outware USING commit_transaction;
- 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
- FOR LS_i = 1 TO it_mxbt //合并重复项(产品)
- IF incasemx[it_mxbt].mtrlid = arg_mtrlid AND &
- incasemx[it_mxbt].ifson_flag = arg_ifson_flag AND &
- arg_ifson_flag = 0 THEN
- rslt = 0
- arG_MSG = "存在相同的产品,在"+incasemx[it_mxbt].mtrlstatus+",请自行手动合并"
- GOTO ext
- END IF
- NEXT
- //写入内容
- it_mxbt++
- incasemx[it_mxbt].mtrlid = arg_mtrlid
- incasemx[it_mxbt].mtrlstatus = arg_mtrlstatus
- incasemx[it_mxbt].pfcode = arg_pfcode
- incasemx[it_mxbt].Qty = arg_qty
- incasemx[it_mxbt].packunit = arg_packunit
- incasemx[it_mxbt].packcode = arg_packcode
- incasemx[it_mxbt].packsize = arg_packsize
- incasemx[it_mxbt].mxdscrp = arg_mxdscrp
- incasemx[it_mxbt].packqty = arg_packqty
- incasemx[it_mxbt].printid = arg_printid
- incasemx[it_mxbt].grossweight = arg_grossweight
- incasemx[it_mxbt].netweight = arg_netweight
- incasemx[it_mxbt].cubage = arg_cubage
- incasemx[it_mxbt].ifson_flag = arg_ifson_flag
- incasemx[it_mxbt].fathermtrlid = arg_fathermtrlid
- incasemx[it_mxbt].packqty_1 = arg_packqty_1
- incasemx[it_mxbt].cusid = arg_cusid
- incasemx[it_mxbt].relid_outware = arg_relid_outware
- incasemx[it_mxbt].relcode_outware = arg_relcode_outware
- incasemx[it_mxbt].discard = arg_discard
- incasemx[it_mxbt].Sonscale = ARG_Sonscale
- ext:
- IF rslt = 0 THEN
- p_clearmx()
- arG_MSG = "第" + String(arg_printid) + "行," + arG_MSG
- END IF
- Return(rslt)
- end function
- on uo_incase.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_incase.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|