• 图形报表问题


    //下面是程序代码,请将代码创建在WanerSoft.Page类库中
    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 WanerSoft.Bussiness;
    using WanerSoft.DAL;
    using WanerSoft.Model;
    using Wuqi.Webdiyer;
    using WanerSoft.Ext;
    using WanerSoft.Data.Provider;
    using System.Text;

    namespace WanerSoft.Page
    {
        
    public class AdUser_MonthReport : AdUserExtend
        {
            
    protected TextBox txt_month;
            
    protected Repeater rp_MonthData;
            
    protected string script;
            
    protected string script_pv;
            
    protected string dateFmt;
            
    protected void Page_Load(object sender, EventArgs e)
            {
                
    if (!IsPostBack)
                {
                    txt_month.Text 
    = DateTime.Now.ToString("yyyy-MM-dd");
                }
                
    if (RequestString("action").Equals("month"))
                {
                    dateFmt 
    = "yyyy-MM";
                }
                
    else if (RequestString("action").Equals("year"))
                {
                    dateFmt 
    = "yyyy";
                }
                
    else
                {
                    dateFmt 
    = "yyyy-MM-dd";
                }
            }

            
    protected void BindMonth()
            {
                StringBuilder sb 
    = new StringBuilder();
                StringBuilder pv 
    = new StringBuilder();
                DateTime mon 
    = Convert.ToDateTime(txt_month.Text);
                
    string month = mon.ToString("yyyyMM");
                SqlHelper Sql 
    = new SqlHelper(SqlExt.DataSumStr);
                DataTable tb 
    = Sql.ExecuteDataTable(CommandType.Text, "select count(id) as c,sumdate from ws_adclickdaysum where sumdate like '" + month + "%' group by sumdate");
                rp_MonthData.DataSource 
    = tb;
                rp_MonthData.DataBind();
                
    for (int i = 0; i < DateTimeExt.MonthDayCount(DateTime.Now); i++)
                {
                    
    if (i < tb.Rows.Count)
                    {
                        sb.Append(
    "d1.push([" + tb.Rows[i]["sumdate"].ToString() + "" + tb.Rows[i]["c"].ToString() + "]); \n");
                        pv.Append(
    "d2.push([" + tb.Rows[i]["sumdate"].ToString() + "" + Ws_WebPvCountView.Find("PvDate='" + tb.Rows[i]["sumdate"].ToString() + "'").Pv.ToString() + "]); \n");
                    }
                    
    else
                    {
                        
    //sb.Append("d1.push([" + DateTime.Now.ToString("yyyyMM") + DateTimeExt.ConvertToDoubleDate(i) + ",0]); \n");
                        
    //sb.Append("d2.push([" + DateTime.Now.ToString("yyyyMM") + DateTimeExt.ConvertToDoubleDate(i) + ",0]); \n");
                    }
                }
                script 
    = sb.ToString();
                script_pv 
    = pv.ToString();
                


            }

            
    protected void BindYear()
            {
                StringBuilder sb 
    = new StringBuilder();
                DateTime mon 
    = new DateTime(Convert.ToInt32(txt_month.Text), 11);
                
    string year = mon.ToString("yyyy");
                SqlHelper Sql 
    = new SqlHelper(SqlExt.DataSumStr);
                DataTable tb 
    = Sql.ExecuteDataTable(CommandType.Text, "select count(id) as c,left(sumdate,6) as sumdate from ws_adclickdaysum where sumdate like '" + year + "%' group by left(sumdate,6)");
                rp_MonthData.DataSource 
    = tb;
                rp_MonthData.DataBind();
                
    for (int i = 0; i < 13; i++)
                {
                    
    if (i < tb.Rows.Count)
                    {
                        sb.Append(
    "d1.push([" + tb.Rows[i]["sumdate"].ToString() + "" + tb.Rows[i]["c"].ToString() + "]);");
                    }
                    
    else
                    {
                        sb.Append(
    "d1.push([" + DateTime.Now.ToString("yyyy"+ DateTimeExt.ConvertToDoubleDate(i) + ",0]);");
                    }
                }
                script 
    = sb.ToString();
                dateFmt 
    = "yyyy";
            }

            
    protected void BindHistory()
            {
                StringBuilder sb 
    = new StringBuilder();
                DateTime mon 
    = Convert.ToDateTime(txt_month.Text);
                
    string year = mon.ToString("yyyy");
                SqlHelper Sql 
    = new SqlHelper(SqlExt.DataSumStr);
                DataTable tb 
    = Sql.ExecuteDataTable(CommandType.Text, "select count(id) as c,left(sumdate,4) as sumdate from ws_adclickdaysum  group by left(sumdate,4)");
                rp_MonthData.DataSource 
    = tb;
                rp_MonthData.DataBind();
                
    for (int i = 0; i < 10; i++)
                {
                    
    if (i<tb.Rows.Count)
                    {
                        sb.Append(
    "d1.push([" + tb.Rows[i]["sumdate"].ToString() + "" + tb.Rows[i]["c"].ToString() + "]);");
                    }
                    
    else
                    {
                        sb.Append(
    "d1.push([" + Convert.ToString(2010+i) + ", 0]);");
                    }
                    


                }
                script 
    = sb.ToString();
            }

            
    protected void View(object sender, EventArgs e)
            {
                
    if (RequestString("action").Equals("month"))
                {
                    BindMonth();
                }
                
    if (RequestString("action").Equals("year"))
                {
                    BindYear();
                }
                
    if (RequestString("action").Equals("history"))
                {
                    BindHistory();
                }

            }


        }
    }
    <%@ Page Language="C#" AutoEventWireup="true" Inherits="WanerSoft.Page.AdUser_MonthReport" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        
    <title></title>

        
    <script type="text/javascript" src="../Inc/jquery.js"></script>
        
    <script type="text/javascript" src="../Inc/excanvas.pack.js"></script>
        
    <script type="text/javascript" src="../Inc/jquery.flot.pack.js"></script>
        
    <script defer="defer" src="../admin/datepicker/WdatePicker.js" type="text/javascript"></script>
        
    <script type="text/javascript" id="source">
        $(
    function(){
            $(
    "#txt_month").focus(function(){WdatePicker({dateFmt:'<%= dateFmt %>',skin:'whyGreen',oncleared:function(){$(this).blur();},onpicked:function(){$(this).blur();}})});
            
    var d1 = [];
            
    var d2=[];
            
    <%= script %>
            
    <%= script_pv %>
        
            $.plot($(
    "#placeholder"), [
                    {
                        data: d1,
                        lines: { show: 
    true, fill: false },
                        points: { show: 
    true },
                        label:
    "IP量"
                    },
                    {
                        data: d2,
                        lines: { show: 
    true, fill: false },
                        points: { show: 
    true },
                        label:
    "PV量"
                    }
                ],
                {
                    lines: { show: 
    true },
                    points: { show: 
    true },
                    xaxis: {
                        min:
    20100101,
                        ticks: [[
    20100101,"一月"],[20100102,"二月"],[20100103,"三月"],[20100104,"四月"],[20100105,"五月"],[20100106,"六月"],[20100107,"七月"],[20100108,"八月"],[20100109,"九月"],[20100110,"十月"],[20100111,"十一月"],[20100112,"十二月"]]
                    },
                    yaxis: {
                        ticks: 
    10
                    }
                }
             );
        });
        
    </script>

    </head>
    <body>
        
    <form id="form1" runat="server">
            
    <div style=" 80%">
                
    <p>
                    选择月份
    <asp:TextBox ID="txt_month" runat="server"></asp:TextBox>&nbsp;
                    
    <asp:Button ID="Btn_View" runat="server" Text="查看" OnClick="View" /></p>
                
    <div id="placeholder" style="800px;height:300px"></div> 
                
    <br />
                
    <table border="1" cellpadding="0" cellspacing="0" style="border:solid 1px #ddd; border-collapse:collapse; 300px;">
                    
    <tr>
                        
    <td>日期</td>
                        
    <td>数量</td>
                    
    </tr>
                    
    <asp:Repeater ID="rp_MonthData" runat="server">
                    
    <ItemTemplate>
                        
    <tr>
                            
    <td><%Eval("sumdate")%></td>
                            
    <td><%Eval("c"%></td>
                        
    </tr>
                    
    </ItemTemplate>
                    
    </asp:Repeater>
                
    </table>
            
    </div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    vijos 1066 弱弱的战壕 树状数组
    vijos 1057 盖房子 简单DP
    完全背包
    HDU 1203 和 HDU 2191
    dp 01背包,完全背包,多重背包 模板
    UVA11624 Fire!
    我们要学习的算法
    Find a way 两路广搜
    NYOJ 最小步数(简单深搜与广搜)
    HDU Dungeon Master广搜
  • 原文地址:https://www.cnblogs.com/kuibono/p/1652537.html
Copyright © 2020-2023  润新知