public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
            if (string.IsNullOrEmpty(searchModel.Location))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_LocationCanNotBeEmpty);
                return View();
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_FirstBatchNumberCanNotBeEmpty);
                return View();
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom) && !string.IsNullOrEmpty(searchModel.LotNoTo))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_FirstBatchNumberBeEmptyCanNotInputSecondBatchNumber);
                return View();
            }



            if (!string.IsNullOrEmpty(searchModel.Location)&&!string.IsNullOrEmpty(searchModel.LotNoFrom))
            {
                ViewBag.Region = searchModel.Region;
                TempData["_AjaxMessage"] = "";
            }
            else
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_SearchConditionNeedLocationAndBatchNo);
            }

            return View();
        }
        public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {

            if (string.IsNullOrEmpty(searchModel.Location))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>())); ;
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom) && !string.IsNullOrEmpty(searchModel.LotNoTo))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }

            ReportSearchStatementModel reportSearchStatementModel = PrepareSearchStatement(command, searchModel);
            GridModel<LocationLotDetail> gridModel = GetAuditInspectionPageData<LocationLotDetail>(reportSearchStatementModel);
            foreach (var locationLotDetail in gridModel.Data)
            {
              locationLotDetail.ItemDescription=genericMgr.FindById<Item>(locationLotDetail.Item).Description;
            }

            return PartialView(gridModel);
        }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            string whereStatement = "where HuId is not Null";

            IList<object> param = new List<object>();


            HqlStatementHelper.AddEqStatement("Location", searchModel.Location, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("HuId", searchModel.HuId, "l", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by l.CreateDate desc";
            }
            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
         public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel) 
        {
            if (string.IsNullOrEmpty(searchModel.Location))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }
            SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
           
            GridModel<LocationLotDetail> List = GetAjaxPageData<LocationLotDetail>(searchStatementModel, command);
            if (List.Data.Count()>0)
            {
                IList<string> ItemCodes = List.Data.Select(i => i.Item).Distinct().ToList();
                //IList<IpMaster> StatusAndIpNo = base.genericMgr.FindAll<IpMaster>("select r from IpMaster as r where IpNo in ()");
                string sql = "select Code,Desc1,RefCode from MD_Item where Code in (";
                foreach (string ItemCode in ItemCodes)
                {
                    sql += "'" + ItemCode + "',";
                }
                sql = sql.Substring(0, sql.Length - 1) + ")";

                IList<object[]> objectList = base.genericMgr.FindAllWithNativeSql<object[]>(sql);
                foreach (var item in objectList)
                {
                    foreach (LocationLotDetail locationLotDetail in List.Data)
                    {
                        if ((string)item[0] == locationLotDetail.Item)
                        {
                            locationLotDetail.ItemDescription = (string)item[1];
                            locationLotDetail.ReferenceItemCode = (string)item[2];
                        }
                    }
                }
            }
            return PartialView(List);
        }
        public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            ViewBag.IsFreeze = searchModel.IsFreeze;
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
            if (string.IsNullOrEmpty(searchModel.Location))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_LocationCanNotBeEmpty);
                return View();
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom) || string.IsNullOrEmpty(searchModel.LotNoFrom))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_SearchConditionNeedManufactureDateAndBatchNo);
                return View();
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom) && !string.IsNullOrEmpty(searchModel.LotNoTo))
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_SearchConditionNeedManufactureDate);
                return View();
            }



            if (!string.IsNullOrEmpty(searchModel.Location)&&!string.IsNullOrEmpty(searchModel.LotNoFrom))
            {

                TempData["_AjaxMessage"] = "";
            }
            else
            {
                SaveWarningMessage(Resources.EXT.ControllerLan.Con_SearchConditionNeedLocationAndBatchNo);
            }

            return View();
        }
 public ActionResult Index()
 {
     LocationLotDetailSearchModel serch = new LocationLotDetailSearchModel();
     serch.TypeLocation = "0";
     TempData["Display"] = "0";
     TempData["LocationLotDetailSearchModel"] = serch;
     return View();
 }
 public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     if (searchCacheModel.isBack == true)
     {
         ViewBag.Page = searchCacheModel.Command.Page == 0 ? 1 : searchCacheModel.Command.Page;
     }
     ViewBag.PageSize = this.ProcessPageSize(command.PageSize);
     return View();
 }
 public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     if (!string.IsNullOrEmpty(searchModel.Location))
     {
         TempData["_AjaxMessage"] = "";
     }
     else
     {
         SaveWarningMessage(Resources.EXT.ControllerLan.Con_LocationSearchConditionCanNotBeEmpty);
     }
     TempData["LocationLotDetailSearchModel"] = searchModel;
     return View();
 }
        public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
             this.ProcessSearchModel(command, searchModel);
             if (!string.IsNullOrEmpty(searchModel.Location))
            {
                TempData["_AjaxMessage"] = "";
            }
            else
            {
                SaveWarningMessage("查询条件中库位为必选项。");
            }
            ViewBag.PageSize = this.ProcessPageSize(command.PageSize);

            return View();
        }
        public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            if (string.IsNullOrEmpty(searchModel.Location))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }

            SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);

            var list = GetAjaxPageData<LocationLotDetail>(searchStatementModel, command);
            foreach (var data in list.Data)
            {
                data.ItemDescription = itemMgr.GetCacheItem(data.Item).Deriction;
            }
            return PartialView(GetAjaxPageData<LocationLotDetail>(searchStatementModel, command));
        }
 public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     SearchCacheModel model = base.ProcessSearchModel(command, searchModel);
     if (model.isBack == true)
     {
         ((dynamic)base.ViewBag).Page = (model.Command.Page == 0) ? 1 : model.Command.Page;
     }
     if (!string.IsNullOrEmpty(searchModel.Location))
     {
         base.TempData["_AjaxMessage"] = "";
     }
     else
     {
         base.SaveWarningMessage(Resources.EXT.ControllerLan.Con_LocationSearchConditionCanNotBeEmpty);
     }
     ((dynamic)base.ViewBag).PageSize = base.ProcessPageSize(command.PageSize);
     return base.View();
 }
        public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {

            if (string.IsNullOrEmpty(searchModel.Location))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>())); ;
            }
            if (string.IsNullOrEmpty(searchModel.LotNoFrom) && !string.IsNullOrEmpty(searchModel.LotNoTo))
            {
                return PartialView(new GridModel(new List<LocationLotDetail>()));
            }

            ReportSearchStatementModel reportSearchStatementModel = PrepareSearchStatement(command, searchModel);
            GridModel<LocationLotDetail> gridModel = GetAuditInspectionPageData<LocationLotDetail>(reportSearchStatementModel);
            IList<FreezeTransaction> freezeTrans = new List<FreezeTransaction>();
            if (searchModel.IsFreeze && gridModel.Data.Count() != 0 )
            {
                freezeTrans = genericMgr.FindAllIn<FreezeTransaction>
                        ("from FreezeTransaction where Freeze=1 and HuId in(? ", gridModel.Data.Select(p => (object)p.HuId));
            }
            var freezeTransDic = freezeTrans.GroupBy(p => p.HuId, (k, g) => new { k, Code = g.OrderBy(p=>p.Id).First() })
                    .ToDictionary(d => d.k, d => d);
            var itemlist = itemMgr.GetCacheAllItem();
            foreach (var locationLotDetail in gridModel.Data)
            {
                locationLotDetail.ItemDescription = itemlist.ValueOrDefault(locationLotDetail.Item).FullDescription;
                if (searchModel.IsFreeze)
                {
                    locationLotDetail.Reason = freezeTransDic.ValueOrDefault(locationLotDetail.HuId).Code.Reason;
                }
            }
            return PartialView(gridModel);
        }
        private string PrepareSqlSearchStatement(LocationLotDetailSearchModel searchModel)
        {
            string whereStatement = @"select ld.HuId,ld.LotNo,ld.Location,ld.Bin,ld.Item,i.Desc1,i.RefCode,ld.UC,ld.OccupyType,ld.QualityType,ld.IsCS,ld.IsFreeze,ld.IsATP,ld.HuQty,ld.HuUom,ld.Qty,ld.BaseUom,hu.HuOption,ld.Direction,ht.Desc1 as DirectionDesc,ic.Code as MaterialsGroup,ic.Desc1 as MaterialsGroupDesc,hu.ItemVersion,hu.Remark
                                    from VIEW_LocationLotDet  as ld 
                                    inner join MD_Item as i on ld.Item=i.Code
                                    inner join INV_Hu as hu on ld.HuId=hu.HuId
                                    left join MRP_HuTo as ht on ld.Direction=ht.Code 
                                    left join (select * from MD_ItemCategory where SubCategory=5) as ic on ic.Code=i.MaterialsGroup 
                                    where ld.HuId is not null  ";
            if (!string.IsNullOrEmpty(searchModel.Location))
            {
                whereStatement += string.Format(" and ld.Location = '{0}'", searchModel.Location);
            }
            if (!string.IsNullOrEmpty(searchModel.Bin))
            {
                whereStatement += string.Format(" and ld.Bin = '{0}'", searchModel.Bin);
            }
            if (!string.IsNullOrEmpty(searchModel.Item))
            {
                whereStatement += string.Format(" and ld.Item = '{0}'", searchModel.Item);
            }
            if (!string.IsNullOrEmpty(searchModel.HuId))
            {
                whereStatement += string.Format(" and ld.HuId like '%{0}%'", searchModel.HuId);
            }
            if (searchModel.OccupyType != null)
            {
                whereStatement += string.Format(" and ld.OccupyType ={0}", searchModel.OccupyType);
            }
            if (searchModel.IsFreeze2 != null)
            {
                whereStatement += string.Format(" and ld.IsFreeze ={0}", searchModel.IsFreeze2);
            }
            if (searchModel.IsATP2 != null)
            {
                whereStatement += string.Format(" and ld.IsATP ={0}", searchModel.IsATP2);
            }
            if (searchModel.IsConsignment2 != null)
            {
                whereStatement += string.Format(" and ld.IsCS ={0}", searchModel.IsConsignment2);
            }
            if (searchModel.QualityType != null)
            {
                whereStatement += string.Format(" and ld.QualityType ={0}", searchModel.QualityType);
            }
            if (!string.IsNullOrWhiteSpace(searchModel.HuOptionHuLot))
            {
                string huOPtionSql = " and hu.HuOption in( ";
                string[] huOptionHuLots = searchModel.HuOptionHuLot.Split(',');
                for (int ir = 0; ir < huOptionHuLots.Length; ir++)
                {
                    huOPtionSql += "'" + huOptionHuLots[ir] + "',";
                }
                whereStatement += huOPtionSql.Substring(0, huOPtionSql.Length - 1) + ")";
            }
            if (!string.IsNullOrWhiteSpace(searchModel.LotNoFrom) && !string.IsNullOrWhiteSpace(searchModel.LotNoTo))
            {
                whereStatement += string.Format(" and ld.LotNo between '{0}' and '{1}' ", searchModel.LotNoFrom, searchModel.LotNoTo);

            }
            else if (!string.IsNullOrWhiteSpace(searchModel.LotNoFrom) && string.IsNullOrWhiteSpace(searchModel.LotNoTo))
            {
                whereStatement += " and ld.LotNo >='" + searchModel.LotNoFrom + "'";
            }
            else if (string.IsNullOrWhiteSpace(searchModel.LotNoFrom) && !string.IsNullOrWhiteSpace(searchModel.LotNoTo))
            {
                whereStatement += " and ld.LotNo <= '" + searchModel.LotNoTo + "'";
            }

            return whereStatement;
        }
        public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            this.GetCommand(ref command, searchModel);
            string sql = PrepareSqlSearchStatement(searchModel);
            int total = this.genericMgr.FindAllWithNativeSql<int>("select count(*) from (" + sql + ") as r1").First();
            string sortingStatement = string.Empty;

            #region
            ////ld.HuId,ld.LotNo,ld.Location,ld.Bin,ld.Item,i.Desc1,i.RefCode,ld.UC,ld.OccupyType,ld.QualityType,ld.IsCS,
            //ld.IsFreeze,ld.IsATP,ld.HuQty,ld.HuUom,ld.Qty,ld.BaseUom,hu.HuOption,ld.Direction,ht.Desc1
            if (command.SortDescriptors.Count != 0)
            {
                if (command.SortDescriptors[0].Member == "UnitCount")
                {
                    command.SortDescriptors[0].Member = "UC";
                }
                else if (command.SortDescriptors[0].Member == "HuStatusOccupyTypeDescription")
                {
                    command.SortDescriptors[0].Member = "OccupyType";
                }
                else if (command.SortDescriptors[0].Member == "HuOptionDesc")
                {
                    command.SortDescriptors[0].Member = "HuOption";
                }
                else if (command.SortDescriptors[0].Member == "QualityTypeDescription")
                {
                    command.SortDescriptors[0].Member = "QualityType";
                }
                else if (command.SortDescriptors[0].Member == "IsConsignment")
                {
                    command.SortDescriptors[0].Member = "IsCS";
                }
                sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
                TempData["sortingStatement"] = sortingStatement;
            }
            #endregion

            if (string.IsNullOrWhiteSpace(sortingStatement))
            {
                sortingStatement = "   order by Location,Item,LotNo,HuId,Direction";
            }
            sql = string.Format("select * from (select RowId=ROW_NUMBER()OVER({0}),r1.* from ({1}) as r1 ) as rt where rt.RowId between {2} and {3}", sortingStatement, sql, (command.Page - 1) * command.PageSize + 1, command.PageSize * command.Page);
            IList<object[]> searchResult = this.genericMgr.FindAllWithNativeSql<object[]>(sql);
            IList<LocationLotDetail> locationLotDetailList = new List<LocationLotDetail>();
            if (searchResult != null && searchResult.Count > 0)
            {
                #region
                //var productTypes = genericMgr.FindAll<ProductType>().ToDictionary(d => d.Code, d => d);
                //ld.HuId,ld.LotNo,ld.Location,ld.Bin,ld.Item,i.Desc1,i.RefCode,ld.UC,ld.OccupyType,ld.QualityType,ld.IsCS,
                //ld.IsFreeze,ld.IsATP,ld.HuQty,ld.HuUom,ld.Qty,ld.BaseUom,hu.HuOption,ld.Direction,ht.Desc1
                locationLotDetailList = (from tak in searchResult
                                         select new LocationLotDetail
                                         {
                                             HuId = (string)tak[1],
                                             LotNo = (string)tak[2],
                                             Location = (string)tak[3],
                                             Bin = (string)tak[4],
                                             Item = (string)tak[5],
                                             ItemDescription = (string)tak[6],
                                             ReferenceItemCode = (string)tak[7],
                                             UnitCount = (decimal)tak[8],
                                             //OccupyType = (string)tak[9],
                                             HuStatusOccupyTypeDescription = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.OccupyType, int.Parse((tak[9]).ToString())),
                                             //QualityType = (string)tak[10],
                                             QualityTypeDescription = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.QualityType, int.Parse((tak[10]).ToString())),
                                             IsConsignment = (bool)tak[11],
                                             IsFreeze = (bool)tak[12],
                                             IsATP = (bool)tak[13],
                                             HuQty = (decimal)tak[14],
                                             HuUom = (string)tak[15],
                                             Qty = (decimal)tak[16],
                                             BaseUom = (string)tak[17],
                                             HuOptionDesc = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.HuOption, int.Parse((tak[18]).ToString())),
                                             Direction = (string)tak[19],
                                             DirectionDescription = (string)tak[20],
                                             MaterialsGroup = (string)tak[21],
                                             MaterialsGroupDesc = (string)tak[22],
                                             ItemVersion = (string)tak[23], //+ (string.IsNullOrWhiteSpace((string)tak[23]) ? "" : "[" + productTypes.ValueOrDefault((string)tak[23]).Description + "]")
                                             Remark = (string)tak[24]  
                                         }).ToList();
                #endregion
            }
            GridModel<LocationLotDetail> gridModel = new GridModel<LocationLotDetail>();
            gridModel.Total = total;
            gridModel.Data = locationLotDetailList;
            return PartialView(gridModel);
        }
예제 #15
0
 public void Export(LocationLotDetailSearchModel searchModel)
 {
     int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
     GridCommand command = new GridCommand();
     command.Page = 1;
     command.PageSize = !this.CheckSearchModelIsNull(searchModel) ? 0 : value;
     ReportSearchStatementModel reportSearchStatementModel = PrepareShelfLifeWarningSearchStatement(command, searchModel);
     var list = GetHuAjaxPageData<Hu>(reportSearchStatementModel);
     var itemCategoryList = this.genericMgr.FindAll<ItemCategory>();
     foreach (var listdata in list.Data)
     {
         listdata.ExpireDateValue = listdata.ExpireDate == null ? "" : listdata.ExpireDate.Value.ToString("yyyy-MM-dd");
         listdata.RemindExpireDateValue = listdata.RemindExpireDate == null ? "" : listdata.RemindExpireDate.Value.ToString("yyyy-MM-dd");
         listdata.MaterialsGroup = itemMgr.GetCacheItem(listdata.Item).MaterialsGroup;
         listdata.MaterialsGroupDesc = GetItemCategory(listdata.MaterialsGroup, Sconit.CodeMaster.SubCategory.MaterialsGroup, itemCategoryList).Description;
     }
     var filename = "";
     if (searchModel.SearchCondition == 1)
     {
         filename = "OutOfExpireTimeWarning.xls";
     }
     else if (searchModel.SearchCondition == 3)
     {
         filename = "ShelfLifeWarningSummary.xls";
     }
     else
     {
         filename = "ShelfLifeWarning.xls";
     }
     ExportToXLS<Hu>(filename, list.Data.ToList());
 }
