private MemberDetailsModel <Dictionary <string, object> > GetDataList(StoresQuery query) { MemberDetailsModel <Dictionary <string, object> > memberDetailsModel = new MemberDetailsModel <Dictionary <string, object> >(); if (query != null) { DbQueryResult storeExpand = StoresHelper.GetStoreExpand(query); memberDetailsModel.rows = DataHelper.DataTableToDictionary(storeExpand.Data); memberDetailsModel.total = storeExpand.TotalRecords; } return(memberDetailsModel); }
private void ExportToExcel(HttpContext context) { try { StoresQuery query = this.getQuery(context); query.PageIndex = 1; query.PageSize = 2147483647; DbQueryResult storeExpand = StoresHelper.GetStoreExpand(query); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">"); stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">"); stringBuilder.AppendLine("<td>门店</td>"); stringBuilder.AppendLine("<td>店员数</td>"); stringBuilder.AppendLine("<td>累计发展会员数</td>"); stringBuilder.AppendLine("<td>累计会员消费</td>"); stringBuilder.AppendLine("<td>累计发展会员订单数</td>"); stringBuilder.AppendLine("</tr>"); DataTable data = storeExpand.Data; foreach (DataRow row in data.Rows) { stringBuilder.AppendLine("<tr>"); stringBuilder.AppendLine("<td>" + row.Field <string>("StoreName") + "</td>"); stringBuilder.AppendLine("<td>" + row.Field <int>("ManagerCount") + "</td>"); stringBuilder.AppendLine("<td>" + row.Field <int>("MemberCount") + "</td>"); stringBuilder.AppendLine("<td>" + row.Field <decimal>("ConsumeTotals").F2ToString("f2") + "</td>"); stringBuilder.AppendLine("<td>" + row.Field <int>("OrderNumbers") + "</td>"); stringBuilder.AppendLine("</tr>"); } stringBuilder.AppendLine("<tr>"); stringBuilder.AppendLine("<td></td>"); stringBuilder.AppendLine("</tr>"); stringBuilder.AppendLine("</table>"); context.Response.Clear(); context.Response.Buffer = false; context.Response.Charset = "GB2312"; context.Response.AppendHeader("Content-Disposition", "attachment;filename=StoresExpand_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"); context.Response.ContentEncoding = Encoding.GetEncoding("GB2312"); context.Response.ContentType = "application/ms-excel"; context.Response.Write(stringBuilder.ToString()); context.Response.End(); } catch (Exception) { throw new HidistroAshxException("导出数据错误"); } }