Beispiel #1
0
        /// <summary>
        /// 根据主表phid取明细剩余金额
        /// </summary>
        /// <param name="id"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public string RestOfAmount(long id, string code)
        {
            List <string>  YskmList             = new List <string>();
            List <Decimal> AmountList           = new List <Decimal>();
            IList <BudgetDtlBudgetDtlModel> dtl = BudgetDtlBudgetDtlFacade.FindByForeignKey(id).Data;

            for (var a = 0; a < dtl.Count; a++)
            {
                if (YskmList.IndexOf(dtl[a].FBudgetAccounts) < 0)
                {
                    YskmList.Add(dtl[a].FBudgetAccounts);
                    AmountList.Add(dtl[a].FAmount + dtl[a].FAmountEdit);
                }
                else
                {
                    AmountList[YskmList.IndexOf(dtl[a].FBudgetAccounts)] += dtl[a].FAmount + dtl[a].FAmountEdit;
                }
            }
            var dicWhere2 = new Dictionary <string, object>();

            new CreateCriteria(dicWhere2).Add(ORMRestrictions <string> .Eq("FProjcode", code))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));
            IList <ExpenseMstModel> ExpenseMstList = ExpenseMstFacade.Find(dicWhere2).Data;

            for (var i = 0; i < ExpenseMstList.Count; i++)
            {
                IList <ExpenseDtlModel> ExpenseDtlList = ExpenseDtlFacade.FindByForeignKey(ExpenseMstList[i].PhId).Data;
                for (var j = 0; j < ExpenseDtlList.Count; j++)
                {
                    var yskmindex = YskmList.IndexOf(ExpenseDtlList[j].FBudgetaccounts);
                    AmountList[yskmindex] = AmountList[yskmindex] - ExpenseDtlList[j].FAmount + ExpenseDtlList[j].FReturnamount;
                }
            }
            var data = new
            {
                YskmList   = YskmList,
                AmountList = AmountList
            };

            //return DataConverterHelper.EntityListToJson(findedresultbudgetdtlbudgetdtl.Data, findedresultbudgetdtlbudgetdtl.Data.Count);
            return(DataConverterHelper.SerializeObject(data));
        }
