PB9.0控件之Graph
来源:互联网 发布:淘宝怎么上架产品 编辑:程序博客网 时间:2024/06/05 21:15
pb在数据交互方面有着得天独厚的优势。对于数据的显示和处理简单、直观、易于理解。PowerBuilder会用到GRAPH作为一种输出工具,直观地显示用户想要看到的数据及数据间的关系。易于对数据进行分析,可以到达Excel图标的功能,但是简单的多。下面就这次毕业论文中使用的实际例子,看看Graph的使用方法和优势。
这里,实现了不同输入条件产生不同的报表。在界面中放置一个Graph控件,界面如下:
在窗体加载时,给出所有成绩的成绩分布情况。这么做其实意义不大。之后可以根据选择的条件动态的改变图表的数据源。
生成图表按钮的代码如下:
intmsg //标记条件控件是否输入int msg2msg=0msg2=0string condition[2]//第一组,条件if trim(tab_result.tabpage_pie.ddlb_fieldname1.text)<>"请选择" thenmsg=msg +1end ifif trim(tab_result.tabpage_pie.ddlb_operator3.text)<>"请选择" thenmsg=msg+ 1end ififtrim(tab_result.tabpage_pie.sle_value4.text)<>"" then msg=msg + 1end if//第二组,条件if trim(tab_result.tabpage_pie.ddlb_fieldname2.text)<>"请选择" thenmsg=msg +1end ifif trim(tab_result.tabpage_pie.ddlb_operator4.text)<>"请选择" thenmsg=msg+ 1end ififtrim(tab_result.tabpage_pie.sle_value5.text)<>"" then msg=msg + 1end if if msg = 3 then //表明第一组条件输入合法 condition[1]= " and "+tab_result.tabpage_pie.dw_condition.describe(tab_result.tabpage_pie.ddlb_fieldname1.text+ "_t.text") + " " +tab_result.tabpage_pie.dw_condition.describe(tab_result.tabpage_pie.ddlb_operator3.text+ "_t.text") + " '"+trim(tab_result.tabpage_pie.sle_value4.text) + "'" end if if msg2=3 then //表明第二组条件输入合法 condition[2]= " and "+tab_result.tabpage_pie.dw_condition.describe(tab_result.tabpage_pie.ddlb_fieldname2.text+ "_t.text") + " " +tab_result.tabpage_pie.dw_condition.describe(tab_result.tabpage_pie.ddlb_operator4.text+ "_t.text") + " '"+trim(tab_result.tabpage_pie.sle_value5.text) + "'" end ifintegerthecount[5],seriesnointeger istring thesql[5],khseriesno=tab_result.tabpage_pie.gr_pie.addseries("成绩分布") //添加数据系列 if isNUll(condition[1])=false and isNUll(condition[2])=falsethen //得到动态的 thesql[1]="select count(*) fromv_result where result>='90'" +condition[1] +condition[2] thesql[2]="select count(*) fromv_result where result>='80' and result<'90'"+condition[1]+condition[2] thesql[3]="select count(*) fromv_result where result>='70' and result<'80'"+condition[1]+condition[2] thesql[4]="select count(*) fromv_result where result>='60'and result<'70'"+condition[1]+condition[2] thesql[5]="select count(*) fromv_result where result<'60'" +condition[1]+condition[2]elseifisNUll(condition[1])=false then thesql[1]="select count(*) from v_resultwhere result>='90'" +condition[1] thesql[2]="select count(*) fromv_result where result>='80' and result<'90'" +condition[1] thesql[3]="select count(*) fromv_result where result>='70' and result<'80'" +condition[1] thesql[4]="select count(*) fromv_result where result>='60'and result<'70'" +condition[1] thesql[5]="select count(*) fromv_result where result<'60'" +condition[1]elseifisnull(condition[2])=false then thesql[1]="select count(*) from v_resultwhere result>='90'" +condition[2] thesql[2]="select count(*) fromv_result where result>='80' and result<'90'" +condition[2] thesql[3]="select count(*) fromv_result where result>='70' and result<'80'" +condition[2] thesql[4]="select count(*) fromv_result where result>='60'and result<'70'" +condition[2] thesql[5]="select count(*) fromv_result where result<'60'" +condition[2]elsethesql[1]="selectcount(*) from v_result where result>='90'" thesql[2]="select count(*) fromv_result where result>='80' and result<'90'" thesql[3]="select count(*) fromv_result where result>='70' and result<'80'" thesql[4]="select count(*) fromv_result where result>='60'and result<'70'" thesql[5]="select count(*) fromv_result where result<'60'"end iffor i = 1 to 5DECLARE mycursor DYNAMIC CURSOR FORSQLSA; //查询数据,使用游标读取PREPARESQLSA From :thesql[i];openmycursor; ifsqlca.sqlcode<0 thenmessagebox("数据库出错","游标无法打开")returnendifFETCHmycursor INTO :thecount[i];closemycursor;nexttab_result.tabpage_pie.gr_pie.addcategory("90分以上") //添加类别tab_result.tabpage_pie.gr_pie.addcategory("80-90分")tab_result.tabpage_pie.gr_pie.addcategory("70-80分")tab_result.tabpage_pie.gr_pie.addcategory("60-70分")tab_result.tabpage_pie.gr_pie.addcategory("不及格") tab_result.tabpage_pie.gr_pie.adddata(seriesno,thecount[1],"90分以上") //为不同的类别加载数据tab_result.tabpage_pie.gr_pie.adddata(seriesno,thecount[2],"80-90分")tab_result.tabpage_pie.gr_pie.adddata(seriesno,thecount[3],"70-80分")tab_result.tabpage_pie.gr_pie.adddata(seriesno,thecount[4],"60-70分")tab_result.tabpage_pie.gr_pie.adddata(seriesno,thecount[5],"不及格") tab_result.tabpage_pie.gr_pie.title= sle_value4.text +sle_value5.text +"成绩分布图" //更改图表名称
这次毕业设计用PB9.0来实现,给我最大的感受是:PB9.0是我目前遇到的对数据的交互最好的语言,简单直观易用。但是在其他方面不是那么的人性化。总体的说就是,有点很明显,缺点也很明显。
0 0
- PB9.0控件之Graph
- PB9.0动态生成控件
- PB控件属性之Graph
- 求解pb9.0习题
- PB9.0 窗体复制
- Graph 控件
- pb9.0出现中文乱码
- PB9.0和.INI文件
- PB9.0连接sqlserver2008 R2
- 【PB】安装PB9.0问题
- PB控件:Graph图形控件
- [原创]PB9.0动态连接MSSQL数据库
- PB9.0如何动态获取系统时间
- PB9.0以上小写转大写
- pb9.0连接sql server2008全攻略
- PB9.0无法连接SQL Server数据库
- PB9核心之——数据窗口对象使用
- leetcode之Clone Graph
- sql server 删除外键
- 实现ubnutn与window7共享:
- Linux给用户添加sudo权限
- linux第四课
- IOS学习之IOS沙盒(sandbox)机制和文件操作
- PB9.0控件之Graph
- UVA 489
- 正则表达式、正则表达式常用功能、匹配器、URL
- Time note
- PL/SQL_触发器2(行触发器)
- Oracle删除数据文件
- 百度搜索V认证生存浅析
- 【转】android生成项目后出现两个图标或点击程序提示未安装的解决办法
- 第五周项目1-三角形类的构造函数(1)