コード例 #1
0
        public ActionResult Index(InBoundRequest request)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            items.Add(new SelectListItem {
                Text = "所有类型", Value = "0", Selected = true
            });
            items.Add(new SelectListItem {
                Text = "入库", Value = "入库"
            });
            items.Add(new SelectListItem {
                Text = "还库材料", Value = "还库材料"
            });
            items.Add(new SelectListItem {
                Text = "出库材料", Value = "出库材料"
            });
            this.ViewData["czlx"] = items;

            this.ViewBag.OperateType = new SelectListItem()
            {
            };
            var ibr = this.StoreService.GetInBound(request);

            return(View(ibr));
        }
コード例 #2
0
ファイル: StoreServices.cs プロジェクト: Rocklee830630/Store
 public IEnumerable <InBoundRecord> GetInBound(InBoundRequest request)
 {
     request = request ?? new InBoundRequest();
     using (var dbContext = new StoreDbContext())
     {
         IQueryable <InBoundRecord> ibr = dbContext.InBoundRecord.Include("DictionaryProperty.DictionaryTree");
         //ibr = dbContext.InBoundRecord.Include("DictionaryTree");
         if (!string.IsNullOrEmpty(request.khmc))
         {
             ibr = ibr.Where(d => d.khmc.Contains(request.khmc));
         }
         if (!string.IsNullOrEmpty(request.ddmc))
         {
             ibr = ibr.Where(d => d.DictionaryProperty.DictionaryTree.name.Contains(request.ddmc));
         }
         if (!string.IsNullOrEmpty(request.clmc))
         {
             ibr = ibr.Where(d => d.DictionaryProperty.clmc.Contains(request.clmc));
         }
         if (!string.IsNullOrEmpty(request.czlx))
         {
             if (request.czlx == "入库" || request.czlx == "还库材料" || request.czlx == "出库材料")
             {
                 ibr = ibr.Where(d => d.boundtype.Contains(request.czlx));
             }
         }
         if (request.starttime.ToString() != "0001/1/1 0:00:00" && request.endtime.ToString() == "0001/1/1 0:00:00")
         { //有开始时间和无结束时间
             ibr = ibr.Where(d => d.CreateTime >= request.starttime);
         }
         if (request.starttime.ToString() == "0001/1/1 0:00:00" && request.endtime.ToString() != "0001/1/1 0:00:00")
         { //无开始时间和有结束时间
             ibr = ibr.Where(m => m.CreateTime <= request.endtime);
         }
         if (request.starttime.ToString() != "0001/1/1 0:00:00" && request.endtime.ToString() != "0001/1/1 0:00:00")
         { //有开始时间和结束时间
             ibr = ibr.Where(m => m.CreateTime <= request.endtime).Where(d => d.CreateTime >= request.starttime);
         }
         return(ibr.OrderByDescending(u => u.CreateTime).ToPagedList(request.PageIndex, request.PageSize));
     }
 }
コード例 #3
0
        public ActionResult Index(InBoundRequest request)
        {
            List <SelectListItem> items = new List <SelectListItem>();

            items.Add(new SelectListItem {
                Text = "所有类型", Value = "0", Selected = true
            });
            items.Add(new SelectListItem {
                Text = "入库", Value = "入库"
            });
            items.Add(new SelectListItem {
                Text = "还库材料", Value = "还库材料"
            });
            items.Add(new SelectListItem {
                Text = "出库材料", Value = "出库材料"
            });
            this.ViewData["czlx"] = items;

            this.ViewBag.OperateType = new SelectListItem()
            {
            };
            var ibr = this.StoreService.GetInBound(request);

            if (request.export == "export")//导出EXCEL
            {
                request.PageSize = 10000000;
                var       ibrAll = this.StoreService.GetInBound(request);
                DataTable dt     = new DataTable();
                dt.Columns.Add("客户名称");
                dt.Columns.Add("订单类别");
                dt.Columns.Add("材料名称");
                dt.Columns.Add("品名");
                dt.Columns.Add("门幅");
                dt.Columns.Add("基数/米");
                dt.Columns.Add("数量");
                dt.Columns.Add("领用人");
                dt.Columns.Add("操作时间");
                dt.Columns.Add("操作类型");

                foreach (InBoundRecord inBoundItem in ibrAll)
                {
                    DataRow dr = dt.NewRow();
                    dr["客户名称"] = inBoundItem.khmc;
                    dr["订单类别"] = inBoundItem.DictionaryProperty.DictionaryTree.name;
                    dr["材料名称"] = inBoundItem.DictionaryProperty.clmc;
                    dr["品名"]   = inBoundItem.DictionaryProperty.pm;
                    dr["门幅"]   = inBoundItem.DictionaryProperty.mf;
                    dr["基数/米"] = inBoundItem.DictionaryProperty.js;
                    dr["数量"]   = inBoundItem.number;
                    dr["领用人"]  = inBoundItem.employment;
                    dr["操作时间"] = inBoundItem.CreateTime;
                    dr["操作类型"] = inBoundItem.boundtype;
                    dt.Rows.Add(dr);
                }
                byte[] excelByte = this.StoreService.DataTable2Excel(dt, "出入库记录");
                using (MemoryStream ms = new MemoryStream())
                {
                    return(File(excelByte, "application/ms-excel", "出入库记录.xls"));
                }
            }
            return(View(ibr));
        }