$PBExportHeader$w_fx_saletaskmx_address.srw
forward
global type w_fx_saletaskmx_address from w_publ_easyq
end type
type cb_3 from uo_imflatbutton within w_fx_saletaskmx_address
end type
end forward

global type w_fx_saletaskmx_address from w_publ_easyq
string title = "修改明细信息"
cb_3 cb_3
end type
global w_fx_saletaskmx_address w_fx_saletaskmx_address

type variables
long ll_taskid
end variables

forward prototypes
public function integer wf_retrieve (long arg_taskid)
public subroutine wf_saveaddress (s_fx_saletaskmx arg_s, ref string arg_msg)
end prototypes

public function integer wf_retrieve (long arg_taskid);int rslt = 1

if (IsNull(arg_taskid)) then return 0

string arg_msg = ''
oleobject list,request,response
request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("taskid",arg_taskid)
response = FXAppCom.DoExecute("GetSaletaskmx", request)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取订单明细有误:' + arg_msg)
	goto ext
end if
list = response.GetArrOfPBDictionary('mxs')
// 订单明细
dw_1.Reset( )
dw_1.SetRedraw(false)
long i
any requiredate
oleobject item

IF ISNULL(list) THEN 
	return rslt
END IF

for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	dw_1.Object.taskid[i] = item.GetInt('taskid')
	dw_1.Object.printid[i] = item.GetInt('printid')
	dw_1.Object.mxcode[i] = item.GetString('mxcode')
	dw_1.Object.fxmtrlid[i] = item.GetInt('fxmtrlid')
	dw_1.Object.mtrlid[i] = item.GetInt('mtrlid')
	dw_1.Object.mtrlcode[i] = item.GetString('mtrlcode')
	dw_1.Object.mtrlname[i] = item.GetString('mtrlname')
	dw_1.Object.mtrlmode[i] = item.GetString('mtrlmode')
	dw_1.Object.status[i] = item.GetString('status')
	dw_1.Object.woodcode[i] = item.GetString('woodcode')
	dw_1.Object.pcode[i] = item.GetString('pcode')
	dw_1.Object.qty[i] = item.GetDouble('qty')
	dw_1.Object.qty_wait[i] = item.GetDouble('qtyWait')
	dw_1.Object.cus_receiveqty[i] = item.GetDouble('cus_receiveqty')
	dw_1.Object.price[i] = item.GetDouble('price')
	dw_1.Object.mxdscrp[i] = item.GetString('mxdscrp')
	dw_1.Object.mxdscrp2[i] = item.GetString('mxdscrp2')
	dw_1.Object.mtrlcuscode[i] = item.GetString('mtrlcuscode')
	dw_1.Object.plancode[i] = item.GetString('plancode')
	dw_1.Object.cus_mtrldef_senddays[i] = item.GetDouble('cus_mtrldef_senddays')
	dw_1.SetItem(i, 'earliestsenddate', item.GetDateTime('earliestSendDate'))
	requiredate = item.GetDateTime('requiredate')
	if (not IsNull(requiredate)) then
		dw_1.Object.requiredate[i] = requiredate
	end if
	dw_1.Object.qty_ready[i] = item.GetDouble('qty_ready')
	dw_1.Object.sptflagstr[i] = item.GetString('sptFlagStr')
	dw_1.Object.date_confirm_flag[i] = item.GetInt('date_confirm_flag')
     
	dw_1.Object.stopQty[i] = item.GetDouble('stopQty')
	dw_1.Object.stopEmp[i] = item.GetString('stopEmp')
	IF NOT IsNull(item.GetDateTime('stopDate')) THEN
		dw_1.Object.stopDate[i] =  item.GetDateTime('stopDate')
	END IF
	dw_1.Object.stopReason[i] = item.GetString('stopReason')
	dw_1.Object.gydscrp[i] = item.GetString('gydscrp')
	dw_1.Object.order_mtrlname_str[i] = item.GetString('order_mtrlname_str')
	dw_1.Object.saletask_mxid[i] = item.GetInt('saletask_mxid')
	dw_1.Object.finishqty[i] = item.GetDouble('finishqty')
	dw_1.Object.nofinishqty[i] = item.GetDouble('nofinishqty')
	dw_1.Object.check_passqty[i] = item.GetDouble('check_passqty')
	dw_1.Object.checktype_fxstr[i] = item.GetString('checktype_fxStr')
	dw_1.Object.checktype_fx[i] = item.GetInt('checktype_fx')
	dw_1.Object.address[i] = item.GetString('address')
