$PBExportHeader$w_sendout_fx.srw
forward
global type w_sendout_fx from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_sendout_fx
end type
type cb_new from uo_imflatbutton within w_sendout_fx
end type
type cb_delete from uo_imflatbutton within w_sendout_fx
end type
type cb_audit from uo_imflatbutton within w_sendout_fx
end type
type cb_cancle_audit from uo_imflatbutton within w_sendout_fx
end type
type cb_print from uo_imflatbutton within w_sendout_fx
end type
type cb_confirm_return from uo_imflatbutton within w_sendout_fx
end type
type ddlb_flag from dropdownlistbox within w_sendout_fx
end type
type cbx_ifback from checkbox within w_sendout_fx
end type
type st_2 from statictext within w_sendout_fx
end type
type em_datea from editmask within w_sendout_fx
end type
type em_datez from editmask within w_sendout_fx
end type
type st_3 from statictext within w_sendout_fx
end type
type dw_uc from datawindow within w_sendout_fx
end type
type cb_add_mx from commandbutton within w_sendout_fx
end type
type cb_delete_mx from commandbutton within w_sendout_fx
end type
type cb_modify from uo_imflatbutton within w_sendout_fx
end type
type dw_pageretr from u_dw_rbtnfilter within w_sendout_fx
end type
type dw_mx from u_dw_rbtnfilter within w_sendout_fx
end type
type cb_1 from uo_imflatbutton within w_sendout_fx
end type
type ddlb_billtype from dropdownlistbox within w_sendout_fx
end type
type st_1 from statictext within w_sendout_fx
end type
type st_4 from statictext within w_sendout_fx
end type
end forward

global type w_sendout_fx 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 ( )
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_flag ddlb_flag
cbx_ifback cbx_ifback
st_2 st_2
em_datea em_datea
em_datez em_datez
st_3 st_3
dw_uc dw_uc
cb_add_mx cb_add_mx
cb_delete_mx cb_delete_mx
cb_modify cb_modify
dw_pageretr dw_pageretr
dw_mx dw_mx
cb_1 cb_1
ddlb_billtype ddlb_billtype
st_1 st_1
st_4 st_4
end type
global w_sendout_fx w_sendout_fx

type variables

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 ()
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.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 ();long li_flag, li_billtype

IF ddlb_flag.text = '待确认' then
	li_flag = 0 
ELSEIF ddlb_flag.text = '已确认' then
	li_flag = 1
ELSE
	li_flag = -1
END IF

IF ddlb_billtype.text = '送货上门' then
	li_billtype = 0
ELSEIF ddlb_billtype.text = '代客发货' then
	li_billtype = 1
ELSE
	li_billtype = -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('billtype', li_billtype)
request.SetInt('flag', li_flag)
request.SetDateTime('begindate', dateA)
request.SetDateTime('enddate', dateZ)

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

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

dw_pageretr.Reset()
dw_mx.Reset()
dw_pageretr.SetRedraw(false)

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

	dw_pageretr.Object.billid[row] = item.GetInt('billid')
	dw_pageretr.Object.billcode[row] = item.GetString('billcode')
	dw_pageretr.Object.billtype[row] = item.GetInt('billtype')
	dw_pageretr.Object.relcode[row] = item.GetString('relcode')
	dw_pageretr.Object.cuscomid[row] = item.GetInt('cuscomid')
	dw_pageretr.Object.sptcomid[row] = item.GetInt('sptcomid')
	dw_pageretr.Object.flag[row] = item.GetInt('flag')
	dw_pageretr.Object.cus_name[row] = item.GetString('cus_name')
	dw_pageretr.Object.cus_address[row] = item.GetString('cus_address')
	dw_pageretr.Object.cus_tele[row] = item.GetString('cus_tele')
	dw_pageretr.Object.rel_rep[row] = item.GetString('rel_rep')
	dw_pageretr.Object.freight[row] = item.GetString('freight')
	dw_pageretr.Object.freight_tele[row] = item.GetString('freight_tele')
	dw_pageretr.Object.freight_address[row] = item.GetString('freight_address')
	dw_pageretr.Object.banktypename[row] = item.GetString('banktypename')
	dw_pageretr.Object.billrelcode[row] = item.GetString('billrelcode')
	dw_pageretr.Object.paytype[row] = item.GetString('paytype')
	dw_pageretr.Object.cus_tele1[row] = item.GetString('cus_tele1')

	
	if not IsNull(item.GetDateTime('sendoutdate')) then dw_pageretr.Object.sendoutdate[row] = item.GetDateTime('sendoutdate')
	if not IsNull(item.GetDateTime('opdate')) then dw_pageretr.Object.opdate[row] = item.GetDateTime('opdate')
	if not IsNull(item.GetDateTime('affirmdate')) then dw_pageretr.Object.affirmdate[row] = item.GetDateTime('affirmdate')

	dw_pageretr.Object.affirmemp[row] = item.GetString('affirmemp')

