protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string starttime = YYCMS.Request.GetQueryString("starttime"); string endtime = YYCMS.Request.GetQueryString("endtime"); string salemanname = YYCMS.Request.GetQueryString("salemanname"); StringBuilder sb = new StringBuilder(); sb.Append(" 1=1 "); if (!String.IsNullOrEmpty(starttime)) { sb.AppendFormat(" and ( DATEDIFF(SS,'{0}',CreateTime)>=0 )", starttime); } if (!String.IsNullOrEmpty(endtime)) { sb.AppendFormat(" and ( DATEDIFF(SS,'{0}',CreateTime)<=0 )", endtime); } if (!String.IsNullOrEmpty(salemanname)) { sb.AppendFormat(" and ( SaleMan like '%{0}%' )", salemanname); } YYCMS.SaleRecords Dal = new YYCMS.SaleRecords(); DataSet dsAll = Dal.GetList(sb.ToString()); decimal sum = 0; foreach (DataRow dr in dsAll.Tables[0].Rows) { sum += Convert.ToDecimal(dr["SumPrice"]); } ltr_sumprice.Text = sum.ToString(); int _pageindex = YYCMS.Request.GetQueryInt("p", 1); int pagesize = 15; int recordcount = 0; DataSet ds = Dal.Pager(_pageindex, pagesize, sb.ToString(), out recordcount); Repeater1.DataSource = ds; Repeater1.DataBind(); Pager1.PageIndex = _pageindex; Pager1.PageSize = pagesize; Pager1.RecordCount = recordcount; Pager1.w = "?starttime=" + starttime + "&endtime=" + endtime + "&salemanname=" + salemanname; } }
public void GetSaleInfoForPie() { var year = YYCMS.Request.GetFormInt("year", 0); YYCMS.SaleRecords Dal = new YYCMS.SaleRecords(); DataSet ds = Dal.GetSaleInfoByYearForPie(year); StringBuilder sb = new StringBuilder(); //{"dataproname":["打印机","电视机"],"dataitems":[{value:335, name:"直接访问"},{value:335, name:"直接访问"}]} sb.Append("{"); sb.Append("\"dataproname\":["); int i = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (i == (ds.Tables[0].Rows.Count - 1)) { sb.AppendFormat("\"{0}\"", dr["ProName"].ToString()); } else { sb.AppendFormat("\"{0}\",", dr["ProName"].ToString()); } i++; } sb.Append("],"); sb.Append("\"dataitems\":["); int j = 0; foreach (DataRow dr in ds.Tables[0].Rows) { sb.Append("{"); sb.AppendFormat("\"value\":{0}, \"name\":\"{1}\"", dr["SaleSumCounts"].ToString(), dr["ProName"].ToString()); if (j == (ds.Tables[0].Rows.Count - 1)) { sb.Append("}"); } else { sb.Append("},"); } j++; } sb.Append("]"); sb.Append("}"); ctx.Response.ContentType = "text/json"; ctx.Response.Write(sb.ToString()); }
public void GetSaleSumPricesByMonth() { var year = YYCMS.Request.GetFormInt("year", 0); YYCMS.SaleRecords Dal = new YYCMS.SaleRecords(); DataSet ds = Dal.GetSaleInfoByYear(year); //{"datamonths":["1月","2月","3月"],"dataitems":[100,200,150]} StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("\"datamonths\":["); int i = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (i == (ds.Tables[0].Rows.Count - 1)) { sb.AppendFormat("\"{0}月\"", dr["SaleMonth"].ToString()); } else { sb.AppendFormat("\"{0}月\",", dr["SaleMonth"].ToString()); } i++; } sb.Append("],"); sb.Append("\"dataitems\":["); int j = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (j == (ds.Tables[0].Rows.Count - 1)) { sb.AppendFormat("{0}", dr["SaleSumprice"].ToString()); } else { sb.AppendFormat("{0},", dr["SaleSumprice"].ToString()); } j++; } sb.Append("],"); sb.Append("\"datasalecounts\":["); int k = 0; foreach (DataRow dr in ds.Tables[0].Rows) { if (k == (ds.Tables[0].Rows.Count - 1)) { sb.AppendFormat("{0}", dr["SaleSumCounts"].ToString()); } else { sb.AppendFormat("{0},", dr["SaleSumCounts"].ToString()); } k++; } sb.Append("]"); sb.Append("}"); ctx.Response.ContentType = "text/json"; ctx.Response.Write(sb.ToString()); }