$PBExportHeader$w_address_ch_fx.srw
$PBExportComments$(协同)地址选择
forward
global type w_address_ch_fx from w_publ_choice
end type
end forward

global type w_address_ch_fx from w_publ_choice
integer width = 2885
integer height = 1812
string title = "地址选择"
boolean center = true
end type
global w_address_ch_fx w_address_ch_fx

type variables
s_fx_address ins_tran
end variables

on w_address_ch_fx.create
call super::create
end on

on w_address_ch_fx.destroy
call super::destroy
end on

event open;call super::open;ins_tran.addressid = 0

cb_retrieve.post event clicked()
end event

event close;call super::close;CloseWithReturn(this, ins_tran)
end event

event resize;call super::resize;dw_ch.Width = this.workspacewidth()
dw_ch.Height = this.workspaceheight() - dw_ch.Y
end event

type cb_func from w_publ_choice`cb_func within w_address_ch_fx
boolean visible = false
integer x = 2295
integer taborder = 0
boolean enabled = false
string normalpicname = "setting.BMP"
end type

type cb_exit from w_publ_choice`cb_exit within w_address_ch_fx
integer x = 311
integer taborder = 30
end type

event cb_exit::clicked;//ins_tran.addressid = 0
setNull(ins_tran.addressid)
Close(parent)
end event

type sle_ch from w_publ_choice`sle_ch within w_address_ch_fx
boolean visible = false
integer taborder = 0
boolean enabled = false
end type

type dw_ch from w_publ_choice`dw_ch within w_address_ch_fx
integer y = 168
integer width = 2866
integer taborder = 40
string dataobject = "dw_fx_address"
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type st_1 from w_publ_choice`st_1 within w_address_ch_fx
boolean visible = false
boolean enabled = false
end type

type cb_retrieve from w_publ_choice`cb_retrieve within w_address_ch_fx
integer taborder = 10
end type

event cb_retrieve::clicked;dw_ch.Reset()

string arg_msg
oleobject req, ret
req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
ret = FXAppCom.DoExecute('GetCusAddressList', req)
arg_msg = ret.GetString('ErrMsg')
if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	return
end if

oleobject list, item
list = ret.GetPBArray('addressList')

long ll_i, ll_insertRow
dw_ch.SetRedraw(false)


//插入空数据行
ll_insertRow = dw_ch.InsertRow(0)
dw_ch.Object.cus_rep[ll_insertRow] = ''
dw_ch.Object.cus_tele[ll_insertRow] = ''
dw_ch.Object.cus_address[ll_insertRow] = ''
dw_ch.Object.ifdefault[ll_insertRow] = 0
dw_ch.Object.freight[ll_insertRow] = ''
dw_ch.Object.freight_tele[ll_insertRow] = ''
dw_ch.Object.addressid[ll_insertRow] = 0

for ll_i = 1 to list.Count
	item = list.GetPBDictionary(ll_i - 1)
	
	ll_insertRow = dw_ch.InsertRow(0)
	dw_ch.Object.cus_rep[ll_insertRow] = item.GetString('cus_rep')
	dw_ch.Object.cus_tele[ll_insertRow] = item.GetString('cus_tele')
	dw_ch.Object.cus_address[ll_insertRow] = item.GetString('cus_address')
	dw_ch.Object.ifdefault[ll_insertRow] = item.GetInt('ifdefault')
	dw_ch.Object.freight[ll_insertRow] = item.GetString('freight')
	dw_ch.Object.freight_tele[ll_insertRow] = item.GetString('freight_tele')
	dw_ch.Object.addressid[ll_insertRow] = item.GetInt('addressid')
next


dw_ch.AcceptText()
dw_ch.SetRedraw(true)


end event

type cb_choice from w_publ_choice`cb_choice within w_address_ch_fx
integer x = 155
integer taborder = 20
end type

event cb_choice::clicked;call super::clicked;long ll_row
ll_row = dw_ch.GetRow()
if (ll_row > 0) then
	ins_tran.addressid = dw_ch.Object.addressid[ll_row]
	ins_tran.cus_rep = dw_ch.Object.cus_rep[ll_row]
	ins_tran.cus_tele = dw_ch.Object.cus_tele[ll_row]
	ins_tran.cus_address = dw_ch.Object.cus_address[ll_row]
	ins_tran.freight = dw_ch.Object.freight[ll_row]
	ins_tran.freight_tele = dw_ch.Object.freight_tele[ll_row]
	ins_tran.ifdefault = dw_ch.Object.ifdefault[ll_row]
	Close(parent)
end if
end event

type ln_bar from w_publ_choice`ln_bar within w_address_ch_fx
end type

type ln_bar2 from w_publ_choice`ln_bar2 within w_address_ch_fx
end type

type r_bar from w_publ_choice`r_bar within w_address_ch_fx
end type

type ln_1 from w_publ_choice`ln_1 within w_address_ch_fx
end type

type ln_2 from w_publ_choice`ln_2 within w_address_ch_fx
end type

