Exemple #1
0
        public static RelationPredicateBucket CreateBucket(short godina, string jqGridFilters)
        {
            RelationPredicateBucket bucket = new RelationPredicateBucket(RacunGlavaFields.Godina == godina);

            if (!string.IsNullOrWhiteSpace(jqGridFilters))
            {
                bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(jqGridFilters, typeof(RacunGlavaFields), DbGenericHelper.GetDbGenericTypeByName));

                JqGridFilter jqGrid = JsonConvert.DeserializeObject <JqGridFilter>(jqGridFilters);
                if (jqGrid != null &&
                    jqGrid.rules != null)
                {
                    DateTime?datumOd = null;
                    DateTime?datumDo = null;
                    foreach (JqGridFilterItem item in jqGrid.rules.Where(r => r.field == "Datum"))
                    {
                        if (item.op == "ge")
                        {
                            datumOd = DateTime.Parse(item.data).Date;
                        }

                        if (item.op == "le")
                        {
                            datumDo = DateTime.Parse(item.data).Date.AddDays(1);
                        }

                        bucket.PredicateExpression.Add(PredicateHelper.FilterValidEntities(datumOd, datumDo, RacunGlavaFields.Datum));
                    }
                }
            }

            return(bucket);
        }
Exemple #2
0
        public ActionResult GetArtiklCollectionForPaging(string sidx, string sord, string filters, int page = 1)
        {
            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                RelationPredicateBucket bucket = new RelationPredicateBucket();
                long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                bucket.PredicateExpression.Add(ArtiklFields.FirmaId == firmaId);

                if (filters != null)
                {
                    bucket.Relations.Add(ArtiklEntity.Relations.PdvEntityUsingPdvId);
                    bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(filters, typeof(ArtiklFields), DbGenericHelper.GetDbGenericTypeByName));
                }

                bool?isSortAscending = PagerBase.IsJqgridSortAscending(sord);

                PrefetchPath2 prefetchPath = new PrefetchPath2(EntityType.ArtiklEntity);
                prefetchPath.Add(ArtiklEntity.PrefetchPathPdv);

                ArtiklPager artiklPager = new ArtiklPager();
                artiklPager.LoadData(adapter, bucket, page, Common.Config.JqGridPageSize, sidx, isSortAscending);

                return(CreateJsonResponse(artiklPager.CreateJqGridRespose()));
            }
        }
Exemple #3
0
        public ActionResult GetPartnerCollectionForPaging(string sidx, string sord, string filters, int page = 1)
        {
            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                RelationPredicateBucket bucket = new RelationPredicateBucket();
                long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                bucket.PredicateExpression.Add(PartnerFields.FirmaId == firmaId);

                if (filters != null)
                {
                    bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(filters, typeof(PartnerFields), DbGenericHelper.GetDbGenericTypeByName));
                }

                if (!string.IsNullOrWhiteSpace(filters))
                {
                    JqGridFilter     jqGridFilter = JsonConvert.DeserializeObject <JqGridFilter>(filters);
                    bool             foo;
                    JqGridFilterItem filterItem = jqGridFilter.rules.Where(r => r.field == PartnerFields.IsActive.Name && bool.TryParse(r.data, out foo)).SingleOrDefault();
                    if (filterItem != null)
                    {
                        bool isActive = bool.Parse(filterItem.data);
                        bucket.PredicateExpression.Add(PartnerFields.IsActive == isActive);
                    }
                }

                bool?isSortAscending = PagerBase.IsJqgridSortAscending(sord);

                PartnerPager partnerPager = new PartnerPager();
                partnerPager.LoadData(adapter, bucket, page, Common.Config.JqGridPageSize, sidx, isSortAscending);

                return(CreateJsonResponse(partnerPager.CreateJqGridRespose()));
            }
        }
Exemple #4
0
        public ActionResult GetTarifaCollectionForPaging(string sidx, string sord, string filters, int page = 1)
        {
            using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
            {
                RelationPredicateBucket bucket = new RelationPredicateBucket();
                long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                bucket.PredicateExpression.Add(TarifaFields.FirmaId == firmaId);

                if (!string.IsNullOrWhiteSpace(filters))
                {
                    bucket.PredicateExpression.Add(PredicateHelper.CreatePredicateFromJqGridFilterString(filters, typeof(TarifaFields), DbGenericHelper.GetDbGenericTypeByName));
                }

                bool?isSortAscending = PagerBase.IsJqgridSortAscending(sord);

                TarifaPager tarifaPager = new TarifaPager();
                tarifaPager.LoadData(adapter, bucket, page, Common.Config.JqGridPageSize, sidx, isSortAscending);

                return(CreateJsonResponse(tarifaPager.CreateJqGridRespose()));
            }
        }