示例#1
0
        /// <summary>
        /// 报损单明细查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="inventoryType">库存类型:入库、出库</param>
        /// <param name="StorageID">仓库ID</param>
        /// <param name="customerID">客户ID</param>
        /// <param name="inventoryDate">出入库时间</param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult LossInventoryDetail(string name, string inventoryType, int StorageID = 0, int customerID = 0, string inventoryDate = "", int p = 1)
        {
            PagerInfo pager = new PagerInfo();
            int       count = InventoryDetailService.GetInventoryCount(name, inventoryType, StorageID, customerID, inventoryDate, OrderType.BSDD.ToString());

            pager.PageIndex = p;
            pager.PageSize  = PAGESIZE;
            pager.SumCount  = count;
            pager.URL       = "LossInventoryDetail";
            List <InventoryDetailEntity> mList = null;

            if (!string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(inventoryType) || StorageID > 0 || customerID > 0 || !string.IsNullOrEmpty(inventoryDate))
            {
                mList = InventoryDetailService.GetInventoryDetailInfoByRule(name, inventoryType, StorageID, customerID, inventoryDate, OrderType.BSDD.ToString(), pager);
            }
            else
            {
                mList = InventoryDetailService.GetInventoryDetailInfoPager(pager);
            }

            ViewBag.inventoryDetail = mList;
            //客户信息
            ViewBag.Customer = CustomerService.GetCustomerByRule("", 1);//只显示使用中的数据
            //默认仓库

            ViewBag.Storage = StorageService.GetStorageByRule("", 1);//只显示使用中的数据

            ViewBag.name          = name ?? "";
            ViewBag.inventoryType = inventoryType ?? "";
            ViewBag.StorageID     = StorageID;
            ViewBag.customerID    = customerID;
            ViewBag.inventoryDate = inventoryDate ?? "";
            ViewBag.Pager         = pager;
            return(View());
        }
示例#2
0
        /// <summary>
        /// 库存明细导出
        /// </summary>
        /// <param name="name"></param>
        /// <param name="inventoryType"></param>
        /// <param name="StorageID"></param>
        /// <param name="customerID"></param>
        /// <param name="inventoryDate"></param>
        /// <returns></returns>
        public FileResult InventoryDetailToExcel(string name, string inventoryType, int StorageID = 0, int customerID = 0, string inventoryDate = "")
        {
            int       count = InventoryDetailService.GetInventoryCount(name, inventoryType, StorageID, customerID, inventoryDate, "");
            PagerInfo pager = new PagerInfo();

            pager.PageIndex = 1;
            pager.PageSize  = count;
            pager.SumCount  = count;
            //获取list数据
            List <InventoryDetailEntity> list = InventoryDetailService.GetInventoryDetailInfoByRule(name, inventoryType, StorageID, customerID, inventoryDate, "", pager);

            //创建Excel文件的对象
            HSSFWorkbook book = new HSSFWorkbook();
            //添加一个sheet
            ISheet sheet1 = book.CreateSheet("Sheet1");

            //
            //给sheet1添加第一行的头部标题
            NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("类型");
            row1.CreateCell(1).SetCellValue("订单属性");
            row1.CreateCell(2).SetCellValue("订单编号");
            row1.CreateCell(3).SetCellValue("所属客户");
            row1.CreateCell(4).SetCellValue("仓库名称");
            row1.CreateCell(5).SetCellValue("商品编号");
            row1.CreateCell(6).SetCellValue("商品名称");
            row1.CreateCell(7).SetCellValue("批次号");
            row1.CreateCell(8).SetCellValue("生产日期");
            row1.CreateCell(9).SetCellValue("保质期");
            row1.CreateCell(10).SetCellValue("规格型号");
            row1.CreateCell(11).SetCellValue("单位");
            row1.CreateCell(12).SetCellValue("数量");
            row1.CreateCell(13).SetCellValue("重量");
            row1.CreateCell(14).SetCellValue("出入库日期");
            row1.CreateCell(15).SetCellValue("备注");
            //将数据逐步写入sheet1各个行
            for (int i = 0; i < list.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(list[i].InventoryType);
                rowtemp.CreateCell(1).SetCellValue(list[i].OrderTypeDesc);
                rowtemp.CreateCell(2).SetCellValue(list[i].OrderNo);
                rowtemp.CreateCell(3).SetCellValue(list[i].customer != null ? list[i].customer.CustomerName : "");
                rowtemp.CreateCell(4).SetCellValue(list[i].storages != null ? list[i].storages.StorageName : "");
                rowtemp.CreateCell(5).SetCellValue(list[i].goods != null ? list[i].goods.GoodsNo : "");
                rowtemp.CreateCell(6).SetCellValue(list[i].goods != null ? list[i].goods.GoodsName : "");
                rowtemp.CreateCell(7).SetCellValue(list[i].BatchNumber);
                rowtemp.CreateCell(8).SetCellValue(list[i].ProductDate.ToShortDateString());
                rowtemp.CreateCell(9).SetCellValue(list[i].goods != null ? list[i].goods.exDate + list[i].goods.exUnits : "");
                rowtemp.CreateCell(10).SetCellValue(list[i].goods != null ? list[i].goods.GoodsModel : "");
                rowtemp.CreateCell(11).SetCellValue(list[i].goods != null ? list[i].goods.Units : "");
                rowtemp.CreateCell(12).SetCellValue(list[i].Quantity);
                rowtemp.CreateCell(13).SetCellValue(list[i].goods != null ? list[i].goods.Weight : "");
                rowtemp.CreateCell(14).SetCellValue(list[i].InventoryDate.ToShortDateString());
                rowtemp.CreateCell(15).SetCellValue(list[i].Remark);
            }
            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);

            string filename = DateTime.Now.ToString("yyyyMMdd") + "{0}商品信息出入库明细 .xls";

            return(File(ms, "application/vnd.ms-excel", string.Format(filename, name)));
        }