コード例 #1
0
        public float GetCostMonthData()
        {
            if (SelectPeriod == "12")
            {
                StartDateInDateTime = StartDateInDateTime.AddDays(-StartDateInDateTime.Day + 1);
                EndDateTime         = StartDateInDateTime.AddYears(1).AddMonths(-StartDateInDateTime.Month + 1).AddDays(-1);
            }
            else
            {
                StartDateInDateTime = StartDateInDateTime.AddDays(-StartDateInDateTime.Day + 1);
                EndDateTime         = StartDateInDateTime.AddMonths(1).AddDays(-StartDateInDateTime.Day);
            }

            var storage = financeRepository.GetMonthSum(Convert.ToInt32(Request.Query["vehicle"]), StartDateInDateTime,
                                                        EndDateTime);

            date = StartDateInDateTime;
            float    cost = 0;
            DateTime dayStorage;
            int      usedValues = 0;

            if (usedValues <= storage.Count - 1)
            {
                dayStorage = DateTime.ParseExact(storage[usedValues].datetime, "MM/dd/yyyy HH:mm:ss",
                                                 CultureInfo.InvariantCulture);
                if (date.Month == dayStorage.Month)
                {
                    cost = storage[usedValues].sumCost;
                    usedValues++;
                }
            }

            return(cost);
        }
コード例 #2
0
        public IActionResult OnGet()
        {
            if (HttpContext.Session.GetString("ID") == null)
            {
                return(RedirectToPage("Login"));
            }

            if (Request.Query.ContainsKey("SelectPeriod"))
            {
                SelectPeriod = Request.Query["SelectPeriod"];
            }

            switch (SelectPeriod)
            {
            case "0.25" or "0" or null:
                DayAmount           = 7;
                StartDateInDateTime = DateTime.Today.AddDays(-6);
                GetDays();
                CreateWeekGraph();
                CreateCostWeekGraph();
                break;

            case "1":
                DayAmount           = 31;
                StartDateInDateTime = DateTime.Today.AddDays(-30);
                CurrentDate         = DateTime.Now;
                GetDays();
                CreateMonthGraph();
                CreateCostMonthGraph();
                break;

            case "3":
                StartDateInDateTime = DateTime.Today;
                StartDateInDateTime = StartDateInDateTime.AddMonths(-Convert.ToInt32(SelectPeriod) + 1);
                CurrentDate         = DateTime.Now;
                GetMonths();
                CreateMonthBasedGraphs(3);
                CreateCostMonthBasedGraphs(3);
                break;

            case "6":
                StartDateInDateTime = DateTime.Today;
                StartDateInDateTime = StartDateInDateTime.AddMonths(-Convert.ToInt32(SelectPeriod) + 1);
                GetMonths();
                CreateMonthBasedGraphs(6);
                CreateCostMonthBasedGraphs(6);
                break;

            case "12":
                StartDateInDateTime = DateTime.Today;
                StartDateInDateTime = StartDateInDateTime.AddMonths(-StartDateInDateTime.Month + 1);
                GetMonths();
                CreateMonthBasedGraphs(12);
                CreateCostMonthBasedGraphs(12);
                break;
            }

            return(Page());
        }