Exemplo n.º 1
0
        public JsonResult ApportionCost(string DefineID, string InputData, string BelongYear, string BelongMonth)
        {
            var dic          = this.GetDataDicByID("S_EP_DefineApportion", DefineID, Config.ConnEnum.InfrasBaseConfig);
            var inputDataDic = new Dictionary <string, object>();

            if (!String.IsNullOrEmpty(InputData))
            {
                inputDataDic = JsonHelper.ToObject(InputData);
            }

            if (String.IsNullOrEmpty(BelongYear))
            {
                throw new Formula.Exceptions.BusinessValidationException("成本分摊必须指定年份");
            }
            if (String.IsNullOrEmpty(BelongMonth))
            {
                throw new Formula.Exceptions.BusinessValidationException("成本分摊必须指定月份");
            }
            var dt = this.SQLDB.ExecuteDataTable(String.Format("SELECT * FROM S_EP_LockAccount WHERE State='{2}' AND BelongYear='{0}' AND BelongMonth='{1}'",
                                                               BelongYear, BelongMonth, "Finish"));

            if (dt.Rows.Count > 0)
            {
                throw new Formula.Exceptions.BusinessValidationException(String.Format("{0}年{1}月已经结账锁定,无法进行分摊计算", dic.GetValue("BelongYear"),
                                                                                       dic.GetValue("BelongMonth")));
            }

            var define = new S_EP_DefineApportion(dic);
            var result = define.CalculateCost(inputDataDic);

            return(Json(result));
        }