$PBExportHeader$w_email_set_list.srw forward global type w_email_set_list from w_publ_base end type type r_bar from rectangle within w_email_set_list end type type tv_1 from treeview within w_email_set_list end type type lv_1 from listview within w_email_set_list end type type cb_1 from uo_imflatbutton within w_email_set_list end type type cb_2 from uo_imflatbutton within w_email_set_list end type type cb_3 from uo_imflatbutton within w_email_set_list end type type cb_4 from uo_imflatbutton within w_email_set_list end type type ln_bar from line within w_email_set_list end type type ln_bar2 from line within w_email_set_list end type end forward global type w_email_set_list from w_publ_base integer width = 2747 integer height = 1908 string title = "邮箱账号管理" boolean maxbox = true boolean resizable = true windowstate windowstate = maximized! r_bar r_bar tv_1 tv_1 lv_1 lv_1 cb_1 cb_1 cb_2 cb_2 cb_3 cb_3 cb_4 cb_4 ln_bar ln_bar ln_bar2 ln_bar2 end type global w_email_set_list w_email_set_list type variables private: long ins_can_see_other = 0 long ins_can_edit = 0 long ins_can_delete = 0 transaction Commit_Tran // 帐号表所有数据库 transaction fj_tran // 邮件附件数据库 end variables forward prototypes private subroutine wf_make_tree () public subroutine wf_listview_dblclk (integer index) private subroutine wf_retrieve_listview () end prototypes private subroutine wf_make_tree ();long ll_root long ll_count,cnt treeviewitem l_tvi tv_1.setredraw(false) long ll_selected, ll_selectedValue = -2 ll_selected = tv_1.Finditem(CurrentTreeItem!, 0) if ll_selected <> -1 then if tv_1.GetItem(ll_selected, l_tvi) = 1 then ll_selectedValue = l_tvi.data end if end if ll_selected = 0 DO UNTIL tv_1.FindItem(RootTreeItem!, 0) = -1 tv_1.DeleteItem(0) LOOP ll_root = tv_1.insertitemlast(0, '所有账号', 1) if tv_1.GetItem(ll_root, l_tvi) = 1 then l_tvi.data = -2 if ll_selectedValue = l_tvi.data then ll_selected = ll_root end if tv_1.SetItem(ll_root, l_tvi) end if long ll_handle ll_handle = tv_1.insertitemlast(ll_root, '(公共账号)', 2) if tv_1.GetItem(ll_handle, l_tvi) = 1 then l_tvi.Data = -1 if ll_selectedValue = l_tvi.data then ll_selected = ll_handle end if ll_count = 0 SELECT count(0) INTO :ll_count FROM u_email_set WHERE ((mailtype = 1)); l_tvi.label = '(公共账号)' + '(' + string(ll_count) + ')' tv_1.SetItem(ll_handle, l_tvi) end if tv_1.selectitem(ll_handle) long ll_empid long ll_id string ls_username // 可以编辑他人的权限 if uo_email_power.can_see_other(sys_msg_pow) then ll_empid = -1 else ll_empid = sys_empid end if long emplist[] emplist[1]=ll_empid f_get_empson(ll_empid, emplist) string ls_sql,emp_str='' for cnt=1 to upperbound(emplist) emp_str+=string(emplist[cnt])+',' next emp_str=mid(emp_str,1,len(emp_str)-1) ls_sql='SELECT Empid, Username'& +' FROM u_user'& +' where (empid in('+emp_str+') or (-1= '+string(ll_empid)+'))'& +' order by Username;' //declare cursor_user cursor for // SELECT Empid, Username // FROM u_user // where (empid in(:ll_empid) or (-1= :ll_empid)) // order by Username; // //open cursor_user; declare cursor_user dynamic cursor for SQLSA; prepare SQLSA from :ls_sql; open DYNAMIC cursor_user; fetch cursor_user INTO :ll_id, :ls_username; do while (sqlca.sqlcode = 0) ll_handle = tv_1.insertitemlast(ll_root, ls_username, 2) if tv_1.GetItem(ll_handle, l_tvi) = 1 then ll_count = 0 SELECT count(0) INTO :ll_count FROM u_email_set WHERE ((mailtype = 0) and (empid = :ll_id)); l_tvi.label = ls_username + '(' + string(ll_count) + ')' l_tvi.data = ll_id if ll_selectedValue = l_tvi.data then ll_selected = ll_handle end if tv_1.SetItem(ll_handle, l_tvi) end if fetch cursor_user INTO :ll_id, :ls_username; loop close cursor_user; tv_1.expandall(ll_root) tv_1.selectitem(ll_selected) tv_1.setredraw(true) end subroutine public subroutine wf_listview_dblclk (integer index);ListViewItem l_lvi s_email_set s_set if lv_1.GetItem(index, l_lvi) = 1 then s_set = l_lvi.data if uo_email_power.can_edit(sys_msg_pow) then s_set.flag = 1 else s_set.flag = 0 end if openWithParm(w_email_set_detail, s_set) wf_retrieve_listview() end if end subroutine private subroutine wf_retrieve_listview ();long ll_handle long arg_empid, arg_mailtype lv_1.setredraw(false) ll_handle = tv_1.finditem(CurrentTreeItem!, 0) if ll_handle = -1 then return treeviewitem l_tvi long ll_empid if tv_1.GetItem(ll_handle, l_tvi) = 1 then arg_empid = l_tvi.data if arg_empid = -1 then // 公共 arg_mailtype = 1 else // 私人 arg_mailtype = 0 end if end if lv_1.deleteitems() declare cursor1 cursor for SELECT mailID, mailuser, mailaddress, popset, popport, smtpset, smtpport, empid, mailtype FROM u_email_set WHERE ((1 = :arg_mailtype) and (mailtype = 1)) OR ((0 = :arg_mailtype) AND (mailtype = 0) and (empid = :arg_empid)); open cursor1; ListViewItem l_lvi s_email_set s_mailset fetch cursor1 INTO :s_mailset.mailid, :s_mailset.mailuser, :s_mailset.mailaddress, :s_mailset.popset, :s_mailset.popport, :s_mailset.smtpset, :s_mailset.smtpport, :s_mailset.empid, :s_mailset.viewtype; do while (sqlca.sqlcode = 0) l_lvi.label = s_mailset.mailuser + '<' + s_mailset.mailaddress + '>' l_lvi.pictureindex = 1 l_lvi.data = s_mailset long ll_index ll_index = lv_1.additem(l_lvi) lv_1.Setitem(ll_index, 2, s_mailset.popset + ':' + string(s_mailset.popport)) lv_1.Setitem(ll_index, 3, s_mailset.smtpset + ':' + string(s_mailset.smtpport)) fetch cursor1 INTO :s_mailset.mailid, :s_mailset.mailuser, :s_mailset.mailaddress, :s_mailset.popset, :s_mailset.popport, :s_mailset.smtpset, :s_mailset.smtpport, :s_mailset.empid, :s_mailset.viewtype; loop close cursor1; lv_1.setredraw(true) end subroutine on w_email_set_list.create int iCurrent call super::create this.r_bar=create r_bar this.tv_1=create tv_1 this.lv_1=create lv_1 this.cb_1=create cb_1 this.cb_2=create cb_2 this.cb_3=create cb_3 this.cb_4=create cb_4 this.ln_bar=create ln_bar this.ln_bar2=create ln_bar2 iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.r_bar this.Control[iCurrent+2]=this.tv_1 this.Control[iCurrent+3]=this.lv_1 this.Control[iCurrent+4]=this.cb_1 this.Control[iCurrent+5]=this.cb_2 this.Control[iCurrent+6]=this.cb_3 this.Control[iCurrent+7]=this.cb_4 this.Control[iCurrent+8]=this.ln_bar this.Control[iCurrent+9]=this.ln_bar2 end on on w_email_set_list.destroy call super::destroy destroy(this.r_bar) destroy(this.tv_1) destroy(this.lv_1) destroy(this.cb_1) destroy(this.cb_2) destroy(this.cb_3) destroy(this.cb_4) destroy(this.ln_bar) destroy(this.ln_bar2) end on event open;call super::open;if sys_project = 0 then //L1权限 ins_can_see_other = 2571 ins_can_edit = 2572 ins_can_delete = 2573 elseif sys_project = 1 then // ecl权限 ins_can_see_other =1411 //2571可以看其它人的 ins_can_edit = 1412 //可以修改的 ins_can_delete = 1444 //可以删除的 end if commit_tran = sqlca Long ll_ConnectionID String arg_msg Int li_ifexit = 0 IF sys_email_sqlca.DBHandle() > 0 THEN fj_tran = sys_email_sqlca ELSE MessageBox('系统提示','要使用邮件功能,请先定义邮件数据库') li_ifexit = 1 END IF IF li_ifexit = 0 THEN wf_make_tree() tv_1.SetFocus( ) ELSE cb_exit.PostEvent(Clicked!) END IF end event event resize;call super::resize;r_bar.width = this.width tv_1.height = newheight - tv_1.y - 8 lv_1.height = tv_1.height lv_1.width = newwidth - lv_1.x - 8 ln_bar.endx = newwidth ln_bar2.endx = newwidth end event event close;call super::close;if isvalid(w_email_view) then // 刷新邮件界面 string ls_msg w_email_view.wf_init(ls_msg) end if end event type cb_func from w_publ_base`cb_func within w_email_set_list boolean visible = false integer x = 1888 integer y = 1600 integer width = 311 integer height = 96 string text = "功能" string normalpicname = "" integer picsize = 0 toolbaralignment pic_align = alignatleft! boolean border = true end type type cb_exit from w_publ_base`cb_exit within w_email_set_list integer x = 965 integer width = 192 integer height = 164 integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type type r_bar from rectangle within w_email_set_list long linecolor = 16777215 integer linethickness = 4 long fillcolor = 1073741824 integer x = 1166 integer width = 229 integer height = 92 end type event constructor;this.fillcolor = 14215660 this.linecolor = 14215660 this.x = -1 this.y = -1 this.height = ln_bar.beginy - 5 end event type tv_1 from treeview within w_email_set_list integer y = 176 integer width = 869 integer height = 1604 integer taborder = 10 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_all.bmp","email_one.bmp"} long picturemaskcolor = 536870912 long statepicturemaskcolor = 536870912 end type event selectionchanged;wf_retrieve_listView() end event type lv_1 from listview within w_email_set_list integer x = 873 integer y = 180 integer width = 1819 integer height = 1592 integer taborder = 10 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! boolean extendedselect = true boolean fullrowselect = true listviewview view = listviewreport! string largepicturename[] = {"email_one.bmp"} long largepicturemaskcolor = 536870912 string smallpicturename[] = {"email_one.bmp"} long smallpicturemaskcolor = 536870912 long statepicturemaskcolor = 536870912 end type event constructor;This.AddColumn("账号" , Left! , 1000) This.AddColumn("POP服务" , Left! , 600) This.AddColumn("SMTP服务" , Left! , 600) end event event doubleclicked;wf_listview_dblclk(index) end event type cb_1 from uo_imflatbutton within w_email_set_list integer width = 192 integer height = 164 integer taborder = 10 boolean bringtotop = true string text = "添加" string normalpicname = "new.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;if not uo_email_power.can_edit(sys_msg_pow) then MessageBox(publ_operator,'你没有添加邮箱账号的权限') return end if long ll_handle ll_handle = tv_1.findItem(CurrentTreeItem!, 0) if ll_handle = -1 then Messagebox('提示', '请先选择账号所属') tv_1.setfocus( ) return end if treeviewitem l_tvi s_email_set s_set long ll_empid if tv_1.GetItem(ll_handle, l_tvi) = 1 then ll_empid = l_tvi.data if ll_empid = -2 then Messagebox('提示', '请先选择账号所属') tv_1.setfocus( ) return elseif ll_empid = -1 then s_set.mailid = 0 s_set.empid = 0 s_set.viewtype = 1 elseif ll_empid >= 0 then s_set.mailid = 0 s_set.empid = ll_empid s_set.viewtype = 0 end if s_set.flag = 1 openwithparm(w_email_set_detail, s_set) wf_make_tree() // wf_retrieve_listView() end if end event type cb_2 from uo_imflatbutton within w_email_set_list integer x = 192 integer width = 192 integer height = 164 integer taborder = 20 boolean bringtotop = true string text = "修改" string normalpicname = "open.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;if not uo_email_power.can_edit(sys_msg_pow) then MessageBox(publ_operator,'你没有修改邮箱账号的权限') return end if if lv_1.totalselected( ) < 1 then MessageBox('提示', '请先选择要修改的账号') return elseif lv_1.totalselected( ) > 1 then MessageBox('提示', '多选状态下不能修改') return end if wf_listView_dblclk(lv_1.selectedindex( )) end event type cb_3 from uo_imflatbutton within w_email_set_list integer x = 384 integer width = 192 integer height = 164 integer taborder = 30 boolean bringtotop = true string text = "删除" string normalpicname = "delete.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;if not uo_email_power.can_delete(sys_msg_pow) then MessageBox(publ_operator,sys_msg_pow) return end if if lv_1.totalselected( ) <= 0 then Messagebox('提示', '请选择要删除的账号') return end if IF MessageBox ("询问","是否确定要删除选中的邮箱账号?(选择确定后记录将不可恢复)",Question!,YesNo! ) = 2 THEN RETURN END IF uo_email_set uo_set uo_set.commit_tran = commit_tran uo_set.fj_tran = fj_tran s_email_set s_set listViewItem l_lvi string ls_msg, ls_sum = '' long ll_handle = 0 ll_handle = lv_1.finditem(ll_handle, DirectionAll!, false, true, false, false) do while (ll_handle > 0) if lv_1.GetItem(ll_handle, l_lvi) = 1 then s_set = l_lvi.data if uo_set.uf_del(s_set.mailid, ls_msg) <> 1 then ls_sum = ls_sum + '删除' + s_set.mailaddress + '失败~t' + ls_msg + '~r~n' end if end if ll_handle = lv_1.finditem(ll_handle, DirectionAll!, false, true, false, false) loop if ls_msg <> '' then MessageBox('错误', ls_sum) end if wf_make_tree() //wf_retrieve_listview() end event type cb_4 from uo_imflatbutton within w_email_set_list integer x = 576 integer width = 384 integer height = 164 integer taborder = 20 boolean bringtotop = true string text = "邮箱类型转换" string normalpicname = "imexport.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;// //if not f_power_ind(3351,sys_msg_pow) then // MessageBox(publ_operator,'你没有修改邮箱类型的权限') // return //end if if lv_1.totalselected( ) < 1 then MessageBox('提示', '请先选择要修改的账号') return elseif lv_1.totalselected( ) > 1 then MessageBox('提示', '多选状态下不能修改') return end if long index index=lv_1.selectedindex( ) ListViewItem l_lvi s_email_set s_set if lv_1.GetItem(index, l_lvi) = 1 then s_set = l_lvi.data openWithParm(w_email_set_mailtype, s_set.mailid) wf_retrieve_listview() end if end event type ln_bar from line within w_email_set_list long linecolor = 268435456 integer linethickness = 4 integer beginy = 172 integer endx = 1961 integer endy = 172 end type type ln_bar2 from line within w_email_set_list long linecolor = 16777215 integer linethickness = 4 integer beginy = 176 integer endx = 1993 integer endy = 176 end type