$PBExportHeader$w_outware_fx_mutiple.srw
forward
global type w_outware_fx_mutiple from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_new from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_delete from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_audit from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_cancle_audit from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_print from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_confirm_return from uo_imflatbutton within w_outware_fx_mutiple
end type
type ddlb_status from dropdownlistbox within w_outware_fx_mutiple
end type
type cbx_ifback from checkbox within w_outware_fx_mutiple
end type
type em_datea from editmask within w_outware_fx_mutiple
end type
type em_datez from editmask within w_outware_fx_mutiple
end type
type st_3 from statictext within w_outware_fx_mutiple
end type
type dw_fx_outware_free from datawindow within w_outware_fx_mutiple
end type
type cb_add_mx from commandbutton within w_outware_fx_mutiple
end type
type cb_delete_mx from commandbutton within w_outware_fx_mutiple
end type
type cb_modify from uo_imflatbutton within w_outware_fx_mutiple
end type
type dw_fx_outware from u_dw_rbtnfilter within w_outware_fx_mutiple
end type
type dw_fx_outware_mx from u_dw_rbtnfilter within w_outware_fx_mutiple
end type
type cb_1 from uo_imflatbutton within w_outware_fx_mutiple
end type
type cb_2 from uo_imflatbutton within w_outware_fx_mutiple
end type
type cbx_1 from checkbox within w_outware_fx_mutiple
end type
type cb_3 from uo_imflatbutton within w_outware_fx_mutiple
end type
type rb_outwarecode from radiobutton within w_outware_fx_mutiple
end type
type sle_outwarecode from singlelineedit within w_outware_fx_mutiple
end type
type rb_date from radiobutton within w_outware_fx_mutiple
end type
end forward

global type w_outware_fx_mutiple from w_publ_base_style
integer width = 4608
integer height = 2880
string title = "发货单"
boolean maxbox = true
event ue_print_outware_all ( )
event ue_print_outware_mx ( )
event ue_print_outware_all_mt ( )
event ue_print_outware_sptcode ( )
cb_refresh cb_refresh
cb_new cb_new
cb_delete cb_delete
cb_audit cb_audit
cb_cancle_audit cb_cancle_audit
cb_print cb_print
cb_confirm_return cb_confirm_return
ddlb_status ddlb_status
cbx_ifback cbx_ifback
em_datea em_datea
em_datez em_datez
st_3 st_3
dw_fx_outware_free dw_fx_outware_free
cb_add_mx cb_add_mx
cb_delete_mx cb_delete_mx
cb_modify cb_modify
dw_fx_outware dw_fx_outware
dw_fx_outware_mx dw_fx_outware_mx
cb_1 cb_1
cb_2 cb_2
cbx_1 cbx_1
cb_3 cb_3
rb_outwarecode rb_outwarecode
sle_outwarecode sle_outwarecode
rb_date rb_date
end type
global w_outware_fx_mutiple w_outware_fx_mutiple

type variables
int isConfirmCommit
boolean ins_inited_parmhistory
end variables

forward prototypes
public subroutine wf_btn_enabled ()
public subroutine wf_retrieve_outware_mx (long arg_outwareid)
public function integer wf_send_outware (ref string arg_msg)
public function integer wf_change_taborder (integer arg_taborder)
public function integer wf_cus_select ()
public subroutine wf_retrieve_outware ()
public subroutine wf_face_changed ()
end prototypes

event ue_print_outware_all();long ll_row

ll_row = dw_fx_outware.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请先选择要打印的单据')
	return
end if

string ls_autocode
string ls_outwarecode
string ls_custname
long ll_cuscomid

ls_autocode = dw_fx_outware.Object.outwarecode[ll_row]
ls_custname = dw_fx_outware.Object.cusname[ll_row]
ll_cuscomid = dw_fx_outware.Object.cuscomid[ll_row]

datastore ds_report
ds_report = create datastore

string dwSyntax,rs_dname,arg_errmsg,dwname
int result_po
dwname = 'dw_print_outware_fx_mx'
result_po = f_getprintout_bycus(dwname,ll_cuscomid,ref rs_dname,ref dwSyntax,ref arg_errmsg)
if dwSyntax <> '' then
	result_po = ds_report.create(dwSyntax)
	if result_po <> 1 then
		ds_report.dataobject = dwname
	end if
else
	ds_report.dataobject = dwname
end if



long mx_row, i

