Exemplo n.º 1
0
        public void ExportToExcel(HttpContext context)
        {
            RefundApplyQuery dataQuery = this.GetDataQuery(context);

            dataQuery.RefundIds = context.Request["Ids"].ToNullString();
            IList <RefundModel> refundApplysNoPage = OrderHelper.GetRefundApplysNoPage(dataQuery);
            StringBuilder       stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>编号</th>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("<th>处理状态</th>");
            stringBuilder.Append("<th>退款原因</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>处理时间</th>");
            stringBuilder.Append("<th>退款途径</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (RefundModel item in refundApplysNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ApplyForTime, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.SupplierId > 0) ? SupplierHelper.GetSupplierName(item.SupplierId) : "平台店", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.HandleStatus, 0), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundReason, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundAmount, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.GetDealTime, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.RefundType, 0), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SupplierRefundApplys" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
Exemplo n.º 2
0
        public void ExportToExcel(HttpContext context)
        {
            ReturnsApplyQuery dataQuery = this.GetDataQuery(context);

            dataQuery.ReturnIds = context.Request["Ids"].ToNullString();
            IList <ReturnInfo> returnApplysNoPage = OrderHelper.GetReturnApplysNoPage(dataQuery);
            StringBuilder      stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>编号</th>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("<th>处理状态</th>");
            stringBuilder.Append("<th>退款/退货原因</th>");
            stringBuilder.Append("<th>退款商品</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>处理时间</th>");
            stringBuilder.Append("<th>退款途径</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();
            DateTime      dateTime;

            foreach (ReturnInfo item in returnApplysNoPage)
            {
                DateTime?handleTime = this.GetHandleTime(item);
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReturnId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ApplyForTime, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.SupplierId > 0) ? SupplierHelper.GetSupplierName(item.SupplierId) : "平台店", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.HandleStatus, 0), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReturnReason, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ShopName + "(" + item.Quantity + ")", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundAmount, false));
                StringBuilder stringBuilder3 = stringBuilder2;
                object        argFields;
                if (!handleTime.HasValue)
                {
                    dateTime  = handleTime.Value;
                    argFields = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    argFields = "";
                }
                stringBuilder3.Append(ExcelHelper.GetXLSFieldsTD(argFields, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.RefundType, 0), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            HttpResponse  response       = context.Response;
            StringBuilder stringBuilder4 = stringWriter.GetStringBuilder();

            dateTime = DateTime.Now;
            DownloadHelper.DownloadFile(response, stringBuilder4, "ReturnApplys" + dateTime.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }