Beispiel #1
0
        public override ActionResult Run()
        {
            DateTime         dt              = new DateTime(Convert.ToInt32(model.Year), Convert.ToInt32(model.Month), 1);
            IList <Hshld>    hshldList       = hshldDao.SelectToInfoByDate(UserSession.Grpd, dt);
            IList <Hshld>    hshldCreditList = hshldDao.SelectToCreditByDate(UserSession.Grpd, dt.AddMonths(-1));
            SearchResultBean dataList        = new SearchResultBean();

            //nomalList create
            foreach (Hshld hshld in hshldList)
            {
                SearchResultBean.Node node = CreateNode(hshld);
                if (String.Equals(hshld.Cd, "010"))
                {
                    dataList.AddAccount(node);
                    node          = (SearchResultBean.Node)node.Clone();
                    node.PriceNum = node.PriceNum * -1;
                }
                dataList.AddTotal(node);
            }

            //CreditList create
            foreach (Hshld hshldCredit in hshldCreditList)
            {
                SearchResultBean.Node node = CreateNode(hshldCredit);
                dataList.AddCredit(node);
            }

            //CreditList create
            dataList.CreditList      = dataList.CreditList.OrderBy((node) => { return(node.Date); }).ToList();
            dataList.CreditAmountNum = SumCreditTotal(dataList.CreditList);

            //Next coding is put the total of credit into the datalist.
            if (!Decimal.Zero.Equals(dataList.CreditAmountNum))
            {
                dataList.AddTotal(CreateSumCreditNode(dataList.CreditAmountNum));
            }

            //AccountList create
            dataList.AccountList      = dataList.AccountList.OrderBy((node) => { return(node.Date); }).ToList();
            dataList.AccountAmountNum = hshldDao.SelectSumAccountTotal(UserSession.Grpd, dt.AddMonths(1));


            dataList.IncomeAmountNum = IncomeTotal(dataList.TotalList);
            dataList.ExpendAmountNum = ExpendTotal(dataList.TotalList);

            //nomalList create
            if (!String.IsNullOrEmpty(model.Day))
            {
                dataList.TotalList = dataList.TotalList.Where(node => String.Equals(model.Day, node.Day)).ToList();
            }
            if (!String.IsNullOrEmpty(model.Type))
            {
                dataList.TotalList = dataList.TotalList.Where(node => String.Equals(model.Type, node.Tp)).ToList();
            }
            dataList.TotalList      = dataList.TotalList.OrderBy((node) => { return(node.Date); }).ToList();
            dataList.TotalAmountNum = SumTotal(dataList.TotalList);

            ResultBean.Add("DATA", dataList);

            ResultBean.Result = Define.RESULT_OK;
            return(Json(ResultBean, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public override ActionResult Run()
        {
            base.Logger.Info("Run Ok!");
            String json = HttpConnector.GetInstance().GetDataRequest("GetHouseholdList.php", new Dictionary <String, Object>()
            {
                { "GID", UserSession.Id },
                { "YEAR", model.Year },
                { "MONTH", model.Month }
            });

            base.Logger.Info("GetHouseholdList.php Ok!");
            IList <HouseHold> householdList = GetListByJson <HouseHold>(json);

            json = HttpConnector.GetInstance().GetDataRequest("GetHouseholdList2.php", new Dictionary <String, Object>()
            {
                { "GID", UserSession.Id },
                { "YEAR", model.Year },
                { "MONTH", model.Month },
                { "CATEGORY", "020" }
            });
            base.Logger.Info("GetHouseholdList2.php Ok!");
            IList <HouseHold> creditList = GetListByJson <HouseHold>(json);

            json = HttpConnector.GetInstance().GetDataRequest("SumHousehold.php", new Dictionary <String, Object>()
            {
                { "GID", UserSession.Id },
                { "CD", "010" },
                { "TP", "011" },
                { "YEAR", model.Year },
                { "MONTH", model.Month }
            });
            base.Logger.Info("SumHousehold.php Ok!");
            HouseholdSum income = GetObjectByJson <HouseholdSum>(json);

            json = HttpConnector.GetInstance().GetDataRequest("SumHousehold.php", new Dictionary <String, Object>()
            {
                { "GID", UserSession.Id },
                { "CD", "010" },
                { "TP", "012" },
                { "YEAR", model.Year },
                { "MONTH", model.Month }
            });
            base.Logger.Info("SumHousehold.php Ok!");
            HouseholdSum     expend     = GetObjectByJson <HouseholdSum>(json);
            Decimal          accountSum = income.Value - expend.Value;
            SearchResultBean result     = new SearchResultBean();

            //nomalList create
            foreach (HouseHold hshld in householdList.OrderBy(node => node.Date))
            {
                SearchResultBean.Node node = CreateNode(hshld);
                if (String.Equals(hshld.Ctgry, "010"))
                {
                    result.AddAccount(node);
                    node          = (SearchResultBean.Node)node.Clone();
                    node.PriceNum = node.PriceNum * -1;
                }
                result.AddTotal(node);
            }
            //crediteList Create
            result.CreditList      = creditList.OrderBy(node => node.Date).Select(node => CreateNode(node)).ToList();
            result.CreditAmountNum = SumCreditTotal(result.CreditList);

            //Next coding is put the total of credit into the datalist.
            if (!Decimal.Zero.Equals(result.CreditAmountNum))
            {
                result.AddTotal(CreateSumCreditNode(result.CreditAmountNum));
            }
            //AccountList create
            result.AccountList      = result.AccountList.OrderBy((node) => { return(node.Date); }).ToList();
            result.AccountAmountNum = accountSum;

            result.IncomeAmountNum = IncomeTotal(result.TotalList);
            result.ExpendAmountNum = ExpendTotal(result.TotalList);

            //nomalList create
            if (!String.IsNullOrEmpty(model.Day))
            {
                result.TotalList = result.TotalList.Where(node => String.Equals(model.Day, node.Day)).ToList();
            }
            if (!String.IsNullOrEmpty(model.Type))
            {
                result.TotalList = result.TotalList.Where(node => String.Equals(model.Type, node.Tp)).ToList();
            }
            result.TotalList      = result.TotalList.OrderBy((node) => { return(node.Date); }).ToList();
            result.TotalAmountNum = SumTotal(result.TotalList);

            ResultBean.Result = Define.RESULT_OK;
            ResultBean.Add("DATA", result);
            base.Logger.Info("Run Ok!");

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