• 报表统计(四) 访问数据库


    View Code
    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    CreateTempChart();
                }
            }
            public void CreateTempChart()
            {
                SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=DEMO;Integrated Security=True");
                string strSql = "SELECT productprice,Worker FROM ChartDB";
                SqlCommand cmd = new SqlCommand(strSql, con);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                this.Chart1.Width = 600;
                this.Chart1.Height = 400;
                this.Chart1.ChartAreas[0].AxisX.Title = "销售人员";
                this.Chart1.ChartAreas[0].AxisY.Title = "销售收入";
                this.Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
                this.Chart1.Series[0].IsValueShownAsLabel = true;
                this.Chart1.Series[0].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Triangle;
                this.Chart1.Titles.Add("销售状况");
                for (int i = 0; i < this.Chart1.Legends.Count; i++)
                {
                    this.Chart1.Legends[i].LegendStyle = System.Web.UI.DataVisualization.Charting.LegendStyle.Row;
                    this.Chart1.Legends[i].Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom;
                    this.Chart1.Legends[i].Alignment = System.Drawing.StringAlignment.Center;
                }
                this.Chart1.Series[0].LegendText = "销售";
                this.Chart1.Series[0].ToolTip = "销售:\t#VALX\n收入:\t#VALY";
                this.Chart1.Series[0].Points.DataBindXY(dr, "Worker", dr, "ProductPrice");
                dr.Close();
                con.Close();
                this.Chart1.DataBind();
           
            }

    用到DataBindXY方法

    怀揣着一点点梦想的年轻人
    相信技术和创新的力量
    喜欢快速反应的工作节奏
  • 相关阅读:
    鼠标点击表格行背景变色
    2006年星座运势全解巨蟹
    去除衣物污渍大本营
    海量数据库的查询优化及分页算法方案[转帖]
    奇怪的Access错误
    深圳易高科技有限公司面试题目
    各大IT公司的起名缘由
    微星横向菜单
    【转】函数参数入栈问题
    堆和栈的区别 (转贴)
  • 原文地址:https://www.cnblogs.com/hfliyi/p/2727340.html
Copyright © 2020-2023  润新知