欢迎来到天天文库
浏览记录
ID:42614753
大小:151.00 KB
页数:6页
时间:2019-09-18
《FastReport绑定数据并进行打印 (1)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、使用FastReport进行打印C#代码//准备工作:打开设计器创建一个空的报表LiShiChuFang.frxDataSetFDataSet=newDataSet();//fastreport中的数据源必须为DataSetif(mDtLishiChufang==null
2、
3、mDtLishiChufang.Rows.Count==0){MsgHelper.MessageBoxWarning("当前无需要打印的信息");return;}//为DataSet添加表并对表命名以方便区分在fastrep
4、ort中的数据源绑定DataTabletable=newDataTable();table.TableName="ChuFang";FDataSet.Tables.Add(table);//为table创建新列table.Columns.Add("Datetime",typeof(string));table.Columns.Add("YaoPinName",typeof(string));table.Columns.Add("ShuLiang",typeof(string));table.Co
5、lumns.Add("ZongDanwei",typeof(string));table.Columns.Add("YongLiang",typeof(string));table.Columns.Add("DanDanwei",typeof(string));table.Columns.Add("PinCi",typeof(string));table.Columns.Add("YongFa",typeof(string));table.Columns.Add("ChiXuTianShu",t
6、ypeof(string));table.Columns.Add("KaiDanRen",typeof(string));doubletotleMoney=0;//对table添加数据for(inti=0;i7、hiChufang.Rows[i]["数量"].ToString(),mDtLishiChufang.Rows[i]["单位"].ToString(),mDtLishiChufang.Rows[i]["单量"].ToString(),mDtLishiChufang.Rows[i]["单量单位"].ToString(),mDtLishiChufang.Rows[i]["频次"].ToString(),mDtLishiChufang.Rows[i]["用法"].ToString(),mDtLishi8、Chufang.Rows[i]["持续天数"].ToString(),mDtLishiChufang.Rows[i]["CaoZuoRenName"].ToString());if(mDtLishiChufang.Rows[i]["总价"]!=null&&mDtLishiChufang.Rows[i]["总价"].ToString().Length>0){totleMoney+=Convert.ToDouble(mDtLishiChufang.Rows[i]["总价"]);}else{conti9、nue;}}//实例化FastReport并load需要的模板FastReport.Reportreport1=newFastReport.Report();report1.Load(Application.StartupPath+"\LiShiChuFang.frx");report1.RegisterData(FDataSet);//在fastreport中显示table的数据以便于进行数据绑定report1.GetDataSource("ChuFang").Enabled=true;Da10、taTablereportdt=newDataTable();//对于fastreport中的参数进行数据绑定FastReport.Data.Parametert1=report1.GetParameter("JiuZhenBianHao");FastReport.Data.Parametert2=report1.GetParameter("KeHuName");FastReport.Data.Parametert3=report1.GetParameter("ChongWuName");Fas
7、hiChufang.Rows[i]["数量"].ToString(),mDtLishiChufang.Rows[i]["单位"].ToString(),mDtLishiChufang.Rows[i]["单量"].ToString(),mDtLishiChufang.Rows[i]["单量单位"].ToString(),mDtLishiChufang.Rows[i]["频次"].ToString(),mDtLishiChufang.Rows[i]["用法"].ToString(),mDtLishi
8、Chufang.Rows[i]["持续天数"].ToString(),mDtLishiChufang.Rows[i]["CaoZuoRenName"].ToString());if(mDtLishiChufang.Rows[i]["总价"]!=null&&mDtLishiChufang.Rows[i]["总价"].ToString().Length>0){totleMoney+=Convert.ToDouble(mDtLishiChufang.Rows[i]["总价"]);}else{conti
9、nue;}}//实例化FastReport并load需要的模板FastReport.Reportreport1=newFastReport.Report();report1.Load(Application.StartupPath+"\LiShiChuFang.frx");report1.RegisterData(FDataSet);//在fastreport中显示table的数据以便于进行数据绑定report1.GetDataSource("ChuFang").Enabled=true;Da
10、taTablereportdt=newDataTable();//对于fastreport中的参数进行数据绑定FastReport.Data.Parametert1=report1.GetParameter("JiuZhenBianHao");FastReport.Data.Parametert2=report1.GetParameter("KeHuName");FastReport.Data.Parametert3=report1.GetParameter("ChongWuName");Fas
此文档下载收益归作者所有