Exemplo n.º 1
0
        protected override GeEventItemListRD ProcessRequest(APIRequest <GeEventItemListRP> pRequest)
        {
            var rd   = new GeEventItemListRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;//后台管理系统,从session里取数据

            T_CTW_LEventBLL _T_CTW_LEventBLL = new JIT.CPOS.BS.BLL.T_CTW_LEventBLL(loggingSessionInfo);

            DataSet ds = _T_CTW_LEventBLL.GeEventItemList(
                pRequest.Parameters.CTWEventId,

                pRequest.Parameters.PageSize,
                pRequest.Parameters.PageIndex,
                CurrentUserInfo.ClientID);

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Columns.Count > 0)
                {
                    rd.TotalCount = Convert.ToInt32(ds.Tables[0].Rows[0]["TotalCount"]);
                    int mod = rd.TotalCount % pRequest.Parameters.PageSize;
                    rd.TotalPage = rd.TotalCount / pRequest.Parameters.PageSize + (mod > 0 ? 1 : 0);
                }
                if (ds.Tables[1] != null && ds.Tables[1].Columns.Count > 0)
                {
                    rd.EventItemList = DataTableToObject.ConvertToList <EventItemInfo>(ds.Tables[1]);
                }
            }
            return(rd);
        }
Exemplo n.º 2
0
        public void SalesItemsListExport(HttpContext pContext)
        {
            string          LeventId         = pContext.Request.QueryString["ctweventId"];
            T_CTW_LEventBLL _T_CTW_LEventBLL = new JIT.CPOS.BS.BLL.T_CTW_LEventBLL(CurrentUserInfo);

            DataSet ds = _T_CTW_LEventBLL.GeEventItemList(LeventId, 10000, 1, CurrentUserInfo.ClientID);
            List <EventItemInfo> eventItemInfo = new List <EventItemInfo>();

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[1] != null && ds.Tables[1].Columns.Count > 0)
                {
                    eventItemInfo = DataTableToObject.ConvertToList <EventItemInfo>(ds.Tables[1]);
                }
            }
            if (eventItemInfo != null)
            {
                string MapUrl            = pContext.Server.MapPath(@"~/Framework/Upload/销售商品清单" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.ms") + ".xls");
                Aspose.Cells.License lic = new Aspose.Cells.License();
                lic.SetLicense("Aspose.Total.lic");
                Workbook  workbook      = new Workbook();
                Worksheet sheetOne      = workbook.Worksheets[0];
                Cells     sheetOneCells = sheetOne.Cells;//单元格

                #region excel初始化
                //为标题设置样式
                Style styleTitle = workbook.Styles[workbook.Styles.Add()]; //新增样式
                styleTitle.HorizontalAlignment = TextAlignmentType.Center; //文字居中
                styleTitle.Font.Name           = "宋体";                     //文字字体
                styleTitle.Font.Size           = 18;                       //文字大小
                styleTitle.Font.IsBold         = true;                     //粗体

                //样式2
                Style style2 = workbook.Styles[workbook.Styles.Add()]; //新增样式
                style2.HorizontalAlignment = TextAlignmentType.Center; //文字居中
                style2.Font.Name           = "宋体";                     //文字字体
                style2.Font.Size           = 14;                       //文字大小
                style2.Font.IsBold         = true;                     //粗体
                style2.IsTextWrapped       = true;                     //单元格内容自动换行
                style2.Borders[BorderType.LeftBorder].LineStyle   = CellBorderType.Thin;
                style2.Borders[BorderType.RightBorder].LineStyle  = CellBorderType.Thin;
                style2.Borders[BorderType.TopBorder].LineStyle    = CellBorderType.Thin;
                style2.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;

                //样式3
                Style style3 = workbook.Styles[workbook.Styles.Add()]; //新增样式
                style3.HorizontalAlignment = TextAlignmentType.Center; //文字居中
                style3.Font.Name           = "宋体";                     //文字字体
                style3.Font.Size           = 12;                       //文字大小
                style3.Borders[BorderType.LeftBorder].LineStyle   = CellBorderType.Thin;
                style3.Borders[BorderType.RightBorder].LineStyle  = CellBorderType.Thin;
                style3.Borders[BorderType.TopBorder].LineStyle    = CellBorderType.Thin;
                style3.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
                #endregion

                sheetOneCells.Merge(0, 0, 1, 9);        //合并单元格
                sheetOneCells[0, 0].PutValue("销售商品清单"); //填写内容
                sheetOneCells[0, 0].SetStyle(styleTitle);
                sheetOneCells.SetRowHeight(0, 38);
                for (int i = 0; i < 9; i++)
                {
                    sheetOneCells[1, i].SetStyle(style2);
                    sheetOneCells.SetColumnWidth(i, 30);
                }
                sheetOneCells.SetRowHeight(1, 25);

                sheetOneCells[1, 0].PutValue("商品名称");
                sheetOneCells[1, 1].PutValue("规格");
                sheetOneCells[1, 2].PutValue("原价");
                sheetOneCells[1, 3].PutValue("团购价");
                sheetOneCells[1, 4].PutValue("已售数量");
                sheetOneCells[1, 5].PutValue("总销售额");
                sheetOneCells[1, 6].PutValue("团购库存剩余");


                for (int i = 0; i < eventItemInfo.Count; i++)
                {
                    sheetOneCells[i + 2, 0].PutValue(eventItemInfo[i].item_name);
                    sheetOneCells[i + 2, 0].SetStyle(style3);

                    sheetOneCells[i + 2, 1].PutValue(eventItemInfo[i].SkuName);
                    sheetOneCells[i + 2, 1].SetStyle(style3);

                    sheetOneCells[i + 2, 2].PutValue(eventItemInfo[i].price);
                    sheetOneCells[i + 2, 2].SetStyle(style3);

                    sheetOneCells[i + 2, 3].PutValue(eventItemInfo[i].SalesPrice);
                    sheetOneCells[i + 2, 3].SetStyle(style3);

                    sheetOneCells[i + 2, 4].PutValue(eventItemInfo[i].SoldQty);
                    sheetOneCells[i + 2, 4].SetStyle(style3);

                    sheetOneCells[i + 2, 5].PutValue(eventItemInfo[i].TotalSales);
                    sheetOneCells[i + 2, 5].SetStyle(style3);

                    sheetOneCells[i + 2, 6].PutValue(eventItemInfo[i].InverTory);
                    sheetOneCells[i + 2, 6].SetStyle(style3);

                    sheetOneCells.SetRowHeight(2 + i, 24);
                }

                workbook.Save(MapUrl);
                Utils.OutputExcel(pContext, MapUrl);//输出Excel文件
            }
        }