$PBExportHeader$w_ljmail_manager_fx.srw
$PBExportComments$(协同)消息管理
forward
global type w_ljmail_manager_fx from w_publ_base_style
end type
type tv_1 from treeview within w_ljmail_manager_fx
end type
type dw_1 from u_dw_rbtnfilter within w_ljmail_manager_fx
end type
type uo_1 from uo_html_editor within w_ljmail_manager_fx
end type
type cbx_all from checkbox within w_ljmail_manager_fx
end type
end forward

global type w_ljmail_manager_fx from w_publ_base_style
integer width = 5015
integer height = 2712
string title = "消息管理"
boolean maxbox = true
boolean resizable = true
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
tv_1 tv_1
dw_1 dw_1
uo_1 uo_1
cbx_all cbx_all
end type
global w_ljmail_manager_fx w_ljmail_manager_fx

forward prototypes
public function integer wf_treeview ()
public function integer wf_retrieve_list (long arg_boxid)
end prototypes

public function integer wf_treeview ();int rslt = 1

// 清空treeview
tv_1.SetRedraw(false)
DO UNTIL tv_1.FindItem(RootTreeItem!, 0) = -1
	tv_1.DeleteItem(0)
LOOP
tv_1.SetRedraw(true)

// 获取sys_ds_ljmailbox
string arg_msg
long i, row
if (sys_ds_ljmailbox.RowCount() <= 0) then
	oleobject list, item
	list = FXAppCom.GetLjmailBox(app_token_fx, ref arg_msg)
	if (arg_msg <> '') then
		rslt = 0
		goto ext
	end if
	
	sys_ds_ljmailbox.Reset()
	for i = 1 to list.Count
		item = list.GetItem(i - 1)
		row = sys_ds_ljmailbox.InsertRow(0)
		
		sys_ds_ljmailbox.Object.boxid[row] = item.GetInt('boxid')
		sys_ds_ljmailbox.Object.boxname[row] = item.GetString('boxname')
		sys_ds_ljmailbox.Object.empid[row] = item.GetInt('empid')
		sys_ds_ljmailbox.Object.parentid[row] = item.GetInt('parentid')
		sys_ds_ljmailbox.Object.boxtype[row] = item.GetInt('boxtype')
	next
	
	sys_ds_ljmailbox.SetSort('boxtype,boxid')
	sys_ds_ljmailbox.Sort()
end if

// 构建treeview
tv_1.SetRedraw(false)
long ll_hand_root, ll_hand
string boxname
long boxid, boxtype, picIndex
treeviewitem l_tvi
ll_hand_root = tv_1.InsertItemLast(0,'我的邮箱',1)
IF tv_1.GetItem(ll_hand_root, l_tvi) = 1 THEN
	l_tvi.Data  = 0
	tv_1.SetItem(ll_hand_root, l_tvi)
END IF

for i = 1 to sys_ds_ljmailbox.RowCount()
	boxtype = sys_ds_ljmailbox.Object.boxtype[i]
	if (boxtype = 1 or boxtype = 2 or boxtype = 3 or boxtype = 4) then // 图片分别对应
		picIndex = boxtype + 1
	else
		picIndex = 1
	end if
	
	boxid = sys_ds_ljmailbox.Object.boxid[i]
	boxname = sys_ds_ljmailbox.Object.boxname[i]
	
	ll_hand = tv_1.InsertItemLast(ll_hand_root, boxname, picIndex)
	IF tv_1.GetItem(ll_hand, l_tvi) = 1 THEN
		l_tvi.Label = boxname
		l_tvi.Data  = boxid
		tv_1.SetItem(ll_hand, l_tvi)
	END IF
next
tv_1.ExpandItem(ll_hand_root)
tv_1.SetRedraw(true)

ext:
if (rslt = 0) then
	MessageBox('提示', '获取邮箱失败:' + arg_msg)
end if
return rslt
end function

public function integer wf_retrieve_list (long arg_boxid);int rslt = 1

if IsNull(arg_boxid) then return 1

dw_1.Reset()

if (arg_boxid < 0) then return 1