for i = 1 to dw_fx_outware_mx.rowcount()
	if Trim(dw_fx_outware_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
	
	mx_row = ds_report.InsertRow(0)
	if ds_report.Describe("tid.ColType") <> '!' then ds_report.setitem(mx_row,'tid', dw_fx_outware_mx.Object.tid[i])
	if ds_report.Describe("taskcode.ColType") <> '!' then ds_report.setitem(mx_row,'taskcode', dw_fx_outware_mx.Object.taskcode[i])
	if ds_report.Describe("outwarecode.ColType") <> '!' then ds_report.setitem(mx_row,'outwarecode', dw_fx_outware_mx.Object.outwarecode[i])
	if ds_report.Describe("username.ColType") <> '!' then ds_report.setitem(mx_row,'username', dw_fx_outware_mx.Object.username[i])
	if ds_report.Describe("outwaredate.ColType") <> '!' then ds_report.setitem(mx_row,'outwaredate', dw_fx_outware_mx.Object.outwaredate[i])
	if ds_report.Describe("autocode.ColType") <> '!' then ds_report.setitem(mx_row,'autocode', dw_fx_outware_mx.Object.autocode[i])
	
	if ds_report.Describe("mtrlcode.ColType") <> '!' then ds_report.setitem(mx_row,'mtrlcode', dw_fx_outware_mx.Object.mtrlcode[i])

	if ds_report.Describe("status.ColType") <> '!' then
		ds_report.setitem(mx_row,'status', dw_fx_outware_mx.Object.status[i])
	end if
	if ds_report.Describe("woodcode.ColType") <> '!' then
		ds_report.setitem(mx_row,'woodcode', dw_fx_outware_mx.Object.woodcode[i])
	end if
	if ds_report.Describe("pcode.ColType") <> '!' then
		ds_report.setitem(mx_row,'pcode', dw_fx_outware_mx.Object.pcode[i])
	end if


	if ds_report.Describe("mtrlname.ColType") <> '!' then ds_report.setitem(mx_row,'mtrlname', dw_fx_outware_mx.Object.mtrlname[i])
	if ds_report.Describe("mtrlmode.ColType") <> '!' then ds_report.setitem(mx_row,'mtrlmode', dw_fx_outware_mx.Object.mtrlmode[i])
	if ds_report.Describe("unit.ColType") <> '!' then ds_report.setitem(mx_row,'unit', dw_fx_outware_mx.Object.L1unit[i])
	if ds_report.Describe("qty.ColType") <> '!' then ds_report.setitem(mx_row,'qty', dw_fx_outware_mx.Object.qty[i])
	if ds_report.Describe("mxcode.ColType") <> '!' then ds_report.setitem(mx_row,'mxcode', dw_fx_outware_mx.Object.mxcode[i])
	
	if ds_report.Describe("custname.ColType") <> '!' then ds_report.setitem(mx_row,'custname', ls_custname)
	if ds_report.Describe("sptname.ColType") <> '!' then ds_report.setitem(mx_row,'sptname', dw_fx_outware_mx.Object.sptname[i])
	if ds_report.Describe("dscrp.ColType") <> '!' then ds_report.setitem(mx_row,'dscrp', dw_fx_outware_mx.Object.mxdscrp[i])
	
	IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
		if ds_report.Describe("mtrlcuscode.ColType") <> '!' then ds_report.setitem(mx_row,'mtrlcuscode', dw_fx_outware_mx.Object.mxdscrp[i])
	ELSE
		if ds_report.Describe("mtrlcuscode.ColType") <> '!' then ds_report.setitem(mx_row,'mtrlcuscode', dw_fx_outware_mx.Object.mtrlcuscode[i])
	END IF
	
	if ds_report.Describe("saletask_mxid.ColType") <> '!' then ds_report.setitem(mx_row,'saletask_mxid', dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[i])
	if ds_report.Describe("storagename.ColType") <> '!' then ds_report.setitem(mx_row,'storagename', dw_fx_outware_mx.Object.storagename[i]) //收货仓库
	if ds_report.Describe("fx_outware_log_packqty.ColType") <> '!' then ds_report.setitem(mx_row,'fx_outware_log_packqty', dw_fx_outware_mx.Object.fx_outware_log_packqty[i]) //单箱数量
	if ds_report.Describe("fx_outware_log_productdate.ColType") <> '!' then ds_report.setitem(mx_row,'fx_outware_log_productdate', dw_fx_outware_mx.Object.fx_outware_log_productdate[i]) //生产日期
	if ds_report.Describe("plancode.ColType") <> '!' then ds_report.setitem(mx_row,'plancode', dw_fx_outware_mx.Object.plancode[i]) //生产批号
	if ds_report.Describe("spt_plancode.ColType") <> '!' then ds_report.setitem(mx_row,'spt_plancode', dw_fx_outware_mx.Object.spt_plancode[i]) //供应方批号
	if ds_report.Describe("relcodestr.ColType") <> '!' then ds_report.setitem(mx_row,'relcodestr', dw_fx_outware_mx.Object.fx_saletaskmx_relcodestr[i]) //生产计划相关号
	if ds_report.Describe("price.ColType") <> '!' then ds_report.setitem(mx_row,'price', dw_fx_outware_mx.Object.fx_saletaskmx_price[i]) //单价
	if ds_report.Describe("taskcodestr.ColType") <> '!' then ds_report.setitem(mx_row,'taskcodestr', dw_fx_outware_mx.Object.taskcodestr[i]) //相关销售单号
	
//	ds_report.Object.tid[mx_row] = dw_fx_outware_mx.Object.tid[i]
//	ds_report.Object.taskcode[mx_row] = dw_fx_outware_mx.Object.taskcode[i]
//	ds_report.Object.outwarecode[mx_row] = dw_fx_outware_mx.Object.outwarecode[i]
//	ds_report.Object.username[mx_row] = dw_fx_outware_mx.Object.username[i]
//	ds_report.Object.outwaredate[mx_row] = dw_fx_outware_mx.Object.outwaredate[i]
//	ds_report.Object.autocode[mx_row] = Trim(dw_fx_outware_mx.Object.autocode[i])
	
//	ds_report.Object.mtrlcode[mx_row] = dw_fx_outware_mx.Object.mtrlcode[i]
//	ds_report.Object.mtrlname[mx_row] = dw_fx_outware_mx.Object.mtrlname[i]
//	ds_report.Object.mtrlmode[mx_row] = dw_fx_outware_mx.Object.mtrlmode[i]
//	ds_report.Object.unit[mx_row] = dw_fx_outware_mx.Object.L1unit[i]
//	ds_report.Object.qty[mx_row] = dw_fx_outware_mx.Object.qty[i]
//	ds_report.Object.mxcode[mx_row] = trim(dw_fx_outware_mx.Object.mxcode[i])
	
//	ds_report.Object.custname[mx_row] = ls_custname //客户名称
//	ds_report.Object.sptname[mx_row] = trim(dw_fx_outware_mx.Object.sptname[i]) //供应商名称
	
//	ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) //产品批号（销售订单相关号）
//	ds_report.Object.dscrp[mx_row] = dw_fx_outware_mx.Object.mxdscrp[i]
//	IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
//		ds_report.Object.mtrlcuscode[mx_row] = dw_fx_outware_mx.Object.mxdscrp[i]
//	 ELSE
//		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i])
//	END IF
//	ds_report.Object.saletask_mxid[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[i] 
//	ds_report.Object.storagename[mx_row] = dw_fx_outware_mx.Object.storagename[i] //收货仓库
//	ds_report.Object.fx_outware_log_packqty[mx_row] = dw_fx_outware_mx.Object.fx_outware_log_packqty[i] //单箱数量
//	ds_report.Object.fx_outware_log_productdate[mx_row] = dw_fx_outware_mx.Object.fx_outware_log_productdate[i] //生产日期
//	ds_report.Object.plancode[mx_row] = dw_fx_outware_mx.Object.plancode[i] //生产批号
//	ds_report.Object.spt_plancode[mx_row] = dw_fx_outware_mx.Object.spt_plancode[i] //供应方批号
//	ds_report.Object.relcodestr[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_relcodestr[i] //生产计划相关号
//	ds_report.Object.price[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_price[i] //单价
//	ds_report.Object.taskcodestr[mx_row] = dw_fx_outware_mx.Object.taskcodestr[i]
next

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_outware_fx_mx'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='收货通知单'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1
LS_PRMSG.cuscomid = ll_cuscomid

Openwithparm(w_publ_preview,LS_PRMSG)





end event

event ue_print_outware_mx();long row
row = dw_fx_outware.GetRow()
if (row <= 0) then 
	messagebox('提示', '请先选择要打印的单据')
	return
end if	


datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_fx_print_saletask_qc'


long i, ll_row
for i = 1 to dw_fx_outware_mx.RowCount()
	ll_row = ds_report.InsertRow(0)
	
	ds_report.Object.taskcode[ll_row] =  dw_fx_outware_mx.Object.taskcode[i]
	ds_report.Object.mtrlcode[ll_row] = dw_fx_outware_mx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[ll_row] =  dw_fx_outware_mx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[ll_row] = dw_fx_outware_mx.Object.mtrlmode[i]
	ds_report.Object.status[ll_row] =  dw_fx_outware_mx.Object.status[i]
	ds_report.Object.qty[ll_row] =  dw_fx_outware_mx.Object.qty[i]
	ds_report.Object.requiredate[ll_row] =  dw_fx_outware_mx.Object.requiredate[i]
next


S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_fx_print_saletask_qc'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='销售发货单'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)

end event

event ue_print_outware_all_mt();long ll_row

ll_row = dw_fx_outware.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请先选择要打印的单据')
	return
end if

string ls_autocode
string ls_outwarecode
string ls_custname

ls_autocode = dw_fx_outware.Object.outwarecode[ll_row]
ls_custname = dw_fx_outware.Object.cusname[ll_row]

datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_print_outware_fx_mx_data'

long mx_row, i

for i = 1 to dw_fx_outware_mx.rowcount()
	if Trim(dw_fx_outware_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
	
	mx_row = ds_report.InsertRow(0)
	ds_report.Object.tid[mx_row] = dw_fx_outware_mx.Object.tid[i]
	ds_report.Object.taskcode[mx_row] = dw_fx_outware_mx.Object.taskcode[i]
	ds_report.Object.outwarecode[mx_row] = dw_fx_outware_mx.Object.outwarecode[i]
	ds_report.Object.username[mx_row] = dw_fx_outware_mx.Object.username[i]
	ds_report.Object.outwaredate[mx_row] = dw_fx_outware_mx.Object.outwaredate[i]
	ds_report.Object.autocode[mx_row] = Trim(dw_fx_outware_mx.Object.autocode[i])
	
	ds_report.Object.mtrlcode[mx_row] = dw_fx_outware_mx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[mx_row] = dw_fx_outware_mx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[mx_row] = dw_fx_outware_mx.Object.mtrlmode[i]
	ds_report.Object.unit[mx_row] = dw_fx_outware_mx.Object.unit[i]
	ds_report.Object.qty[mx_row] = dw_fx_outware_mx.Object.qty[i]
	ds_report.Object.mxcode[mx_row] = trim(dw_fx_outware_mx.Object.mxcode[i])
	
	ds_report.Object.custname[mx_row] = ls_custname //客户名称
	ds_report.Object.sptname[mx_row] = trim(dw_fx_outware_mx.Object.sptname[i]) //供应商名称
	ds_report.Object.order_mtrlname_str[mx_row] = dw_fx_outware_mx.Object.order_mtrlname_str[i]
	
//	ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) //产品批号（销售订单相关号）
	ds_report.Object.dscrp[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
	IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
	 ELSE
		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i])
	END IF
	ds_report.Object.saletask_mxid[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[i] //供应商名称
	ds_report.Object.storagename[mx_row] = dw_fx_outware_mx.Object.storagename[i] //收货仓库
next

ds_report.SetSort("mtrlcuscode A,mtrlname A, mtrlmode A")

ds_report.Sort()

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_outware_fx_mx_mt'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='收货通知单(唛头)'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)





end event

event ue_print_outware_sptcode();long ll_row

ll_row = dw_fx_outware.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请先选择要打印的单据')
	return
end if

string ls_autocode
string ls_outwarecode
string ls_custname

ls_autocode = dw_fx_outware.Object.outwarecode[ll_row]
ls_custname = dw_fx_outware.Object.cusname[ll_row]

datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_print_outware_fx_mx_sptcode'

datastore ds_group_mx
ds_group_mx = create datastore
ds_group_mx.dataobject = 'dw_fx_outware_log_mutiple'

string groupkey[]
long mx_row, i ,j
boolean isFind

for i = 1 to dw_fx_outware_mx.rowcount()
	//勾选打印
	if dw_fx_outware_mx.object.ch[i] = 0 then continue
	
	//根据字段合并打印
	//mtrlname mtrlcode plancode mtrlmode sptcode fx_outware_log_packqty fx_outware_log_productdate
	isFind = false
	for j = 1 to ds_group_mx.rowcount()
		if dw_fx_outware_mx.object.mtrlname[i] = ds_group_mx.object.mtrlname[j] &
			and dw_fx_outware_mx.object.mtrlcode[i] = ds_group_mx.object.mtrlcode[j] &
			and dw_fx_outware_mx.object.plancode[i] = ds_group_mx.object.plancode[j] &
			and dw_fx_outware_mx.object.mtrlmode[i] = ds_group_mx.object.mtrlmode[j] &
			and dw_fx_outware_mx.object.sptcode[i] = ds_group_mx.object.sptcode[j] &
			and dw_fx_outware_mx.object.fx_outware_log_packqty[i] = ds_group_mx.object.fx_outware_log_packqty[j] &
			and dw_fx_outware_mx.object.fx_outware_log_productdate[i] = ds_group_mx.object.fx_outware_log_productdate[j] &
		then
			isFind = true
			ds_group_mx.object.qty[j] = ds_group_mx.object.qty[j] + dw_fx_outware_mx.object.qty[i]
			exit
		end if
	next
	if not isFind then
		mx_row = ds_group_mx.InsertRow(0)
		ds_group_mx.object.mtrlname[mx_row] = dw_fx_outware_mx.object.mtrlname[i] 
		ds_group_mx.object.mtrlcode[mx_row] = dw_fx_outware_mx.object.mtrlcode[i] 
		ds_group_mx.object.plancode[mx_row] =  dw_fx_outware_mx.object.plancode[i]
		ds_group_mx.object.mtrlmode[mx_row] = dw_fx_outware_mx.object.mtrlmode[i]
		ds_group_mx.object.sptcode[mx_row] = dw_fx_outware_mx.object.sptcode[i]
		ds_group_mx.object.fx_outware_log_packqty[mx_row] = dw_fx_outware_mx.object.fx_outware_log_packqty[i]
		ds_group_mx.object.fx_outware_log_productdate[mx_row] = dw_fx_outware_mx.object.fx_outware_log_productdate[i]
		ds_group_mx.object.qty[mx_row] = dw_fx_outware_mx.object.qty[i]
		ds_group_mx.object.autocode[mx_row] = dw_fx_outware_mx.object.autocode[i]
	end if
next

if ds_group_mx.rowcount() = 0 then
	MessageBox('提示', '请先勾选要打印的明细行')
	return
end if

for i = 1 to ds_group_mx.rowcount()
	if Trim(ds_group_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
	double allqty,packqty,packcount_cal
	integer packcount
	allqty = ds_group_mx.Object.qty[i]
	packqty = ds_group_mx.Object.fx_outware_log_packqty[i]
	if packqty <= 0 or isnull(packqty)  then packqty = 1

	packcount_cal = allqty/packqty
	packcount = int(packcount_cal)
	if packcount < packcount_cal then packcount = packcount + 1
	
	do while(allqty > 0)
		
		mx_row = ds_report.InsertRow(0)
		
		ds_report.object.mtrlname[mx_row] = ds_group_mx.object.mtrlname[i] 
		ds_report.object.mtrlcode[mx_row] = ds_group_mx.object.mtrlcode[i] 
		ds_report.object.plancode[mx_row] =  ds_group_mx.object.plancode[i]
		ds_report.object.mtrlmode[mx_row] = ds_group_mx.object.mtrlmode[i]
		ds_report.object.sptcode[mx_row] = ds_group_mx.object.sptcode[i]
		ds_report.object.fx_outware_log_packqty[mx_row] = ds_group_mx.object.fx_outware_log_packqty[i]
		ds_report.object.fx_outware_log_productdate[mx_row] = ds_group_mx.object.fx_outware_log_productdate[i]
		ds_report.object.qty[mx_row] = ds_group_mx.object.qty[i]
		if allqty - packqty >= 0 then
			ds_report.Object.fx_outware_log_packqty[mx_row] = ds_group_mx.Object.fx_outware_log_packqty[i] //单箱数量
		else
			ds_report.Object.fx_outware_log_packqty[mx_row] = allqty //单箱数量
		end if
		ds_report.Object.packcount[mx_row] = packcount
		allqty = allqty - packqty
	loop
next

//for i = 1 to dw_fx_outware_mx.rowcount()
//	if Trim(dw_fx_outware_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
//	double allqty,packqty,packcount_cal
//	integer packcount
//	allqty = dw_fx_outware_mx.Object.qty[i]
//	packqty = dw_fx_outware_mx.Object.fx_outware_log_packqty[i]
//	packcount_cal = allqty/packqty
//	packcount = int(packcount_cal)
//	if packcount < packcount_cal then packcount = packcount + 1
//	
//	if packqty <= 0 or isnull(packqty)  then packqty = 1
//	do while(allqty > 0)
//		
//		mx_row = ds_report.InsertRow(0)
//		ds_report.Object.tid[mx_row] = dw_fx_outware_mx.Object.tid[i]
//		ds_report.Object.taskcode[mx_row] = dw_fx_outware_mx.Object.taskcode[i]
//		ds_report.Object.fx_outware_log_outwarecode[mx_row] = dw_fx_outware_mx.Object.outwarecode[i]
//		ds_report.Object.username[mx_row] = dw_fx_outware_mx.Object.username[i]
//		ds_report.Object.outwaredate[mx_row] = dw_fx_outware_mx.Object.outwaredate[i]
//		ds_report.Object.autocode[mx_row] = Trim(dw_fx_outware_mx.Object.autocode[i])
//		
//		ds_report.Object.mtrlcode[mx_row] = dw_fx_outware_mx.Object.mtrlcode[i]
//		ds_report.Object.mtrlname[mx_row] = dw_fx_outware_mx.Object.mtrlname[i]
//		ds_report.Object.mtrlmode[mx_row] = dw_fx_outware_mx.Object.mtrlmode[i]
//		ds_report.Object.unit[mx_row] = dw_fx_outware_mx.Object.unit[i]
//		ds_report.Object.qty[mx_row] = dw_fx_outware_mx.Object.qty[i]
//		ds_report.Object.mxcode[mx_row] = trim(dw_fx_outware_mx.Object.mxcode[i])
//		
//		ds_report.Object.custname[mx_row] = ls_custname //客户名称
//		ds_report.Object.sptname[mx_row] = trim(dw_fx_outware_mx.Object.sptname[i]) //供应商名称
//		ds_report.Object.order_mtrlname_str[mx_row] = dw_fx_outware_mx.Object.order_mtrlname_str[i]
//		
//	//	ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) //产品批号（销售订单相关号）
//		ds_report.Object.dscrp[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
//		IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
//			ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
//		 ELSE
//			ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i])
//		END IF
//		ds_report.Object.saletask_mxid[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[i] //供应商名称
//		ds_report.Object.spt_plancode[mx_row] = dw_fx_outware_mx.Object.spt_plancode[i] //供应方批号
//		ds_report.Object.storagename[mx_row] = dw_fx_outware_mx.Object.storagename[i] //收货仓库
//		ds_report.Object.sptcode[mx_row] = dw_fx_outware_mx.Object.sptcode[i] //供应商编码
//		ds_report.Object.fx_outware_log_productdate[mx_row] = dw_fx_outware_mx.Object.fx_outware_log_productdate[i] //生产日期
//		ds_report.Object.plancode[mx_row] = dw_fx_outware_mx.Object.plancode[i] //生产批号
//		if allqty - packqty >= 0 then
//			ds_report.Object.fx_outware_log_packqty[mx_row] = dw_fx_outware_mx.Object.fx_outware_log_packqty[i] //单箱数量
//		else
//			ds_report.Object.fx_outware_log_packqty[mx_row] = allqty //单箱数量
//		end if
//		ds_report.Object.packcount[mx_row] = packcount
//		allqty = allqty - packqty
//	loop
//next

ds_report.SetSort("mtrlcode A,mtrlname A, mtrlmode A,plancode A")

ds_report.Sort()

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_outware_fx_mx_sptcode'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='发货单(明细)'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)





end event

public subroutine wf_btn_enabled ();if dw_edit_mode OR if_modify_mode then
	cb_refresh.enabled = false
	cb_new.text = '保存'
	cb_new.normalpicname = "save.bmp"
	cb_modify.text = '放弃'
	cb_modify.normalpicname = "undo.bmp"
	cb_delete.enabled = false
	cb_audit.enabled = false
	cb_cancle_audit.enabled = false
	cb_print.enabled = false
	cb_confirm_return.enabled = false
	cb_add_mx.enabled = true
	cb_delete_mx.enabled = true
else
	cb_refresh.enabled = true
	cb_new.text = '新建'
	cb_new.normalpicname = "new.bmp"
	cb_modify.text = '修改'
	cb_modify.normalpicname = "open.bmp"
	cb_delete.enabled = true
	cb_audit.enabled = true
	cb_cancle_audit.enabled = true
	cb_print.enabled = true
	cb_confirm_return.enabled = true
	cb_add_mx.enabled = false
	cb_delete_mx.enabled = false
end if

cb_new.of_init_draw()
cb_new.of_paint()
cb_new.TriggerEvent('ue_textchange')
cb_modify.of_init_draw()
cb_modify.of_paint()
cb_modify.TriggerEvent('ue_textchange')
end subroutine

public subroutine wf_retrieve_outware_mx (long arg_outwareid);if isnull(arg_outwareid) or arg_outwareid <= 0 then
	return 
end if

string arg_msg
oleobject request, response
oleobject list, item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('outwareid', arg_outwareid)

response = FXAppCom.DoExecute('GetOutwareLogByOutwareid', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	MessageBox('提示', '获取发货明细失败:' + arg_msg)
	return
end if

list = response.GetPBArray('logs')

datetime dt
any acceptdate, outwaredate
dt = datetime(date('1899-12-30'), time('00:00:00'))

dw_fx_outware_mx.Reset()
dw_fx_outware_mx.SetRedraw(false)
long i,row
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	
	row = dw_fx_outware_mx.InsertRow(0)

	dw_fx_outware_mx.SetItem(row, 'ch', 1)
	dw_fx_outware_mx.SetItem(row, 'logid', item.GetInt('logid'))
	dw_fx_outware_mx.SetItem(row, 'taskid', item.GetInt('taskid'))
	dw_fx_outware_mx.SetItem(row, 'printid', item.GetInt('printid'))
	dw_fx_outware_mx.SetItem(row, 'mxcode', item.GetString('mxcode'))
	dw_fx_outware_mx.SetItem(row, 'qty', item.GetDouble('qty'))
	dw_fx_outware_mx.SetItem(row, 'userid', item.GetInt('userid'))
	dw_fx_outware_mx.SetItem(row, 'username', item.GetString('username'))
	dw_fx_outware_mx.SetItem(row, 'outwaredate', item.GetDateTime('outwaredate'))
	dw_fx_outware_mx.SetItem(row, 'outwarecode', item.GetString('outwarecode'))
	dw_fx_outware_mx.SetItem(row, 'acceptQty', item.GetDouble('acceptQty'))
	dw_fx_outware_mx.SetItem(row, 'logStatus', item.GetInt('logStatus'))
	dw_fx_outware_mx.SetItem(row, 'acceptUserName', item.GetString('acceptUserName'))
	dw_fx_outware_mx.SetItem(row, 'acceptdate', item.GetDateTime('acceptdate'))
	dw_fx_outware_mx.SetItem(row, 'inwarecode_erp', item.GetString('inwarecode_erp'))

	dw_fx_outware_mx.SetItem(row, 'tmpacceptqty', item.GetDouble('tmpacceptqty'))
	dw_fx_outware_mx.SetItem(row, 'tmpacceptemp', item.GetString('tmpacceptemp'))
	dw_fx_outware_mx.SetItem(row, 'checkqty', item.GetDouble('checkqty'))
	dw_fx_outware_mx.SetItem(row, 'goodqty', item.GetDouble('goodqty'))
	dw_fx_outware_mx.SetItem(row, 'badqty', item.GetDouble('badqty'))
	dw_fx_outware_mx.SetItem(row, 'goodinqty', item.GetDouble('goodinqty'))
	dw_fx_outware_mx.SetItem(row, 'badinqty', item.GetDouble('badinqty'))	
	dw_fx_outware_mx.SetItem(row, 'autocode', item.GetString('autocode'))	
	dw_fx_outware_mx.SetItem(row, 'mtrlcode', item.GetString('mtrlcode'))	
	dw_fx_outware_mx.SetItem(row, 'mtrlname', item.GetString('mtrlname'))	
	dw_fx_outware_mx.SetItem(row, 'mtrlmode', item.GetString('mtrlmode'))	
	dw_fx_outware_mx.SetItem(row, 'unit', item.GetString('unit'))	
	dw_fx_outware_mx.SetItem(row, 'status', item.GetString('status'))	
	dw_fx_outware_mx.SetItem(row, 'woodcode', item.GetString('woodcode'))	
	dw_fx_outware_mx.SetItem(row, 'pcode', item.GetString('pcode'))	
	dw_fx_outware_mx.SetItem(row, 'mtrlid', item.GetInt('mtrlid'))	
	dw_fx_outware_mx.SetItem(row, 'earliestSendDate', item.GetDatetime('earliestSendDate'))	
	dw_fx_outware_mx.SetItem(row, 'requiredate', item.GetDatetime('requiredate'))
	dw_fx_outware_mx.SetItem(row, 'cus_mtrldef_senddays', item.GetInt('cus_mtrldef_senddays'))	
	dw_fx_outware_mx.SetItem(row, 'cus_receiveqty', item.GetDouble('cus_receiveqty'))
	dw_fx_outware_mx.SetItem(row, 'taskqty', item.GetDouble('taskqty'))	
	dw_fx_outware_mx.SetItem(row, 'tid', item.GetString('tid'))	
	dw_fx_outware_mx.SetItem(row, 'taskcode', item.GetString('taskcode'))	
	dw_fx_outware_mx.SetItem(row, 'sptflag', item.GetString('sptflag'))	
	dw_fx_outware_mx.SetItem(row, 'sptflagStr', item.GetString('sptflagStr'))	
	dw_fx_outware_mx.SetItem(row, 'sptname', item.GetString('sptname'))	
	dw_fx_outware_mx.SetItem(row, 'mtrlcuscode', item.GetString('mtrlcuscode'))	
	dw_fx_outware_mx.SetItem(row, 'backqty', item.GetDouble('backqty'))
	dw_fx_outware_mx.SetItem(row, 'mxdscrp', item.GetString('mxdscrp'))
	dw_fx_outware_mx.SetItem(row, 'fx_saletaskmx_saletask_mxid', item.GetInt('saletask_mxid'))
	dw_fx_outware_mx.SetItem(row, 'order_mtrlname_str', item.GetString('order_mtrlname_str'))
	dw_fx_outware_mx.SetItem(row, 'L1unit', item.GetString('L1unit'))
	dw_fx_outware_mx.SetItem(row, 'spt_plancode', item.GetString('spt_plancode'))
	dw_fx_outware_mx.SetItem(row, 'if_spt_plancode', item.GetInt('if_spt_plancode'))	
	dw_fx_outware_mx.SetItem(row, 'storagename', item.GetString('storagename'))	
	dw_fx_outware_mx.SetItem(row, 'fx_outware_log_packqty', item.GetDouble('packqty'))
	dw_fx_outware_mx.SetItem(row, 'plancode', item.GetString('plancode'))
	dw_fx_outware_mx.SetItem(row, 'fx_outware_log_productdate', item.GetDateTime('productdate'))
	dw_fx_outware_mx.SetItem(row, 'sptcode', item.GetString('sptcode'))
	dw_fx_outware_mx.SetItem(row, 'fx_saletaskmx_relcodestr', item.GetString('relcodestr'))
	dw_fx_outware_mx.SetItem(row, 'fx_saletaskmx_price', item.GetDouble('price'))
	dw_fx_outware_mx.SetItem(row, 'taskcodestr', item.GetString('taskcodestr'))
	dw_fx_outware_mx.SetItem(row, 'sys_option_taskplancode', item.GetInt('sys_option_taskplancode'))
	dw_fx_outware_mx.SetItem(row, 'ifplancode_ware', item.GetInt('ifplancode_ware'))
	dw_fx_outware_mx.SetItem(row, 'storage_plancode_rule_buy', item.GetInt('storage_plancode_rule_buy'))
	dw_fx_outware_mx.SetItem(row, 'mtrldef_plancode_rule_buy', item.GetInt('mtrldef_plancode_rule_buy'))
next
dw_fx_outware_mx.SetRedraw(true)
cbx_1.checked = true
end subroutine

public function integer wf_send_outware (ref string arg_msg);int rslt = 1

if (dw_fx_outware_mx.RowCount() <= 0) then
	rslt = 0
	arg_msg = '没有发货明细'
	goto ext
end if

long ll_getrow, ll_outwareid
ll_getrow = dw_fx_outware_free.GetRow()


string ls_dscrp
datetime ldt_outwaredate
date ld_tempdate 

dw_fx_outware_free.AcceptText()
ls_dscrp = dw_fx_outware_free.Object.dscrp[ll_getrow]

ld_tempdate = date(dw_fx_outware_free.Object.outwaredate[ll_getrow])
ldt_outwaredate = datetime(ld_tempdate, now())

if if_modify_mode then
	ll_outwareid = dw_fx_outware_free.Object.outwareid[ll_getrow]
else
	ll_outwareid = 0
end if

//IF ISNULL(dw_fx_outware_free.Object.carnum[ll_getrow])THEN
//	rslt = 0
//	arg_msg = '请输入车牌号！'
//	goto ext
//END IF
//
//IF ISNULL(dw_fx_outware_free.Object.driver[ll_getrow]) THEN
//	rslt = 0
//	arg_msg = '请输入司机名！'
//	goto ext
//END IF
IF ISNULL(dw_fx_outware_free.Object.cuscomid[ll_getrow]) OR dw_fx_outware_free.Object.cuscomid[ll_getrow] = 0 THEN
	rslt = 0
	arg_msg = '请选择客户！'
	goto ext
END IF

dw_fx_outware_free.AcceptText()
dw_fx_outware_mx.AcceptText()

oleobject item, outware, mxs
outware = FXAppCom.CreatePbDictionary()
outware.SetInt('outwareid', ll_outwareid)
outware.SetString('dscrp', ls_dscrp)
outware.SetDateTime('outwaredate', ldt_outwaredate)
outware.SetString('carnum', dw_fx_outware_free.Object.carnum[ll_getrow])
outware.SetString('driver', dw_fx_outware_free.Object.driver[ll_getrow])
IF NOT IsNull(dw_fx_outware_free.Object.driver[ll_getrow]) THEN
	outware.SetDateTime('estimated_arrival_date', dw_fx_outware_free.Object.estimated_arrival_date[ll_getrow])
END IF
outware.SetInt('cuscomid',dw_fx_outware_free.Object.cuscomid[ll_getrow])

mxs = FXAppCom.CreArrOfPbDictionary()
long i, cnt = 0
DateTime ld_now
ld_now = DateTime(Today(),Now())
for i = 1 to dw_fx_outware_mx.RowCount()
//	if (dw_fx_outware_mx.Object.earliestsenddate[i] > ld_now) then dw_fx_outware_mx.Object.qty[i] = 0
	if (dw_fx_outware_mx.Object.qty[i] <= 0) then continue
	
//	if (dw_fx_outware_mx.Object.qty[i] > dw_fx_outware_mx.Object.tempqty[i]) then
//		rslt = 0
//		arg_msg = "行:" + string(dw_fx_outware_mx.Object.compute_2[i]) + "发货数:" +  string(dw_fx_outware_mx.Object.qty[i]) + "不能大于未送货数"  + string(dw_fx_outware_mx.Object.tempqty[i])
//		goto ext
//	end if

	IF dw_fx_outware_free.Object.cusname[ll_getrow] = '浙江路得坦摩汽车部件股份有限公司' THEN
		//非路得打包时要注释
		if isnull(dw_fx_outware_mx.Object.fx_outware_log_productdate[i]) then
			rslt = 0
			arg_msg = "行:" + string(dw_fx_outware_mx.Object.compute_2[i]) + ",需要填写生产日期"
			goto ext
		end if
		if isnull(dw_fx_outware_mx.Object.fx_outware_log_packqty[i]) or dw_fx_outware_mx.Object.fx_outware_log_packqty[i] <= 0 then
			rslt = 0
			arg_msg = "行:" + string(dw_fx_outware_mx.Object.compute_2[i]) + ",需要填写单箱数量"
			goto ext
		end if
	END IF

	
	
//	if isnull(dw_fx_outware_mx.Object.spt_plancode[i]) and dw_fx_outware_mx.Object.if_spt_plancode[i] = 1 then
//		rslt = 0
//		arg_msg = "行:" + string(dw_fx_outware_mx.Object.compute_2[i]) + ",需要填写供应方批号"
//		goto ext
//	end if
//	
	cnt ++
	item = FXAppCom.CreatePbDictionary()
	item.SetInt('taskid', dw_fx_outware_mx.Object.taskid[i])
	item.SetInt('printid', dw_fx_outware_mx.Object.printid[i])
	item.SetDouble('qty', dw_fx_outware_mx.Object.qty[i])
	item.SetString('mxcode', dw_fx_outware_mx.Object.outwarecode[i]) // 暂时存放相关发货单号(非明细编号)
	item.SetInt('mtrlid', dw_fx_outware_mx.Object.mtrlid[i])
	item.SetString('spt_plancode', dw_fx_outware_mx.Object.spt_plancode[i])
	item.SetDouble('packqty', dw_fx_outware_mx.Object.fx_outware_log_packqty[i])
	item.SetDatetime('productdate', dw_fx_outware_mx.Object.fx_outware_log_productdate[i])
	item.SetString('plancode', dw_fx_outware_mx.Object.plancode[i])
	
	mxs.Add(item)
next

if (cnt <= 0) then
	rslt = 0
	arg_msg = '没有发货数大于0的明细'
	goto ext
end if

oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outware', outware)
request.SetObject('mxs', mxs)
if isConfirmCommit = 1 then request.SetObject('checkplancodetype', 1)

response = FXAppCom.DoExecute('SendOutwareMxMutiple', request)
arg_msg = response.GetString('ErrMsg')
If (arg_msg <> '') Then
	rslt = 0
	goto ext
End If

string tip
tip = response.GetString("tip")
IF tip <> '' THEN
	MessageBox('Tip', tip)
END IF

ext:
return rslt
end function

public function integer wf_change_taborder (integer arg_taborder);IF arg_taborder = 0 THEN
	dw_fx_outware_free.SetTaborder('dscrp', 0)
	dw_fx_outware_free.SetTaborder('outwaredate', 0)
	dw_fx_outware_free.SetTaborder('carnum',0)
	dw_fx_outware_free.SetTaborder('driver',0)
	dw_fx_outware_free.SetTaborder('estimated_arrival_date',0)
	
	dw_fx_outware_mx.SetTaborder('qty', 0)
	dw_fx_outware_mx.SetTaborder('outwarecode', 0)
	
	dw_fx_outware_mx.SetTaborder('spt_plancode', 0)
	dw_fx_outware_mx.SetTaborder('fx_outware_log_packqty', 0)
	dw_fx_outware_mx.SetTaborder('fx_outware_log_productdate', 0)
	dw_fx_outware_mx.SetTaborder('plancode', 0)
ELSE
	IF NOT ins_inited_parmhistory THEN
		oleobject lo_request, lo_response, lo_list
		string ls_item, ls_driverVals, ls_carnumVals, ls_msg
		Long ll_i
	
		lo_request = FXAppCom.CreatePbDictionary()
		lo_request.SetString("token", app_token_fx)
		lo_response = FXAppCom.DoExecute('GetOutwareParmHistory', lo_request)
	
		ls_msg = lo_response.GetString('ErrMsg')
		IF (ls_msg <> '') THEN
			MessageBox('', "初始化下拉列表失败：" + ls_msg)
		END IF
		lo_list = lo_response.GetPBArray("driverList")
		IF lo_list.Count > 0 THEN
			FOR ll_i = 1 TO lo_list.Count
				ls_item = lo_list.GetString(ll_i - 1)
				ls_driverVals += ls_item + "~t" + ls_item + "/"
			NEXT
			dw_fx_outware_free.modify("driver.values = '" + ls_driverVals +"'")
		END IF
		lo_list = lo_response.GetPBArray("carnumList")
		IF lo_list.Count > 0 THEN
			FOR ll_i = 1 TO lo_list.Count
				ls_item = lo_list.GetString(ll_i - 1)
				ls_carnumVals += ls_item + "~t" + ls_item + "/"
			NEXT
			dw_fx_outware_free.modify("carnum.values = '" + ls_carnumVals +"'")
		END IF
		ins_inited_parmhistory = TRUE
	END IF
	dw_fx_outware_free.SetTaborder('dscrp', 10)
	dw_fx_outware_free.SetTaborder('outwaredate', 20)
	dw_fx_outware_free.SetTaborder('carnum',30)
	dw_fx_outware_free.SetTaborder('driver',40)
	dw_fx_outware_free.SetTaborder('estimated_arrival_date',50)
	
	dw_fx_outware_mx.SetTaborder('qty', 20)
	dw_fx_outware_mx.SetTaborder('outwarecode', 30)
	
	dw_fx_outware_mx.SetTaborder('spt_plancode', 40)
	dw_fx_outware_mx.SetTaborder('fx_outware_log_packqty', 50)
	dw_fx_outware_mx.SetTaborder('fx_outware_log_productdate', 60)
	dw_fx_outware_mx.SetTaborder('plancode', 60)

END IF

return 1
end function

public function integer wf_cus_select ();IF NOT dw_edit_mode THEN RETURN 0
long ori_cuscomid, new_cuscomid, row
row = dw_fx_outware_free.GetRow()
ori_cuscomid = dw_fx_outware_free.Object.cuscomid[row]
IF ori_cuscomid > 0 THEN
      IF dw_fx_outware_mx.RowCount() > 0 THEN
            MessageBox('','修改客户前需要先清除发货明细')
            RETURN 0
      END IF
END IF

s_fx_company s_tran, s_ret
OpenWithParm(w_cus_ch_fx, s_tran)
s_ret = Message.PowerObjectParm
IF not IsNull(s_ret) then
	IF (s_ret.ifselect) then
		new_cuscomid = s_ret.comid[1]
		IF (ori_cuscomid <> new_cuscomid) then
			dw_fx_outware_mx.Reset() // 重选客户，清空明细
		END IF
		
		dw_fx_outware_free.Object.cuscomid[row] = new_cuscomid
		dw_fx_outware_free.Object.cusname[row] = s_ret.comname[1]
		
		dw_fx_outware_free.AcceptText()
		RETURN 1
	END IF
END IF
RETURN 0
end function

public subroutine wf_retrieve_outware ();string arg_msg
oleobject request,response,FxOutwares,item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
IF sle_outwarecode.Enabled THEN
	IF Trim(sle_outwarecode.Text) = "" THEN
		MessageBox('','请先填写单号')
		sle_outwarecode.setfocus()
		RETURN
	ELSE
		request.SetString('outwarecode', Trim(sle_outwarecode.Text))
	END IF
END IF
IF cbx_ifback.Enabled THEN
	long ll_ifback
	if cbx_ifback.checked = false then
		ll_ifback = 0
	else
		ll_ifback = 1
	end if
	request.SetInt('ifback', ll_ifback)
END IF
IF ddlb_status.Enabled THEN
	long status
	long ll_pos
	ll_pos = Pos(ddlb_status.Text, '[')
	if (ll_pos <= 0) then
		status = -1
	else
		status = Long(Mid(ddlb_status.Text, ll_pos + 1, Len(ddlb_status.Text) - ll_pos - 1))
	end if
	request.SetInt('status', status)
END IF
IF em_dateA.Enabled THEN
	datetime dateA
	dateA = DateTime(Date(em_dateA.Text), Time(0))
	request.SetDateTime('startdate', dateA)
END IF
IF em_dateZ.Enabled THEN
	datetime dateZ
	dateZ = DateTime(Date(em_dateZ.Text), Time('23:59:59'))
	request.SetDateTime('enddate', dateZ)
END IF

request.SetInt('billtype', 0)//刷新0和1数据

response = FXAppCom.DoExecute('GetFxOutwareList', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
    messagebox('提示', '获取发货单列表失败，原因：' + arg_msg)
    return
end if

dw_fx_outware.Reset()
dw_fx_outware_mx.Reset()
dw_fx_outware.SetRedraw(false)

FxOutwares = response.GetArrOfPBDictionary('FxOutwares')
long i,row
for i = 1 to FxOutwares.Count
    item = FxOutwares.GetItem(i - 1)
    
    row = dw_fx_outware.InsertRow(0)

    dw_fx_outware.Object.outwareid[row] = item.GetInt('outwareid')
    dw_fx_outware.Object.outwarecode[row] = item.GetString('outwarecode')
    dw_fx_outware.Object.outwaredate[row] = item.GetDateTime('outwaredate')
    dw_fx_outware.Object.sptcomid[row] = item.GetInt('sptcomid')
    dw_fx_outware.Object.cuscomid[row] = item.GetInt('cuscomid')
    dw_fx_outware.Object.dscrp[row] = item.GetString('dscrp')
    dw_fx_outware.Object.status[row] = item.GetInt('status')
    dw_fx_outware.Object.statusStr[row] = item.GetString('statusStr')
    dw_fx_outware.Object.thflag[row] = item.GetInt('thflag')
    dw_fx_outware.Object.opemp[row] = item.GetString('opemp')
    dw_fx_outware.Object.opdate[row] = item.GetDateTime('opdate')
    dw_fx_outware.Object.modifyemp[row] = item.GetString('modifyemp')
	if not IsNull(item.GetDateTime('modifydate')) then
		dw_fx_outware.Object.modifydate[row] = item.GetDateTime('modifydate')
	end if
    dw_fx_outware.Object.auditemp[row] = item.GetString('auditemp')
	if not IsNull(item.GetDateTime('auditdate')) then
    		dw_fx_outware.Object.auditdate[row] = item.GetDateTime('auditdate')
	end if
     dw_fx_outware.Object.cusname[row] = item.GetString('cusname')
	dw_fx_outware.Object.carnum[row] = item.GetString('carnum')
	dw_fx_outware.Object.driver[row] = item.GetString('driver')
	if not IsNull(item.GetDateTime('estimated_arrival_date')) then
    		dw_fx_outware.Object.estimated_arrival_date[row] = item.GetDateTime('estimated_arrival_date')
	end if
		
	dw_fx_outware.Object.billtype[row] = item.GetInt('billtype')
	dw_fx_outware.Object.relsendoutid[row] = item.GetInt('relsendoutid')
	dw_fx_outware.Object.relsendoutcode[row] = item.GetString('relsendoutcode')
next
// 相似表格：采购订单明细跟踪表-下方明细

dw_fx_outware.SetRedraw(true)

if (dw_fx_outware.RowCount() > 0) then
	dw_fx_outware.SelectRow(0, false)
	dw_fx_outware.SelectRow(1, true)
	dw_fx_outware.SetRow(1)
	dw_fx_outware.post event RowFocusChanged(1)
end if
end subroutine

public subroutine wf_face_changed ();IF rb_outwarecode.Checked THEN
	sle_outwarecode.Enabled = true
	em_datea.Enabled = false
	em_datez.Enabled = false
	cbx_ifback.Enabled = false
	ddlb_status.Enabled = false
ELSEIF rb_date.Checked THEN
	sle_outwarecode.Enabled = false
	em_datea.Enabled = true
	em_datez.Enabled = true
	cbx_ifback.Enabled = true
	ddlb_status.Enabled = true
END IF
end subroutine

on w_outware_fx_mutiple.create
int iCurrent
call super::create
this.cb_refresh=create cb_refresh
this.cb_new=create cb_new
this.cb_delete=create cb_delete
this.cb_audit=create cb_audit
this.cb_cancle_audit=create cb_cancle_audit
this.cb_print=create cb_print
this.cb_confirm_return=create cb_confirm_return
this.ddlb_status=create ddlb_status
this.cbx_ifback=create cbx_ifback
this.em_datea=create em_datea
this.em_datez=create em_datez
this.st_3=create st_3
this.dw_fx_outware_free=create dw_fx_outware_free
this.cb_add_mx=create cb_add_mx
this.cb_delete_mx=create cb_delete_mx
this.cb_modify=create cb_modify
this.dw_fx_outware=create dw_fx_outware
this.dw_fx_outware_mx=create dw_fx_outware_mx
this.cb_1=create cb_1
this.cb_2=create cb_2
this.cbx_1=create cbx_1
this.cb_3=create cb_3
this.rb_outwarecode=create rb_outwarecode
this.sle_outwarecode=create sle_outwarecode
this.rb_date=create rb_date
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_refresh
this.Control[iCurrent+2]=this.cb_new
this.Control[iCurrent+3]=this.cb_delete
this.Control[iCurrent+4]=this.cb_audit
this.Control[iCurrent+5]=this.cb_cancle_audit
this.Control[iCurrent+6]=this.cb_print
this.Control[iCurrent+7]=this.cb_confirm_return
this.Control[iCurrent+8]=this.ddlb_status
this.Control[iCurrent+9]=this.cbx_ifback
this.Control[iCurrent+10]=this.em_datea
this.Control[iCurrent+11]=this.em_datez
this.Control[iCurrent+12]=this.st_3
this.Control[iCurrent+13]=this.dw_fx_outware_free
this.Control[iCurrent+14]=this.cb_add_mx
this.Control[iCurrent+15]=this.cb_delete_mx
this.Control[iCurrent+16]=this.cb_modify
this.Control[iCurrent+17]=this.dw_fx_outware
this.Control[iCurrent+18]=this.dw_fx_outware_mx
this.Control[iCurrent+19]=this.cb_1
this.Control[iCurrent+20]=this.cb_2
this.Control[iCurrent+21]=this.cbx_1
this.Control[iCurrent+22]=this.cb_3
this.Control[iCurrent+23]=this.rb_outwarecode
this.Control[iCurrent+24]=this.sle_outwarecode
this.Control[iCurrent+25]=this.rb_date
end on

on w_outware_fx_mutiple.destroy
call super::destroy
destroy(this.cb_refresh)
destroy(this.cb_new)
destroy(this.cb_delete)
destroy(this.cb_audit)
destroy(this.cb_cancle_audit)
destroy(this.cb_print)
destroy(this.cb_confirm_return)
destroy(this.ddlb_status)
destroy(this.cbx_ifback)
destroy(this.em_datea)
destroy(this.em_datez)
destroy(this.st_3)
destroy(this.dw_fx_outware_free)
destroy(this.cb_add_mx)
destroy(this.cb_delete_mx)
destroy(this.cb_modify)
destroy(this.dw_fx_outware)
destroy(this.dw_fx_outware_mx)
destroy(this.cb_1)
destroy(this.cb_2)
destroy(this.cbx_1)
destroy(this.cb_3)
destroy(this.rb_outwarecode)
destroy(this.sle_outwarecode)
destroy(this.rb_date)
end on

event resize;call super::resize;int li_free_width,li_free_height

li_free_width = 1810 //dw_fx_outwar_free宽度 
li_free_height = 1220 //dw_fx_outware_free高度

//dw_fx_outware_free
dw_fx_outware_free.width =  li_free_width
dw_fx_outware_free.height =   li_free_height
//dw_fx_outware
dw_fx_outware.x = li_free_width + 30
dw_fx_outware.y = dw_fx_outware_free.y
dw_fx_outware.width = this.workspacewidth() - li_free_width
dw_fx_outware.height = dw_fx_outware_free.height
//cb_add_mx, cb_delete_mx
cb_add_mx.x = 40
cb_add_mx.y = dw_fx_outware_free.y + li_free_height + 20
cb_delete_mx.x = cb_add_mx.width + 20
cb_delete_mx.y = cb_add_mx.y
//cbx_1
cbx_1.y = cb_add_mx.y + cb_add_mx.height + 30
//dw_fx_outware_mx
dw_fx_outware_mx.y = cbx_1.y + cbx_1.height + 30
dw_fx_outware_mx.width = this.workspacewidth()
dw_fx_outware_mx.height = this.workspaceheight() - cbx_1.y - cbx_1.height - 30

end event

event open;call super::open;wf_movetocenter()

dw_fx_outware_free.insertrow(0)

cbx_ifback.Checked = false
ddlb_status.SelectItem(7)

em_dateA.Text = String(RelativeDate(Today(), - 30))
em_dateZ.Text = String(Today())

s_edit_index_tran s_tran
s_tran = Message.PowerObjectParm

If Not IsNull(s_tran) AND IsValid(s_tran) Then
	sle_outwarecode.Text = s_tran.arg_string_code
End If
IF Trim(sle_outwarecode.Text) = "" THEN
	rb_date.Checked = true
ELSE
	rb_outwarecode.Checked = true
END IF
wf_face_changed()
wf_retrieve_outware()
end event

type cb_func from w_publ_base_style`cb_func within w_outware_fx_mutiple
boolean visible = false
integer x = 1970
integer y = 4
end type

type cb_exit from w_publ_base_style`cb_exit within w_outware_fx_mutiple
integer x = 1984
integer y = 4
end type

event cb_exit::clicked;if dw_edit_mode or if_modify_mode then
	IF MessageBox('提示','是否放弃新建/修改,并退出?',Question! ,OKCancel! , 1 ) = 2 THEN
		return
	END IF
end if 

close(parent)
end event

type ln_bar from w_publ_base_style`ln_bar within w_outware_fx_mutiple
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_outware_fx_mutiple
end type

type r_bar from w_publ_base_style`r_bar within w_outware_fx_mutiple
integer x = 2135
end type

type cb_refresh from uo_imflatbutton within w_outware_fx_mutiple
integer width = 151
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "刷新"
string normalpicname = "refresh.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;wf_retrieve_outware()
end event

type cb_new from uo_imflatbutton within w_outware_fx_mutiple
integer x = 155
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "新建"
string normalpicname = "new.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long rslt = 1
string arg_msg
if dw_edit_mode then // 新建/修改保存
	isConfirmCommit = 1
	if wf_send_outware(ref arg_msg) = 0 then
		if pos(arg_msg,'已有相同批号') > 0 then
			int isCommit
			isCommit = MessageBox("系统提示", arg_msg, Exclamation!, OKCancel!, 2)
			IF isCommit = 1 THEN
				isConfirmCommit = 0
				if wf_send_outware(ref arg_msg) = 0 then
					messagebox('提示', '保存失败,原因:' + arg_msg)
					rslt = 0
					goto ext
				END IF
			ELSE
				rslt = 0
				goto ext
			END IF
		else
			messagebox('提示', '保存失败,原因:' + arg_msg)
			rslt = 0
			goto ext
		end if
	end if
	wf_change_taborder(0)
	
	Messagebox('提示', '保存成功')
	wf_retrieve_outware()
else
	long li_row
	dw_fx_outware.reset()
	li_row = dw_fx_outware.insertrow(0)
	dw_fx_outware.Object.outwaredate[li_row]  = today()
	dw_fx_outware.Object.estimated_arrival_date[li_row] = today()
	
	dw_fx_outware_mx.reset()
	
	dw_fx_outware_free.Reset()
	dw_fx_outware.RowsCopy(li_row, li_row, Primary!, dw_fx_outware_free, 1, Primary!)
	wf_change_taborder(1)

end if

ext:
if rslt = 1 then 
	dw_edit_mode = Not dw_edit_mode
	if_modify_mode = false
	wf_btn_enabled()
end if
end event

type cb_delete from uo_imflatbutton within w_outware_fx_mutiple
integer x = 494
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "删除"
string normalpicname = "delete.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_status,ll_outwareid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能删除!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]
ll_outwareid = dw_fx_outware.Object.outwareid[ll_row]
if ll_status <> 0 then
	messagebox('提示', '不是待审核单据,不能删除!')
	return
end if

IF dw_fx_outware.Object.relsendoutid[ll_row] > 0 THEN
	messagebox('提示', '由客户提货通知单 自动生成不能操作!')
	return
END IF 

oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outwareid', ll_outwareid)

string arg_msg
response = FXAppCom.DoExecute('DelFxOutware', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	messagebox('提示', '删除失败,' + arg_msg)
else
	messagebox('提示', '删除成功！')
	wf_retrieve_outware()
end if
end event

type cb_audit from uo_imflatbutton within w_outware_fx_mutiple
integer x = 663
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "审核"
string normalpicname = "audit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_status, ll_outwareid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能审核!')
    return
end if	

ll_status = dw_fx_outware.Object.status[ll_row]
ll_outwareid = dw_fx_outware.Object.outwareid[ll_row]

if ll_status <> 0 then
	messagebox('提示', '不是待审核单据,不能审核!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outwareid', ll_outwareid)
request.SetObject('status', 1)

string arg_msg
response = FXAppCom.DoExecute('SaveFxOutwareStatus', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	messagebox('提示', '审核失败,' + arg_msg)
else
	messagebox('提示', '审核成功！')
	wf_retrieve_outware()
end if


end event

type cb_cancle_audit from uo_imflatbutton within w_outware_fx_mutiple
integer x = 832
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "撤审"
string normalpicname = "caudit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_status, ll_outwareid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能撤审!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]
ll_outwareid = dw_fx_outware.Object.outwareid[ll_row]

if ll_status <> 1 then
	messagebox('提示', '不是已审核单据,不能撤审!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outwareid', ll_outwareid)
request.SetObject('status', 0)

string arg_msg
response = FXAppCom.DoExecute('SaveFxOutwareStatus', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	messagebox('提示', '撤审失败,' + arg_msg)
else
	messagebox('提示', '撤审成功！')
	wf_retrieve_outware()
end if
end event

type cb_print from uo_imflatbutton within w_outware_fx_mutiple
integer x = 997
integer y = 4
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (dw_edit_mode) then return

long ll_row, ll_status
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]


if ll_status = 0 then
	messagebox('提示', '待审核单据,不能打印！')
	return
end if

Parent.TriggerEvent('ue_print_outware_all')


end event

type cb_confirm_return from uo_imflatbutton within w_outware_fx_mutiple
boolean visible = false
integer x = 1170
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "退货已收"
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_status, ll_outwareid
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能退货!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]
ll_outwareid = dw_fx_outware.Object.outwareid[ll_row]

if ll_status <> 4 then
	messagebox('提示', '单据状态不是退货中,不能确认退货!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outwareid', ll_outwareid)
request.SetObject('status', 5)

string arg_msg
response = FXAppCom.DoExecute('SaveFxOutwareStatus', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	messagebox('提示', '确认失败,' + arg_msg)
else
	messagebox('提示', '确认成功！')
	wf_retrieve_outware()
end if
end event

type ddlb_status from dropdownlistbox within w_outware_fx_mutiple
integer x = 2496
integer y = 188
integer width = 306
integer height = 496
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"待审[0]","在途[1]","验收中[2]","已收货[3]","退货中[4]","退货已收[5]","全部"}
borderstyle borderstyle = stylelowered!
end type

type cbx_ifback from checkbox within w_outware_fx_mutiple
integer x = 2167
integer y = 192
integer width = 311
integer height = 76
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "是否退货"
end type

type em_datea from editmask within w_outware_fx_mutiple
integer x = 1207
integer y = 188
integer width = 389
integer height = 84
integer taborder = 90
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type em_datez from editmask within w_outware_fx_mutiple
integer x = 1701
integer y = 188
integer width = 389
integer height = 84
integer taborder = 100
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type st_3 from statictext within w_outware_fx_mutiple
integer x = 1595
integer y = 204
integer width = 96
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "到"
alignment alignment = center!
boolean focusrectangle = false
end type

type dw_fx_outware_free from datawindow within w_outware_fx_mutiple
integer x = 37
integer y = 288
integer width = 1792
integer height = 1244
integer taborder = 30
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_outware_free"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;if (not dw_edit_mode) then return

if (row <= 0) then return

if dwo.Type = 'column' and dwo.Name = 'cusname' then
	wf_cus_select()
end if
end event

type cb_add_mx from commandbutton within w_outware_fx_mutiple
integer x = 37
integer y = 1552
integer width = 306
integer height = 84
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "增明细"
end type

event clicked;Long currow, cuscomid
currow = dw_fx_outware_free.GetRow()
cuscomid = dw_fx_outware_free.Object.cuscomid[currow]
IF IsNull(cuscomid) OR cuscomid = 0 THEN
	MessageBox('','请先选择发货客户')
	IF wf_cus_select() = 0 THEN RETURN
	cuscomid = dw_fx_outware_free.Object.cuscomid[currow]
END IF
datastore arg_ds
arg_ds = create datastore
arg_ds.DataObject = 'dw_fx_saletaskmx_sel'

OpenWithParm(w_fx_saletaskmx_sel, cuscomid)
arg_ds = Message.PowerObjectParm
IF IsValid(arg_ds) THEN
	dw_fx_outware_mx.SetRedraw(false)
	long row, i
	string ls_findstr
	Datetime ld_now
	ld_now = DateTime(Today(),Now())
	for i = arg_ds.RowCount() TO 1 STEP -1
		if (arg_ds.Object.qty[i] <= arg_ds.Object.cus_receiveqty[i] + arg_ds.Object.qty_wait[i]) then continue // '齐货' 跳过

		//DONE:已选择过滤
		ls_findstr = 'taskid=' + string(arg_ds.Object.taskid[i]) + " AND printid=" + string(arg_ds.Object.printid[i]) 
		IF dw_fx_outware_mx.Find(ls_findstr,1,dw_fx_outware_mx.RowCount()) > 0 THEN 
			continue
		END IF
	
		row = dw_fx_outware_mx.InsertRow(0)
		dw_fx_outware_mx.Object.taskid[row] = arg_ds.Object.taskid[i]
		dw_fx_outware_mx.Object.printid[row] = arg_ds.Object.printid[i]
		dw_fx_outware_mx.Object.mxcode[row] = arg_ds.Object.mxcode[i]
		dw_fx_outware_mx.Object.fxmtrlid[row] = arg_ds.Object.fxmtrlid[i]
		dw_fx_outware_mx.Object.mtrlid[row] = arg_ds.Object.mtrlid[i]
		dw_fx_outware_mx.Object.mtrlcode[row] = arg_ds.Object.mtrlcode[i]
		dw_fx_outware_mx.Object.mtrlname[row] = arg_ds.Object.mtrlname[i]
		dw_fx_outware_mx.Object.mtrlmode[row] = arg_ds.Object.mtrlmode[i]
		dw_fx_outware_mx.Object.status[row] = arg_ds.Object.status[i]
		dw_fx_outware_mx.Object.woodcode[row] = arg_ds.Object.woodcode[i]
		dw_fx_outware_mx.Object.pcode[row] = arg_ds.Object.pcode[i]
		dw_fx_outware_mx.Object.taskqty[row] = arg_ds.Object.qty[i] //订单数量
		dw_fx_outware_mx.Object.qty_wait[row] = arg_ds.Object.qty_wait[i]
		dw_fx_outware_mx.Object.cus_receiveqty[row] = arg_ds.Object.cus_receiveqty[i]
//		IF arg_ds.Object.earliestsenddate[i] > ld_now THEN
//			dw_fx_outware_mx.Object.qty[row] = 0 //发货数量
//		ELSE 
			dw_fx_outware_mx.Object.qty[row] = arg_ds.Object.outqty[i]
//		END IF
		
		dw_fx_outware_mx.Object.outwarecode[row] = ''
		dw_fx_outware_mx.Object.requiredate[row] = arg_ds.Object.requiredate[i]
	//	dw_fx_outware_mx.Object.price[row] = arg_ds.Object.price[i]row] = arg_ds.Object.mxdscrp[i]
//		dw_fx_outware_mx.Object.mxdscrp2[row] = arg_ds.Object.mxdscrp2[i]
		dw_fx_outware_mx.Object.mtrlcuscode[row] = arg_ds.Object.mtrlcuscode[i]
//		dw_fx_outware_mx.Object.plancode[row] = arg_ds.Object.plancode[i]
		dw_fx_outware_mx.Object.cus_mtrldef_senddays[row] = arg_ds.Object.cus_mtrldef_senddays[i]
//		dw_fx_outware_mx.Object.mxdscrp[
		dw_fx_outware_mx.Object.earliestsenddate[row] = arg_ds.Object.earliestsenddate[i]
		dw_fx_outware_mx.Object.tid[row] = arg_ds.Object.tid[i]
		dw_fx_outware_mx.Object.taskcode[row] = arg_ds.Object.taskcode[i]
		dw_fx_outware_mx.Object.unit[row] = arg_ds.Object.unit[i]
		dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[row] = arg_ds.Object.saletask_mxid[i]
		
		dw_fx_outware_mx.Object.tempqty[row] = arg_ds.Object.outqty[i] //临时发货数，判断限制使用
		dw_fx_outware_mx.Object.billtype[row] = arg_ds.Object.billtype[i]
		dw_fx_outware_mx.Object.if_spt_plancode[row] = arg_ds.Object.if_spt_plancode[i]
		dw_fx_outware_mx.Object.sys_option_taskplancode[row] = arg_ds.Object.sys_option_taskplancode[i]
		dw_fx_outware_mx.Object.ifplancode_ware[row] = arg_ds.Object.ifplancode_ware[i]
		dw_fx_outware_mx.Object.storage_plancode_rule_buy[row] = arg_ds.Object.storage_plancode_rule_buy[i]
		dw_fx_outware_mx.Object.mtrldef_plancode_rule_buy[row] = arg_ds.Object.mtrldef_plancode_rule_buy[i]
	next
	dw_fx_outware_mx.SetRedraw(true)
END IF
end event

type cb_delete_mx from commandbutton within w_outware_fx_mutiple
integer x = 352
integer y = 1552
integer width = 306
integer height = 84
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "删明细"
end type

event clicked;if dw_fx_outware_mx.RowCount() <= 0 then
	Messagebox('提示', '请先添加明细！')
	return
end if

long i, index
index = 0
FOR i = dw_fx_outware_mx.RowCount() TO 1 STEP -1
	IF  dw_fx_outware_mx.Object.ch[i] = 1 THEN
		index++
		dw_fx_outware_mx.DeleteRow(i)
	END IF
NEXT
IF index = 0 THEN
	MessageBox('提示', '请先勾选要删除的发货明细!')
END IF
end event

type cb_modify from uo_imflatbutton within w_outware_fx_mutiple
integer x = 325
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "修改"
string normalpicname = "open.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if dw_edit_mode then
	if MessageBox('提示','是否放弃新建/修改操作?',Question! ,OKCancel! , 1 ) = 1 then
		wf_change_taborder(0)
		
		dw_edit_mode = false
	     if_modify_mode = false	  
		wf_btn_enabled()
		wf_retrieve_outware()
	end if
else
	long ll_row, ll_status
	
	ll_row = dw_fx_outware.GetRow()
	IF ll_row <= 0 THEN
		messagebox('提示', '请选择当前行,不能修改!')
	end if	
	
	ll_status = dw_fx_outware.Object.status[ll_row]
	
	if ll_status <> 0 then
		messagebox('提示', '不是待审核单据,不能修改!')
		return
	end if
	
	IF dw_fx_outware.Object.relsendoutid[ll_row] > 0 THEN
		messagebox('提示', '由客户提货通知单 自动生成不能操作!')
		return
	END IF 
	
	
	wf_change_taborder(1)
	dw_edit_mode = true
	if_modify_mode = true
	wf_btn_enabled()
end if


end event

type dw_fx_outware from u_dw_rbtnfilter within w_outware_fx_mutiple
integer x = 1842
integer y = 276
integer width = 1714
integer height = 1244
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string dataobject = "dw_fx_outware_mutiple"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
boolean hsplitscroll = true
borderstyle borderstyle = styleshadowbox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
boolean autosave_setlayout_use = false
boolean autosave_columnvisible_use = false
end type

event rowfocuschanged;call super::rowfocuschanged;if IsNull(currentrow) then
	IF THIS.rowcount() > 0 then
		THIS.SelectRow(0,FALSE)
		THIS.SelectRow(1,TRUE)
		THIS.setrow(1)
		currentrow =1
	end if
end if

if IsNull(currentrow) then return
if (currentrow <= 0) then return

this.SelectRow(0, false)
this.SelectRow(currentrow, true)

dw_fx_outware_free.Reset( )
this.RowsCopy(currentrow, currentrow, Primary!, dw_fx_outware_free, 1, Primary!)

long ll_outwareid
ll_outwareid = this.Object.outwareid[currentrow]

wf_retrieve_outware_mx(ll_outwareid)
end event

type dw_fx_outware_mx from u_dw_rbtnfilter within w_outware_fx_mutiple
integer x = 32
integer y = 1724
integer width = 3506
integer height = 852
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_fx_outware_log_mutiple"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event clicked;call super::clicked;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if

end event

event doubleclicked;call super::doubleclicked;IF NOT dw_edit_mode THEN RETURN

IF dwo.Name = 'fx_outware_log_productdate_t'  THEN
	//批设置
	dw_fx_outware_mx.accepttext()
	dw_fx_outware_mx.SetRedraw	(false)
	integer i
	for i = 2 to dw_fx_outware_mx.rowcount()
		dw_fx_outware_mx.object.fx_outware_log_productdate[i] = dw_fx_outware_mx.object.fx_outware_log_productdate[1]
	next
	dw_fx_outware_mx.SetRedraw	(true)
	
END IF

end event

event dwnkey;call super::dwnkey;IF KeyDown(KeyControl!) And KeyDown(KeyV!) Then
	IF This.GetColumnName( ) = 'fx_outware_log_productdate' THEN
		string copytext,linetext[]
		integer i,r
		copytext = Clipboard()
		IF pos(copytext , '~r~n') > 0 then
			f_split(copytext,'~r~n',linetext)
			for i = 1 to Upperbound(linetext)
				r = i + dw_fx_outware_mx.getrow() - 1
				if r <= dw_fx_outware_mx.rowcount() and isDate(linetext[i]) then
					dw_fx_outware_mx.object.fx_outware_log_productdate[r] = Date(linetext[i])
				end if
			next
		END IF
	END IF
END IF
end event

event itemchanged;call super::itemchanged;if dwo.name = 'ch' then
	long i
	boolean isChecked
	isChecked = true
	for i = 1 to this.rowcount()
		if i = row and data = '0' then
			isChecked = false
		elseif i <> row and this.object.ch[i] = 0 then
			isChecked = false
		end if
	next
	cbx_1.checked = isChecked
end if
end event

event itemfocuschanged;call super::itemfocuschanged;if dw_edit_mode and dwo.name = 'plancode' then
		int sys_option_taskplancode,storage_plancode_rule_buy,mtrldef_plancode_rule_buy,ifplancode_ware
		sys_option_taskplancode = dw_fx_outware_mx.Object.sys_option_taskplancode[row]
		ifplancode_ware = dw_fx_outware_mx.Object.ifplancode_ware[row]
		storage_plancode_rule_buy = dw_fx_outware_mx.Object.storage_plancode_rule_buy[row]
		mtrldef_plancode_rule_buy = dw_fx_outware_mx.Object.mtrldef_plancode_rule_buy[row]
			//系统选项[038-使用批号库存]为[1-使用批号库存]或者[2-按仓库属性限制]仓库属性[使用批号库存]为1启用
			//仓库属性[采购进仓批号规则]为[2-按协同系统发货单]
			//或仓库属性[采购进仓批号规则]为[3-按物料设置]且物料属性为[2-按协同系统发货单]
			//满足条件时可编辑
			if  not ((sys_option_taskplancode = 1 or (sys_option_taskplancode = 2 and ifplancode_ware = 1)) &
			AND (storage_plancode_rule_buy = 2 or (storage_plancode_rule_buy = 3 AND mtrldef_plancode_rule_buy = 2)))  &
		then
			this.setcolumn('qty')
			messagebox("系统提示","物料属性控制自动生成批号，不允许修改")
		end if
end if
end event

type cb_1 from uo_imflatbutton within w_outware_fx_mutiple
integer x = 1161
integer y = 4
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "唛头打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (dw_edit_mode) then return

long ll_row, ll_status
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]


if ll_status = 0 then
	messagebox('提示', '待审核单据,不能打印！')
	return
end if

Parent.TriggerEvent('ue_print_outware_all_mt')


end event

type cb_2 from uo_imflatbutton within w_outware_fx_mutiple
integer x = 1435
integer y = 4
integer width = 274
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "明细打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (dw_edit_mode) then return

long ll_row, ll_status
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
	return
end if	

ll_status = dw_fx_outware.Object.status[ll_row]


//if ll_status = 0 then
//	messagebox('提示', '待审核单据,不能打印！')
//	return
//end if

Parent.TriggerEvent('ue_print_outware_sptcode')


end event

type cbx_1 from checkbox within w_outware_fx_mutiple
integer x = 101
integer y = 1648
integer width = 402
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "全选\全不选"
boolean checked = true
end type

event clicked;long i

for i = 1 to dw_fx_outware_mx.rowcount()
	if this.checked then
		dw_fx_outware_mx.object.ch[i] = 1
	else
		dw_fx_outware_mx.object.ch[i] = 0
	end if
next
end event

type cb_3 from uo_imflatbutton within w_outware_fx_mutiple
integer x = 1710
integer width = 274
integer height = 164
integer taborder = 90
boolean bringtotop = true
string text = "明细报表"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;open(w_outwaremx_tracking)
end event

type rb_outwarecode from radiobutton within w_outware_fx_mutiple
integer x = 55
integer y = 200
integer width = 247
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "单号含"
end type

event clicked;wf_face_changed()
end event

type sle_outwarecode from singlelineedit within w_outware_fx_mutiple
integer x = 311
integer y = 188
integer width = 434
integer height = 84
integer taborder = 100
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type rb_date from radiobutton within w_outware_fx_mutiple
integer x = 841
integer y = 200
integer width = 357
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "发货日期从"
end type

event clicked;wf_face_changed()
end event