예제 #16
0
        private ReportSearchStatementModel PrepareShelfLifeWarningSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            ReportSearchStatementModel reportSearchStatementModel = new ReportSearchStatementModel();
            reportSearchStatementModel.ProcedureName = "USP_Report_ShelfLifeWarning";

            SqlParameter[] parameters = new SqlParameter[6];

            parameters[0] = new SqlParameter("@Location", SqlDbType.VarChar, 8000);
            parameters[0].Value = searchModel.Location;

            parameters[1] = new SqlParameter("@Item", SqlDbType.VarChar, 8000);
            parameters[1].Value = searchModel.Item;

            if (searchModel.SearchCondition == 0)
            {
                searchModel.GetType = "ByExpireTime";
            }
            else if (searchModel.SearchCondition == 1)
            {
                searchModel.GetType = "ByOutOfExpireTime";
            }
            else if (searchModel.SearchCondition == 2)
            {
                searchModel.GetType = "ByRemindExpireTime";
            }
            else
            {
                searchModel.GetType = "Summary";
            }
            parameters[2] = new SqlParameter("@Type", SqlDbType.VarChar);
            parameters[2].Value = searchModel.GetType;

            parameters[3] = new SqlParameter("@PageSize", SqlDbType.VarChar);
            parameters[3].Value = command.PageSize;

            parameters[4] = new SqlParameter("@Page", SqlDbType.VarChar);
            parameters[4].Value = command.Page;

            //parameters[5] = new SqlParameter("@IsSumByItem", SqlDbType.VarChar);
            //parameters[5].Value = searchModel.IsSumByItem;
            reportSearchStatementModel.Parameters = parameters;

            return reportSearchStatementModel;
        }
