Ejemplo n.º 1
0
        private void boid()
        {
            DataTable dt;
            string    sqlstring;


            books_hz hz = new books_hz();

            dt = hz.bookshz_all_cbs("");
            //qg_grid1.DataSource = dt;
            //qg_grid1.AutoGenerateColumns = true;



            //DataTable dt_two = dt.DefaultView.ToTable(true, "出版社", "金额"); select distinct

            DataTable dt_two = dt.Clone();      // 克隆dt 的结构,包括所有 dt 架构和约束,并无数据;

            DataRow[] rows = dt.Select("排序=1"); // 从dt 中查询符合条件的记录;
            foreach (DataRow row in rows)       // 将查询的结果添加到dt中;
            {
                dt_two.Rows.Add(row.ItemArray);
            }

            chart1.DataSource = dt_two;
            chart1.DataBind();
        }
Ejemplo n.º 2
0
        private void boid()
        {
            DataTable dt;
            string    sqlstring;


            books_hz hz = new books_hz();

            dt = hz.bookshz_all_cbs("");
            //qg_grid1.DataSource = dt;
            //qg_grid1.AutoGenerateColumns = true;



            //DataTable dt_two = dt.DefaultView.ToTable(true, "出版社", "金额"); select distinct

            DataTable dt_two = dt.Clone();      // 克隆dt 的结构,包括所有 dt 架构和约束,并无数据;

            DataRow[] rows = dt.Select("排序=1"); // 从dt 中查询符合条件的记录;
            foreach (DataRow row in rows)       // 将查询的结果添加到dt中;
            {
                dt_two.Rows.Add(row.ItemArray);
            }

            DataColumn dc1 = new DataColumn("金额百分比", Type.GetType("System.Decimal"));

            dc1.DefaultValue = 0;
            dt_two.Columns.Add(dc1);

            decimal sumtemp1 = dt_two.Compute("sum(金额)", "true").ToString().ToDecimal();

            if (sumtemp1 > 0)
            {
                foreach (DataRow row in dt_two.Rows)
                {
                    row["金额百分比"] = Math.Round(row["金额"].ToString().ToDecimal() / sumtemp1, 4);
                }
            }



            chart1.DataSource = dt_two;
            chart1.DataBind();
        }