$PBExportHeader$w_ljmail_contact_ch_fx.srw
$PBExportComments$(协同)通信录选择
forward
global type w_ljmail_contact_ch_fx from w_publ_base_style
end type
type dw_1 from u_dw_rbtnfilter within w_ljmail_contact_ch_fx
end type
type cb_ok from uo_imflatbutton within w_ljmail_contact_ch_fx
end type
type cb_retrieve from uo_imflatbutton within w_ljmail_contact_ch_fx
end type
end forward

global type w_ljmail_contact_ch_fx from w_publ_base_style
integer width = 3310
integer height = 2080
string title = "通信录"
boolean minbox = false
windowtype windowtype = response!
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
boolean center = true
dw_1 dw_1
cb_ok cb_ok
cb_retrieve cb_retrieve
end type
global w_ljmail_contact_ch_fx w_ljmail_contact_ch_fx

type variables
s_fx_ljmail_contact ins_contact
end variables

on w_ljmail_contact_ch_fx.create
int iCurrent
call super::create
this.dw_1=create dw_1
this.cb_ok=create cb_ok
this.cb_retrieve=create cb_retrieve
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.dw_1
this.Control[iCurrent+2]=this.cb_ok
this.Control[iCurrent+3]=this.cb_retrieve
end on

on w_ljmail_contact_ch_fx.destroy
call super::destroy
destroy(this.dw_1)
destroy(this.cb_ok)
destroy(this.cb_retrieve)
end on

event open;call super::open;s_fx_ljmail_contact temp
temp = Message.PowerObjectParm
if (IsValid(temp) and not IsNull(temp)) then
	ins_contact = temp
end if

ins_contact.ifch = 0

string arg_msg
FXAppCom.UpdateContact(app_token_fx, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '更新(系统)通信录失败:' + arg_msg)
end if

cb_retrieve.post event clicked()
end event

event resize;call super::resize;cb_exit.X = this.workspacewidth( ) - cb_exit.Width
end event

type cb_func from w_publ_base_style`cb_func within w_ljmail_contact_ch_fx
boolean visible = false
integer taborder = 50
boolean enabled = false
end type

type cb_exit from w_publ_base_style`cb_exit within w_ljmail_contact_ch_fx
integer x = 1125
integer taborder = 30
end type

type ln_bar from w_publ_base_style`ln_bar within w_ljmail_contact_ch_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_ljmail_contact_ch_fx
end type

type r_bar from w_publ_base_style`r_bar within w_ljmail_contact_ch_fx
end type

type dw_1 from u_dw_rbtnfilter within w_ljmail_contact_ch_fx
integer y = 168
integer width = 3333
integer height = 1848
integer taborder = 40
boolean bringtotop = true
string dataobject = "dw_fx_ljmail_contact"
boolean hscrollbar = true
boolean vscrollbar = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event itemfocuschanged;call super::itemfocuschanged;if (row > 0) then
	this.SetRow(row)
	this.SelectRow(0, false)
	this.SelectRow(row, true)
end if
end event

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 cb_ok from uo_imflatbutton within w_ljmail_contact_ch_fx
integer x = 151
integer width = 151
integer height = 164
integer taborder = 20
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, j
dw_1.SetFilter('')
dw_1.Filter()

s_fx_ljmail_contact ch
for i = 1 to dw_1.RowCount()
	if (dw_1.Object.ch[i] = 1) then
		j ++
		
		ch.cid[j] = dw_1.Object.cid[i]
		ch.userid[j] = dw_1.Object.userid[i]
		ch.revCusCommID[j] = dw_1.Object.revCusCommID[i]
		ch.revName[j] = dw_1.Object.revName[i]
		ch.relType[j] = dw_1.Object.relType[i]
		ch.revEmpid[j] = dw_1.Object.revEmpid[i]
		ch.revLjmail[j] = dw_1.Object.revLjmail[i]
		ch.revRep[j] = dw_1.Object.revRep[i]
		ch.dscrp[j] = dw_1.Object.dscrp[i]
	end if
next

if (j <= 0) then
	MessageBox('提示', '请勾选收件人')
	return
end if

ins_contact = ch
ins_contact.ifch = 1
CloseWithReturn(parent, ins_contact)
end event

type cb_retrieve from uo_imflatbutton within w_ljmail_contact_ch_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;string arg_msg
oleobject list, item

list = FXAppCom.GetContact(app_token_fx, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取通信录失败:' + arg_msg)
	return
end if

dw_1.Reset()
dw_1.SetRedraw(false)
long i, row
for i = 1 to list.Count
	item = list.GetItem(i - 1)
	row = dw_1.InsertRow(0)
	
	dw_1.Object.ch[row] = 0
	dw_1.Object.cid[row] = item.GetInt('cid')
	dw_1.Object.userid[row] = item.GetInt('userid')
	dw_1.Object.revCusCommID[row] = item.GetInt('revCusCommID')
	dw_1.Object.revEmpid[row] = item.GetInt('revEmpid')
	dw_1.Object.relType[row] = item.GetInt('relType')
	dw_1.Object.revName[row] = item.GetString('revName')
	dw_1.Object.revLjmail[row] = item.GetString('revLjmail')
	dw_1.Object.revRep[row] = item.GetString('revRep')
	dw_1.Object.dscrp[row] = item.GetString('dscrp')
next

for i = 1 to UpperBound(ins_contact.revljmail)
	row = dw_1.Find('revName = "' + ins_contact.revname[i] + '" and revLjmail = "' + ins_contact.revljmail[i] + '"', 1, dw_1.RowCount())
	if (row > 0) then
		dw_1.Object.ch[row] = 1
	end if
next

dw_1.SetSort('ch,reltype,revname')
dw_1.Sort()
dw_1.SetRedraw(true)
end event

