コード例 #1
0
        protected override ActionResult Display(GridCommand command, string id, bool isNew)
        {
            int totalRows = 0;
            IEnumerable <CycleDetails> resultList;

            if (isNew == true || id == "0")
            {
                if (TempEntityList.Count <= 0)
                {
                    ItemLibrary        ItemLibrary = new smART.Library.ItemLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                    IEnumerable <Item> itemList    = ItemLibrary.GetAll().Where(o => o.IsActive == true && o.Active_Ind == true);
                    int iValue = 1;
                    foreach (var item in itemList)
                    {
                        CycleDetails cycleDetails = new CycleDetails();
                        cycleDetails.Item = item;
                        cycleDetails.ID   = iValue;
                        TempEntityList.Add(cycleDetails);
                        iValue++;
                    }
                    resultList = TempEntityList;
                    Session["CycleDetails"] = TempEntityList;
                }
                else
                {
                    resultList = _cycleDetailsOps.GetAllByPaging(TempEntityList, out totalRows,
                                                                 command.Page,
                                                                 command.PageSize,
                                                                 command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].Member,
                                                                 command.SortDescriptors.Count == 0 ? "" : command.SortDescriptors[0].SortDirection == System.ComponentModel.ListSortDirection.Descending ? "Desc" : "Asc",
                                                                 IncludePredicates,
                                                                 (command.FilterDescriptors.Count == 0 ? null : command.FilterDescriptors)
                                                                 );
                }
                Session["CycleDetails"] = TempEntityList;
                totalRows = TempEntityList.Count;
            }
            else
            {
                resultList = ((IParentChildLibrary <CycleDetails>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize == 0 ? 20 : command.PageSize, "", "Asc", IncludePredicates);
            }

            return(View(new GridModel {
                Data = resultList, Total = totalRows
            }));
        }
コード例 #2
0
        protected override ActionResult Display(GridCommand command, string id, bool isNew)
        {
            int totalRows = 0;
            IEnumerable <PriceListItem> resultList; // = ((IParentChildLibrary<TEntity>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize==0?20:command.PageSize, "", "Asc", IncludePredicates);

            //if (isNew==true || id=="0" || id==null)
            if (isNew == true || id == "0")
            {
                //PriceListItem priceListItem = new PriceListItem();
                //priceListItem.Item = new Item() { ID=1,Item_Category="A",Item_Group="B",Long_Name="Item1",Short_Name="I1",Site_Org_ID=1,Priced=true,Active_Ind=true};
                //TempEntityList.Add(priceListItem);

                if (id == "-1")
                {
                    string      dbContextConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString();
                    ItemLibrary ItemLibrary = new smART.Library.ItemLibrary();
                    ItemLibrary.Initialize(dbContextConnectionString);
                    IEnumerable <Item> itemList = ItemLibrary.GetAll().Where(o => o.Priced == true);
                    int iValue = 1;
                    foreach (var item in itemList)
                    {
                        PriceListItem priceListItem = new PriceListItem();
                        priceListItem.Item = item;
                        priceListItem.ID   = iValue;
                        TempEntityList.Add(priceListItem);
                        iValue++;
                        //((PriceListItemLibrary)Library).Add(priceListItem);
                    }
                }
                resultList = TempEntityList;
                totalRows  = TempEntityList.Count;
            }
            else
            {
                resultList = ((IParentChildLibrary <PriceListItem>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize == 0 ? 20 : command.PageSize, "", "Asc", IncludePredicates);
                //resultList = ((IParentChildLibrary<PriceListItem>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize, "", "Asc", IncludePredicates);
            }

            return(View(new GridModel {
                Data = resultList, Total = totalRows
            }));
        }