Пример #1
0
        public IList <MAccount> GetByAccountCat(MAccountCat accountCat)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(MAccount));

            criteria.Add(Expression.Eq("AccountCatId", accountCat));
            criteria.SetCacheable(true);
            IList <MAccount> list = criteria.List <MAccount>();

            return(list);
        }
Пример #2
0
        public virtual ActionResult GetList(string accountCatId)
        {
            IList <MAccount> accounts;

            if (!string.IsNullOrEmpty(accountCatId))
            {
                MAccountCat accountCat = _mAccountCatRepository.Get(accountCatId);
                accounts = _mAccountRepository.GetByAccountCat(accountCat);
            }
            else
            {
                accounts = _mAccountRepository.GetAll();
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0}:{1}", string.Empty, "-Pilih Akun-");
            foreach (MAccount mAccount in accounts)
            {
                sb.AppendFormat(";{0}:{1}", mAccount.Id, mAccount.AccountName);
            }
            return(Content(sb.ToString()));
        }
Пример #3
0
        public IEnumerable <MAccount> GetPagedAccountList(string orderCol, string orderBy, int pageIndex, int maxRows, ref int totalRows, MAccountCat accountCat)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(MAccount));

            ////calculate total rows
            //totalRows = Session.CreateCriteria(typeof(MAccount))
            //    .SetProjection(Projections.RowCount())
            //    .FutureValue<int>().Value;

            ////get list results
            //if (maxRows != 0)
            //{
            //    criteria.SetMaxResults(maxRows)
            //        .SetFirstResult((pageIndex - 1)*maxRows);
            //}

            //  criteria.AddOrder(new Order(orderCol, orderBy.Equals("asc") ? true : false))
            //  ;
            criteria.Add(Expression.Eq("AccountCatId", accountCat));
            criteria.Add(Expression.IsNull("AccountParentId"));
            criteria.SetCacheable(true);
            IEnumerable <MAccount> list = criteria.List <MAccount>();

            return(list);

            IQuery q = Session.CreateQuery(
                @"
            select distinct acc
            from MAccount as acc
                left outer join fetch acc.Children
                where acc.AccountCatId = :accountCatType
               
");

            q.SetEntity("AccountCatId", accountCat);
            return(q.List <MAccount>());
        }
Пример #4
0
        public virtual ActionResult List(string sidx, string sord, int page, int rows, string accountCatId)
        {
            MAccountCat accountCat = _mAccountCatRepository.Get(accountCatId);

            int totalRecords = 0;
            var accounts     = _mAccountRepository.GetPagedAccountList(sidx, sord, page, 0, ref totalRecords, accountCat);
            int pageSize     = rows;
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            string level;

            //var jsonData = new
            //{
            //    total = totalPages,
            //    page = page,
            //    records = totalRecords,
            //    rows = (
            //        from itemCat in itemCats
            //        //where itemCat.AccountParentId == null
            //        select new
            //        {
            //            i = itemCat.Id.ToString(),
            //            cell = new string[] {
            //                itemCat.Id,
            //                itemCat.AccountName,
            //                itemCat.AccountDesc,
            //                 "0"

            //            }
            //        }).ToArray()
            //};

            IEnumerable <MAccount> result = new List <MAccount>();

            result = Helper.Extensions <MAccount> .Traverse(accounts, i => i.Children);

            //result = accounts.Traverse(i => i.Children);
            var jsonData = new
            {
                total   = totalPages,
                page    = page,
                records = totalRecords,
                rows    = (
                    from acc in result
                    select new
                {
                    i = acc.Id.ToString(),
                    cell = new string[] {
                        acc.Id,
                        acc.Id,
                        acc.AccountName,
                        acc.AccountParentId != null ? acc.AccountParentId.Id : null,
                        //acc.AccountParentId != null ? acc.AccountParentId.AccountName : null,
                        acc.AccountDesc,
                        GetLevel(acc, true).ToString(),
                        acc.AccountParentId != null ? string.Format("<![CDATA[{0}]]>", acc.AccountParentId.Id) : "NULL",
                        // acc.Children.Count == 0  ? true.ToString() : false.ToString(),
                        //acc.AccountParentId != null ? false.ToString():true.ToString(),
                        true.ToString(),
                        true.ToString()
                    }
                }).ToArray()
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }