⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
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.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    int sum1 = 0; int sum2 = 0; int sum3 = 0; int sum4 = 0; int sum5 = 0; int sum6 = 0; int sum7 = 0;
    int sum8 = 0; int sum9 = 0; int sum10 = 0; int sum11 = 0; int sum12 = 0; int sum13 = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Server=(local);database=db_05;Uid=sa;Pwd=");
        SqlDataAdapter dap = new SqlDataAdapter("SELECT DATEPART(YY,日期) AS [年份],"
        + "SUM(流量) AS [总流量],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 1 THEN 流量 ELSE NULL END) AS [1月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 2 THEN 流量 ELSE NULL END) AS [2月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 3 THEN 流量 ELSE NULL END) AS [3月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 4 THEN 流量 ELSE NULL END) AS [4月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 5 THEN 流量 ELSE NULL END) AS [5月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 6 THEN 流量 ELSE NULL END) AS [6月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 7 THEN 流量 ELSE NULL END) AS [7月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 8 THEN 流量 ELSE NULL END) AS [8月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 9 THEN 流量 ELSE NULL END) AS [9月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 10 THEN 流量 ELSE NULL END) AS [10月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 11 THEN 流量 ELSE NULL END) AS [11月],"
        + "SUM(CASE DATEPART(MM,日期) WHEN 12 THEN 流量 ELSE NULL END) AS [12月] "
        + "FROM 网站流量表 GROUP BY DATEPART(YY,日期)", con);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    { 
        if (e.Row.RowIndex >= 0)
        {
            if (e.Row.Cells[1].Text != " ")
                sum1 += Convert.ToInt32(e.Row.Cells[1].Text);
            else
                sum1 += 0;
            if (e.Row.Cells[2].Text != " ")
                sum2 += Convert.ToInt32(e.Row.Cells[2].Text);
            else
                sum2 += 0;
            if (e.Row.Cells[3].Text != " ")
                sum3 += Convert.ToInt32(e.Row.Cells[3].Text);
            else
                sum3 += 0;
            if (e.Row.Cells[4].Text != " ")
                sum4 += Convert.ToInt32(e.Row.Cells[4].Text);
            else
                sum4 += 0;
            if (e.Row.Cells[5].Text != " ")
                sum5 += Convert.ToInt32(e.Row.Cells[5].Text);
            else
                sum5 += 0;
            if (e.Row.Cells[6].Text != " ")
                sum6 += Convert.ToInt32(e.Row.Cells[6].Text);
            else
                sum6 += 0;
            if (e.Row.Cells[7].Text != " ")
                sum7 += Convert.ToInt32(e.Row.Cells[7].Text);
            else
                sum7 += 0;
            if (e.Row.Cells[8].Text != " ")
                sum8 += Convert.ToInt32(e.Row.Cells[8].Text);
            else
                sum8 += 0;
            if (e.Row.Cells[9].Text != " ")
                sum9 += Convert.ToInt32(e.Row.Cells[9].Text);
            else
                sum9 += 0;
            if (e.Row.Cells[10].Text != " ")
                sum10 += Convert.ToInt32(e.Row.Cells[10].Text);
            else
                sum10 += 0;
            if (e.Row.Cells[11].Text != " ")
                sum11 += Convert.ToInt32(e.Row.Cells[11].Text);
            else
                sum11 += 0;
            if (e.Row.Cells[12].Text != " ")
                sum12 += Convert.ToInt32(e.Row.Cells[12].Text);
            else
                sum12 += 0;
            if (e.Row.Cells[13].Text != " ")
                sum13 += Convert.ToInt32(e.Row.Cells[13].Text);
            else
                sum13 += 0;
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = "总计";
            e.Row.Cells[1].Text = sum1.ToString();
            e.Row.Cells[2].Text = sum2.ToString();
            e.Row.Cells[3].Text = sum3.ToString();
            e.Row.Cells[4].Text = sum4.ToString();
            e.Row.Cells[5].Text = sum5.ToString();
            e.Row.Cells[6].Text = sum6.ToString();
            e.Row.Cells[7].Text = sum7.ToString();
            e.Row.Cells[8].Text = sum8.ToString();
            e.Row.Cells[9].Text = sum9.ToString();
            e.Row.Cells[10].Text = sum10.ToString();
            e.Row.Cells[11].Text = sum11.ToString();
            e.Row.Cells[12].Text = sum12.ToString();
            e.Row.Cells[13].Text = sum13.ToString();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -