$PBExportHeader$w_outware_fx_mutiple_up.srw
forward
global type w_outware_fx_mutiple_up from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_new from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_delete from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_audit from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_cancle_audit from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_print from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type cb_confirm_return from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type ddlb_status from dropdownlistbox within w_outware_fx_mutiple_up
end type
type cbx_ifback from checkbox within w_outware_fx_mutiple_up
end type
type st_2 from statictext within w_outware_fx_mutiple_up
end type
type em_datea from editmask within w_outware_fx_mutiple_up
end type
type em_datez from editmask within w_outware_fx_mutiple_up
end type
type st_3 from statictext within w_outware_fx_mutiple_up
end type
type dw_fx_outware_free from datawindow within w_outware_fx_mutiple_up
end type
type cb_modify from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type dw_fx_outware from u_dw_rbtnfilter within w_outware_fx_mutiple_up
end type
type cb_1 from uo_imflatbutton within w_outware_fx_mutiple_up
end type
type st_1 from statictext within w_outware_fx_mutiple_up
end type
type tab_1 from tab within w_outware_fx_mutiple_up
end type
type tabpage_1 from userobject within tab_1
end type
type dw_fx_outware_mx from u_dw_rbtnfilter within tabpage_1
end type
type tabpage_1 from userobject within tab_1
dw_fx_outware_mx dw_fx_outware_mx
end type
type tabpage_2 from userobject within tab_1
end type
type cb_delete_barcode from commandbutton within tabpage_2
end type
type cb_add_barcode from commandbutton within tabpage_2
end type
type cb_delete_mx from commandbutton within tabpage_2
end type
type cb_add_mx from commandbutton within tabpage_2
end type
type dw_barcode from u_dw_rbtnfilter within tabpage_2
end type
type tabpage_2 from userobject within tab_1
cb_delete_barcode cb_delete_barcode
cb_add_barcode cb_add_barcode
cb_delete_mx cb_delete_mx
cb_add_mx cb_add_mx
dw_barcode dw_barcode
end type
type tab_1 from tab within w_outware_fx_mutiple_up
tabpage_1 tabpage_1
tabpage_2 tabpage_2
end type
type cb_file from uo_imflatbutton within w_outware_fx_mutiple_up
end type
end forward

global type w_outware_fx_mutiple_up from w_publ_base_style
integer width = 4608
integer height = 3404
string title = "代客发货单"
boolean maxbox = true
event ue_print_outware_all ( )
event ue_print_outware_mx ( )
event ue_print_outware_all_mt ( )
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
st_2 st_2
em_datea em_datea
em_datez em_datez
st_3 st_3
dw_fx_outware_free dw_fx_outware_free
cb_modify cb_modify
dw_fx_outware dw_fx_outware
cb_1 cb_1
st_1 st_1
tab_1 tab_1
cb_file cb_file
end type
global w_outware_fx_mutiple_up w_outware_fx_mutiple_up

type variables
datawindow dw_fx_outware_mx // 订单明细
datawindow dw_barcode // 条码明细
end variables

forward prototypes
public subroutine wf_btn_enabled ()
public subroutine wf_retrieve_outware ()
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 function integer wf_retrieve_barcode ()
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

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.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] //供应商名称
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

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] //供应商名称
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.obj_dwNAME='dw_print_outware_fx_mx_data'
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
	tab_1.tabpage_2.cb_add_barcode.enabled = true
	tab_1.tabpage_2.cb_delete_barcode.enabled = true
	cb_new.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
	tab_1.tabpage_2.cb_add_barcode.enabled = false
	tab_1.tabpage_2.cb_delete_barcode.enabled = false
	cb_new.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 ();long status, ll_ifback

if cbx_ifback.checked = false then
	ll_ifback = 0
else
	ll_ifback = 1
end if

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

datetime dateA, dateZ
dateA = DateTime(Date(em_dateA.Text), Time(0))
dateZ = DateTime(Date(em_dateZ.Text), Time('23:59:59'))

