Beispiel #1
0
    //初始数据
    private void PopulateControls()
    {
        DataTable lists = bll.GetItemNumDetailList(userId, today, Convert.ToInt32(catTypeId), itemType, itemName, "list");

        List.DataSource = lists;
        List.DataBind();

        this.hidChartData.Value = ItemHelper.GetChartData(lists, "ItemBuyDate");
    }
    private void PopulateControls()
    {
        string title = Request.QueryString["title"];

        int      userId = Convert.ToInt32(Session["UserID"]);
        DateTime today  = Utility.GetRequestDate(Request.QueryString["date"]);

        string catTypeId = "0";

        if (Request.QueryString["catTypeId"] != null && Request.QueryString["catTypeId"] != "")
        {
            catTypeId = Request.QueryString["catTypeId"];
        }

        string itemType = Request.QueryString["itemType"] ?? "";
        string itemName = Request.QueryString["itemName"] ?? "";

        MonthBLL  bll = new MonthBLL();
        DataTable dt  = bll.GetItemNumDetailList(userId, today, Convert.ToInt32(catTypeId), itemType, itemName, "chart");

        decimal priceMax      = 0m;
        string  max           = "1";
        string  step          = "1";
        string  itemNameValue = "";
        string  itemPrice     = "";

        if (dt.Rows.Count > 0)
        {
            priceMax = Convert.ToDecimal(dt.Rows[0]["ItemPrice"]);
            max      = Math.Ceiling(priceMax).ToString();
            step     = Math.Floor(Convert.ToDouble(max) / 10).ToString();

            int i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                if (i == 15)
                {
                    break;
                }
                string dot = (i < 15 - 1 && i < dt.Rows.Count - 1 ? "," : "");
                itemNameValue += "{\"text\":\"" + Convert.ToDateTime(dr["ItemBuyDate"]).ToString("yyyy-MM-dd") + "\",\"rotate\":90}" + dot;
                itemPrice     += dr["ItemPrice"].ToString() + dot;
                i++;
            }
        }
        else
        {
            itemNameValue = "{\"text\":\"0\"},{\"text\":\"1\"}";
        }

        Response.Write(GetChartJsonString(itemNameValue, itemPrice, title, max, step));
        Response.End();
    }