OWC绘图控件研究(3)

系统 1375 0

1.前台代码:

<% ... @PageLanguage = " C# " AutoEventWireup = " true " CodeFile = " testowc.aspx.cs " Inherits = " web_testowc " %>

<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 无标题页 </ title >

< script type ="text/javascript" language ="javaScript" src ="/_layouts/images/include/timein.js" ></ script >
< script language ="javascript" > ...
<!--
function Ini()
... {
var chart = document.getElementById( " Chart " ); // newActiveXObject("OWC11.ChartSpace.11");
var c = chart.Constants;
if (chart == null )
... {
alert(
" 您没有安装Office! " );
}

chart.Clear();
var m_Chart = chart.Charts.Add( 0 );
// m_Chart.PlotArea.Interior.SetOneColorGradient(c.chGradientVariantStart,c.chGradientVariantStart,0.15,"Silver")

m_Chart.HasLegend
= true

m_Chart.HasTitle
= true
m_Chart.Title.Caption
= " 油耗量统计分析 " ;
m_Chart.Axes(
0 ).HasTitle = true ;
m_Chart.Axes(
0 ).Title.Caption = " 月份 " ;
m_Chart.Axes(
1 ).HasTitle = true ;
m_Chart.Axes(
1 ).Title.Caption = " 油耗量 " ;

m_Chart.type
= 0 ;
<% for ( int i = 0 ;i < arr1.Count;i ++ )
... { %>
var aCats <%= i %> = <% = arr1[i].ToString() %> ;
var aVals <%= i %> = <% = arr2[i].ToString() %> ;
var oSer <%= i %> = m_Chart.SeriesCollection.Add( <% = i %> );
oSer
<%= i %> .SetData(c.chDimSeriesNames, - 1 , <% = i.ToString() %> );
oSer
<%= i %> .SetData(c.chDimCategories, - 1 ,aCats <% = i %> );
oSer
<%= i %> .SetData(c.chDimValues, - 1 ,aVals <% = i %> );
<%
}
%>

chart.AllowPropertyToolbox
= true ;
chart.DisplayToolbar
= true ;

}

-->
</ script >

</ head >
< body onload ="javascript:Ini()" style ="text-align:center" >
< form id ="form1" runat ="server" >
< div style ="text-align:center" >
&nbsp; < table style ="width:874px" >
< tr >
< td colspan ="4" >
</ td >
</ tr >
< tr >
< td style ="text-align:right" >
< input style ="width:125px" id ="txtSTime" readonlytype ="text" runat ="server" />< img
style ="cursor:hand" onclick ="fPopUpCalendarDlg(txtSTime,'/_layouts/images/include/timein.htm','yyyy-mm-dd');returnfalse"
alt
="弹出日历下拉菜单" src ="/_layouts/images/include/datetime.gif" align ="middle" />
</ td >
< td >
~
</ td >
< td style ="text-align:left" colspan ="2" >
< input style ="width:125px" id ="txtSTime1" readonlytype ="text" runat ="server" />< img
style ="cursor:hand" onclick ="fPopUpCalendarDlg(txtSTime1,'/_layouts/images/include/timein.htm','yyyy-mm-dd');returnfalse"
alt
="弹出日历下拉菜单" src ="/_layouts/images/include/datetime.gif" align ="middle" />
< asp:DropDownList ID ="DropDownList1" runat ="server" >
</ asp:DropDownList >
< asp:TextBox ID ="TextBox1" runat ="server" Width ="97px" ></ asp:TextBox >
< asp:Button ID ="btnOk" runat ="server" Text ="确定" OnClick ="btnOk_Click" /></ td >
</ tr >
< tr >
< td colspan ="4" style ="height:339px" >
< object id ="Chart" name ="Chart" codebase ="http://www.smnpc.cn/bin/OWC11.DLL#version=11,0,6555,0"
classid
="clsid:0002E55D-0000-0000-C000-000000000046" progid ="OWC11.ChartSpace.11" width ="650px" height ="450px" >
</ object >
</ td >
</ tr >
</ table >
</ div >
</ form >
</ body >
</ html >

2.后台代码:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using System.Data.SqlClient;
using System.Text;
using Yesidea.DAO;

public partial class web_testowc:System.Web.UI.Page
... {
DbHelperSQLdbhelper
= new DbHelperSQL( new BaseDAO());
protected ArrayListarr1 = new ArrayList();
protected ArrayListarr2 = new ArrayList();
protected ArrayListarr3 = new ArrayList();
public string []driver = new string [ 2 ];

protected void Page_Load( object sender,EventArgse)
... {
if ( ! IsPostBack)
... {
Yesidea.BO.CarInfocar
= new Yesidea.BO.CarInfo();
DataSetds
= car.GetList( "" );
this .DropDownList1.DataSource = ds;
this .DropDownList1.DataTextField = " Cnumber " ;
this .DropDownList1.DataValueField = " Cnumber " ;
this .DropDownList1.DataBind();
}

}


protected void btnOk_Click( object sender,EventArgse)
... {
driver
= new string [] ... { " 王云 " , " 测试 " } ;
for ( int j = 0 ;j < driver.Length;j ++ )
... {
GetData(
this .txtSTime.Value, this .txtSTime1.Value, this .DropDownList1.SelectedValue,driver[j].ToString());
}

}


public int MonthStr(DateTimestime,DateTimeetime)
... {
int i = (etime.Year - stime.Year) * 12 + (etime.Month - stime.Month);
return i;
}


protected DataSetCreateDriverOilDataSet( string stime, string etime, string cnumber, string cdriver)
... {
string cmdtxt = String.Empty;
if (stime != "" && etime != "" && cnumber != "" && cdriver != "" )
... {
cmdtxt
= " selectCnumber,Cdriver,sum(cfutel)asFutel,datename(year,Etime)as[Year],datename(month,Etime)as[Month]fromViewDriverUOil " ;
cmdtxt
+= " whereEtime>' " + stime + " 'andEtime<' " + etime + " 'andCdriver=(' " + cdriver + " ')andCnumber=(' " + cnumber + " ') " ;
cmdtxt
+= " groupbyCdriver,Cnumber,datename(month,Etime),datename(year,Etime) " ;
cmdtxt
+= " orderby[Year]asc,[Month]asc " ;
// Response.Write(cmdtxt);
}

else if (stime != "" && etime != "" && cnumber == "" && cdriver != "" )
... {
cmdtxt
= " selectCdriver,sum(cfutel)asFutel,datename(year,Etime)as[Year],datename(month,Etime)as[Month]fromViewDriverUOil " ;
http://im
分享到:
评论

OWC绘图控件研究(3)


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论