Exemplo n.º 1
0
        public ActionResult DownLoad()
        {
            object con = new SystemCache().GetCache("stockout_query");

            if (con == null)
            {
                return(new EmptyResult());
            }

            var dataList = _sto_StockOutBusiness.GetStockOutList(
                $"{con.GetPropertyValue("StoreId")}",
                $"{con.GetPropertyValue("OutNo")}",
                $"{con.GetPropertyValue("B_OutDate")}",
                $"{con.GetPropertyValue("E_OutDate")}",
                new Pagination()
            {
                PageRows = Int32.MaxValue
            });

            string    outputFileName = $"出库-{DateTime.Now.ToString("yyyyMMddHHmmss")}";
            DataTable dataTable      = new DataTable();

            dataTable.Columns.Add(new DataColumn("仓库"));
            dataTable.Columns.Add(new DataColumn("出库单号"));
            dataTable.Columns.Add(new DataColumn("出库时间"));
            dataTable.Columns.Add(new DataColumn("出库操作员"));

            dataTable.Columns.Add(new DataColumn("材料编码"));
            dataTable.Columns.Add(new DataColumn("材料名称"));
            dataTable.Columns.Add(new DataColumn("规格"));
            dataTable.Columns.Add(new DataColumn("单位"));
            dataTable.Columns.Add(new DataColumn("数量"));
            dataTable.Columns.Add(new DataColumn("出库类型"));
            dataTable.Columns.Add(new DataColumn("申请编号"));
            dataTable.Columns.Add(new DataColumn("备注"));

            foreach (StockOutListItem item in dataList)
            {
                DataRow newRow = dataTable.NewRow();
                newRow[0]  = item.StoreName;
                newRow[1]  = item.OutNo;
                newRow[2]  = item.OutDate;
                newRow[3]  = item.OutOperID;
                newRow[4]  = item.MatNo;
                newRow[5]  = item.MatName;
                newRow[6]  = item.GuiGe;
                newRow[7]  = item.UnitName;
                newRow[8]  = item.Quantity;
                newRow[9]  = item.OutType == 0? "工程领料" : "普通领料";
                newRow[10] = item.ApplyNo;
                newRow[11] = item.Context;
                dataTable.Rows.Add(newRow);
            }
            OperateExcel.ExportToExcel(System.Web.HttpContext.Current, dataTable, outputFileName);

            return(new EmptyResult());
        }