next

dw_pageretr.SetRedraw(true)

if (dw_pageretr.RowCount() > 0) then
	dw_pageretr.SelectRow(0, false)
	dw_pageretr.SelectRow(1, true)
	dw_pageretr.SetRow(1)
	dw_pageretr.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('billid', arg_outwareid)

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

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

list = response.GetPBArray('mxList')


any acceptdate, outwaredate

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

	dw_mx.SetItem(row, 'billid', item.GetInt('billid'))
	dw_mx.SetItem(row, 'printid', item.GetInt('printid'))
	dw_mx.SetItem(row, 'reltaskid', item.GetInt('reltaskid'))
	dw_mx.SetItem(row, 'relprintid', item.GetInt('relprintid'))
	dw_mx.SetItem(row, 'sendoutqty', item.GetDouble('sendoutqty'))
	dw_mx.SetItem(row, 'saleout_pid_erp', item.GetInt('saleout_pid_erp'))
	dw_mx.SetItem(row, 'fx_saletaskmx_mtrlcode', item.GetString('mtrlcode'))
	dw_mx.SetItem(row, 'fx_saletaskmx_mtrlname', item.GetString('mtrlname'))
	dw_mx.SetItem(row, 'fx_saletaskmx_STATUS', item.GetString('STATUS'))
	dw_mx.SetItem(row, 'fx_saletaskmx_woodcode', item.GetString('woodcode'))
	dw_mx.SetItem(row, 'fx_saletaskmx_pcode', item.GetString('pcode'))
	
next
dw_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
//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
//	
//	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
//
//oleobject request,response
//
//request = FXAppCom.CreatePbDictionary()
//request.SetString('token', app_token_fx)
//request.SetObject('outware', outware)
//request.SetObject('mxs', mxs)
//
//response = FXAppCom.DoExecute('SendOutwareMxMutiple', request)
//arg_msg = response.GetString('ErrMsg')
//
//if (arg_msg <> '') then
//	rslt = 0
//	goto ext
//end if
//
//ext:
//return rslt
return 1
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)
//ELSE
//	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)
//
//END IF
//
return 1
end function

public function integer wf_cus_select ();return 1
end function

on w_sendout_fx.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_flag=create ddlb_flag
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_uc=create dw_uc
this.cb_add_mx=create cb_add_mx
this.cb_delete_mx=create cb_delete_mx
this.cb_modify=create cb_modify
this.dw_pageretr=create dw_pageretr
this.dw_mx=create dw_mx
this.cb_1=create cb_1
this.ddlb_billtype=create ddlb_billtype
this.st_1=create st_1
this.st_4=create st_4
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_flag
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_uc
this.Control[iCurrent+15]=this.cb_add_mx
this.Control[iCurrent+16]=this.cb_delete_mx
this.Control[iCurrent+17]=this.cb_modify
this.Control[iCurrent+18]=this.dw_pageretr
this.Control[iCurrent+19]=this.dw_mx
this.Control[iCurrent+20]=this.cb_1
this.Control[iCurrent+21]=this.ddlb_billtype
this.Control[iCurrent+22]=this.st_1
this.Control[iCurrent+23]=this.st_4
end on

on w_sendout_fx.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_flag)
destroy(this.cbx_ifback)
destroy(this.st_2)
destroy(this.em_datea)
destroy(this.em_datez)
destroy(this.st_3)
destroy(this.dw_uc)
destroy(this.cb_add_mx)
destroy(this.cb_delete_mx)
destroy(this.cb_modify)
destroy(this.dw_pageretr)
destroy(this.dw_mx)
destroy(this.cb_1)
destroy(this.ddlb_billtype)
destroy(this.st_1)
destroy(this.st_4)
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 = 1264 //dw_fx_outware_free高度