string arg_msg
oleobject request,response,FxOutwares,item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('ifback', ll_ifback)
request.SetInt('status', status)
request.SetDateTime('startdate', dateA)
request.SetDateTime('enddate', dateZ)
request.SetInt('billtype', 2)//刷新2数据

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')
	
	dw_fx_outware.Object.fx_sendout_cus_name[row] = item.GetString('cus_name')
	dw_fx_outware.Object.fx_sendout_cus_address[row] = item.GetString('cus_address')
	dw_fx_outware.Object.fx_sendout_cus_tele[row] = item.GetString('cus_tele')
	dw_fx_outware.Object.fx_sendout_rel_rep[row] = item.GetString('rel_rep')
	dw_fx_outware.Object.fx_sendout_freight[row] = item.GetString('freight')
	dw_fx_outware.Object.fx_sendout_freight_tele[row] = item.GetString('freight_tele')
	dw_fx_outware.Object.fx_sendout_freight_address[row] = item.GetString('freight_address')
	dw_fx_outware.Object.fx_sendout_banktypename[row] = item.GetString('banktypename')
	dw_fx_outware.Object.fx_sendout_billrelcode[row] = item.GetString('billrelcode')
	dw_fx_outware.Object.fx_sendout_paytype[row] = item.GetString('paytype')
	dw_fx_outware.Object.fx_sendout_cus_tele1[row] = item.GetString('cus_tele1')
	
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_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, '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'))
	
next
dw_fx_outware_mx.SetRedraw(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,barcodeList,barcode
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])
outware.SetInt('relsendoutid',dw_fx_outware_free.Object.relsendoutid[ll_getrow])
outware.SetString('relsendoutcode', dw_fx_outware_free.Object.relsendoutcode[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
	
	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])
	
	mxs.Add(Item)
Next

If (cnt <= 0) Then
	rslt = 0
	arg_msg = '没有发货数大于0的明细'
	Goto ext
End If

Int j
//条码明细
barcodeList = FXAppCom.CreArrOfPbDictionary()
For j = 1 To dw_barcode.RowCount()
	barcode = FXAppCom.CreatePbDictionary()
	
	barcode.SetInt('outwareid', ll_outwareid)
	barcode.SetString('barcode', dw_barcode.Object.barcode[j])
	
	barcodeList.Add(barcode)
Next

oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outware', outware)
request.SetObject('mxs', mxs)
request.SetObject('barcodeList', barcodeList)


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


if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ext:
Return rslt




end function

public function integer wf_change_taborder (integer arg_taborder);IF arg_taborder = 0 THEN
	dw_fx_outware_mx.SetTaborder('qty', 0)
ELSE
	dw_fx_outware_mx.SetTaborder('qty', 20)
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 function integer wf_retrieve_barcode ();Int rslt = 1
dw_barcode.Reset()

String arg_msg
Long ll_row, outwareid
ll_row = dw_fx_outware.GetRow()
If IsNull(ll_row) Then Goto ext
If (ll_row <= 0) Then Goto ext
outwareid = dw_fx_outware.Object.outwareid[ll_row]
If IsNull(outwareid) Then Goto ext

oleobject req, rsp

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

rsp = FXAppCom.DoExecute('GetFxSaletaskBuyBarcode', req)
arg_msg = rsp.GetString('ErrMsg')

If (arg_msg <> '') Then
	rslt = 0
	MessageBox('提示', '获取订单条码失败:' + arg_msg)
	Goto ext
End If

oleobject list, Item
list = rsp.GetPBArray('barcodeList')

dw_barcode.SetRedraw(False)
Long i, row
For i = 1 To list.Count
	Item = list.GetPBDictionary(i - 1)
	
	row = dw_barcode.InsertRow(0)
	
	dw_barcode.SetItem(row, 'taskid', Item.GetInt('taskid'))
	dw_barcode.SetItem(row, 'printid', Item.GetInt('printid'))
	dw_barcode.SetItem(row, 'barcode', Item.GetString('barcode'))
	dw_barcode.SetItem(row, 'taskcode', Item.GetString('taskcode'))
	dw_barcode.SetItem(row, 'mtrlcode', Item.GetString('mtrlcode'))
	dw_barcode.SetItem(row, 'mtrlname', Item.GetString('mtrlname'))
	dw_barcode.SetItem(row, 'mtrlmode', Item.GetString('mtrlmode'))
	dw_barcode.SetItem(row, 'status', Item.GetString('status'))
	dw_barcode.SetItem(row, 'woodcode', Item.GetString('woodcode'))
	dw_barcode.SetItem(row, 'pcode', Item.GetString('pcode'))
	dw_barcode.SetItem(row, 'qty', Item.GetInt('qty'))
	dw_barcode.SetItem(row, 'printnum', Item.GetInt('printnum'))
	dw_barcode.SetItem(row, 'packqty', Item.GetDouble('packqty'))
	
	
