$PBExportHeader$w_company_ch_mutil.srw
forward
global type w_company_ch_mutil from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_company_ch_mutil
end type
type cb_select from uo_imflatbutton within w_company_ch_mutil
end type
type dw_company_choose from u_dw_rbtnfilter within w_company_ch_mutil
end type
type cbx_1 from checkbox within w_company_ch_mutil
end type
end forward

global type w_company_ch_mutil from w_publ_base_style
integer width = 3607
integer height = 2436
string title = "公司选择"
boolean minbox = false
windowtype windowtype = response!
cb_refresh cb_refresh
cb_select cb_select
dw_company_choose dw_company_choose
cbx_1 cbx_1
end type
global w_company_ch_mutil w_company_ch_mutil

type variables
s_edit_index_tran s_rslt
end variables

forward prototypes
public subroutine wf_retrieve_company ()
end prototypes

public subroutine wf_retrieve_company ();string arg_msg
long i,row
oleobject request,response,mxs,item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('userid', 0)

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

if (arg_msg <> '') then
    messagebox('提示', '获取订单明细失败，原因：' + arg_msg)
    return
end if

dw_company_choose.Reset()
dw_company_choose.SetRedraw(false)

mxs = response.GetArrOfPBDictionary('companies')
Datetime ld_now,requiredate
ld_now = DateTime(Today(),Now())
for i = 1 to mxs.Count
    item = mxs.GetItem(i - 1)
    
    row = dw_company_choose.InsertRow(0)
	
	dw_company_choose.SetItem(row, 'comid', item.GetInt('comid'))
	dw_company_choose.SetItem(row, 'fx_company_comname', item.GetString('comname'))
	dw_company_choose.SetItem(row, 'fx_company_simplename', item.GetString('simplename'))
	dw_company_choose.SetItem(row, 'fx_company_tele', item.GetString('tele'))
	dw_company_choose.SetItem(row, 'fx_company_address', item.GetString('address'))
	dw_company_choose.SetItem(row, 'fx_relation_relcode', item.GetString('relcode'))
	dw_company_choose.SetItem(row, 'fx_company_fx_title_erp', item.GetString('fx_title_erp'))
next

dw_company_choose.SetRedraw(true)
end subroutine

on w_company_ch_mutil.create
int iCurrent
call super::create
this.cb_refresh=create cb_refresh
this.cb_select=create cb_select
this.dw_company_choose=create dw_company_choose
this.cbx_1=create cbx_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_refresh
this.Control[iCurrent+2]=this.cb_select
this.Control[iCurrent+3]=this.dw_company_choose
this.Control[iCurrent+4]=this.cbx_1
end on

on w_company_ch_mutil.destroy
call super::destroy
destroy(this.cb_refresh)
destroy(this.cb_select)
destroy(this.dw_company_choose)
destroy(this.cbx_1)
end on

event resize;call super::resize;r_bar.height = this.height
dw_company_choose.width = this.workspacewidth()
dw_company_choose.height = this.workspaceheight() - dw_company_choose.y
end event

event open;call super::open;s_rslt.b_long = 0

wf_movetocenter()

wf_retrieve_company()
end event

event close;call super::close;closewithreturn(this, s_rslt)
end event

type cb_func from w_publ_base_style`cb_func within w_company_ch_mutil
boolean visible = false
end type

type cb_exit from w_publ_base_style`cb_exit within w_company_ch_mutil
integer x = 315
end type

type ln_bar from w_publ_base_style`ln_bar within w_company_ch_mutil
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_company_ch_mutil
end type

type r_bar from w_publ_base_style`r_bar within w_company_ch_mutil
end type

type cb_refresh from uo_imflatbutton within w_company_ch_mutil
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_company()
end event

type cb_select from uo_imflatbutton within w_company_ch_mutil
integer x = 151
integer width = 165
integer height = 164
integer taborder = 10
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 i, cnt = 0

long arr_comid[]

for i = 1 to dw_company_choose.RowCount()
	if dw_company_choose.Object.ch[i] = 0 then continue
	
	cnt++
	arr_comid[cnt] = dw_company_choose.Object.comid[i]
next

if cnt = 0 then
	MessageBox('提示', '请先选择要操作的公司!')
	return	
end if

s_rslt.arr_long = arr_comid
s_rslt.b_long = 1
Close(PARENT)
end event

type dw_company_choose from u_dw_rbtnfilter within w_company_ch_mutil
integer y = 180
integer width = 3593
integer height = 2180
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_company_ch_mutil"
boolean hscrollbar = true
boolean vscrollbar = 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.SetRow(row)
	THIS.SelectRow(0, FALSE)
	THIS.SelectRow(row, TRUE)
END IF
end event

type cbx_1 from checkbox within w_company_ch_mutil
integer x = 622
integer y = 52
integer width = 457
integer height = 96
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
long backcolor = 67108864
string text = "全选/全不选"
end type

event constructor;this.backcolor = 14215660
end event

event clicked;Long ll_check

IF This.Checked THEN
	ll_check = 1
ELSE
	ll_check = 0
END IF

long i

for i = 1 to dw_company_choose.RowCount()
	dw_company_choose.Object.ch[i] = ll_check
next
end event

