$PBExportHeader$uo_sendtoexcel.sru forward global type uo_sendtoexcel from nonvisualobject end type end forward global type uo_sendtoexcel from nonvisualobject event oe_invoke_ouerevent ( long arg_tid, long arg_actionid, uo_sendtoexcel obj_sendtoexcel ) event oe_sendtoexcel ( s_xls_billlist str_billlist ) end type global uo_sendtoexcel uo_sendtoexcel type variables Transaction commit_transaction //数据commit事务 datastore ds string userpwd = '' int use_userpwd = 0 uo_xls_constant uo_const powerobject TriggerEventObject string TriggerEventName string cur_biltype = '' private: boolean ifsetting = false //s_xls_bill s_bill_info s_xls_templates s_tem uo_xlsmanager obj_xls long actionid boolean allowedit boolean ifclose end variables forward prototypes private function integer of_gettemplatesdata (ref s_xls_templates arg_tem, ref string arg_msg) private function integer of_getcolumninfo (ref s_xls_bill arg_bill_info, s_xls_templates arg_tem, ref string arg_msg) public function s_xls_billlist of_getbillinfo (long arg_templateid, ref string arg_msg) public function datastore of_getbillinfo_ds (long arg_billid, ref string arg_msg) public function datastore of_getbillcolumninfo_ds (long arg_billid, ref string arg_msg) private function integer of_activetemplate (ref string arg_msg) public function integer of_setxlsmax (ref string arg_msg) public function integer of_set_screenupdating (boolean ifupdate, ref string arg_msg) public function integer of_setsign (string arg_signname, integer arg_flag, integer arg_type, string arg_billflag, string arg_billname, boolean arg_chk, boolean arg_addchk, ref string arg_msg) public function integer of_templateedit_init (olecontrol arg_ole, long arg_templateid, ref string arg_msg) public function integer of_lock_xls (boolean iflock, ref string arg_msg) public function integer of_check_sign (ref string arg_msg) public function integer of_updatetemplate (boolean arg_ifcommit, ref string arg_msg) public function integer of_setexcelwindowsize (integer arg_windowstate, string arg_msg) public function s_xls_templates of_gettemplatedata (long arg_billid, long arg_templatesid, ref string arg_msg) public function integer of_delete_template (long arg_billid, long arg_templatesid, boolean ifcommint, string arg_msg) public function integer of_disconnect (ref string arg_msg) public function integer of_setoption (long arg_actionid, boolean arg_allowedit, boolean arg_ifclose, ref string arg_msg) protected function menu of_createitembytype (string arg_billtype, string arg_allow_print_tpidlist, string arg_allow_send_tpidlist) public function menu of_createmenu (string arg_billtype, string arg_allow_print_tpidlist, string arg_allow_send_tpidlist) public function integer of_inserttemplate (long arg_tid, blob arg_template, string arg_templatename, integer arg_ifpic, ref string arg_msg, boolean ifcommint) public function integer of_updatetemp_ifpic (long arg_tid, long arg_templatesid, string arg_templatesname, integer arg_ifpic, ref string arg_msg, boolean arg_ifcommit) public function datastore of_getbillinfo_ds_panel (long arg_billid, ref string arg_msg) end prototypes event oe_invoke_ouerevent(long arg_tid, long arg_actionid, uo_sendtoexcel obj_sendtoexcel);if IsValid(TriggerEventObject) then TriggerEventObject.triggerevent( TriggerEventName,arg_tid,arg_actionid) end event event oe_sendtoexcel(s_xls_billlist str_billlist); IF Not ifsetting THEN RETURN String arg_msg //uo_const.create_new_pwd( ) s_tem.templatesid = str_billlist.templateid IF of_gettemplatesdata(s_tem,arg_msg) <> 1 THEN RETURN ///////////// // s_tem.templates = str_billlist.templates s_tem.templatesname = str_billlist.templatesname s_tem.tid = str_billlist.billid s_tem.templatesid = str_billlist.templateid w_xls w_ole Open(w_ole) w_ole.ole_1.DisplayName = s_tem.templatesname +String(Today(),'yyyy-mm-dd hh:mm:ss')+String(Rand(30000)) w_ole.ole_1.ObjectData = s_tem.templates obj_xls.str_billlist = str_billlist obj_xls.s_tem = s_tem obj_xls.uo_const = uo_const obj_xls.ole_con = w_ole.ole_1 obj_xls.ins_w_ole=w_ole obj_xls.AllowEdit = AllowEdit obj_xls.ifclose = ifclose obj_xls.actionid = actionid IF obj_xls.of_sendtoexcel(arg_msg) <> 1 THEN MessageBox('错误',arg_msg) END IF end event private function integer of_gettemplatesdata (ref s_xls_templates arg_tem, ref string arg_msg);TRY if isnull(arg_msg) then arg_msg = '' SELECT TemplatesName,id,tid INTO :arg_tem.TemplatesName, :arg_tem.templatesid, :arg_tem.tid FROM U_XLS_Templates Where id = :arg_tem.templatesid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = " 查询模版失败" RETURN 0 END IF SELECTBLOB Templates INTO :arg_tem.Templates FROM U_XLS_Templates Where id = :arg_tem.templatesid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = " 查询模版失败" RETURN 0 END IF IF IsNull(s_tem.Templates) THEN arg_msg = '模版不存在' RETURN 0 END IF Catch(runtimeerror err) arg_msg = err.Text RETURN 0 END TRY RETURN 1 end function private function integer of_getcolumninfo (ref s_xls_bill arg_bill_info, s_xls_templates arg_tem, ref string arg_msg);Long rslt = 1,i = 0,cnt = 0 //arg_bill_info.billid = 0 arg_bill_info.billname = '' arg_bill_info.datawindow = '' arg_bill_info.count = 0 SELECT billid, billname, DefaultDataWindow INTO :arg_bill_info.billid, :arg_bill_info.billname, :arg_bill_info.datawindow FROM U_XLS_BillList Where billid = :arg_tem.tid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "读取单据信息失败" GOTO ext END IF i = 1 cnt = 0 SELECT count(*) INTO :cnt FROM U_XLS_BillColumn_Def Where billid = :arg_tem.tid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,单据字段数量" GOTO ext END IF open(w_xls_sys_wait_jdt) //初始化进度条 w_xls_sys_wait_jdt.show() w_xls_sys_wait_jdt.wf_accepttol(cnt) w_xls_sys_wait_jdt.wf_inc(0) w_xls_sys_wait_jdt.st_msg.text="正在获取字段信息..." s_xls_bill_column column[] DECLARE cur_column CURSOR FOR SELECT ColumnID, ColumnName , SignNAME, ColumnType FROM U_XLS_BillColumn_Def Where billid = :arg_tem.tid USING commit_transaction; OPEN cur_column; FETCH cur_column INTO :column[i].ColumnID, :column[i].ColumnName, :column[i].SignNAME, :column[i].ColumnType; DO WHILE commit_transaction.SQLCode = 0 column[i].SignNAME = uo_const.sign_begin+ column[i].SignNAME + uo_const.sign_end w_xls_sys_wait_jdt.wf_inc(i) i++ FETCH cur_column INTO :column[i].ColumnID, :column[i].ColumnName, :column[i].SignNAME, :column[i].ColumnType; LOOP CLOSE cur_column; IF i <> (cnt+1) THEN rslt = 0 arg_msg = "查询操作失败,单据字段数量" GOTO ext END IF arg_bill_info.count = cnt arg_bill_info.column = column ext: close(w_xls_sys_wait_jdt) RETURN rslt end function public function s_xls_billlist of_getbillinfo (long arg_templateid, ref string arg_msg);s_xls_billlist str_billlist,null_billlist Long rslt = 1 //Long ll_billid //IF IsNull(arg_msg) THEN arg_msg = '' //SELECT billid // INTO :ll_billid // FROM U_XLS_BillList INNER JOIN // U_XLS_Templates ON U_XLS_BillList.BillID = U_XLS_Templates.tid // WHERE (U_XLS_Templates.id = :arg_templateid) // Using commit_transaction; //IF commit_transaction.SQLCode <> 0 THEN // arg_msg += '~n查询单据ID失败~n'+commit_transaction.SQLErrText // rslt = 0 // GOTO ext //END IF //str_billlist.billid = ll_billid str_billlist.templateid = arg_templateid str_billlist.count = 0 s_tem.templatesid = str_billlist.templateid IF of_gettemplatesdata(s_tem,arg_msg) <> 1 THEN rslt = 0 GOTO ext END IF str_billlist.billid = s_tem.tid str_billlist.templates = s_tem.templates str_billlist.templatesname = s_tem.templatesname datastore ds_bill,ds_column ds_bill = THIS.of_getbillinfo_ds( str_billlist.billid, arg_msg) IF IsNull( ds_bill) THEN rslt = 0 GOTO ext END IF IF ds_bill.RowCount( ) <= 0 THEN rslt = 0 arg_msg += '该单据还没有定义字段标记' GOTO ext END IF s_xls_bill_column s_column s_xls_bill s_bill Long i,j FOR i = 1 TO ds_bill.RowCount( ) s_bill.billid = ds_bill.Object.billid[i] s_bill.billname = ds_bill.Object.billname[i] s_bill.datawindow = ds_bill.Object.defaultdatawindow[i] s_bill.billtype = ds_bill.Object.billtype[i] s_bill.Sign = ds_bill.Object.u_xls_billlist_sign[i] s_bill.billflag = ds_bill.Object.billflag[i] s_bill.parentid = ds_bill.Object.parentid[i] s_bill.ds_data = CREATE datastore s_bill.ds_data.DataObject = s_bill.datawindow s_bill.ds_data.SetTransObject(commit_transaction) s_bill.count = 0 ds_column = THIS.of_getbillcolumninfo_ds( str_billlist.billid, arg_msg) IF IsNull( ds_column) THEN rslt = 0 GOTO ext END IF FOR j = 1 TO ds_column.RowCount( ) IF ds_column.Object.u_xls_billcolumn_def_columnid[j] = 0 THEN CONTINUE IF ds_column.Object.u_xls_billcolumn_def_billid[j] <> s_bill.billid THEN CONTINUE s_column.columnid = ds_column.Object.u_xls_billcolumn_def_columnid[j] s_column.columnname = ds_column.Object.u_xls_billcolumn_def_columnname[j] s_column.signname = ds_column.Object.u_xls_billcolumn_def_signname[j] s_column.signnameformat = ds_column.Object.efname[j] s_column.columntype = ds_column.Object.u_xls_billcolumn_def_columntype[j] s_bill.count++ s_bill.column[s_bill.count] = s_column NEXT str_billlist.count++ str_billlist.bill[str_billlist.count] = s_bill NEXT ext: IF rslt = 1 THEN RETURN str_billlist ELSE RETURN null_billlist END IF end function public function datastore of_getbillinfo_ds (long arg_billid, ref string arg_msg);datastore ids_bill ids_bill = create datastore ids_bill.dataobject = 'ds_xls_bill' ids_bill.settransobject(commit_transaction) if isnull(arg_msg) then arg_msg = '' if ids_bill.retrieve(arg_billid,uo_const.sign_begin ,uo_const.sign_end) < 0 then arg_msg+="~n查询单据列表失败~n"+commit_transaction.sqlerrtext setnull(ids_bill) end if return ids_bill end function public function datastore of_getbillcolumninfo_ds (long arg_billid, ref string arg_msg);datastore ids_bill ids_bill = create datastore ids_bill.dataobject = 'ds_xls_billcolumn' ids_bill.settransobject(commit_transaction) if isnull(arg_msg) then arg_msg = '' if ids_bill.retrieve(arg_billid,uo_const.sign_begin ,uo_const.sign_end) < 0 then arg_msg+="~n查询单据列表失败~n"+commit_transaction.sqlerrtext setnull(ids_bill) end if return ids_bill end function private function integer of_activetemplate (ref string arg_msg);long rslt = 1 try if IsValid(obj_xls) then obj_xls.of_activetemplate() obj_xls.of_set_caption(False) end if catch(runtimeerror err) arg_msg +=err.text rslt = 0 end try return rslt end function public function integer of_setxlsmax (ref string arg_msg);long rslt = 1 try if IsValid (obj_xls) then obj_xls.of_setxlsmax() catch(runtimeerror err) arg_msg +=err.text rslt = 0 end try return rslt end function public function integer of_set_screenupdating (boolean ifupdate, ref string arg_msg);TRY if IsValid(obj_xls) then obj_xls.of_set_screenupdating(ifupdate ) Catch(runtimeerror err) arg_msg = err.Text RETURN 0 END TRY RETURN 1 end function public function integer of_setsign (string arg_signname, integer arg_flag, integer arg_type, string arg_billflag, string arg_billname, boolean arg_chk, boolean arg_addchk, ref string arg_msg);try if IsValid(obj_xls) then obj_xls.of_setsign(arg_signname,arg_flag,arg_type,arg_billflag,arg_billname,arg_chk,arg_addchk) catch(runtimeerror err) arg_msg = err.text return 0 end try return 1 end function public function integer of_templateedit_init (olecontrol arg_ole, long arg_templateid, ref string arg_msg);Long rslt = 1 IF IsNull(arg_msg) THEN arg_msg = '' IF IsNull(arg_templateid) THEN arg_templateid = 0 IF Not IsValid(arg_ole) THEN arg_msg += '连接olecontrol失败!' rslt = 0 GOTO ext END IF Long ll_billid SELECT billid INTO :ll_billid FROM U_XLS_BillList INNER JOIN U_XLS_Templates ON U_XLS_BillList.BillID = U_XLS_Templates.tid WHERE (U_XLS_Templates.id = :arg_templateid) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg += '~n查询单据ID失败~n'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF s_tem = of_gettemplatedata(ll_billid,arg_templateid,arg_msg) IF IsNull(s_tem.templates ) Or s_tem.templatesname = '' THEN arg_msg += '查询相应模版失败,模版可能不存在' rslt = 0 GOTO ext END IF arg_ole.DisplayName = s_tem.templatesname +String(Today(),'yyyy-mm-dd hh:mm:ss')+String(Rand(30000)) arg_ole.ObjectData = s_tem.templates obj_xls.s_tem = s_tem obj_xls.uo_const = uo_const obj_xls.ole_con = arg_ole IF of_activetemplate(arg_msg) <> 1 THEN rslt = 0 GOTO ext END IF ext: RETURN rslt end function public function integer of_lock_xls (boolean iflock, ref string arg_msg);TRY if not IsValid(obj_xls) then return 1 IF iflock THEN obj_xls.of_workbooklock( ) ELSE obj_xls.of_workbookunlock( ) END IF Catch(runtimeerror err) arg_msg = err.Text RETURN 0 END TRY RETURN 1 end function public function integer of_check_sign (ref string arg_msg);return 1 end function public function integer of_updatetemplate (boolean arg_ifcommit, ref string arg_msg); IF IsNull(s_tem.templates ) THEN arg_msg = '模版内容为空!' RETURN 0; END IF if of_check_sign(arg_msg) <> 1 then return 0 s_tem.templates = obj_xls.ole_con.ObjectData TRY UPDATEBLOB U_XLS_Templates Set templates = :s_tem.templates Where U_XLS_Templates.tid = :s_tem.tid AND U_XLS_Templates.ID = :s_tem.templatesid using commit_transaction; IF commit_transaction.SQLDBCode = 0 THEN IF arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN 1 ELSE ROLLBACK USING commit_transaction; arg_msg = "更新模版失败" RETURN 0 END IF Catch(runtimeerror err) arg_msg = err.Text ROLLBACK USING commit_transaction; RETURN 0 END TRY //commit_transaction.AutoCommit = false RETURN 1 end function public function integer of_setexcelwindowsize (integer arg_windowstate, string arg_msg);try obj_xls.of_setexcelwindowsize( arg_WindowState) catch(runtimeerror err) arg_msg = err.text return 0 end try return 1 end function public function s_xls_templates of_gettemplatedata (long arg_billid, long arg_templatesid, ref string arg_msg); s_xls_templates tem s_tem = tem s_tem.tid = arg_billid s_tem.templatesid = arg_templatesid TRY SELECT TemplatesName INTO :s_tem.TemplatesName FROM U_XLS_Templates Where ID = :arg_templatesid AND tid = :arg_billid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = " 查询模版失败" s_tem.templatesname = '' RETURN s_tem END IF SELECTBLOB templates INTO :s_tem.templates FROM U_XLS_Templates Where ID = :arg_templatesid AND tid = :arg_billid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = " 查询模版失败" SetNull(s_tem.templates ) RETURN s_tem END IF Catch(runtimeerror err) arg_msg = err.Text s_tem.templatesname = '' SetNull(s_tem.templates ) RETURN s_tem END TRY RETURN s_tem end function public function integer of_delete_template (long arg_billid, long arg_templatesid, boolean ifcommint, string arg_msg); UPDATEBLOB U_XLS_Templates Set U_XLS_Templates.templates = '' Where U_XLS_Templates.tid = :arg_billid AND U_XLS_Templates.ID = :arg_templatesid; IF commit_transaction.SQLDBCode <> 0 THEN ROLLBACK USING commit_transaction; arg_msg = '删除模版失败' RETURN 0 END IF DELETE FROM U_XLS_Templates Where U_XLS_Templates.tid = :arg_billid AND U_XLS_Templates.ID = :arg_templatesid using commit_transaction; IF commit_transaction.SQLDBCode = 0 THEN IF ifcommint THEN COMMIT USING commit_transaction; END IF arg_msg = '模版删除成功!' ELSE ROLLBACK USING commit_transaction; arg_msg = '模版删除失败' RETURN 0 END IF RETURN 1 end function public function integer of_disconnect (ref string arg_msg);long rslt = 1 try if IsValid(obj_xls) then obj_xls.of_set_caption(false) // obj_xls.DisconnectObject() // Destroy obj_xls // SetNull(obj_xls) end if catch(runtimeerror err) arg_msg +=err.text rslt = 0 end try return rslt end function public function integer of_setoption (long arg_actionid, boolean arg_allowedit, boolean arg_ifclose, ref string arg_msg);Long rslt = 1 IF IsNull(arg_msg) THEN arg_msg = '' actionid = arg_actionid AllowEdit = arg_allowedit ifclose = arg_ifclose IF rslt = 0 THEN ifsetting = False ELSE ifsetting = True END IF RETURN rslt end function protected function menu of_createitembytype (string arg_billtype, string arg_allow_print_tpidlist, string arg_allow_send_tpidlist);menu arg_menu,xls_item // arg_menu = CREATE xls_menuitem //if not IsValid(arg_menu) then arg_menu = Create xls_menu Long i,cnt,j = 0,k Integer iiPos Long ls_Templatesid String ls_TemplatesName String ls_billname Long tid[] String tname[] arg_menu.Tag = arg_billtype SELECT billname INTO :ls_billname FROM U_XLS_BillList WHERE U_XLS_BillList.BillType = :arg_billtype USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ls_billname = '' END IF arg_menu.Text = ls_billname DECLARE dft_xls CURSOR FOR SELECT U_XLS_Templates.id,U_XLS_Templates.TemplatesName FROM U_XLS_BillList,U_XLS_Templates WHERE U_XLS_BillList.billid = U_XLS_Templates.tid AND U_XLS_BillList.BillType = :arg_billtype USING commit_transaction; OPEN dft_xls; cnt = 0 FETCH dft_xls INTO :ls_Templatesid,:ls_TemplatesName; DO WHILE commit_transaction.SQLCode = 0 cnt ++ tid[cnt] = ls_Templatesid tname[cnt] = ls_TemplatesName FETCH dft_xls INTO :ls_Templatesid,:ls_TemplatesName; LOOP CLOSE dft_xls; String qik = '' FOR i = 1 TO cnt IF Pos(arg_allow_print_tpidlist,String(tid[i])+',') > 0 OR arg_allow_print_tpidlist = '0' THEN xls_item = CREATE xls_menuitem iiPos = UpperBound(arg_menu.Item)+1 arg_menu.Item[iiPos] = xls_item.Item[2] IF j < 10 THEN qik = '[&'+String( j )+']' ELSE qik = '' END IF arg_menu.Item[iiPos].Text = '[预览]'+tname[i]+qik j++ arg_menu.Item[iiPos].Tag = String(tid[i]) arg_menu.Item[iiPos].Visible = TRUE arg_menu.Item[iiPos].Enabled = TRUE END IF NEXT IF cnt > 0 And (Len(arg_allow_send_tpidlist) > 1 OR arg_allow_send_tpidlist = '0') THEN xls_item = CREATE menu iiPos = UpperBound(arg_menu.Item)+1 arg_menu.Item[iiPos] = xls_item arg_menu.Item[iiPos].Text = '-' arg_menu.Item[iiPos].Visible = TRUE arg_menu.Item[iiPos].Enabled = TRUE FOR i = 1 TO cnt IF Pos(arg_allow_send_tpidlist,String(tid[i])+',') > 0 OR arg_allow_send_tpidlist = '0' THEN xls_item = CREATE xls_menuitem iiPos = UpperBound(arg_menu.Item)+1 arg_menu.Item[iiPos] = xls_item.Item[1] IF j < 10 THEN qik = '[&'+String( j )+']' ELSE qik = '' END IF arg_menu.Item[iiPos].Text = tname[i]+qik j++ arg_menu.Item[iiPos].Tag = String(tid[i]) arg_menu.Item[iiPos].Visible = TRUE arg_menu.Item[iiPos].Enabled = TRUE END IF NEXT END IF RETURN arg_menu end function public function menu of_createmenu (string arg_billtype, string arg_allow_print_tpidlist, string arg_allow_send_tpidlist); IF arg_billTYPE = '' THEN menu arg_menu,xls_item arg_menu = Create menu setnull(arg_menu) // Integer iiPos // String bulltype[] // DECLARE dft_xls CURSOR FOR // SELECT U_XLS_BillList.billtype // FROM U_XLS_BillList // Using commit_transaction; // OPEN dft_xls; // FETCH dft_xls Into :arg_billTYPE; // DO WHILE commit_transaction.SQLCode = 0 // bulltype[ UpperBound(bulltype)+1] = arg_billTYPE // FETCH dft_xls Into :arg_billTYPE; // LOOP // CLOSE dft_xls; // // Long i // FOR iiPos = 1 To UpperBound(bulltype) // xls_item = This.of_createitembytype( bulltype[iiPos]) // arg_menu.Item[iiPos] = xls_item // NEXT RETURN arg_menu ELSE RETURN This.of_createitembytype( arg_billTYPE,arg_allow_print_tpidlist,arg_allow_send_tpidlist) END IF end function public function integer of_inserttemplate (long arg_tid, blob arg_template, string arg_templatename, integer arg_ifpic, ref string arg_msg, boolean ifcommint); s_tem.templates = arg_template s_tem.tid = arg_tid s_tem.templatesname = arg_templatename SELECT Max(ID) INTO :s_tem.templatesid FROM U_XLS_Templates USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = "插入新纪录失败" + commit_transaction.SQLErrText RETURN 0 END IF IF IsNull(s_tem.templatesid) THEN s_tem.templatesid = 10 IF s_tem.templatesid < 10 THEN s_tem.templatesid = 10 s_tem.templatesid++ INSERT INTO U_XLS_Templates (TID, ID, TemplatesName, ifpic) VALUES (:s_tem.tid , :s_tem.templatesid , :s_tem.TemplatesName, :arg_ifpic ) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ROLLBACK USING commit_transaction; arg_msg = "插入模版失败" + commit_transaction.SQLErrText RETURN 0 END IF //commit_transaction.autocommit=true UPDATEBLOB U_XLS_Templates Set templates = :s_tem.templates Where U_XLS_Templates.tid = :s_tem.tid AND U_XLS_Templates.ID = :s_tem.templatesid USING commit_transaction; IF commit_transaction.SQLDBCode = 0 THEN IF ifcommint THEN COMMIT USING commit_transaction; END IF RETURN 1 ELSE arg_msg = "上传模版失败" ROLLBACK USING commit_transaction; RETURN 0 END IF RETURN 1 end function public function integer of_updatetemp_ifpic (long arg_tid, long arg_templatesid, string arg_templatesname, integer arg_ifpic, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 IF IsNull(arg_tid) THEN arg_tid = 0 IF IsNull(arg_templatesid) THEN arg_templatesid = 0 IF IsNull(arg_templatesname) THEN arg_templatesname = '' IF IsNull(arg_ifpic) THEN arg_ifpic = 0 IF arg_tid <= 0 THEN rslt = 0 arg_msg = '错误的单据ID' GOTO ext END IF IF arg_templatesid <= 0 THEN rslt = 0 arg_msg = '错误的模版ID' GOTO ext END IF IF Trim(arg_templatesname) = '' THEN rslt = 0 arg_msg = '必须输入模版名称' GOTO ext END IF UPDATE U_XLS_Templates SET TemplatesName = :arg_templatesname, ifpic = :arg_ifpic WHERE tid = :arg_tid AND id = :arg_templatesid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '更新模版信息失败' GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF arg_ifcommit AND rslt = 1 THEN COMMIT USING commit_transaction; END IF RETURN rslt end function public function datastore of_getbillinfo_ds_panel (long arg_billid, ref string arg_msg);datastore ids_bill ids_bill = create datastore ids_bill.dataobject = 'ds_xls_bill_panel' ids_bill.settransobject(commit_transaction) if isnull(arg_msg) then arg_msg = '' if ids_bill.retrieve(arg_billid,uo_const.sign_begin ,uo_const.sign_end) < 0 then arg_msg+="~n查询单据列表失败~n"+commit_transaction.sqlerrtext setnull(ids_bill) end if return ids_bill end function on uo_sendtoexcel.create call super::create TriggerEvent( this, "constructor" ) end on on uo_sendtoexcel.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event destructor;//if isvalid(w_ole ) then close(w_ole) // //if IsValid(w_ole) then // close(w_ole) //end if // end event event constructor;// w_ole = create w_xls_ole obj_xls = Create uo_xlsmanager commit_transaction = sqlca //uo_const = create uo_xls_constant end event