Next
dw_barcode.SetRedraw(True)

ext:
Return rslt

end function

on w_outware_fx_mutiple_up.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.st_2=create st_2
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_modify=create cb_modify
this.dw_fx_outware=create dw_fx_outware
this.cb_1=create cb_1
this.st_1=create st_1
this.tab_1=create tab_1
this.cb_file=create cb_file
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.st_2
this.Control[iCurrent+11]=this.em_datea
this.Control[iCurrent+12]=this.em_datez
this.Control[iCurrent+13]=this.st_3
this.Control[iCurrent+14]=this.dw_fx_outware_free
this.Control[iCurrent+15]=this.cb_modify
this.Control[iCurrent+16]=this.dw_fx_outware
this.Control[iCurrent+17]=this.cb_1
this.Control[iCurrent+18]=this.st_1
this.Control[iCurrent+19]=this.tab_1
this.Control[iCurrent+20]=this.cb_file
end on

on w_outware_fx_mutiple_up.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.st_2)
destroy(this.em_datea)
destroy(this.em_datez)
destroy(this.st_3)
destroy(this.dw_fx_outware_free)
destroy(this.cb_modify)
destroy(this.dw_fx_outware)
destroy(this.cb_1)
destroy(this.st_1)
destroy(this.tab_1)
destroy(this.cb_file)
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 = 1880 //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
//tab
tab_1.Width = this.workspacewidth( ) - 10
tab_1.Height = this.workspaceheight( ) - tab_1.y
// 订单明细
dw_fx_outware_mx.Width = tab_1.Width - 20
dw_fx_outware_mx.Height = tab_1.Height - 100

// 条码明细
dw_barcode.Width = tab_1.Width - 20
dw_barcode.Height = tab_1.Height - 290
end event

event open;this.triggerevent('ue_before_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())

wf_retrieve_outware()
end event

event ue_before_open;call super::ue_before_open;dw_fx_outware_mx = tab_1.tabpage_1.dw_fx_outware_mx
dw_barcode = tab_1.tabpage_2.dw_barcode
end event

type cb_func from w_publ_base_style`cb_func within w_outware_fx_mutiple_up
boolean visible = false
integer x = 1618
end type

type cb_exit from w_publ_base_style`cb_exit within w_outware_fx_mutiple_up
integer x = 1559
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_up
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_outware_fx_mutiple_up
end type

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

type cb_refresh from uo_imflatbutton within w_outware_fx_mutiple_up
integer x = 5
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_up
integer x = 155
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
boolean enabled = false
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 // 新建/修改保存
	if wf_send_outware(ref arg_msg) = 0 then
		messagebox('提示', '保存失败,原因:' + arg_msg)
		rslt = 0
		goto ext
	end if
	wf_change_taborder(0)
	
	Messagebox('提示', '保存成功')
	wf_retrieve_outware()

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_up
boolean visible = false
integer x = 494
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
boolean enabled = false
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_up
integer x = 485
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_up
integer x = 649
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_up
integer x = 814
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_up
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_up
integer x = 201
integer y = 192
integer width = 425
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
string text = "全部"
boolean sorted = false
boolean vscrollbar = true
string item[] = {"待审核[0]","待客户确认[1]","客户已确认[2]","全部"}
borderstyle borderstyle = stylelowered!
end type

type cbx_ifback from checkbox within w_outware_fx_mutiple_up
boolean visible = false
integer x = 32
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 = 67108864
string text = "是否退货"
end type

type st_2 from statictext within w_outware_fx_mutiple_up
integer x = 658
integer y = 204
integer width = 288
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 = 16777215
string text = "发货日期从"
alignment alignment = center!
boolean focusrectangle = false
end type

type em_datea from editmask within w_outware_fx_mutiple_up
integer x = 969
integer y = 192
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_up
integer x = 1463
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_up
integer x = 1358
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_up
integer x = 37
integer y = 288
integer width = 1792
integer height = 1880
integer taborder = 30
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_outware_free_up"
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_modify from uo_imflatbutton within w_outware_fx_mutiple_up
integer x = 320
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('提示', '请选择当前行,不能修改!')
		return
	end if	
	
	ll_status = dw_fx_outware.Object.status[ll_row]
	
	if ll_status <> 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_up
integer x = 1842
integer y = 276
integer width = 1714
integer height = 1880
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string dataobject = "dw_fx_outware_mutiple_up"
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)
wf_retrieve_barcode()
end event

