private SendGoodOrders <Dictionary <string, object> > GetDataList(SendGoodOrderQuery query) { this.setting = SettingsManager.GetMasterSettings(); SendGoodOrders <Dictionary <string, object> > sendGoodOrders = new SendGoodOrders <Dictionary <string, object> >(); if (query != null) { DbQueryResult storeSendGoodOrders = StoresHelper.GetStoreSendGoodOrders(query); List <Dictionary <string, object> > list = DataHelper.DataTableToDictionary(storeSendGoodOrders.Data); foreach (Dictionary <string, object> item in list) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(item["OrderId"].ToString()); Dictionary <string, object> dictionary = item; DateTime dateTime = orderInfo.ShippingDate; dictionary.Add("ShippingDateStr", dateTime.ToString("yyyy-MM-dd HH:mm:ss")); Dictionary <string, object> dictionary2 = item; dateTime = orderInfo.OrderDate; dictionary2.Add("OrderDateStr", dateTime.ToString("yyyy-MM-dd HH:mm:ss")); item.Add("OrderTotalStr", orderInfo.GetPayTotal()); item.Add("OrderProfitStr", orderInfo.GetProfit()); } decimal orderSummaryTotal = default(decimal); decimal orderSummaryProfit = default(decimal); StoresHelper.GetStoreSendGoodTotalAmount(query, out orderSummaryTotal, out orderSummaryProfit); sendGoodOrders.OrderSummaryTotal = orderSummaryTotal; sendGoodOrders.OrderSummaryProfit = orderSummaryProfit; sendGoodOrders.rows = list; sendGoodOrders.total = storeSendGoodOrders.TotalRecords; } return(sendGoodOrders); }
private void ExportToExcel(HttpContext context) { SendGoodOrderQuery query = this.GetQuery(context); DbQueryResult storeSendGoodOrdersNoPage = StoresHelper.GetStoreSendGoodOrdersNoPage(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("<td>订单金额</td>"); stringBuilder.AppendLine("<td>利润</td>"); stringBuilder.AppendLine("</tr>"); decimal d = default(decimal); decimal d2 = default(decimal); DataTable data = storeSendGoodOrdersNoPage.Data; foreach (DataRow row in data.Rows) { OrderInfo orderInfo = OrderHelper.GetOrderInfo(row["OrderId"].ToNullString()); d += orderInfo.GetTotal(false); d2 += orderInfo.GetProfit(); stringBuilder.AppendLine("<tr>"); StringBuilder stringBuilder2 = stringBuilder; DateTime value = row["ShippingDate"].ToDateTime().Value; stringBuilder2.AppendLine("<td>" + value.ToString("yyyy-MM-dd HH:mm:ss") + "</td>"); StringBuilder stringBuilder3 = stringBuilder; value = row["OrderDate"].ToDateTime().Value; stringBuilder3.AppendLine("<td>" + value.ToString("yyyy-MM-dd HH:mm:ss") + "</td>"); stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + row["OrderId"].ToNullString() + "</td>"); stringBuilder.AppendLine("<td>" + row["Username"].ToNullString() + "</td>"); stringBuilder.AppendLine("<td>" + row["ShipTo"].ToNullString() + "</td>"); StringBuilder stringBuilder4 = stringBuilder; decimal num = orderInfo.GetTotal(false); stringBuilder4.AppendLine("<td>" + num.ToString("N2") + "</td>"); StringBuilder stringBuilder5 = stringBuilder; num = orderInfo.GetProfit(); stringBuilder5.AppendLine("<td>" + num.ToString("N2") + "</td>"); stringBuilder.AppendLine("</tr>"); } stringBuilder.AppendLine("<tr>"); stringBuilder.AppendLine("<td>订单总金额:" + d.ToString("N2") + "</td>"); stringBuilder.AppendLine("<td>订单总利润:" + d2.ToString("N2") + "</td>"); 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=发货统计.xls"); context.Response.ContentEncoding = Encoding.GetEncoding("GB2312"); context.Response.ContentType = "application/ms-excel"; context.Response.Write(stringBuilder.ToString()); context.Response.End(); }
private void GetList(HttpContext context) { SendGoodOrderQuery query = this.GetQuery(context); SendGoodOrdersModel <Dictionary <string, object> > dataList = this.GetDataList(query); string s = base.SerializeObjectToJson(dataList); context.Response.Write(s); context.Response.End(); }
private SendGoodOrderQuery GetQuery(HttpContext context) { SendGoodOrderQuery sendGoodOrderQuery = new SendGoodOrderQuery(); int pageIndex = 1; int pageSize = 10; string empty = string.Empty; if (!string.IsNullOrEmpty(context.Request["StartDate"])) { DateTime?dateTimeParam = base.GetDateTimeParam(context, "StartDate"); if (dateTimeParam.HasValue) { sendGoodOrderQuery.ShippingStartDate = dateTimeParam.Value; } } if (!string.IsNullOrEmpty(context.Request["EndDate"])) { DateTime?dateTimeParam2 = base.GetDateTimeParam(context, "EndDate"); if (dateTimeParam2.HasValue) { sendGoodOrderQuery.ShippingEndDate = dateTimeParam2.Value; } } empty = context.Request["page"]; if (!string.IsNullOrWhiteSpace(empty)) { try { pageIndex = int.Parse(empty); } catch { pageIndex = 1; } } empty = context.Request["rows"]; if (!string.IsNullOrWhiteSpace(empty)) { try { pageSize = int.Parse(empty); } catch { pageSize = 10; } } sendGoodOrderQuery.PageIndex = pageIndex; sendGoodOrderQuery.PageSize = pageSize; sendGoodOrderQuery.StoreId = base.CurrentManager.StoreId; sendGoodOrderQuery.IsCount = true; sendGoodOrderQuery.SortBy = "FinishDate"; sendGoodOrderQuery.SortOrder = SortAction.Desc; return(sendGoodOrderQuery); }
private SendGoodOrdersModel <Dictionary <string, object> > GetDataList(SendGoodOrderQuery query) { SendGoodOrdersModel <Dictionary <string, object> > sendGoodOrdersModel = new SendGoodOrdersModel <Dictionary <string, object> >(); decimal orderSummaryTotal = default(decimal); decimal orderProfitTotal = default(decimal); StoresHelper.GetStoreSendGoodTotalAmount(query, out orderSummaryTotal, out orderProfitTotal); sendGoodOrdersModel.OrderSummaryTotal = orderSummaryTotal; sendGoodOrdersModel.OrderProfitTotal = orderProfitTotal; DbQueryResult storeSendGoodOrders = StoresHelper.GetStoreSendGoodOrders(query); sendGoodOrdersModel.rows = DataHelper.DataTableToDictionary(storeSendGoodOrders.Data); sendGoodOrdersModel.total = storeSendGoodOrders.TotalRecords; foreach (Dictionary <string, object> row in sendGoodOrdersModel.rows) { OrderInfo orderInfo = TradeHelper.GetOrderInfo(row.ToObject <OrderInfo>().OrderId); row.Add("StatisticsOrderTotal", orderInfo.GetPayTotal()); row.Add("StatisticsOrderProfit", orderInfo.GetProfit()); } return(sendGoodOrdersModel); }
private SendGoodOrderQuery getQuery(HttpContext context) { int num = 1; int num2 = 10; int num3 = 0; int storeId = 0; num = base.GetIntParam(context, "page", false).Value; if (num < 1) { num = 1; } num2 = base.GetIntParam(context, "rows", false).Value; if (num2 < 1) { num2 = 10; } if (!string.IsNullOrEmpty(context.Request["StoreId"])) { storeId = context.Request["StoreId"].ToInt(0); } SendGoodOrderQuery sendGoodOrderQuery = new SendGoodOrderQuery(); if (!string.IsNullOrEmpty(context.Request["StartDate"])) { sendGoodOrderQuery.ShippingStartDate = base.GetDateTimeParam(context, "StartDate").Value; } if (!string.IsNullOrEmpty(context.Request["EndDate"])) { sendGoodOrderQuery.ShippingEndDate = base.GetDateTimeParam(context, "EndDate").Value; } sendGoodOrderQuery.StoreId = storeId; sendGoodOrderQuery.PageIndex = num; sendGoodOrderQuery.PageSize = num2; sendGoodOrderQuery.SortOrder = SortAction.Desc; return(sendGoodOrderQuery); }