Beispiel #1
0
        public ActionResult Index(int?page, string searchTB_Filter)
        {
            IQueryable <Currency> list = db.Currencies.Where(x => x.UserId == UserId);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list = list.ApplyFilterPatern(filter,
                                                  x => x.Name,
                                                  x => x.ShortName);
                }
            }

            list = list.OrderBy(x => x.Name);
            var model = SearchablePagedList <Currency> .Create(list, page, 25, searchTB_Filter);

            if (Request.IsAjaxRequest())
            {
                return new JsonResult
                       {
                           Data = new
                           {
                               html = this.RenderPartialView("IndexList", model)
                           }
                       }
            }
            ;
            else
            {
                return(View("Index", model));
            }
        }
Beispiel #2
0
        public static IDisposable Table <T>(this HtmlHelper helper, string type, SearchablePagedList <T> model)
        {
            helper.ViewContext.Writer.Write(String.Format(@"<table class=""table table-hover {0}"">", type));

            string pager = "";

            if ((model != null) && (String.IsNullOrEmpty(model.SearchString)))
            {
                pager = helper.PagerForString(model, "Index", helper.ViewContext.Controller.GetType().Name.Replace("Controller", ""), "Gett()");
            }

            return(new TagTerminator(helper, @"</table>" + pager));
        }
Beispiel #3
0
        public ActionResult Index(int?page, string searchTB_Filter, bool?isSelect)
        {
            IQueryable <Member> list = db.Members
                                       .Where(x => x.UserId == UserId);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list = list.ApplyFilterPatern(filter,
                                                  x => x.Email
                                                  , x => x.FirstName
                                                  , x => x.FullName
                                                  , x => x.LastName
                                                  , x => x.MiddleName
                                                  );
                }
            }

            list = list.OrderBy(x => x.FullName).ThenBy(x => x.LastName).ThenBy(x => x.FirstName);
            var r    = list.ToList();
            var item = r.FirstOrDefault(x => x.Id == UserId);

            if (item != null)
            {
                r.Remove(item);
                r.Insert(0, item);
            }
            var model = SearchablePagedList <Member> .Create(r, page, 25, searchTB_Filter);

            if (Request.IsAjaxRequest())
            {
                return new JsonResult
                       {
                           Data = new
                           {
                               html = this.RenderPartialView("IndexList", model)
                           }
                       }
            }
            ;
            else
            {
                return(View("Index", model));
            }
        }
Beispiel #4
0
        public ActionResult Index(Guid?currencyId, int?page, string searchTB_Filter)
        {
            if (!currencyId.HasValue)
            {
                return(RedirectToAction("Index", "Currency"));
            }

            ViewBag.currencyId = currencyId;

            IQueryable <CurrencyRate> list = db.CurrencyRates.Include(x => x.Currency).Where(x => x.Currency.UserId == UserId);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list = list.ApplyFilterPatern(filter,
                                                  x => x.Currency.Name,
                                                  x => x.Currency.ShortName,
                                                  x => x.DateTime
                                                  );
                }
            }

            list = list.Where(x => x.CurrencyId == currencyId.Value);

            list = list.OrderByDescending(x => x.DateTime);
            var model = SearchablePagedList <CurrencyRate> .Create(list, page, 25, searchTB_Filter);

            if (Request.IsAjaxRequest())
            {
                return new JsonResult
                       {
                           Data = new
                           {
                               html = this.RenderPartialView("IndexList", model)
                           }
                       }
            }
            ;
            else
            {
                return(View("Index", model));
            }
        }
Beispiel #5
0
 public static IDisposable Table <T>(this HtmlHelper helper, SearchablePagedList <T> model)
 {
     return(Table <T>(helper, "", null));
 }
Beispiel #6
0
 public static IDisposable TableStripped <T>(this HtmlHelper helper, SearchablePagedList <T> model)
 {
     return(Table(helper, "table-striped", model));
 }