type cb_1 from uo_imflatbutton within w_outware_fx_mutiple_up
integer x = 978
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 st_1 from statictext within w_outware_fx_mutiple_up
integer x = 32
integer y = 204
integer width = 155
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 = 134217739
string text = "状态"
alignment alignment = center!
boolean focusrectangle = false
end type

type tab_1 from tab within w_outware_fx_mutiple_up
integer y = 2188
integer width = 3525
integer height = 1056
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
boolean raggedright = true
boolean focusonbuttondown = true
integer selectedtab = 1
tabpage_1 tabpage_1
tabpage_2 tabpage_2
end type

on tab_1.create
this.tabpage_1=create tabpage_1
this.tabpage_2=create tabpage_2
this.Control[]={this.tabpage_1,&
this.tabpage_2}
end on

on tab_1.destroy
destroy(this.tabpage_1)
destroy(this.tabpage_2)
end on

event selectionchanged;If dw_edit_mode Then Return
String tabText
tabText = Control[newindex].Text
If (dw_fx_outware.GetRow() <= 0) Then Return
Long ll_outwareid
ll_outwareid = dw_fx_outware.Object.outwareid[dw_fx_outware.GetRow()]


Choose Case tabText
	Case '订单明细'
		wf_retrieve_outware_mx(ll_outwareid)
	Case '条码明细'
		wf_retrieve_barcode()
End Choose




end event

type tabpage_1 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3488
integer height = 944
long backcolor = 134217739
string text = "订单明细"
long tabtextcolor = 33554432
long tabbackcolor = 134217739
long picturemaskcolor = 536870912
dw_fx_outware_mx dw_fx_outware_mx
end type

on tabpage_1.create
this.dw_fx_outware_mx=create dw_fx_outware_mx
this.Control[]={this.dw_fx_outware_mx}
end on

on tabpage_1.destroy
destroy(this.dw_fx_outware_mx)
end on

type dw_fx_outware_mx from u_dw_rbtnfilter within tabpage_1
integer y = 8
integer width = 3488
integer height = 940
integer taborder = 30
boolean bringtotop = true
string dataobject = "dw_fx_outware_log_mutiple_up"
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

type tabpage_2 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3488
integer height = 944
long backcolor = 134217739
string text = "条码明细"
long tabtextcolor = 33554432
long tabbackcolor = 134217739
long picturemaskcolor = 536870912
cb_delete_barcode cb_delete_barcode
cb_add_barcode cb_add_barcode
cb_delete_mx cb_delete_mx
cb_add_mx cb_add_mx
dw_barcode dw_barcode
end type

on tabpage_2.create
this.cb_delete_barcode=create cb_delete_barcode
this.cb_add_barcode=create cb_add_barcode
this.cb_delete_mx=create cb_delete_mx
this.cb_add_mx=create cb_add_mx
this.dw_barcode=create dw_barcode
this.Control[]={this.cb_delete_barcode,&
this.cb_add_barcode,&
this.cb_delete_mx,&
this.cb_add_mx,&
this.dw_barcode}
end on

on tabpage_2.destroy
destroy(this.cb_delete_barcode)
destroy(this.cb_add_barcode)
destroy(this.cb_delete_mx)
destroy(this.cb_add_mx)
destroy(this.dw_barcode)
end on

type cb_delete_barcode from commandbutton within tabpage_2
integer x = 343
integer y = 8
integer width = 306
integer height = 84
integer taborder = 50
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_barcode.RowCount() <= 0 then
	Messagebox('提示', '请先添加明细！')
	return
end if

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

type cb_add_barcode from commandbutton within tabpage_2
integer x = 27
integer y = 8
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;s_edit_index_tran s_tran, s_ret
OpenWithParm(w_outware_barcode_ch, s_tran)
s_ret = Message.PowerObjectParm

Long i,num
String arg_msg,arg_msg_temp
num = UpperBound(s_ret.arr_string)

If num <= 0 Then Return