string arg_msg
oleobject list, item
list = FXAppCom.GetLjmailByBoxid(app_token_fx, arg_boxid, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

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.msgid[row] = item.GetInt('msgid')
	dw_1.Object.boxid[row] = item.GetInt('boxid')
	dw_1.Object.sendcomid[row] = item.GetInt('sendcomid')
	dw_1.Object.sendcomname[row] = item.GetString('sendcomname')
	dw_1.Object.sendempid[row] = item.GetInt('sendempid')
	dw_1.Object.sendempname[row] = item.GetString('sendempname')
	dw_1.Object.sendflag[row] = item.GetInt('sendflag')
	dw_1.Object.opemp[row] = item.GetString('opemp')
	if not IsNull(item.GetDateTime('opdate')) then
		dw_1.Object.opdate[row] = item.GetDateTime('opdate')
	end if
	dw_1.Object.modemp[row] = item.GetString('modemp')
	if not IsNull(item.GetDateTime('moddate')) then
		dw_1.Object.moddate[row] = item.GetDateTime('moddate')
	end if
	dw_1.Object.subject[row] = item.GetString('subject')
	dw_1.Object.htmlbody[row] = item.GetString('htmlbody')
	dw_1.Object.reltype[row] = item.GetInt('reltype')
	dw_1.Object.relid[row] = item.GetInt('relid')
	if not IsNull(item.GetDateTime('sendtime')) then
		dw_1.Object.sendtime[row] = item.GetDateTime('sendtime')
	end if
	dw_1.Object.ljmail[row] = item.GetString('ljmail')
	dw_1.Object.ifread[row] = item.GetInt('ifread')
	dw_1.Object.serialnum[row] = item.GetString('serialnum')
	dw_1.Object.subjectmin[row] = item.GetString('subjectmin')
	dw_1.Object.comname[row] = item.GetString('comname')
next

if (arg_boxid > 0) then
	long boxtype
	row = sys_ds_ljmailbox.Find('boxid = ' + string(arg_boxid), 1, sys_ds_ljmailbox.RowCount())
	if (row > 0) then
		boxtype = sys_ds_ljmailbox.Object.boxtype[row]
		if (boxtype = 1 or boxtype = 3) then // 收\已发
			dw_1.SetSort('sendtime desc')
		else // 待发(草稿)\废
			dw_1.SetSort('opdate desc')
		end if
		dw_1.Sort()
	end if
else
	dw_1.SetSort('opdate desc')
	dw_1.Sort()
end if
dw_1.SetRedraw(true)

if (dw_1.RowCount() > 0) then
	dw_1.post event RowFocusChanged(1)
else
	uo_1.uf_sethtml('')
end if

ext:
if (rslt = 0) then
	MessageBox('提示', '获取邮件列表失败:' + arg_msg)
end if
return rslt
end function

on w_ljmail_manager_fx.create
int iCurrent
call super::create
this.tv_1=create tv_1
this.dw_1=create dw_1
this.uo_1=create uo_1
this.cbx_all=create cbx_all
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.tv_1
this.Control[iCurrent+2]=this.dw_1
this.Control[iCurrent+3]=this.uo_1
this.Control[iCurrent+4]=this.cbx_all
end on

on w_ljmail_manager_fx.destroy
call super::destroy
destroy(this.tv_1)
destroy(this.dw_1)
destroy(this.uo_1)
destroy(this.cbx_all)
end on

event open;call super::open;// 获取邮箱，treeview
if (wf_treeview() <> 1) then
	Close(this)
	return
end if

uo_1.uf_setreadonly( )
end event

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

uo_1.Width = this.workspacewidth( )
uo_1.Height = this.workspaceheight( ) - uo_1.Y

cb_exit.X = this.workspacewidth( ) - cb_exit.Width
end event

type cb_func from w_publ_base_style`cb_func within w_ljmail_manager_fx
boolean visible = false
boolean enabled = false
string normalpicname = "setting.BMP"
integer picsize = 16
end type

type cb_exit from w_publ_base_style`cb_exit within w_ljmail_manager_fx
integer x = 2272
end type

type ln_bar from w_publ_base_style`ln_bar within w_ljmail_manager_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_ljmail_manager_fx
long linecolor = 268435456
integer beginy = 168
integer endy = 168
end type

type r_bar from w_publ_base_style`r_bar within w_ljmail_manager_fx
end type

type tv_1 from treeview within w_ljmail_manager_fx
integer y = 272
integer width = 695
integer height = 880
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
string picturename[] = {"email_one.bmp","email_rev.bmp","email_sent.bmp","email_send.bmp","email_dust.bmp"}
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type

event clicked;treeviewitem tvi
long boxid
if (this.GetItem(handle, tvi) = 1) then
	boxid = tvi.Data
	if (not IsNull(boxid) and boxid >= 0) then
		wf_retrieve_list(boxid)
	end if
end if
end event

type dw_1 from u_dw_rbtnfilter within w_ljmail_manager_fx
integer x = 695
integer y = 272
integer width = 4023
integer height = 880
integer taborder = 20
boolean bringtotop = true
string dataobject = "dw_ljmail_msg_list"
boolean hscrollbar = true
boolean vscrollbar = 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

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 rowfocuschanged;call super::rowfocuschanged;if IsNull(currentrow) then return
if (currentrow <= 0) then return

string html
html = this.Object.htmlbody[currentrow]

uo_1.uf_sethtml(html)
end event

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

long msgid
msgid = this.Object.msgid[row]
if not IsNull(msgid) then
	if (msgid > 0) then
		OpenWithParm(w_ljmail_msg_fx, msgid)
	end if
end if
end event

type uo_1 from uo_html_editor within w_ljmail_manager_fx
integer y = 1152
integer width = 3291
integer height = 1140
integer taborder = 30
boolean bringtotop = true
end type

on uo_1.destroy
call uo_html_editor::destroy
end on

type cbx_all from checkbox within w_ljmail_manager_fx
integer x = 722
integer y = 192
integer width = 251
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "全选"
end type

