OWC绘图控件研究(3)

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" > ...
<!--
functionIni()
...{
varchart=document.getElementById("Chart");//newActiveXObject("OWC11.ChartSpace.11");
varc=chart.Constants;
if(chart==null)
...{
alert(
"您没有安装Office!");
}

chart.Clear();
varm_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(inti=0;i<arr1.Count;i++)
...{%>
varaCats<%=i%>=<%=arr1[i].ToString()%>;
varaVals<%=i%>=<%=arr2[i].ToString()%>;
varoSer<%=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
=newDbHelperSQL(newBaseDAO());
protectedArrayListarr1=newArrayList();
protectedArrayListarr2=newArrayList();
protectedArrayListarr3=newArrayList();
publicstring[]driver=newstring[2];

protectedvoidPage_Load(objectsender,EventArgse)
...{
if(!IsPostBack)
...{
Yesidea.BO.CarInfocar
=newYesidea.BO.CarInfo();
DataSetds
=car.GetList("");
this.DropDownList1.DataSource=ds;
this.DropDownList1.DataTextField="Cnumber";
this.DropDownList1.DataValueField="Cnumber";
this.DropDownList1.DataBind();
}

}


protectedvoidbtnOk_Click(objectsender,EventArgse)
...{
driver
=newstring[]...{"王云","测试"};
for(intj=0;j<driver.Length;j++)
...{
GetData(
this.txtSTime.Value,this.txtSTime1.Value,this.DropDownList1.SelectedValue,driver[j].ToString());
}

}


publicintMonthStr(DateTimestime,DateTimeetime)
...{
inti=(etime.Year-stime.Year)*12+(etime.Month-stime.Month);
returni;
}


protectedDataSetCreateDriverOilDataSet(stringstime,stringetime,stringcnumber,stringcdriver)
...{
stringcmdtxt=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);
}

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

你可能感兴趣的:(JavaScript,Web,UI,C#,asp)