If Not IsNull(s_ret) Then
	For i = 1 To num
		oleobject req, rsp
		
		req = FXAppCom.CreatePbDictionary()
		req.SetString('token', app_token_fx)
		req.SetString('barcode', s_ret.arr_string[i])
		
		rsp = FXAppCom.DoExecute('GetFxSaletaskBuyBarcode', req)
		arg_msg_temp = rsp.GetString('ErrMsg')
		
		If (arg_msg_temp <> '') Then
			MessageBox('提示', '获取条码失败:' + arg_msg_temp)
			Return
		End If
		
		oleobject list, Item
		list = rsp.GetPBArray('barcodeList')
		
		dw_barcode.SetRedraw(False)
		Long j, row,q,cnt
		For j = 1 To list.Count
			Item = list.GetPBDictionary(j - 1)
			cnt = 0
			For q = 1 To dw_fx_outware_mx.RowCount()
				If Item.GetString('taskcode') = dw_fx_outware_mx.Object.taskcode[q] Then
					cnt++
				End If
			Next
			
			If cnt = 0 Then
				arg_msg += "条码"+Item.GetString('barcode')+ "不是明细订单对应的条码~r~n"
				Continue
			End If
			
			cnt = 0
			For q = 1 To dw_barcode.RowCount()
				If Item.GetString('barcode') = dw_barcode.Object.barcode[q] Then
					cnt++
				End If
			Next
			
			If cnt > 0 Then
				arg_msg += "条码"+Item.GetString('barcode')+ "已存在~r~n"
				Continue
			End If
			
			row = dw_barcode.InsertRow(0)
			
			dw_barcode.SetItem(row, 'taskid', Item.GetInt('taskid'))
			dw_barcode.SetItem(row, 'printid', Item.GetInt('printid'))
			dw_barcode.SetItem(row, 'barcode', Item.GetString('barcode'))
			dw_barcode.SetItem(row, 'taskcode', Item.GetString('taskcode'))
			dw_barcode.SetItem(row, 'mtrlcode', Item.GetString('mtrlcode'))
			dw_barcode.SetItem(row, 'mtrlname', Item.GetString('mtrlname'))
			dw_barcode.SetItem(row, 'mtrlmode', Item.GetString('mtrlmode'))
			dw_barcode.SetItem(row, 'status', Item.GetString('status'))
			dw_barcode.SetItem(row, 'woodcode', Item.GetString('woodcode'))
			dw_barcode.SetItem(row, 'pcode', Item.GetString('pcode'))
			dw_barcode.SetItem(row, 'qty', Item.GetInt('qty'))
			dw_barcode.SetItem(row, 'printnum', Item.GetInt('printnum'))
			dw_barcode.SetItem(row, 'packqty', Item.GetDouble('packqty'))
			
			
		Next
		dw_barcode.SetRedraw(True)
	Next
	If arg_msg <> "" Then
		MessageBox('提示',  arg_msg)
		Return
	End If
End If









end event

type cb_delete_mx from commandbutton within tabpage_2
boolean visible = false
integer x = 334
integer y = 1564
integer width = 306
integer height = 84
integer taborder = 50
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(0)
	END IF
NEXT
IF index = 0 THEN
	MessageBox('提示', '请先勾选要删除的发货明细!')
END IF
end event

type cb_add_mx from commandbutton within tabpage_2
boolean visible = false
integer x = 18
integer y = 1564
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;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]
	next
	dw_fx_outware_mx.SetRedraw(true)
END IF
end event

type dw_barcode from u_dw_rbtnfilter within tabpage_2
integer y = 104
integer width = 3237
integer height = 648
integer taborder = 40
string dataobject = "dw_fx_saletask_buy_barcode"
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 dw_edit_mode then return

if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if
end event

type cb_file from uo_imflatbutton within w_outware_fx_mutiple_up
integer x = 1253
integer height = 164
integer taborder = 50
boolean bringtotop = true
string text = "附件管理"
string normalpicname = "fj.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long currentrow
string ls_taskcode
Long ll_status
currentrow = dw_fx_outware.GetRow()

IF currentrow <= 0 THEN
	MessageBox('提示', '请先选择权限!')
	RETURN
END IF

ls_taskcode = dw_fx_outware.Object.outwarecode[currentrow]


ll_status = dw_fx_outware.Object.status[currentrow]

//if ll_status <> 2 then
//	messagebox('提示', '不是审核状态,不能操作!')
//	return
//end if


s_edit_index_tran s_pic
s_pic.d_string  = ls_taskcode
s_pic.d_long = 2068 
s_pic.e_long = dw_fx_outware.Object.outwareid[currentrow]
s_pic.f_long = 0
s_pic.work_mode = 1

OpenWithParm(w_fj_manage,s_pic)
end event

