zoukankan      html  css  js  c++  java
  • 报表统计(四) 访问数据库

    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方法

    怀揣着一点点梦想的年轻人
    相信技术和创新的力量
    喜欢快速反应的工作节奏
  • 相关阅读:
    使用pipenv管理虚拟环境
    使用cookiecutter创建django项目
    Django中ModelViewSet的应用
    Redis添加历史浏览记录
    Django中配置用Redis做缓存和session
    点击即复制
    PostGreSQL数据库安装配置说明
    IntelliJ IDEA 2017.1.4 x64配置说明
    Struts2之2.5.10.1HelloWorld
    Apache Shiro系列(1)
  • 原文地址:https://www.cnblogs.com/hfliyi/p/2727340.html
Copyright © 2011-2022 走看看