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">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>无标题页</title>
<scripttype="text/javascript"language="javaScript"src="/_layouts/images/include/timein.js"></script>
<scriptlanguage="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>
<bodyonload="javascript:Ini()"style="text-align:center">
<formid="form1"runat="server">
<divstyle="text-align:center">
<tablestyle="width:874px">
<tr>
<tdcolspan="4">
</td>
</tr>
<tr>
<tdstyle="text-align:right">
<inputstyle="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>
<tdstyle="text-align:left"colspan="2">
<inputstyle="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:DropDownListID="DropDownList1"runat="server">
</asp:DropDownList>
<asp:TextBoxID="TextBox1"runat="server"Width="97px"></asp:TextBox>
<asp:ButtonID="btnOk"runat="server"Text="确定"OnClick="btnOk_Click"/></td>
</tr>
<tr>
<tdcolspan="4"style="height:339px">
<objectid="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.后台代码:
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Text;
usingSystem.Data.SqlClient;
usingSystem.Text;
usingYesidea.DAO;
publicpartialclassweb_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";
本文介绍了一个使用OWC组件绘制油耗统计分析图表的Web应用程序实例。该应用通过前后端结合的方式,根据用户选择的时间段和车辆信息,动态展示不同月份的油耗量趋势。
7万+

被折叠的 条评论
为什么被折叠?



