Exemplo n.º 1
0
        public ActionResult PagingQueryReplace(string receiptNo, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            using (ERPClient client = new ERPClient())
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                MethodReturnResult <List <MaterialReceiptReplace> > MaterialReceiptReplaceDetailAll = new MethodReturnResult <List <MaterialReceiptReplace> >();
                //获取全部领料明细
                if (cache[receiptNo] != null)
                {
                    MaterialReceiptReplaceDetailAll = (MethodReturnResult <List <MaterialReceiptReplace> >)cache[receiptNo];
                }
                else
                {
                    MethodReturnResult <DataSet> result = client.GetERPMaterialReceiptDetail(receiptNo);
                    MaterialReceiptReplaceDetailAll = client.GetMaterialReceiptReplaceDetail(result, 0, 20);
                }

                List <MaterialReceiptReplaceViewModel> list = new List <MaterialReceiptReplaceViewModel>();
                if (MaterialReceiptReplaceDetailAll.Code == 0 && MaterialReceiptReplaceDetailAll.Data != null)
                {
                    //将数组添加到缓存中——使用Add方法
                    if (cache[receiptNo] == null)
                    {
                        cache.Add(receiptNo, MaterialReceiptReplaceDetailAll, null, DateTime.Now.AddSeconds(900), TimeSpan.Zero, CacheItemPriority.Normal, null);
                    }
                    int count = 0;
                    if ((pageNo + 1) * pageSize < MaterialReceiptReplaceDetailAll.Data.Count)
                    {
                        count = (pageNo + 1) * pageSize;
                    }
                    else
                    {
                        count = MaterialReceiptReplaceDetailAll.Data.Count;
                    }
                    for (int i = Convert.ToInt32(pageNo * pageSize); i < count; i++)
                    {
                        MaterialReceiptReplaceViewModel model = new MaterialReceiptReplaceViewModel()
                        {
                            ItemNo              = MaterialReceiptReplaceDetailAll.Data[i].Key,
                            OrderNumber         = MaterialReceiptReplaceDetailAll.Data[i].OrderNumber,
                            OldMaterialCode     = MaterialReceiptReplaceDetailAll.Data[i].OldMaterialCode,
                            OldMaterialLot      = MaterialReceiptReplaceDetailAll.Data[i].OldMaterialLot,
                            MaterialCode        = MaterialReceiptReplaceDetailAll.Data[i].MaterialCode,
                            MaterialLot         = MaterialReceiptReplaceDetailAll.Data[i].MaterialLot,
                            Qty                 = MaterialReceiptReplaceDetailAll.Data[i].Qty,
                            CellPower           = MaterialReceiptReplaceDetailAll.Data[i].CellPower,
                            CellGrade           = MaterialReceiptReplaceDetailAll.Data[i].CellGrade,
                            OldCellColor        = MaterialReceiptReplaceDetailAll.Data[i].OldCellColor,
                            CellColor           = MaterialReceiptReplaceDetailAll.Data[i].CellColor,
                            OldSupplierCode     = MaterialReceiptReplaceDetailAll.Data[i].OldSupplierCode,
                            OldSupplierName     = MaterialReceiptReplaceDetailAll.Data[i].OldSupplierName,
                            SupplierCode        = MaterialReceiptReplaceDetailAll.Data[i].SupplierCode,
                            SupplierName        = MaterialReceiptReplaceDetailAll.Data[i].SupplierName,
                            OldManufacturerCode = MaterialReceiptReplaceDetailAll.Data[i].OldManufacturerCode,
                            OldManufacturerName = MaterialReceiptReplaceDetailAll.Data[i].OldManufacturerName,
                            ManufacturerCode    = MaterialReceiptReplaceDetailAll.Data[i].ManufacturerCode,
                            ManufacturerName    = MaterialReceiptReplaceDetailAll.Data[i].ManufacturerName,
                            SupplierMaterialLot = MaterialReceiptReplaceDetailAll.Data[i].SupplierMaterialLot,
                            Description         = MaterialReceiptReplaceDetailAll.Data[i].Description
                        };
                        list.Add(model);
                    }
                    PagingConfig cfg = new PagingConfig()
                    {
                        PageNo   = pageNo,
                        PageSize = pageSize,
                        Records  = MaterialReceiptReplaceDetailAll.Data.Count
                    };
                    ViewBag.MaterialReceiptReplace = list;
                    //ViewBag.MaterialReceiptReplaceDetailAll = MaterialReceiptReplaceDetailAll;
                    ViewBag.ReceiptNo    = receiptNo;
                    ViewBag.PagingConfig = cfg;
                }
                return(PartialView("_ListPartial"));
            }
        }
