$PBExportHeader$uo_email_box.sru forward global type uo_email_box from nonvisualobject end type end forward global type uo_email_box from nonvisualobject end type global uo_email_box uo_email_box type variables long boxid string boxname long isdefault long mailid string boxtype long parentid long picindex Transaction commit_tran Transaction fj_tran PROTECTEDWRITE string C_inbox = '收件箱' PROTECTEDWRITE string C_outbox = '发件箱' PROTECTEDWRITE string C_sentbox = '已发件箱' PROTECTEDWRITE string C_trunkbox = '废件箱' PROTECTEDWRITE string C_userDefine = '新邮箱' end variables forward prototypes public function integer uf_newbox (long arg_mailid, long arg_parentid, string arg_name, boolean arg_if_commit, ref string arg_msg) public function integer p_getinfo (long arg_boxid, ref string arg_msg) public function integer uf_rename (long arg_boxid, string arg_newname, ref string arg_msg) public function integer uf_del (long arg_boxid, ref string arg_msg) end prototypes public function integer uf_newbox (long arg_mailid, long arg_parentid, string arg_name, boolean arg_if_commit, ref string arg_msg);int rslt = 1 long ll_boxid ll_boxid = f_sys_scidentity(0,"u_email_box","boxid",arG_MSG,False, commit_tran) if ll_boxid <= 0 then rslt = 0 goto ext end if long ll_ifdefault string ls_boxtype long ll_picindex if arg_name = C_inbox OR arg_name = C_outbox OR arg_name = C_sentbox OR arg_name = C_trunkbox then ll_ifdefault = 1 ls_boxtype = arg_name if arg_name = C_inbox then ll_picindex = 3 elseif arg_name = C_outbox then ll_picindex = 4 elseif arg_name = C_sentbox then ll_picindex = 5 elseif arg_name = C_trunkbox then ll_picindex = 6 end if else ll_ifdefault = 0 ls_boxtype = C_userDefine ll_picindex = 9 end if INSERT INTO u_email_box (boxid ,boxname ,isdefault ,mailid ,boxtype ,parentid ,picindex) VALUES (:ll_boxid ,:arg_name ,:ll_ifdefault ,:arg_mailid ,:ls_boxtype ,:arg_parentid ,:ll_picindex) using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '新建子目录失败,' + commit_tran.sqlerrtext goto ext end if boxid = ll_boxid boxname = arg_name isdefault = ll_ifdefault mailid = arg_mailid boxtype = ls_boxtype parentid = arg_parentid picindex = ll_picindex ext: if rslt = 0 then rollback using commit_tran; elseif arg_if_commit then commit using commit_tran; end if return rslt end function public function integer p_getinfo (long arg_boxid, ref string arg_msg);int rslt = 1 if arg_boxid <= 0 then rslt = 0 arg_msg = '非法唯一码' goto ext end if long ll_cnt SELECT COUNT(0) INTO :ll_cnt FROM u_email_box WHERE boxid = :arg_boxid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '查询邮箱数量失败,' + commit_tran.sqlerrtext goto ext end if if ll_cnt = 0 then rslt = 0 arg_msg = '邮箱不存在' goto ext end if SELECT boxid ,boxname ,isdefault ,mailid ,boxtype ,parentid ,picindex INTO :boxid, :boxname, :isdefault, :mailid, :boxtype, :parentid, :picindex FROM u_email_box WHERE boxid = :arg_boxid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '查询邮箱资料失败,' + commit_tran.sqlerrtext goto ext end if ext: return rslt end function public function integer uf_rename (long arg_boxid, string arg_newname, ref string arg_msg);int rslt = 1 if p_getinfo(arg_boxid, arg_msg) <> 1 then rslt = 0 goto ext end if if isdefault = 1 then rslt = 0 arg_msg = '默认邮箱不能重命名' goto ext end if UPDATE u_email_box SET boxname = :arg_newname WHERE boxid = :arg_boxid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '目录重命名失败,' + commit_tran.sqlerrtext goto ext end if boxname = arg_newname ext: if rslt = 0 then rollback using commit_tran; else commit using commit_tran; end if return rslt end function public function integer uf_del (long arg_boxid, ref string arg_msg);int rslt = 1 if p_getinfo(arg_boxid, arg_msg) <> 1 then rslt = 0 goto ext end if long ll_cnt SELECT COUNT(0) INTO :ll_cnt FROM u_email_msg WHERE boxid = :arg_boxid using fj_tran; if fj_tran.sqlcode <> 0 then rslt = 0 arg_msg = '查询邮箱内邮件数量失败,' + fj_tran.sqlerrtext goto ext end if if ll_cnt > 0 then rslt = 0 arg_msg = '邮箱内含有邮件,不能删除' goto ext end if SELECT COUNT(0) INTO :ll_cnt FROM u_email_box WHERE parentid = :arg_boxid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '查询子邮箱数量失败,' + commit_tran.sqlerrtext goto ext end if if ll_cnt > 0 then rslt = 0 arg_msg = '邮箱内包含子邮箱,不能删除' goto ext end if if isdefault = 1 then rslt = 0 arg_msg = '默认邮箱不能删除' goto ext end if DELETE FROM u_email_box WHERE boxid = :arg_boxid using commit_tran; if commit_tran.sqlcode <> 0 then rslt = 0 arg_msg = '删除邮箱失败,' + commit_tran.sqlerrtext goto ext end if ext: if rslt = 0 then rollback using commit_tran; else commit using commit_tran; end if return rslt end function on uo_email_box.create call super::create TriggerEvent( this, "constructor" ) end on on uo_email_box.destroy TriggerEvent( this, "destructor" ) call super::destroy end on