Exemplo n.º 1
0
        /// <summary>
        /// 根据项目代码获取额度核销总金额
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public decimal GetHXsumByCode(string code)
        {
            decimal sum      = 0;
            var     dicWhere = new Dictionary <string, object>();

            new CreateCriteria(dicWhere).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(dicWhere).Data;

            if (ExpenseMstList.Count > 0)
            {
                for (var i = 0; i < ExpenseMstList.Count; i++)
                {
                    if (ExpenseMstList[i].FIfKeyEvaluation == 1)
                    {
                        var dicWhere2 = new Dictionary <string, object>();
                        new CreateCriteria(dicWhere2).Add(ORMRestrictions <Int64> .Eq("MstPhid", ExpenseMstList[i].PhId));
                        IList <ExpenseHxModel> ExpenseHxList = ExpenseHxFacade.Find(dicWhere2).Data;
                        if (ExpenseHxList.Count > 0)
                        {
                            for (var j = 0; j < ExpenseHxList.Count; j++)
                            {
                                sum += ExpenseHxList[j].FAmount;
                            }
                        }
                    }
                }
            }
            return(sum);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 额度核销执行完毕确认
        /// </summary>
        /// <param name="id"></param>
        /// <param name="FPlayamount"></param>
        /// <param name="FReturnamount"></param>
        /// <param name="dtls"></param>
        /// <returns></returns>
        public CommonResult SaveHXgo(long id, Decimal FPlayamount, Decimal FReturnamount, List <ExpenseDtlModel> dtls)
        {
            CommonResult    result = new CommonResult();
            ExpenseMstModel mst    = ExpenseMstFacade.Find(id).Data;

            mst.FPlayamount      = FPlayamount;
            mst.FIfKeyEvaluation = 1;
            mst.FReturnamount    = FReturnamount;
            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);

            List <ExpenseDtlModel> ExpenseDtlList = new List <ExpenseDtlModel>();

            for (var j = 0; j < dtls.Count; j++)
            {
                ExpenseDtlModel dtl = ExpenseDtlFacade.Find(dtls[j].PhId).Data;
                dtl.FReturnamount   = dtls[j].FReturnamount;
                dtl.PersistentState = PersistentState.Modified;
                ExpenseDtlList.Add(dtl);
            }
            result = ExpenseDtlFacade.FacadeHelper.Save <long>(ExpenseDtlList);
            return(result);
        }
Exemplo n.º 4
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);
        }