1、用友UAP报表高级开发之输出事件 报表输出事件1.原理运用.net动态编译原理,所以语法上完全遵守c#语法规则,写的代码要在运行时期取编译运行的2.执行时间加载完数据和个时候,要呈现前把该脚本功能应用上3.报表元数据组成:C#标准语法和报表中已经存在的变量组成4.脚本对象:4.1.filter【功能介绍】过滤条件对象,获取过滤条件中的值【对象函数】返回过滤条件区间初始值(编码):string GetValue1(string key);返回过滤条件区间结束值(编码):string GetValue2(string key);返回过滤条件区间初始值(名称): string GetName1(st
2、ring key);返回过滤条件区间结束值(名称):string GetName2(string key);【用例】filter.GetValue1(订单号)4.2.global【功能介绍】全局对象,定义全局变量【对象函数】执行SQL语句:object ExecuteScalar(string sql)执行SQL语句并返回结果:DataSet Execute(string sql)报表中的全局变量:.varent-定义的全局变量【用例】global.ExecuteScalar(select top 1 ccode from SA_Sale);global.A A为报表中定义的全局变量4.3.c
3、urrent 【功能介绍】获取当前行【对象函数】获取当前行的某列(只有get):object currentcolumnname获取当前行的某列:.columnname -列值【用例】current.订单号current订单号定义sb.Append(public class Currentrn); sb.Append(rn); sb.Append(private RowData _rowdata;rn); sb.Append(public Current(RowData rowdata)rn); sb.Append(rn); sb.Append(_rowdata=rowdata;rn); sb
4、.Append(rn); sb.Append(public object thisstring namern); sb.Append(rn); sb.Append(getrn); sb.Append(rn); sb.Append(return _rowdataname;rn); sb.Append(rn); sb.Append(setrn); sb.Append(rn); sb.Append(_rowdataname=value;rn); sb.Append(rn); sb.Append(rn);4.4.privious【功能介绍】获取前一行【对象函数】获取前一行的某列:object prev
5、iouscolumnname获取前一行的某列:.columnname -列值【用例】previous.订单号previous订单号【功能介绍】获取系统参数【对象函数】执行SQL语句:void ExecuteNonQuery(string sql)执行SQL语句,返回结果:object ExecuteScalar(string sql)执行SQL语句,返回结果:DataSet Exec(string sql)在Meta库中执行SQL语句,返回结果:DataSet ExecFromMeta(string sql)用户名:string UserName当前日期:string Date当前时间:str
6、ing Time当前年:int Year当前月:int Month当前日:int Day帐套年:int AccountYear帐套月:int AccountMonth用户自定义参数:string CusDefineInfo(string key)公司信息:string CompanyInfo(string key)【用例】datahelper.CusDefineInfo(存货.自定义项1)4.5.args【功能介绍】传递参数【对象函数】取参数对象:object thisstring key取参数对象:object GetValue(string key);【用例】argsfilterflag4
7、.6.indexs【功能介绍】分组索引【对象函数】startindex -每一分组的开始序号endindex -每一分组的结束序号currentindex -当前序号4.7.groups【功能介绍】分组函数,获取报表的分组情况及指定分组【对象函数】取指定分组:Group thisint index 取分组级次:int Levelsget;取此组的分组数:int Countget;4.8.currenggoup【功能介绍】分组函数,获取当前组信息【对象函数】获取分组:string thisstring name 获取下级分组:Groups ChildGroups获取上级分组:Group Pare
8、nt 分组的可见性:bool Visible 分组的级次:int Level4.9.Cells【功能介绍】字段组函数,获取指定字段【对象函数】获取指定列:Cell thisstring namecell.Caption=cellscInvCode.ToString();4.10.Report【功能介绍】报表对象,获取报表信息【对象函数】获取报表的分组级次:int GroupLevels获取二次过滤条件:string RowFilter.FilterStringstring GroupFilterreportsummaryData【功能介绍】报表汇总对象,获取报表的汇总信息【对象函数】获取指定字
9、段的汇总数:Double thisstring mapname【用例】this存货数量5.例子5.1.根据已有内容,动态显示另外一个值比“数据权限查询”报表中的 有权if(cell.Value.ToString().Trim() = 1) cell.Caption=;elsecell.Caption=;5.2.获取当前登陆语言,并且动态显示列名称if(cell.Value.ToString().Trim() = ) if(datahelper.Login.LocaleID.ToLower() = zh-cn) cell.Caption=来源自身; if(datahelper.Login.Loc
10、aleID.ToLower() = zh-tw) cell.Caption=來源自身; if(datahelper.Login.LocaleID.ToLower() = en-us) cell.Caption=Inherit From Self;5.3.根据不同值,显示不同的背景色,起醒目提示作用if (Convert.ToDouble(cell.Value) 100000)cell.ForeColor = Color.Red;效果】销售额字段按上述条件变化背景色;提成额按上述条件设置为红色。5.4.计算逻辑复杂计算列,需要根据上一行内容来动态计算,完全是靠代码写出来的如应付总账表中的余额本币
11、列if( currentindex = 0 ) /current.ye = current.ye+current.jf-current.df-current.jf2+current.df2;else current.ye = previous.ye+current.jf-current.df-current.jf2+current.df2;return current.ye;6.附录(编译后的具体代码)public class CellcWhName:ICellEventpublic void Prepaint(Report report, RowData data, Cell innerce
12、ll, FilterSrv filter, AgileArgs args, DataHelper datahelper, ReportSummaryData reportsummary, RowBalance rowbalance, AccumulateData accumulate, BalanceData balance,object others) Current current=null; int grouplevels=report.GroupLevels; int currentindex=-1; int startindex=-1; Groups groups=null; Gro
13、up currentgroup=null; RowData columntodata=null; Current previous=new Current(rowbalance); if(rowbalance !=null ) currentindex=rowbalance.CurrentIndex; startindex=rowbalance.StartIndex; SemiRow cells=(data!=null?data.SemiRow:null); SemiRow row=cells; IKeyToObject nametodata=cells as IKeyToObject; St
14、imulateCell cell=new StimulateCell(innercell); if(data is Group) cell.bInGroup=true; currentgroup=data as Group; columntodata=currentgroup; else if(!(data is ReportSummaryData) current=new Current(data); columntodata=data; else cell.bInReportSummary=true; columntodata=data; if(nametodata=null) namet
15、odata=columntodata as IKeyToObject; Global global; if (datahelper.Global = null) global = new Global(); global.DataHelper = datahelper; datahelper.Global = global; else global = datahelper.Global as Global; /cell.Caption=current.Function0;/(cellscWhName as Cell).Caption=current.Function0;cell.Caption=cellscInvCode.ToString();cell.Caption=report.GroupLevels;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1