Beispiel #7
0
        public ActionResult Index(DateTime?DateFrom, DateTime?DateTo, int?page, string searchTB_Filter, Guid memberId, Guid currencyId)
        {
            DateFrom         = DefaultDateFrom(DateFrom);
            DateTo           = DefaultDateTo(DateTo);
            ViewBag.DateFrom = DateFrom.Value.ToStringD();
            ViewBag.DateTo   = DateTo.Value.ToStringD();

            List <MemberMotion> list = new List <MemberMotion>();


            var c      = db.Currencies.Find(currencyId);
            var member = db.Members.FirstOrDefault(x => x.Id == memberId & x.UserId == UserId);

            memberId = db.Members.FirstOrDefault(x => x.UserId == member.MainMemberId & x.MainMemberId == UserId).Id;

            ViewBag.Currency = db.Currencies.FirstOrDefault(x => x.UserId == UserId & x.CurrencyType == c.CurrencyType);
            ViewBag.Member   = member;


            IQueryable <MemberDayReport> list1 = db.MemberDayReports.Where(x => x.Member.MainMemberId == UserId & x.MemberId == memberId & x.DateTime >= DateFrom & x.DateTime <= DateTo);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list1 = list1.ApplyFilterPatern(filter,
                                                    x => x.DateTime
                                                    , x => x.Member.FirstName
                                                    , x => x.Member.FullName
                                                    , x => x.Member.LastName
                                                    , x => x.Member.MiddleName
                                                    );
                }
            }
            list1 = list1.OrderByDescending(x => x.DateTime).ThenBy(x => x.Member.FullName).ThenBy(x => x.Member.LastName).ThenBy(x => x.Member.FirstName);

            IQueryable <MemberPayment> list2 = db.MemberPayments.Where(x => x.Member.MainMemberId == UserId & x.DateTime >= DateFrom & x.DateTime <= DateTo & x.MemberId == memberId);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list2 = list2.ApplyFilterPatern(filter,
                                                    x => x.DateTime
                                                    , x => x.Member.FirstName
                                                    , x => x.Member.FullName
                                                    , x => x.Member.LastName
                                                    , x => x.Member.MiddleName
                                                    );
                }
            }
            list2 = list2.OrderByDescending(x => x.DateTime).ThenBy(x => x.Member.FullName).ThenBy(x => x.Member.LastName).ThenBy(x => x.Member.FirstName);

            list.AddRange(list1.ToList());
            list.AddRange(list2.ToList());

            decimal rest = db.MemberDayReports.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId).Sum(x => (decimal?)x.Amount * (decimal?)x.Value) ?? 0;

            rest        -= db.MemberPayments.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId).Sum(x => (decimal?)x.Amount) ?? 0;
            ViewBag.Rest = rest;


            var debtStart = db.MemberDayReports.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId & x.DateTime < DateFrom).Sum(x => (decimal?)x.Amount * (decimal?)x.Value) ?? 0;

            debtStart -= db.MemberPayments.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId & x.DateTime < DateFrom).Sum(x => (decimal?)x.Amount) ?? 0;

            var debtEnd = db.MemberDayReports.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId & x.DateTime < DateTo).Sum(x => (decimal?)x.Amount * (decimal?)x.Value) ?? 0;

            debtEnd -= db.MemberPayments.Where(x => x.MemberId == memberId & x.Member.MainMemberId == UserId & x.DateTime < DateTo).Sum(x => (decimal?)x.Amount) ?? 0;

            ViewBag.DebtStart = debtStart;
            ViewBag.OnEnd     = debtEnd;

            var model = SearchablePagedList <MemberMotion> .Create(list, page, 25, searchTB_Filter);

            FillViewBag();
            if (Request.IsAjaxRequest())
            {
                return new JsonResult
                       {
                           Data = new
                           {
                               html = this.RenderPartialView("IndexList", model)
                           }
                       }
            }
            ;

            return(View(model));
        }
Beispiel #8
0
        public ActionResult Index(int?page, string searchTB_Filter)
        {
            var DateTo = DefaultDateTo(DateTime.Now);

            var q1 =
                from payments in db.MemberDayReports.Where(x => x.UserId == UserId & x.DateTime < DateTo)
                group payments by new { payments.Member } into g
                select new
            {
                Member = g.Key.Member,
                Amount = g.Sum(x => x.Value * x.Amount)
            };

            var q2 =
                from payments in db.MemberPayments.Where(x => x.UserId == UserId & x.DateTime < DateTo)
                group payments by new { payments.Member } into g
                select new {
                Member = g.Key.Member,
                Amount = g.Sum(x => x.Amount)
            };

            IQueryable <MemberDebt> list =
                from report in q1
                join payments in q2
                on new { MemberId = report.Member.Id } equals new { MemberId = payments.Member.Id } into paymentsJ
            from payments in paymentsJ.DefaultIfEmpty()
            group new { report, payments } by new { report.Member } into g
                                    select new MemberDebt
            {
                Member = g.Key.Member,
                Debt   = g.Sum(x => x.report.Amount - ((decimal?)x.payments.Amount ?? 0))
            };

            list = list.Where(x => x.Debt != 0);

            if (!String.IsNullOrEmpty(searchTB_Filter))
            {
                string[] filters = searchTB_Filter.Split(' ');
                foreach (var filter in filters)
                {
                    list = list.ApplyFilterPatern(filter,
                                                  x => x.Member.FirstName
                                                  , x => x.Member.FullName
                                                  , x => x.Member.LastName
                                                  , x => x.Member.MiddleName
                                                  );
                }
            }

            list = list.OrderBy(x => x.Member.FullName).ThenBy(x => x.Member.LastName).ThenBy(x => x.Member.FirstName).ThenBy(x => x.Currency.ShortName);
            var model = SearchablePagedList <MemberDebt> .Create(list, page, 25, searchTB_Filter);

            FillViewBag();
            if (Request.IsAjaxRequest())
            {
                return new JsonResult
                       {
                           Data = new
                           {
                               html = this.RenderPartialView("IndexList", model)
                           }
                       }
            }
            ;

            return(View(model));
        }