next
dw_1.AcceptText()
dw_1.SetSort('printid')
dw_1.Sort()
dw_1.SetRedraw(true)

ext:
return rslt
end function

public subroutine wf_saveaddress (s_fx_saletaskmx arg_s, ref string arg_msg);oleobject request, response,item
request = FxAppCom.CreatePbDictionary()
request.setString('token', app_token_fx)


item = FxAppCom.CreatePbDictionary()
item.setInt('taskid', arg_s.taskid)
item.setInt('printid', arg_s.printid)
item.setString('address', arg_s.fx_address)
item.setString('mtrlcuscode', arg_s.mtrlcuscode)
item.setString('mxdscrp', arg_s.mxdscrp)
item.setString('mxdscrp2', arg_s.mxdscrp2)
request.SetObject('task',item)

response = FxAppCom.DoExecute('SaveSaletaskmxAddress', request)
arg_msg = response.getString('ErrMsg')
end subroutine

on w_fx_saletaskmx_address.create
int iCurrent
call super::create
this.cb_3=create cb_3
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_3
end on

on w_fx_saletaskmx_address.destroy
call super::destroy
destroy(this.cb_3)
end on

event open;call super::open;ll_taskid = message.doubleParm


wf_retrieve(ll_taskid)
end event

type cb_func from w_publ_easyq`cb_func within w_fx_saletaskmx_address
boolean visible = false
end type

type cb_exit from w_publ_easyq`cb_exit within w_fx_saletaskmx_address
integer x = 338
end type

type cb_2 from w_publ_easyq`cb_2 within w_fx_saletaskmx_address
boolean visible = false
end type

type cb_psetup from w_publ_easyq`cb_psetup within w_fx_saletaskmx_address
boolean visible = false
end type

type cb_1 from w_publ_easyq`cb_1 within w_fx_saletaskmx_address
end type

type st_3 from w_publ_easyq`st_3 within w_fx_saletaskmx_address
boolean visible = false
end type

type st_4 from w_publ_easyq`st_4 within w_fx_saletaskmx_address
boolean visible = false
end type

type em_1 from w_publ_easyq`em_1 within w_fx_saletaskmx_address
boolean visible = false
end type

type em_2 from w_publ_easyq`em_2 within w_fx_saletaskmx_address
boolean visible = false
end type

type ddlb_yl from w_publ_easyq`ddlb_yl within w_fx_saletaskmx_address
boolean visible = false
end type

type cbx_yl from w_publ_easyq`cbx_yl within w_fx_saletaskmx_address
boolean visible = false
end type

type dw_1 from w_publ_easyq`dw_1 within w_fx_saletaskmx_address
integer y = 184
integer height = 2048
string dataobject = "dw_fx_saletaskmx_edit"
end type

event dw_1::doubleclicked;call super::doubleclicked;if row <= 0 then return

if dwo.name = 'address' then
	long ll_printid
	string arg_msg
	s_fx_address ins_address
	open(w_address_ch_fx)
	
	ins_address = message.powerObjectParm
	if isnull(ins_address.addressid) then return
	
	dw_1.object.address[row] = ins_address.cus_address
end if
end event

event dw_1::constructor;call super::constructor;//dw_1.Object.qty.color = rgb(255,255,255)
//dw_1.Object.price.color = rgb(255,255,255)
//dw_1.Object.mtrlcuscode.color = rgb(255,255,255)
//dw_1.Object.mxdscrp.color = rgb(255,255,255)
//dw_1.Object.mxdscrp2.color = rgb(255,255,255)

