$PBExportHeader$w_cus_ch_fx.srw
$PBExportComments$(协同)客户选择
forward
global type w_cus_ch_fx from w_publ_choice
end type
end forward

global type w_cus_ch_fx from w_publ_choice
integer width = 4311
integer height = 1920
string title = "选择客户"
long backcolor = 16777215
boolean center = true
end type
global w_cus_ch_fx w_cus_ch_fx

type variables
s_fx_company ins_s, ins_ret
end variables

forward prototypes
public function integer wf_retrieve ()
end prototypes

public function integer wf_retrieve ();int rslt = 1

string arg_msg
long i, insertRow
oleobject obj, parm, list, item
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
obj = FXAppCom.GetMyCustList(parm, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

dw_ch.SetRedraw(false)
dw_ch.Reset()
list = obj.GetPBArray('list')
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	insertRow = dw_ch.InsertRow(0)
	
	dw_ch.Object.comid[insertRow] = item.GetInt('comid')
	dw_ch.Object.comname[insertRow] = item.GetString('comname')
	dw_ch.Object.simplename[insertRow] = item.GetString('simplename')
	dw_ch.Object.custype[insertRow] = item.GetString('custype')
	dw_ch.Object.tele[insertRow] = item.GetString('tele')
	dw_ch.Object.address[insertRow] = item.GetString('address')
	dw_ch.Object.freight[insertRow] = item.GetString('freight')
	dw_ch.Object.freight_tele[insertRow] = item.GetString('freight_tele')
	dw_ch.Object.relid[insertRow] = item.GetInt('relid')
next
dw_ch.AcceptText()
dw_ch.SetRedraw(true)

ext:
if (rslt = 0) then
	MessageBox('提示', arg_msg)
end if
return rslt
end function

on w_cus_ch_fx.create
call super::create
end on

on w_cus_ch_fx.destroy
call super::destroy
end on

event open;this.triggerevent('ue_before_open')

ins_s = Message.PowerObjectParm
if (not IsNull(ins_s)) then
	if (IsValid(ins_s)) then
		if (not IsNull(ins_s.ds)) then
			IF IsValid(ins_s.ds) THEN
				if (ins_s.ds.RowCount() > 0 and ins_s.ds.DataObject = 'dw_fx_cust_ch') then
					dw_ch.Object.Data = ins_s.ds.Object.Data
					return
				end if
			END IF
		end if
	end if
end if

wf_retrieve()
end event

event close;CloseWithReturn(this, ins_ret)
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_cus_ch_fx
end type

type cb_exit from w_publ_choice`cb_exit within w_cus_ch_fx
end type

event cb_exit::clicked;ins_ret.ifselect = false

Close(parent)
end event

type sle_ch from w_publ_choice`sle_ch within w_cus_ch_fx
boolean visible = false
integer x = 2473
integer y = 32
boolean enabled = false
end type

type dw_ch from w_publ_choice`dw_ch within w_cus_ch_fx
integer y = 176
integer width = 4242
integer height = 1344
string dataobject = "dw_fx_cust_ch"
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_cus_ch_fx
boolean visible = false
integer x = 2290
integer y = 60
boolean enabled = false
end type

type cb_retrieve from w_publ_choice`cb_retrieve within w_cus_ch_fx
end type

event cb_retrieve::clicked;wf_retrieve()
end event

type cb_choice from w_publ_choice`cb_choice within w_cus_ch_fx
end type

event cb_choice::clicked;call super::clicked;long row
row = dw_ch.GetRow()
if (row <= 0) then
	MessageBox('提示', '请在下面的清单内选中一个客户')
	return
end if

if not dw_ch.IsSelected(row) then
	MessageBox('提示', '请在下面的清单内选中一个客户')
	return
end if

ins_ret.comid[1] = dw_ch.Object.comid[row]
ins_ret.comname[1] = Trim(dw_ch.Object.comname[row])
ins_ret.simplename[1] = Trim(dw_ch.Object.simplename[row])
ins_ret.relid[1] = dw_ch.Object.relid[row]
ins_ret.ifselect = true

Close(parent)
end event

type ln_bar from w_publ_choice`ln_bar within w_cus_ch_fx
end type

type ln_bar2 from w_publ_choice`ln_bar2 within w_cus_ch_fx
end type

type r_bar from w_publ_choice`r_bar within w_cus_ch_fx
end type

type ln_1 from w_publ_choice`ln_1 within w_cus_ch_fx
end type

type ln_2 from w_publ_choice`ln_2 within w_cus_ch_fx
end type