Exemplo n.º 2
0
        //领料明细前20条
        public ActionResult GetMaterialReceiptDetail(string ReceiptNo)
        {
            using (ERPClient client = new ERPClient())
            {
                PagingConfig cfg = new PagingConfig();
                List <MaterialReceiptReplaceViewModel> list   = new List <MaterialReceiptReplaceViewModel>();
                MethodReturnResult <DataSet>           result = client.GetERPMaterialReceiptDetail(ReceiptNo);
                if (result.Code == 0 && result.Data.Tables[0].Rows.Count > 0)
                {
                    MethodReturnResult <List <MaterialReceiptReplace> > lstMaterialReceiptReplace = new MethodReturnResult <List <MaterialReceiptReplace> >();
                    //获取全部领料明细
                    if (cache[ReceiptNo] != null)
                    {
                        lstMaterialReceiptReplace = (MethodReturnResult <List <MaterialReceiptReplace> >)cache[ReceiptNo];
                    }
                    else
                    {
                        lstMaterialReceiptReplace = client.GetMaterialReceiptReplaceDetail(result, 0, 20);
                    }

                    if (lstMaterialReceiptReplace.Code == 0 && lstMaterialReceiptReplace.Data != null)
                    {
                        //将全部领料明细写入缓存
                        //将数组添加到缓存中——使用Add方法
                        if (cache[ReceiptNo] == null)
                        {
                            cache.Add(ReceiptNo, lstMaterialReceiptReplace, null, DateTime.Now.AddSeconds(900), TimeSpan.Zero, CacheItemPriority.Normal, null);
                        }

                        cfg.Records = result.Data.Tables[0].Rows.Count;
                        int count = 0;
                        if ((cfg.PageNo + 1) * cfg.PageSize < lstMaterialReceiptReplace.Data.Count)
                        {
                            count = (cfg.PageNo + 1) * cfg.PageSize;
                        }
                        else
                        {
                            count = lstMaterialReceiptReplace.Data.Count;
                        }
                        //生成领料明细前20条
                        for (int i = Convert.ToInt32(cfg.PageNo * cfg.PageSize); i < count; i++)
                        {
                            MaterialReceiptReplaceViewModel model = new MaterialReceiptReplaceViewModel()
                            {
                                ItemNo              = lstMaterialReceiptReplace.Data[i].Key,
                                OrderNumber         = lstMaterialReceiptReplace.Data[i].OrderNumber,
                                OldMaterialCode     = lstMaterialReceiptReplace.Data[i].OldMaterialCode,
                                OldMaterialLot      = lstMaterialReceiptReplace.Data[i].OldMaterialLot,
                                MaterialCode        = lstMaterialReceiptReplace.Data[i].MaterialCode,
                                MaterialLot         = lstMaterialReceiptReplace.Data[i].MaterialLot,
                                Qty                 = lstMaterialReceiptReplace.Data[i].Qty,
                                CellPower           = lstMaterialReceiptReplace.Data[i].CellPower,
                                CellGrade           = lstMaterialReceiptReplace.Data[i].CellGrade,
                                OldCellColor        = lstMaterialReceiptReplace.Data[i].OldCellColor,
                                CellColor           = lstMaterialReceiptReplace.Data[i].CellColor,
                                OldSupplierCode     = lstMaterialReceiptReplace.Data[i].OldSupplierCode,
                                OldSupplierName     = lstMaterialReceiptReplace.Data[i].OldSupplierName,
                                SupplierCode        = lstMaterialReceiptReplace.Data[i].SupplierCode,
                                SupplierName        = lstMaterialReceiptReplace.Data[i].SupplierName,
                                OldManufacturerCode = lstMaterialReceiptReplace.Data[i].OldManufacturerCode,
                                OldManufacturerName = lstMaterialReceiptReplace.Data[i].OldManufacturerName,
                                ManufacturerCode    = lstMaterialReceiptReplace.Data[i].ManufacturerCode,
                                ManufacturerName    = lstMaterialReceiptReplace.Data[i].ManufacturerName,
                                SupplierMaterialLot = lstMaterialReceiptReplace.Data[i].SupplierMaterialLot,
                                Description         = lstMaterialReceiptReplace.Data[i].Description
                            };
                            list.Add(model);
                        }
                    }
                    ViewBag.MaterialReceiptReplace = list;
                    //ViewBag.MaterialReceiptReplaceDetailAll = JsonConvert.SerializeObject(lstMaterialReceiptReplace);
                    ViewBag.ReceiptNo    = ReceiptNo;
                    ViewBag.PagingConfig = cfg;
                }
                return(PartialView("_ListPartial"));
            }
        }