예제 #17
0
        public ActionResult _AjaxShelfLifeWarningList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            if (command.Page == null)
            {
                command.Page = 1;
            }
            //command.PageSize = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(com.Sconit.Entity.SYS.EntityPreference.CodeEnum.MaxRowSizeOnPage)); ;
            ReportSearchStatementModel reportSearchStatementModel = PrepareShelfLifeWarningSearchStatement(command, searchModel);
            var list = GetHuAjaxPageData<Hu>(reportSearchStatementModel);
            var itemCategoryList = this.genericMgr.FindAll<ItemCategory>();
            foreach (var listdata in list.Data)
            {
                listdata.ExpireDateValue = listdata.ExpireDate == null ? "": listdata.ExpireDate.Value.ToString("yyyy-MM-dd");
                listdata.RemindExpireDateValue = listdata.RemindExpireDate == null ? "" : listdata.RemindExpireDate.Value.ToString("yyyy-MM-dd");
                listdata.MaterialsGroup = itemMgr.GetCacheItem(listdata.Item).MaterialsGroup;
                listdata.MaterialsGroupDesc = GetItemCategory(listdata.MaterialsGroup, Sconit.CodeMaster.SubCategory.MaterialsGroup, itemCategoryList).Description;
            }

            //foreach (var listData in list.Data)
            //{
            //    if (listData.RemindExpireDate <= DateTime.Now && listData.ExpireDate >= DateTime.Now)
            //    {
            //        listData.ExpireStatus = "预警";
            //    }
            //    else if (listData.ExpireDate < DateTime.Now)
            //    {
            //        listData.ExpireStatus = "过期";
            //    }
            //}
            return PartialView(list);
        }
 private string PrepareSqlSearchStatement(LocationLotDetailSearchModel searchModel)
 {
     string str = @"Select isnull(a.HuId,'') HuId,isnull(a.LotNo,'') LotNo,a.Location,isnull(a.Bin,'') Bin,
             a.Item, c.Desc1,c.RefCode,Isnull(a.UC,0) UC,a.OccupyType,a.QualityType,a.IsCS, 
             a.IsFreeze,a.IsATP,isnull(a.HuQty,0)HuQty,isnull(a.HuUom,'')HuUom,a.Qty,isnull (a.BaseUom,'')BaseUom,  '' As HuOption,a.Direction,'' as DirectionDesc,
             '' as MaterialsGroup,'' as MaterialsGroupDesc,'' As ItemVersion,b.Party As Party ,
             a.Id from VIEW_LocationLotDet a with(nolock),BIL_PlanBill b 
             with(nolock),  MD_Item c with(nolock),MD_Location d with
             (nolock)  where a.PlanBill =b.Id and a.Item =c.Code and 
             a.Location =d.Code  and a.IsCS=1 ";
     if (!string.IsNullOrEmpty(searchModel.Location))
     {
         str = str + string.Format(" and d.Code = '{0}'", searchModel.Location);
         if (searchModel.Location == "9103")
         {
             str = str + " and b.Party in ('30003','30037','30029','30038','30023','30010','30224','30008')";
         }
     }
     else
     {
         str = str + " and 1=2 ";
     }
     if (!string.IsNullOrEmpty(searchModel.Party))
     {
         str = str + string.Format(" and b.Party = '{0}'", searchModel.Party);
     }
     if (!string.IsNullOrEmpty(searchModel.Item))
     {
         str = str + string.Format(" and c.Code = '{0}'", searchModel.Item);
        private SearchStatementModel PrepareSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            string whereStatement = "where HuId is not Null";

            IList<object> param = new List<object>();

            HqlStatementHelper.AddEqStatement("Location", searchModel.Location, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Bin", searchModel.Bin, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("HuId", searchModel.HuId, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("OccupyType", searchModel.OccupyType, "l", ref whereStatement, param);
            if (searchModel.LotNo != null & searchModel.LotNoTo != null)
            {
                HqlStatementHelper.AddBetweenStatement("LotNo", searchModel.LotNo, searchModel.LotNoTo, "l", ref whereStatement, param);
            }
            else if (searchModel.LotNo != null & searchModel.LotNoTo == null)
            {
                HqlStatementHelper.AddGeStatement("LotNo", searchModel.LotNo, "l", ref whereStatement, param);
            }
            else if (searchModel.LotNo == null & searchModel.LotNoTo != null)
            {
                HqlStatementHelper.AddLeStatement("LotNo", searchModel.LotNoTo, "l", ref whereStatement, param);
            }
            HqlStatementHelper.AddEqStatement("IsFreeze", searchModel.IsFreeze, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsConsignment", searchModel.IsConsignment, "l", ref whereStatement, param);
            //HqlStatementHelper.AddEqStatement("IsATP", searchModel.IsATP, "l", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by l.Location,l.Item,l.LotNo,l.HuId,l.Direction";
            }
            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
        public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
        {

            //TempData["Display"] = searchModel.Level;
            //TempData["LocationLotDetailSearchModel"] = searchModel;
            //ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            //if (searchModel.hideSupper)
            //    ViewBag.HideParty = false;
            //else
            //    ViewBag.HideParty = true;
            //if(searchModel.hideLotNo)
            //    ViewBag.HideLotNo = false;
            //else
            //    ViewBag.HideLotNo = true;

            //IList<Location> locationList = GetReportLocations(searchModel.SAPLocation,searchModel.plantFrom, searchModel.plantTo, searchModel.regionFrom, searchModel.regionTo, searchModel.locationFrom, searchModel.locationTo);
            //IList<Item> itemList = GetReportItems(searchModel.itemFrom, searchModel.itemTo);
            //if (string.IsNullOrEmpty(ViewBag.Location))
            //    ViewBag.Location = Resources.View.LocationDetailView.LocationDetailView_Location;
            //else
            //ViewBag.Location = ViewBag.Location;


            //if (locationList.Count > 200)
            //{
            //    if (string.IsNullOrEmpty(searchModel.itemFrom) && string.IsNullOrEmpty(searchModel.itemTo))
            //    {
            //        SaveErrorMessage("物料代码为必选项!");
            //        return View();
            //    }
            //}
            //if (itemList.Count > 200)
            //{
            //    SaveErrorMessage("零件超过200个!");
            //    return View();
            //}

            //if (searchModel.TypeLocation == "0")
            //{
            //    if (string.IsNullOrEmpty(searchModel.Level))
            //    {
            //        SaveWarningMessage("汇总至为必选项!");
            //        return View();
            //    }
            //    if (string.IsNullOrEmpty(searchModel.itemFrom) && string.IsNullOrEmpty(searchModel.itemTo) && string.IsNullOrEmpty(searchModel.locationFrom) && string.IsNullOrEmpty(searchModel.locationTo)
            //        && string.IsNullOrEmpty(searchModel.plantFrom) && string.IsNullOrEmpty(searchModel.plantTo) && string.IsNullOrEmpty(searchModel.regionFrom) && string.IsNullOrEmpty(searchModel.regionTo)
            //        && string.IsNullOrEmpty(searchModel.TheFactory) && string.IsNullOrEmpty(searchModel.TheFactoryTo))
            //    {
            //        SaveWarningMessage("请根据条件查询!");
            //        return View();
            //    }



            //    if (string.IsNullOrEmpty(searchModel.itemFrom))
            //    {
            //        if (!string.IsNullOrEmpty(searchModel.itemTo))
            //        {
            //            SaveWarningMessage("错误:第一个物料为空的情况下,不能输入第二个物料!");
            //            return View();
            //        }
            //    }
            //    if (string.IsNullOrEmpty(searchModel.locationFrom))
            //    {
            //        if (!string.IsNullOrEmpty(searchModel.locationTo))
            //        {
            //            SaveWarningMessage("错误:第一个库位为空的情况下,不能输入第二个库位!");
            //            return View();
            //        }
            //    }

            //    if (string.IsNullOrEmpty(searchModel.regionFrom))
            //    {
            //        if (!string.IsNullOrEmpty(searchModel.regionTo))
            //        {
            //            SaveWarningMessage("错误:第一个区域为空的情况下,不能输入第二个区域!");
            //            return View();
            //        }
            //    }

            //    if (string.IsNullOrEmpty(searchModel.TheFactory))
            //    {
            //        if (!string.IsNullOrEmpty(searchModel.TheFactoryTo))
            //        {
            //            SaveWarningMessage("错误:第一个工厂为空的情况下,不能输入第二个工厂!");
            //            return View();
            //        }
            //    }

            //    if (string.IsNullOrEmpty(searchModel.plantFrom))
            //    {
            //        if (!string.IsNullOrEmpty(searchModel.plantTo))
            //        {
            //            SaveWarningMessage("错误:第一个分厂为空的情况下,不能输入第二个分厂!");
            //            return View();
            //        }
            //    }
            //}
            //else
            //{
            //    if (string.IsNullOrEmpty(searchModel.SAPLocation))
            //    {
            //        SaveWarningMessage("错误:根据SAP库位查询,SAP库位不能为空!");
            //        return View();
            //    }
            //}
            //string locations = string.Empty;
            //string items = string.Empty;
            //string[] locationArr = searchModel.locations.Split(',');
            //string[] itemArr = searchModel.items.Split(',');
            //for (int i = 0; i < locationArr.Length; i++)
            //{
            //    if (!string.IsNullOrWhiteSpace(locationArr[i]) && locationArr[i] != "null" && locationArr[i] != "NULL")
            //    {
            //        locations += locationArr[i]+",";
            //    }
            //}

            //for (int i = 0; i < itemArr.Length; i++)
            //{
            //    if (!string.IsNullOrWhiteSpace(itemArr[i]) && itemArr[i] != "null" && itemArr[i] != "NULL")
            //    {
            //        items += itemArr[i] + ",";
            //    }
            //}
            //ViewBag.Locations = locations;
            //ViewBag.Items = items;
            ViewBag.IsShowCSSupplier = searchModel.IsShowCSSupplier;
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
            return View();
        }
        private ReportSearchStatementModel PrepareSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            ReportSearchStatementModel reportSearchStatementModel = new ReportSearchStatementModel();
            reportSearchStatementModel.ProcedureName = "USP_Report_RealTimeLocationDet";

            IList<Location> locationList = GetReportLocations(searchModel.SAPLocation,searchModel.plantFrom, searchModel.plantTo, searchModel.regionFrom, searchModel.regionTo, searchModel.locationFrom, searchModel.locationTo);
            string location = string.Empty;
            foreach (var lcoList in locationList)
            {
                if (location == string.Empty)
                {
                    location = lcoList.Code;
                }
                else
                {
                    location += "," + lcoList.Code;
                }
            }


            IList<Item> itemList = GetReportItems(searchModel.itemFrom, searchModel.itemTo);
            string item = string.Empty;
            foreach (var ite in itemList)
            {
                if (item == string.Empty)
                {
                    item = ite.Code;
                }
                else
                {
                    item += "," + ite.Code;
                }
            }
           

            SqlParameter[] parameters = new SqlParameter[9];

            parameters[0] = new SqlParameter("@Locations", SqlDbType.VarChar, 8000);
            parameters[0].Value = location;

            parameters[1] = new SqlParameter("@Items", SqlDbType.VarChar, 8000);
            parameters[1].Value = item;

            parameters[2] = new SqlParameter("@SortDesc", SqlDbType.VarChar, 50);
            parameters[2].Value = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            parameters[3] = new SqlParameter("@PageSize", SqlDbType.Int);
            parameters[3].Value = command.PageSize;

            parameters[4] = new SqlParameter("@Page", SqlDbType.Int);
            parameters[4].Value = command.Page;

            parameters[5] = new SqlParameter("@SummaryLevel", SqlDbType.VarChar, 50);
            parameters[5].Value = searchModel.Level;

            //逻辑修改,默认按供应商group
            parameters[6] = new SqlParameter("@IsGroupByManufactureParty", SqlDbType.Bit);
            parameters[6].Value = true;

            parameters[7] = new SqlParameter("@IsGroupByLotNo", SqlDbType.Bit);
            parameters[7].Value = searchModel.hideLotNo;


            parameters[8] = new SqlParameter("@IsSummaryBySAPLoc", SqlDbType.Bit);
            parameters[8].Value = searchModel.TypeLocation == "1" ? true : false; ;
            reportSearchStatementModel.Parameters = parameters;

            return reportSearchStatementModel;
        }
        public ActionResult _AjaxCopyList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {

            DataTable locationArrayTable = new DataTable("LocationArrayTable");
            locationArrayTable.Columns.Add("Field", typeof(string));
            if (!string.IsNullOrEmpty(searchModel.locations))
            {
                string loctions = searchModel.locations.Replace("\r\n", ",");
                loctions = loctions.Replace("\n", ",");
                string[] locationArr = loctions.Split(',');
                for (int i = 0; i < locationArr.Length; i++)
                {
                    if (!string.IsNullOrWhiteSpace(locationArr[i]) && locationArr[i] != "null" && locationArr[i] != "NULL")
                    {
                        locationArrayTable.Rows.Add(locationArr[i]);
                    }
                }
            }

            DataTable itemArrayTable = new DataTable("ItemArrayTable");
            itemArrayTable.Columns.Add("Field", typeof(string));
            if (!string.IsNullOrEmpty(searchModel.items))
            {
                string items = searchModel.items.Replace("\r\n", ",");
                items = items.Replace("\n", ",");
                string[] itemArr = items.Split(',');
                for (int i = 0; i < itemArr.Length; i++)
                {
                    if (!string.IsNullOrWhiteSpace(itemArr[i]) && itemArr[i] != "null" && itemArr[i] != "NULL")
                    {
                        itemArrayTable.Rows.Add(itemArr[i]);
                    }
                }
            }

            SqlParameter[] parameters = new SqlParameter[10];
            parameters[0] = new SqlParameter("@LocationArrayTable", System.Data.SqlDbType.Structured);
            parameters[0].Value = locationArrayTable;

            parameters[1] = new SqlParameter("@IsSapLocation", System.Data.SqlDbType.Bit);
            parameters[1].Value = searchModel.IsSapLocation;

            parameters[2] = new SqlParameter("@ItemArrayTable", System.Data.SqlDbType.Structured);
            parameters[2].Value = itemArrayTable;

            parameters[3] = new SqlParameter("@IsShowCSSupplier", System.Data.SqlDbType.Bit);
            parameters[3].Value = searchModel.IsShowCSSupplier;

            parameters[4] = new SqlParameter("@SortCloumn", System.Data.SqlDbType.VarChar,50);
            parameters[4].Value =command.SortDescriptors.Count>0? command.SortDescriptors[0].Member:string.Empty;

            parameters[5] = new SqlParameter("@SortRule", System.Data.SqlDbType.VarChar, 50);
            parameters[5].Value = command.SortDescriptors.Count > 0 ? command.SortDescriptors[0].SortDirection == ListSortDirection.Descending ? "desc" : "asc":string.Empty;

            parameters[6] = new SqlParameter("@PageSize", SqlDbType.Int);
            parameters[6].Value = command.PageSize;

            parameters[7] = new SqlParameter("@Pager", SqlDbType.Int);
            parameters[7].Value = command.Page;

            parameters[8] = new SqlParameter("@UserId", SqlDbType.Int);
            parameters[8].Value = CurrentUser.Id;

            parameters[9] = new SqlParameter("@RowCount", System.Data.SqlDbType.VarChar, 50);
            parameters[9].Direction = ParameterDirection.Output;

            IList<LocationDetailView> locationDetailView = new List<LocationDetailView>();
            try
            {
                DataSet dataSet = sqlDao.GetDatasetByStoredProcedure("USP_Search_LocationLotDet", parameters, false);

                //Item, Desc1, RefCode, Uom, Location, Qty, CSQty, QulifiedQty, InspectedQty, RejectedQty 
                //Item, Desc1, RefCode, Uom, Location, Qty, CSSupplier, QulifiedQty, InspectedQty, RejectedQty
                if (dataSet.Tables[0] != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in dataSet.Tables[0].Rows)
                    {
                       //row.ItemArray[0].ToString()
                        LocationDetailView lotDet = new LocationDetailView();
                        lotDet.Item = row.ItemArray[0].ToString();
                        lotDet.ItemDescription = row.ItemArray[1].ToString();
                        lotDet.RefrenceItemCode = row.ItemArray[2].ToString();
                        lotDet.Uom = row.ItemArray[3].ToString();
                        lotDet.Location = row.ItemArray[4].ToString();
                        lotDet.Qty = Convert.ToDecimal(row.ItemArray[5]);
                        if (searchModel.IsShowCSSupplier)
                        {
                            lotDet.suppliers = row.ItemArray[6].ToString();
                        }
                        else
                        {
                            lotDet.ConsignmentQty = Convert.ToDecimal(row.ItemArray[6]);
                        }
                        lotDet.QualifyQty = Convert.ToDecimal(row.ItemArray[7]);
                        lotDet.InspectQty = Convert.ToDecimal(row.ItemArray[8]);
                        lotDet.RejectQty = Convert.ToDecimal(row.ItemArray[9]);
                        locationDetailView.Add(lotDet);
                    }
                }
            }
            catch (BusinessException be)
            {
                SaveBusinessExceptionMessage(be);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException != null)
                    {
                        SaveErrorMessage(ex.InnerException.InnerException.Message);
                    }
                    else
                    {
                        SaveErrorMessage(ex.InnerException.Message);
                    }
                }
                else
                {
                    SaveErrorMessage(ex.Message);
                }
            }
            GridModel<LocationDetailView> gridModel = new GridModel<LocationDetailView>();
            gridModel.Total = string.IsNullOrWhiteSpace(parameters[9].Value.ToString()) ? 0 : Convert.ToInt32(parameters[9].Value);
            gridModel.Data = locationDetailView;
            return PartialView(gridModel);
        }
        public void ExportXLS(LocationLotDetailSearchModel searchModel)
        {
            int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = value;

            string sql = PrepareSqlSearchStatement(searchModel);
            string sortingStatement = TempData["sortingStatement"] as string;
            TempData["sortingStatement"] = sortingStatement;
            if (string.IsNullOrWhiteSpace(sortingStatement))
            {
                sortingStatement = "   order by Location,Item,LotNo,HuId,Direction";
            }
            IList<object[]> searchResult = this.genericMgr.FindAllWithNativeSql<object[]>("select top " + value + " 1,r.* from (" + sql + ") as r ");
            IList<LocationLotDetail> locationLotDetailList = new List<LocationLotDetail>();
            if (searchResult != null && searchResult.Count > 0)
            {
                #region
                var productTypes = genericMgr.FindAll<ProductType>().ToDictionary(d => d.Code, d => d);
                //ld.HuId,ld.LotNo,ld.Location,ld.Bin,ld.Item,i.Desc1,i.RefCode,ld.UC,ld.OccupyType,ld.QualityType,ld.IsCS,
                //ld.IsFreeze,ld.IsATP,ld.HuQty,ld.HuUom,ld.Qty,ld.BaseUom,hu.HuOption,ld.Direction,ht.Desc1
                locationLotDetailList = (from tak in searchResult
                                         select new LocationLotDetail
                                         {
                                             HuId = (string)tak[1],
                                             LotNo = (string)tak[2],
                                             Location = (string)tak[3],
                                             Bin = (string)tak[4],
                                             Item = (string)tak[5],
                                             ItemDescription = (string)tak[6],
                                             ReferenceItemCode = (string)tak[7],
                                             UnitCount = (decimal)tak[8],
                                             HuStatusOccupyTypeDescription = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.OccupyType, int.Parse((tak[9]).ToString())),
                                             QualityTypeDescription = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.QualityType, int.Parse((tak[10]).ToString())),
                                             IsConsignment = (bool)tak[11],
                                             IsFreeze = (bool)tak[12],
                                             IsATP = (bool)tak[13],
                                             HuQty = (decimal)tak[14],
                                             HuUom = (string)tak[15],
                                             Qty = (decimal)tak[16],
                                             BaseUom = (string)tak[17],
                                             HuOptionDesc = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.HuOption, int.Parse((tak[18]).ToString())),
                                             Direction = (string)tak[19],
                                             DirectionDescription = (string)tak[20],
                                             MaterialsGroup = (string)tak[21],
                                             MaterialsGroupDesc = (string)tak[22],
                                             ItemVersion = (string)tak[23] + (string.IsNullOrWhiteSpace((string)tak[23]) ? "" : "[" + productTypes.ValueOrDefault((string)tak[23]).Description + "]")
                                         }).ToList();
                #endregion
            }
            ExportToXLS<LocationLotDetail>("LocationLotDetail.xls", locationLotDetailList);
        }
        public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            if (searchModel.TypeLocation == "0")
            {
                if (string.IsNullOrEmpty(searchModel.Level))
                {
                    return PartialView(new GridModel(new List<LocationDetailView>()));
                }

                if (string.IsNullOrEmpty(searchModel.itemFrom) && string.IsNullOrEmpty(searchModel.itemTo) && string.IsNullOrEmpty(searchModel.locationFrom) && string.IsNullOrEmpty(searchModel.locationTo)
                    && string.IsNullOrEmpty(searchModel.plantFrom) && string.IsNullOrEmpty(searchModel.plantTo) && string.IsNullOrEmpty(searchModel.regionFrom) && string.IsNullOrEmpty(searchModel.regionTo))
                {
                    return PartialView(new GridModel(new List<LocationDetailView>()));
                }

                if (string.IsNullOrEmpty(searchModel.itemFrom))
                {
                    if (!string.IsNullOrEmpty(searchModel.itemTo))
                    {
                        return PartialView(new GridModel(new List<LocationDetailView>()));
                    }
                }
                if (string.IsNullOrEmpty(searchModel.locationFrom))
                {
                    if (!string.IsNullOrEmpty(searchModel.locationTo))
                    {
                        return PartialView(new GridModel(new List<LocationDetailView>()));
                    }
                }

                if (string.IsNullOrEmpty(searchModel.regionFrom))
                {
                    if (!string.IsNullOrEmpty(searchModel.regionTo))
                    {
                        return PartialView(new GridModel(new List<LocationDetailView>()));
                    }
                }

                if (string.IsNullOrEmpty(searchModel.TheFactory))
                {
                    if (!string.IsNullOrEmpty(searchModel.TheFactoryTo))
                    {
                        return PartialView(new GridModel(new List<LocationDetailView>()));
                    }
                }

                if (string.IsNullOrEmpty(searchModel.plantFrom))
                {
                    if (!string.IsNullOrEmpty(searchModel.plantTo))
                    {
                        return PartialView(new GridModel(new List<LocationDetailView>()));
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(searchModel.SAPLocation))
                {
                    return PartialView(new GridModel(new List<LocationDetailView>()));
                }
            }
           
     
            IList<Location> locationList = GetReportLocations(searchModel.SAPLocation,searchModel.plantFrom, searchModel.plantTo, searchModel.regionFrom, searchModel.regionTo, searchModel.locationFrom, searchModel.locationTo);
            IList<Item> itemList = GetReportItems(searchModel.itemFrom, searchModel.itemTo);
            if (locationList.Count > 200)
            {
                if (string.IsNullOrEmpty(searchModel.itemFrom) && string.IsNullOrEmpty(searchModel.itemTo))
                {
                    return PartialView(new GridModel(new List<LocationDetailView>()));
                }
            }
            if (itemList.Count > 200)
            {
                return PartialView(new GridModel(new List<LocationDetailView>()));
            }


            ReportSearchStatementModel reportSearchStatementModel = PrepareSearchStatement(command, searchModel);
           
            GridModel<LocationDetailView> gridModel = GetReportAjaxPageData<LocationDetailView>(reportSearchStatementModel);

            //foreach (LocationDetailView locationDetail in gridModel.Data)
            //{
            //    Item item = base.genericMgr.FindById<Item>(locationDetail.Item);
            //    locationDetail.ItemDescription = item.Description;
            //    locationDetail.Uom = item.Uom;
            //    //locationDetail.Name = base.genericMgr.FindById<Location>(locationDetail.Location).Name; ;
            //}
            reportSearchStatementModel.Parameters[3].Value = gridModel.Total;
            TempData["LocationDetailView"] = reportSearchStatementModel;
            return PartialView(gridModel);
        }
 public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     this.GetCommand(ref command, searchModel);
     string sql = PrepareSqlSearchStatement(searchModel);
     int num = base.genericMgr.FindAllWithNativeSql<int>("select count(*) from (" + sql + ") as r1").First<int>();
     string sortingStatement = string.Empty;
     if (command.SortDescriptors.Count != 0)
     {
         if (command.SortDescriptors[0].Member == "UnitCount")
         {
             command.SortDescriptors[0].Member = "UC";
         }
         else if (command.SortDescriptors[0].Member == "HuStatusOccupyTypeDescription")
         {
             command.SortDescriptors[0].Member = "OccupyType";
         }
         else if (command.SortDescriptors[0].Member == "HuOptionDesc")
         {
             command.SortDescriptors[0].Member = "HuOption";
         }
         else if (command.SortDescriptors[0].Member == "QualityTypeDescription")
         {
             command.SortDescriptors[0].Member = "QualityType";
         }
         else if (command.SortDescriptors[0].Member == "IsConsignment")
         {
             command.SortDescriptors[0].Member = "IsCS";
         }
         else if (command.SortDescriptors[0].Member == "ManufactureParty")
         {
             command.SortDescriptors[0].Member = "Party";
         }
         sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
         base.TempData["sortingStatement"] = sortingStatement;
     }
     if (string.IsNullOrWhiteSpace(sortingStatement))
     {
         sortingStatement = "   order by Location,Item,HuId";
     }
     sql = string.Format("select * from (select RowId=ROW_NUMBER()OVER({0}),r1.* from ({1}) as r1 ) as rt where rt.RowId between {2} and {3}", new object[] { sortingStatement, sql, ((command.Page - 1) * command.PageSize) + 1, command.PageSize * command.Page });
     IList<object[]> list = base.genericMgr.FindAllWithNativeSql<object[]>(sql);
     IList<LocationLotDetail> list2 = new List<LocationLotDetail>();
     if ((list != null) && (list.Count > 0))
     {
         list2 = (from tak in list
                  select new LocationLotDetail
                  {
                      HuId = (string)tak[1],
                      LotNo = (string)tak[2],
                      Location = (string)tak[3],
                      Bin = (string)tak[4],
                      Item = (string)tak[5],
                      ItemDescription = (string)tak[6],
                      ReferenceItemCode = (string)tak[7],
                      UnitCount = (decimal)tak[8],
                      IsConsignment = (bool)tak[11],
                      IsFreeze = (bool)tak[12],
                      IsATP = (bool)tak[13],
                      HuQty = (decimal)tak[14],
                      HuUom = (string)tak[15],
                      Qty = (decimal)tak[16],
                      BaseUom = (string)tak[17],
                      ManufactureParty = (string)tak[24],
                      Id = (int)tak[25]
                  }).ToList<LocationLotDetail>();
     }
     GridModel<LocationLotDetail> model = new GridModel<LocationLotDetail>
     {
         Total = num,
         Data = list2
     };
     return base.PartialView(model);
 }
        private ReportSearchStatementModel PrepareSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
           
            ReportSearchStatementModel reportSearchStatementModel = new ReportSearchStatementModel();
            reportSearchStatementModel.ProcedureName = "USP_Busi_GetPlusInventoryHuId";
            SqlParameter[] parameters = new SqlParameter[6];
            parameters[0] = new SqlParameter("@Location", SqlDbType.VarChar, 50);
            parameters[0].Value = searchModel.Location;

            parameters[1] = new SqlParameter("@Item", SqlDbType.VarChar, 50);
            parameters[1].Value = searchModel.Item;

            parameters[2] = new SqlParameter("@LotNoFrom", SqlDbType.VarChar, 50);
            parameters[2].Value = searchModel.LotNoFrom;

            parameters[3] = new SqlParameter("@LotNoTo", SqlDbType.VarChar,50);
            parameters[3].Value = searchModel.LotNoTo;


            parameters[4] = new SqlParameter("@IsFrozen", SqlDbType.Bit);
            parameters[4].Value = searchModel.IsFreeze;

            parameters[5] = new SqlParameter("@IsConsignment", SqlDbType.Bit);
            parameters[5].Value = searchModel.IsConsignment;
            reportSearchStatementModel.Parameters = parameters;
            return reportSearchStatementModel;
        }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, LocationLotDetailSearchModel searchModel)
        {
            string whereStatement = " where HuId is not null";

            IList<object> param = new List<object>();
            SecurityHelper.AddLocationPermissionStatement(ref whereStatement, "l", "Location");
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("LotNo", searchModel.LotNo, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Location", searchModel.Location, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ManufactureParty", searchModel.ManufactureParty, "l", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsFreeze", searchModel.IsFreeze, "l", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
 public ActionResult List(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     TempData["LocationLotDetailSearchModel"] = searchModel;
     return View();
 }
 public ActionResult _CopySearchResult(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     return PartialView();
 }
 public ActionResult _AjaxList(GridCommand command, LocationLotDetailSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<LocationLotDetail>(searchStatementModel, command));
 }