//dw_1.modify("qty_t.color='" + string(rgb(0,0,0)) + "'")
//dw_1.modify("price_t.color='" + string(rgb(0,0,0)) + "'")
//dw_1.modify("mtrlcuscode_t.color='" + string(rgb(0,0,0)) + "'")
//dw_1.modify("mxdscrp_t.color='" + string(rgb(0,0,0)) + "'")
//dw_1.modify("mxdscrp2_t.color='" + string(rgb(0,0,0)) + "'")
end event

type sle_mtrl from w_publ_easyq`sle_mtrl within w_fx_saletaskmx_address
end type

type sle_cust from w_publ_easyq`sle_cust within w_fx_saletaskmx_address
end type

type st_mtrl from w_publ_easyq`st_mtrl within w_fx_saletaskmx_address
end type

type st_cust from w_publ_easyq`st_cust within w_fx_saletaskmx_address
end type

type cbx_loginretr from w_publ_easyq`cbx_loginretr within w_fx_saletaskmx_address
end type

type pb_em1 from w_publ_easyq`pb_em1 within w_fx_saletaskmx_address
boolean visible = false
end type

type pb_em2 from w_publ_easyq`pb_em2 within w_fx_saletaskmx_address
boolean visible = false
end type

type pb_2 from w_publ_easyq`pb_2 within w_fx_saletaskmx_address
boolean visible = false
end type

type cb_help from w_publ_easyq`cb_help within w_fx_saletaskmx_address
boolean visible = false
end type

type cb_copyself from w_publ_easyq`cb_copyself within w_fx_saletaskmx_address
boolean visible = false
end type

type gb_1 from w_publ_easyq`gb_1 within w_fx_saletaskmx_address
end type

type ln_bar from w_publ_easyq`ln_bar within w_fx_saletaskmx_address
end type

type ln_bar2 from w_publ_easyq`ln_bar2 within w_fx_saletaskmx_address
end type

type r_bar from w_publ_easyq`r_bar within w_fx_saletaskmx_address
end type

type ln_1 from w_publ_easyq`ln_1 within w_fx_saletaskmx_address
end type

type ln_2 from w_publ_easyq`ln_2 within w_fx_saletaskmx_address
end type

type ln_3 from w_publ_easyq`ln_3 within w_fx_saletaskmx_address
end type

type ln_4 from w_publ_easyq`ln_4 within w_fx_saletaskmx_address
end type

type cb_3 from uo_imflatbutton within w_fx_saletaskmx_address
integer x = 160
integer width = 169
integer height = 164
integer taborder = 80
boolean bringtotop = true
string text = "保存"
boolean border = false
end type

event clicked;call super::clicked;//open(w_address_ch_fx)

long row, ll_printid
string arg_msg, ls_errMsg
s_fx_saletaskmx s_mx
dw_1.accepttext()

for row = 1 to dw_1.rowCount()
	arg_msg = ''
	s_mx.printid = dw_1.Object.printid[row]
	s_mx.taskid = dw_1.Object.taskid[row]
	s_mx.fx_address = dw_1.Object.address[row]
	s_mx.mtrlcuscode = dw_1.Object.mtrlcuscode[row]
	s_mx.mxdscrp = dw_1.Object.mxdscrp[row]
	s_mx.mxdscrp2 = dw_1.Object.mxdscrp2[row]
	
	
	wf_saveaddress(s_mx, ref arg_msg)
	if arg_msg <> '' then
		ls_errMsg += "【" + dw_1.Object.mxcode[row] + "】" + arg_msg
		continue
	end if
next

if ls_errMsg <> '' then
	messagebox('提示', ls_errMsg + "保存地址失败")
	return
else
	messagebox('成功', '保存成功')
end if

close(parent)


end event