//dw_fx_outware_free
dw_uc.width =  li_free_width
dw_uc.height =   li_free_height
//dw_fx_outware
dw_pageretr.x = li_free_width + 30
dw_pageretr.y = dw_uc.y
dw_pageretr.width = this.workspacewidth() - li_free_width
dw_pageretr.height = dw_uc.height

//dw_mx
dw_mx.y = dw_pageretr.y + dw_pageretr.height + 30
dw_mx.width = this.workspacewidth()
dw_mx.height = this.workspaceheight() - dw_pageretr.y - dw_pageretr.height - 30

end event

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

dw_uc.insertrow(0)


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

wf_retrieve_outware()
end event

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

type cb_exit from w_publ_base_style`cb_exit within w_sendout_fx
integer x = 553
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_sendout_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_sendout_fx
end type

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

type cb_refresh from uo_imflatbutton within w_sendout_fx
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_sendout_fx
boolean visible = false
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()
//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_sendout_fx
boolean visible = false
integer x = 699
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

type cb_audit from uo_imflatbutton within w_sendout_fx
integer x = 160
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_billid
	
ll_row = dw_pageretr.GetRow()

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

ll_billid = dw_pageretr.Object.billid[ll_row]


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('billid', ll_billid)

string arg_msg
response = FXAppCom.DoExecute('AffirmFxSendout', 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_sendout_fx
boolean visible = false
integer x = 832
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
boolean enabled = false
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_sendout_fx
boolean visible = false
integer x = 997
integer y = 4
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
boolean enabled = false
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_sendout_fx
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_flag from dropdownlistbox within w_sendout_fx
integer x = 183
integer y = 184
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
string text = "全部"
boolean sorted = false
boolean vscrollbar = true
string item[] = {"待确认","已确认","全部"}
borderstyle borderstyle = stylelowered!
end type

type cbx_ifback from checkbox within w_sendout_fx
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
boolean enabled = false
string text = "是否退货"
end type

type st_2 from statictext within w_sendout_fx
integer x = 1001
integer y = 196
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_sendout_fx
integer x = 1312
integer y = 184
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_sendout_fx
integer x = 1806
integer y = 180
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_sendout_fx
integer x = 1701
integer y = 196
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_uc from datawindow within w_sendout_fx
integer y = 288
integer width = 1792
integer height = 1264
integer taborder = 30
boolean bringtotop = true
string title = "none"
string dataobject = "dw_sendout_fx"
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_sendout_fx
boolean visible = false
integer x = 32
integer y = 1452
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

type cb_delete_mx from commandbutton within w_sendout_fx
boolean visible = false
integer x = 347
integer y = 1452
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

type cb_modify from uo_imflatbutton within w_sendout_fx
integer x = 329
integer width = 219
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;long ll_row, ll_billid
	
ll_row = dw_pageretr.GetRow()

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

ll_billid = dw_pageretr.Object.billid[ll_row]


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('billid', ll_billid)

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

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


end event

type dw_pageretr from u_dw_rbtnfilter within w_sendout_fx
integer x = 1806
integer y = 276
integer width = 1714
integer height = 1264
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string dataobject = "dw_sendout_fx_index"
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_uc.Reset( )
this.RowsCopy(currentrow, currentrow, Primary!, dw_uc, 1, Primary!)

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

wf_retrieve_outware_mx(ll_outwareid)
end event

type dw_mx from u_dw_rbtnfilter within w_sendout_fx
integer y = 1572
integer width = 3506
integer height = 828
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_sendoutmx_fx"
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 cb_1 from uo_imflatbutton within w_sendout_fx
boolean visible = false
integer x = 1161
integer y = 4
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
boolean enabled = false
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_pageretr.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
end if	

ll_status = dw_pageretr.Object.status[ll_row]


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

Parent.TriggerEvent('ue_print_outware_all_mt')


end event

type ddlb_billtype from dropdownlistbox within w_sendout_fx
integer x = 672
integer y = 180
integer width = 306
integer height = 496
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 = "全部"
boolean sorted = false
boolean vscrollbar = true
string item[] = {"送货上门","代客发货","全部"}
borderstyle borderstyle = stylelowered!
end type

type st_1 from statictext within w_sendout_fx
integer x = 9
integer y = 192
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 st_4 from statictext within w_sendout_fx
integer x = 503
integer y = 192
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

