コード例 #1
0
        public ActionResult GetProduct(int id, int pageIndex = 1, int pageSize = 10, string datetime = "", string pid = "", string displayName = "", string times = "", string status = "")
        {
            ShareMakeMoneyManager manager = new ShareMakeMoneyManager();
            int total = 0;
            var list  = manager.GetProductEntities(id, pageIndex, pageSize, datetime, pid, displayName, times, status, out total).OrderByDescending(p => p.CreateDate).Select(o => new
            {
                BatchGuid   = o.BatchGuid,
                CreateDate  = string.Format("{0:yyyy-MM-dd HH:mm:ss}", o.CreateDate),
                DisplayName = o.DisplayName,
                ID          = o.ID,
                IsMakeMoney = o.IsMakeMoney == true ? "启用" : "禁用",
                IsShare     = o.IsShare == true ? "显示" : "不显示",
                Orderby     = o.Orderby,
                PID         = o.PID,
                Times       = o.Times
            });

            ViewBag.pageNumber = pageIndex;
            ViewBag.pageSize   = pageSize;
            ViewBag.Total      = total;
            return(Content(JsonConvert.SerializeObject(new
            {
                total = total,
                rows = list
            })));
        }
コード例 #2
0
        public ActionResult SelectProducts(string datetime, string pid, string displayName, string times, string status, int id)
        {
            ShareMakeMoneyManager manager = new ShareMakeMoneyManager();

            return(Content(JsonConvert.SerializeObject(manager.GetProductEntities(datetime, pid, displayName, times, status, id).OrderByDescending(p => p.CreateDate).Select(o => new
            {
                BatchGuid = o.BatchGuid,
                CreateDate = string.Format("{0:yyyy-MM-dd}", o.CreateDate),
                DisplayName = o.DisplayName,
                ID = o.ID,
                IsMakeMoney = o.IsMakeMoney == true ? "启用" : "禁用",
                IsShare = o.IsShare == true ? "显示" : "不显示",
                Orderby = o.Orderby,
                PID = o.PID,
                Times = o.Times
            }))));
        }
コード例 #3
0
        public ActionResult Export(int id)
        {
            ShareMakeMoneyManager manager = new ShareMakeMoneyManager();

            using (var stream = new MemoryStream(System.IO.File.ReadAllBytes(Server.MapPath(@"~/Content/Export/分享赚钱商品.xlsx"))))
            {
                var list         = manager.GetProductEntities(id).OrderByDescending(p => p.CreateDate).ToList();
                var xssfWorkbook = new XSSFWorkbook(stream); //创建Workbook对象  2007+
                                                             // var hssfWorkbook = new HSSFWorkbook(stream)://2003
                if (list.Count > 0)
                {
                    var i     = 0;
                    var sheet = xssfWorkbook.GetSheetAt(0);
                    foreach (var item in list)
                    {
                        var row = sheet.CreateRow((i++) + 1);
                        row.CreateCell(0).SetCellValue(item.ID);
                        row.CreateCell(1).SetCellValue(item.FKID.Value);
                        row.CreateCell(2).SetCellValue(item.BatchGuid);
                        row.CreateCell(3).SetCellValue(item.CreateDate.ToString());
                        row.CreateCell(4).SetCellValue(item.PID);
                        row.CreateCell(5).SetCellValue(item.DisplayName);
                        row.CreateCell(6).SetCellValue(item.Times.ToString());
                        row.CreateCell(7).SetCellValue(item.IsMakeMoney ? "启用" : "禁用");
                        row.CreateCell(8).SetCellValue(item.IsShare ? "显示" : "不显示");
                        row.CreateCell(9).SetCellValue(item.Orderby.Value);
                    }
                }

                Response.AppendHeader("Content-Disposition", "attachment;fileName=分享赚钱商品" + ".xlsx");
                xssfWorkbook.Write(Response.OutputStream);
                Response.End();
            }

            return(Json(true));
        }