示例#1
0
        public ActionResult GetList()
        {
            int      Status      = WebUtil.GetFormValue <int>("Status", 0);
            string   OrderNum    = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   BadType     = WebUtil.GetFormValue <string>("BadType", string.Empty);
            string   ProductType = WebUtil.GetFormValue <string>("ProductType", string.Empty);
            string   beginTime   = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime     = WebUtil.GetFormValue <string>("endTime", string.Empty);
            int      pageSize    = WebUtil.GetFormValue <int>("PageSize", 10);
            int      pageIndex   = WebUtil.GetFormValue <int>("PageIndex", 1);
            PageInfo pageInfo    = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            MoveOrderEntity entity = new MoveOrderEntity();

            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!ProductType.IsEmpty())
            {
                entity.Where("ProductType", ECondition.Eth, ProductType);
            }
            if (!BadType.IsEmpty())
            {
                entity.Where("BadType", ECondition.Eth, BadType);
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            Bill <MoveOrderEntity, MoveOrderDetailEntity> bill = new MoveOrder();
            List <MoveOrderEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <MoveOrderEntity>() : listResult;
            string json = ConvertJson.ListToJson <MoveOrderEntity>(listResult, "List");

            this.ReturnJson.AddProperty("Data", json);
            this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
            return(Content(this.ReturnJson.ToString()));
        }
示例#2
0
        public ActionResult ToExcel()
        {
            int      Status      = WebUtil.GetFormValue <int>("Status", 0);
            string   OrderNum    = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   BadType     = WebUtil.GetFormValue <string>("BadType", string.Empty);
            string   ProductType = WebUtil.GetFormValue <string>("ProductType", string.Empty);
            string   beginTime   = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime     = WebUtil.GetFormValue <string>("endTime", string.Empty);
            PageInfo pageInfo    = new PageInfo()
            {
                PageIndex = 1, PageSize = int.MaxValue
            };
            MoveOrderEntity entity = new MoveOrderEntity();

            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!ProductType.IsEmpty())
            {
                entity.Where("ProductType", ECondition.Eth, ProductType);
            }
            if (!BadType.IsEmpty())
            {
                entity.Where("BadType", ECondition.Eth, BadType);
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            Bill <MoveOrderEntity, MoveOrderDetailEntity> bill = new MoveOrder();
            List <MoveOrderEntity> listResult = bill.GetList(entity, ref pageInfo);

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("移库单编号 "));
                dt.Columns.Add(new DataColumn("移库类型"));
                dt.Columns.Add(new DataColumn("关联单号"));
                dt.Columns.Add(new DataColumn("移库总数"));
                dt.Columns.Add(new DataColumn("移库人"));
                dt.Columns.Add(new DataColumn("状态"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (MoveOrderEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.OrderNum;
                    row[2] = EnumHelper.GetEnumDesc <EMoveType>(t.MoveType);
                    row[3] = t.ContractOrder;
                    row[4] = t.Num;
                    row[5] = t.CreateUserName;
                    row[6] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                    row[7] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }

                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("移库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("移库管理", "移库单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }