ChartShow.aspx
来源:互联网 发布:网上挣钱软件 编辑:程序博客网 时间:2024/06/11 09:14
ChartShow.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="ChartShow.aspx.cs" Inherits="WatchManager.ChartShow" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<div class="BannerText">
Information View
</div>
<div class="TopControlList">
Date:<asp:TextBox ID="txtDate" runat="server" onfocus="WdatePicker()"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
<asp:RadioButton ID="radDaily" GroupName="Range" Text="Daily" runat="server" Checked="true" />
<asp:RadioButton ID="radWeekly" GroupName="Range" Text="Weekly" runat="server" />
<asp:RadioButton ID="radMonthly" GroupName="Range" Text="Monthly" runat="server" />
<asp:RadioButton ID="radYear" GroupName="Range" Text="Year" runat="server" />
</div>
<div class="MainContent">
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" >
</asp:Timer>
<asp:Chart ID="myChart" runat="server" Width="750px">
<legends><asp:Legend Alignment="Center" Docking="Bottom" Name="myLengend" Title="图例"></asp:Legend></legends>
<series>
<asp:Series Name="WatchValue" ChartType="Spline" XValueMember="WatchTime" BorderWidth="2"
YValueMembers="WatchValue" ToolTip="#VAL" XValueType="String" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMax" ChartType="Spline" XValueMember="WatchTime" BorderWidth="2"
YValueMembers="WatchMax" ToolTip="#VAL" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMin" ChartType="Spline" XValueMember="WatchTime" BorderWidth="2"
YValueMembers="WatchMin" ToolTip="#VAL" Legend="myLengend">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</chartareas>
</asp:Chart>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /></Triggers>
</asp:UpdatePanel>
<asp:Chart ID="ChartWeek" runat="server" Width="750px" BorderlineWidth="2" Visible="false">
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" Name="myLengend" Title="图例">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="WatchValue" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchValue" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMax" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMax" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMin" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMin" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
<asp:Chart ID="ChartMonth" runat="server" Width="750px" BorderlineWidth="2" Visible="false">
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" Name="myLengend" Title="图例">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="WatchValue" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchValue" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMax" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMax" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMin" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMin" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
<asp:Chart ID="ChartYear" runat="server" Width="750px" BorderlineWidth="2" Visible="false">
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" Name="myLengend" Title="图例">
</asp:Legend>
</Legends>
<Series>
<asp:Series Name="WatchValue" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchValue" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
<EmptyPointStyle Label="1" />
</asp:Series>
<asp:Series Name="WatchMax" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMax" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
<asp:Series Name="WatchMin" ChartType="Spline" XValueMember="WatchDateTime" BorderWidth="2"
YValueMembers="WatchMin" ToolTip="#VAL" XValueType="DateTime" Legend="myLengend">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</div>
</asp:Content>
ChartShow.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace WatchManager
{
public partial class ChartShow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
Bind();
}
}
protected void SetTimer()
{
int hour = DateTime.Now.Hour;
if ((hour + 1) % 2 == 0)
{
Timer1.Interval = (60 - DateTime.Now.Minute) * 60 * 1000 + (60 - DateTime.Now.Second) * 1000;
}
else
{
Timer1.Interval = 1 * 60 * 60 * 1000 + (60 - DateTime.Now.Minute) * 60 * 1000 + (60 - DateTime.Now.Second) * 1000;
}
}
protected void Bind()
{
string strID = "0";
if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
{
strID = Request.QueryString["ID"].ToString();
}
if (strID == "0")
{
Response.Redirect("DataView.aspx");
}
else
{
if (radDaily.Checked == true){ BindDaily(strID); SetTimer();}
if (radWeekly.Checked == true) BindWeekly(strID);
if (radMonthly.Checked == true) BindMonthly(strID);
if (radYear.Checked == true) BindYear(strID);
//myChart.ChartAreas["ChartArea1"].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
}
}
protected void BindDaily(string strID)
{
myChart.Visible = true;
ChartWeek.Visible = false;
ChartMonth.Visible = false;
ChartYear.Visible = false;
DBAccess.DataControl dbControl = new DBAccess.DataControl();
string strDate = txtDate.Text;
myChart.DataSource = dbControl.GetDailyChart(strID, strDate);
myChart.DataBind();
myChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
}
protected void BindWeekly(string strID)
{
myChart.Visible = false;
ChartWeek.Visible = true;
ChartMonth.Visible = false;
ChartYear.Visible = false;
DBAccess.DataControl dbControl = new DBAccess.DataControl();
string strStart="";
string strEnd="";
DateTime tempDate=Convert.ToDateTime(txtDate.Text);
for (int i = 0; i < 7; i++)
{
if (tempDate.DayOfWeek.ToString() == "Sunday")
{
strEnd = tempDate.ToShortDateString();
strStart = tempDate.AddDays(-6).ToShortDateString();
i = 8;
}
else
{
tempDate=tempDate.AddDays(1);
}
}
ChartWeek.DataSource = dbControl.GetWeeklyChart(strID, strStart, strEnd);
ChartWeek.DataBind();
//ChartWeek.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
}
protected void BindMonthly(string strID)
{
myChart.Visible = false;
ChartWeek.Visible = false;
ChartMonth.Visible = true;
ChartYear.Visible = false;
DBAccess.DataControl dbControl = new DBAccess.DataControl();
ChartMonth.DataSource = dbControl.GetMonthlyChart(strID, Convert.ToDateTime(txtDate.Text));
ChartMonth.DataBind();
// ChartMonth.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 5;
}
protected void BindYear(string strID)
{
myChart.Visible = false;
ChartWeek.Visible = false;
ChartMonth.Visible = false;
ChartYear.Visible = true;
DBAccess.DataControl dbControl = new DBAccess.DataControl();
ChartYear.DataSource = dbControl.GetYearChart(strID, Convert.ToDateTime(txtDate.Text));
ChartYear.DataBind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Bind();
}
protected void Timer1_Tick(object sender, EventArgs e)
{
Timer1.Interval = 2 * 60 * 60 * 1000;
}
}
}
DataView.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WatchManager
{
public partial class DataView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtEndDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
txtStartDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
Bind();
}
}
protected void Bind()
{
string strStartDate = txtStartDate.Text;
string strEndDate = txtEndDate.Text;
DBAccess.DataControl dbControl = new DBAccess.DataControl();
repData.DataSource = dbControl.GetViewData(strStartDate,strEndDate);
repData.DataBind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Bind();
}
}
}
- ChartShow.aspx
- aspx
- upload.aspx
- ServU.aspx
- Search.aspx
- addteach aspx
- IIS ASPX
- 厌恶aspx
- Login.aspx
- products.aspx
- servu.aspx
- aspx马
- ASPX文件
- PageImage.aspx
- PageImageAccess.aspx
- PageImageSQL.aspx
- PageLoadData.aspx
- PageSaveData.aspx
- 西电网络攻防大赛Windows内核编程第3题
- 一个合格的程序员应该读过哪些书
- 黑马程序员之C# 学习笔记:打包的简述
- Bash折腾日记01
- DataControl.cs
- ChartShow.aspx
- 快速理解VirtualBox的四种网络连接方式
- DataManage.aspx.cs
- C#用Oracle.DataAccess中连接Oracle要注意版本问题!
- 使用html与javascript制作简单的网页时钟
- A Perfect SopCast Uninstall Guide
- Windows环境中通过WMareWare安装ubantu
- 计算机视觉领域的一些牛人博客,超有实力的研究机构等的网站链接
- VC++深入详解(4):MFC菜单设计