Beispiel #2
0
        /// <summary>
        /// 额度核销撤销
        /// </summary>
        /// <param name="id"></param>
        /// <param name="FPlayamount"></param>
        /// <returns></returns>
        public CommonResult SaveHXreturn(long id, Decimal FPlayamount)
        {
            CommonResult    result = new CommonResult();
            ExpenseMstModel mst    = ExpenseMstFacade.Find(id).Data;

            mst.FPlayamount      = FPlayamount;
            mst.FIfKeyEvaluation = 0;
            mst.FReturnamount    = 0;
            mst.PersistentState  = PersistentState.Modified;

            var dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("FProjcode", mst.FProjcode))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1))
            .Add(ORMRestrictions <System.Int64> .NotEq("PhId", mst.PhId));
            IList <ExpenseMstModel> ExpenseMstList = ExpenseMstFacade.Find(dicWhere).Data;

            for (var i = 0; i < ExpenseMstList.Count; i++)
            {
                ExpenseMstList[i].FPlayamount     = FPlayamount;
                ExpenseMstList[i].PersistentState = PersistentState.Modified;
            }
            ExpenseMstList.Add(mst);
            result = ExpenseMstFacade.FacadeHelper.Save <long>(ExpenseMstList);

            IList <ExpenseDtlModel> ExpenseDtlList = ExpenseDtlFacade.FindByForeignKey(id).Data;

            for (var j = 0; j < ExpenseDtlList.Count; j++)
            {
                ExpenseDtlList[j].FReturnamount   = 0;
                ExpenseDtlList[j].PersistentState = PersistentState.Modified;
            }
            result = ExpenseDtlFacade.FacadeHelper.Save <long>(ExpenseDtlList);
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 根据预算主键获取信息
        /// </summary>
        /// <param name="YsPhid"></param>
        /// <returns></returns>
        public object GetinfoByProjCode(long YsPhid)
        {
            //一些必要数据加入中文名
            RichHelpDac    helpdac   = new RichHelpDac();
            BudgetMstModel budgetMst = BudgetMstFacade.Find(YsPhid).Data;

            helpdac.CodeToName <BudgetMstModel>(budgetMst, "FExpenseCategory", "FExpenseCategory_EXName", "GHExpenseCategory");
            string  FExpenseCategory                   = budgetMst.FExpenseCategory; //项目类型
            string  FExpenseCategory_EXName            = budgetMst.FExpenseCategory_EXName;
            Decimal FProjAmount                        = budgetMst.FBudgetAmount;    //核定预算数
            IList <BudgetDtlBudgetDtlModel> budgetDtls = BudgetDtlBudgetDtlFacade.FacadeHelper.FindByForeignKey(YsPhid).Data;

            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FSourceOfFunds", "FSourceOfFunds_EXName", "GHSourceOfFunds", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FPaymentMethod", "FPaymentMethod_EXName", "GHPaymentMethod", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FExpensesChannel", "FExpensesChannel_EXName", "GHExpensesChannel", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FBudgetAccounts", "FBudgetAccounts_EXName", "GHBudgetAccounts", "");
            helpdac.CodeToName <BudgetDtlBudgetDtlModel>(budgetDtls, "FQtZcgnfl", "FQtZcgnfl_EXName", "GHQtZcgnfl", "");

            var dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere).Add(ORMRestrictions <string> .Eq("FProjcode", budgetMst.FProjCode))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));  //去除被额度返还的原单据
            var findedresultmst = base.Find(dicWhere).Data;

            Decimal FrozenSum = 0; //冻结数
            Decimal UsedSum   = 0; //已使用数

            for (var i = 0; i < findedresultmst.Count; i++)
            {
                if (findedresultmst[i].FApprovestatus == "3" || findedresultmst[i].FApprovestatus == "4")
                {
                    UsedSum += findedresultmst[i].FSurplusamount;
                    UsedSum -= findedresultmst[i].FReturnamount;
                }
                else
                {
                    FrozenSum += findedresultmst[i].FSurplusamount;
                    FrozenSum -= findedresultmst[i].FReturnamount;
                }
            }
            Decimal FPlayamount = FProjAmount - FrozenSum - UsedSum;//可编报数

            Dictionary <string, Decimal> Yskm_Amount = new Dictionary <string, Decimal>();
            List <Decimal> AmountList = new List <Decimal>();

            for (var a = 0; a < budgetDtls.Count; a++)
            {
                if (!Yskm_Amount.ContainsKey(budgetDtls[a].FBudgetAccounts))
                {
                    Yskm_Amount.Add(budgetDtls[a].FBudgetAccounts, budgetDtls[a].FBudgetAmount);
                }
                else
                {
                    Yskm_Amount[budgetDtls[a].FBudgetAccounts] += budgetDtls[a].FBudgetAmount;
                }
            }
            //去除已经做的单据
            var dicWhere2 = new Dictionary <string, object>();

            new CreateCriteria(dicWhere2).Add(ORMRestrictions <string> .Eq("FProjcode", budgetMst.FProjCode))
            .Add(ORMRestrictions <System.Int32> .Eq("FLifeCycle", 0))
            .Add(ORMRestrictions <System.Int32> .NotEq("FIfpurchase", 1));
            IList <ExpenseMstModel> ExpenseMstList = ExpenseMstFacade.Find(dicWhere2).Data;

            for (var i = 0; i < ExpenseMstList.Count; i++)
            {
                IList <ExpenseDtlModel> ExpenseDtlList = ExpenseDtlFacade.FindByForeignKey(ExpenseMstList[i].PhId).Data;
                for (var j = 0; j < ExpenseDtlList.Count; j++)
                {
                    if (!string.IsNullOrEmpty(ExpenseDtlList[j].FBudgetaccounts) && Yskm_Amount.ContainsKey(ExpenseDtlList[j].FBudgetaccounts))
                    {
                        Yskm_Amount[ExpenseDtlList[j].FBudgetaccounts] = Yskm_Amount[ExpenseDtlList[j].FBudgetaccounts] - ExpenseDtlList[j].FAmount + ExpenseDtlList[j].FReturnamount;
                    }
                }
            }

            object result = new
            {
                FExpenseCategory        = FExpenseCategory,
                FExpenseCategory_EXName = FExpenseCategory_EXName,
                FProjAmount             = FProjAmount,
                FrozenSum   = FrozenSum,
                UsedSum     = UsedSum,
                FPlayamount = FPlayamount,
                Yskm_Amount = Yskm_Amount,
                budgetDtls  = budgetDtls
            };

            return(result);
        }
Beispiel #4
0
 /// <summary>
 /// 通过外键值获取ExpenseDtl明细数据
 /// </summary>
 /// <param name="id">外键值</param>
 /// <returns></returns>
 public FindedResults <ExpenseDtlModel> FindExpenseDtlByForeignKey <TValType>(TValType id)
 {
     return(ExpenseDtlFacade.FindByForeignKey(id));
 }