public ActionResult List(GridCommand command, ProductLineLocationDetailSearchModel searchModel)
        {
            this.ProcessSearchModel(command, searchModel);
            if (string.IsNullOrEmpty(searchModel.OrderNo))
            {
                SaveWarningMessage("请输入订单号。");
                return View(new List<OrderBomDetail>());
            }
            else
            {
                TempData["_AjaxMessage"] = "";
                string sql = PrepareSearchStatement(searchModel);
                IList<object[]> list = base.genericMgr.FindAllWithNativeSql<object[]>(sql);
                IList<OrderBomDetail> OrderBomDetailList = new List<OrderBomDetail>();
                OrderBomDetailList = (from tak in list
                                      select new OrderBomDetail
                                      {
                                          OrderNo = (string)tak[0],
                                          Item = (string)tak[1],
                                          ItemDescription = (string)tak[2],
                                          ReferenceItemCode = (string)tak[3],
                                          Uom = (string)tak[4],
                                          ManufactureParty = (string)tak[5],
                                          Operation = (int)tak[6],
                                          OpReference = (string)tak[7],
                                          OrderedQty = (decimal)tak[8],
                                          HuId = (string)tak[9],
                                          FeedQty = (decimal)tak[10],
                                      }).ToList();
                return View(OrderBomDetailList);
            }

           
        }
        public ActionResult List(GridCommand command, ProductLineLocationDetailSearchModel searchModel)
        {
            this.ProcessSearchModel(command, searchModel);
            if (string.IsNullOrEmpty(searchModel.ProductLine) && string.IsNullOrEmpty(searchModel.OrderNo))
            {
               SaveWarningMessage("请输入生产线代码或订单号。");
            }
            else
            {
                 TempData["_AjaxMessage"] = "";
            }
            ViewBag.PageSize = this.ProcessPageSize(command.PageSize);

            return View();
        }
        public ActionResult List(GridCommand command, ProductLineLocationDetailSearchModel searchModel)
        {
            this.ProcessSearchModel(command, searchModel);
            if (string.IsNullOrEmpty(searchModel.ProductLine) && string.IsNullOrEmpty(searchModel.OrderNo))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_PleaseInputProductionLineCodeOrOrderNumber);
            }
            else
            {
                 TempData["_AjaxMessage"] = "";
            }
            ViewBag.PageSize = this.ProcessPageSize(command.PageSize);

            return View();
        }
        public ActionResult _AjaxList(GridCommand command, ProductLineLocationDetailSearchModel searchModel)
        {
            if (string.IsNullOrEmpty(searchModel.ProductLine) && string.IsNullOrEmpty(searchModel.OrderNo))
            {
                return PartialView(new GridModel(new List<ProductLineLocationDetail>()));
            }
            string sql = this.PrepareSearchStatement(command, searchModel);
            //base.genericMgr.FindAllWithNativeSql<object[]>(sql);
            IList<object[]> objectList = base.genericMgr.FindAllWithNativeSql<object[]>(sql + "select  * from #temp where ID_Num   between   " + (command.Page - 1) * command.PageSize + "   and   " + command.Page* command.PageSize + ";drop table #temp ;");

            IList<object> CountList = base.genericMgr.FindAllWithNativeSql<object>(sql + "select  count(*) as counts from #temp ;drop table #temp;");

            //if (objectList.Count > 0) {
            //    base.genericMgr.FindAllWithNativeSql<object[]>("drop table #temp ;");
            //}

            IList<ProductLineLocationDetail> ProductLineLocationDetailList = new List<ProductLineLocationDetail>();
            ProductLineLocationDetailList = (from tak in objectList
                                             select new ProductLineLocationDetail
                                 {
                                     ProductLine = (string)tak[1],
                                     OrderNo = (string)tak[2],
                                     Operation = (int?)tak[3],
                                     OpReference = (string)tak[4],
                                     TraceCode = (string)tak[5],
                                     Item = (string)tak[6],
                                     ItemDescription = (string)tak[7],
                                     ReferenceItemCode = (string)tak[8],
                                     HuId = (string)tak[9],
                                     LotNo = (string)tak[10],
                                     Qty = (decimal)tak[11],
                                      BackFlushQty= (decimal)tak[12],
                                     VoidQty = (decimal)tak[13],
                                     CreateUserName = (string)tak[14],
                                     CreateDate = (DateTime)tak[15],
                                     LocationFrom=(string)tak[16],
                                    
                                 }).ToList();
         
            GridModel<ProductLineLocationDetail> gridList = new GridModel<ProductLineLocationDetail>();
            gridList.Data = ProductLineLocationDetailList;
            gridList.Total = Convert.ToInt32(CountList[0]);
            return PartialView(gridList);
        }
        private string PrepareSearchStatement( ProductLineLocationDetailSearchModel searchModel)
        {
            StringBuilder Sb = new StringBuilder();
            string whereStatement = @"select d.orderno,d.item,d.itemdesc,d.refitemcode,d.uom,isnull(d.manufactureparty,'') as manufactureparty,d.op,d.opref,d.orderqty,isnull(p.huid,'') as huid,isnull(p.qty,0) as qty from ord_orderbomdet d 
                                        left join PRD_ProdLineLocationDet p
                                        on d.item=p.item and d.orderno=p.orderno
                                        and d.op=p.op and d.opref=p.opref
                                        where d.isscanhu=1 and d.OrderNo='" +searchModel.OrderNo+"'";
            Sb.Append(whereStatement);

            if (!string.IsNullOrEmpty(searchModel.Item))
            {
                Sb.Append(string.Format(" and d.Item = '{0}'", searchModel.Item));
            }
            if (!string.IsNullOrEmpty(searchModel.HuId))
            {
                Sb.Append(string.Format(" and p.HuId = '{0}'", searchModel.HuId));
            }

            return Sb.ToString();

        }
        private string PrepareSearchStatement(GridCommand command, ProductLineLocationDetailSearchModel searchModel)
        {
            StringBuilder Sb = new StringBuilder();
            string whereStatement = @"select identity(int, 1,1) as id_Num,* into #temp from ( select  prodline,orderno,op,opref,tracecode,item,itemdesc,refitemcode,huid,lotno,sum(qty) as qty,sum(bfqty) as bfqty,sum(voidqty) as voidqty,createusernm,createdate,LocFrom 
from PRD_ProdLineLocationDet where isClose=0 "  ;
            Sb.Append(whereStatement);
        string later="group by prodline,orderno,op,opref,tracecode,item,itemdesc,refitemcode,huid,lotno,createusernm,createdate,LocFrom ) as result;";
      
        if (!string.IsNullOrEmpty(searchModel.ProductLine)) {
            Sb.Append(string.Format(" and prodline = '{0}'", searchModel.ProductLine));
        }
        if (!string.IsNullOrEmpty(searchModel.OrderNo))
        {
            Sb.Append(string.Format(" and OrderNo = '{0}'", searchModel.OrderNo));
        }
        if (!string.IsNullOrEmpty(searchModel.Item))
        {
            Sb.Append(string.Format(" and Item = '{0}'", searchModel.Item));
        }

        Sb.Append(later);
        return Sb.ToString();

        }