public ActionResult Item(string keyGuid, CostFormularEntity entity, bool isOnlyPlaceHolder = true)
        {
            bool   isSuccessful   = false;
            string displayMessage = string.Empty;

            CostFormularEntity targetEntity = null;

            if (GuidHelper.IsInvalidOrEmpty(keyGuid))
            {
                targetEntity = new CostFormularEntity();
                SetTargetEntityValue(entity, ref targetEntity);
                isSuccessful = CostFormularBLL.Instance.Create(targetEntity);
            }
            else
            {
                targetEntity = CostFormularBLL.Instance.Get(keyGuid);
                SetTargetEntityValue(entity, ref targetEntity);

                isSuccessful = CostFormularBLL.Instance.Update(targetEntity);
            }

            if (isSuccessful == true)
            {
                displayMessage = "数据保存成功";
            }
            else
            {
                displayMessage = "数据保存失败";
            }

            return(Json(new LogicStatusInfo(isSuccessful, displayMessage)));
        }
        public ActionResult Item(string keyGuid, CostFormularEntity entity, bool isOnlyPlaceHolder = true)
        {
            bool isSuccessful = false;
            string displayMessage = string.Empty;

            CostFormularEntity targetEntity = null;
            if (GuidHelper.IsInvalidOrEmpty(keyGuid))
            {
                targetEntity = new CostFormularEntity();
                SetTargetEntityValue(entity, ref targetEntity);
                isSuccessful = CostFormularBLL.Instance.Create(targetEntity);
            }
            else
            {
                targetEntity = CostFormularBLL.Instance.Get(keyGuid);
                SetTargetEntityValue(entity, ref targetEntity);

                isSuccessful = CostFormularBLL.Instance.Update(targetEntity);
            }

            if (isSuccessful == true)
            {
                displayMessage = "数据保存成功";
            }
            else
            {
                displayMessage = "数据保存失败";
            }

            return Json(new LogicStatusInfo(isSuccessful, displayMessage));
        }
Example #3
0
        /// <summary>
        /// 计算具体的费用
        /// </summary>
        /// <param name="costFormularKey"></param>
        /// <param name="salarySummary"></param>
        /// <returns></returns>
        private static decimal CalculateCostDetails(Guid costFormularKey, SalarySummaryEntity salarySummary)
        {
            decimal            result         = 0M;
            CostFormularEntity formularEntity = CostFormularBLL.Instance.Get(costFormularKey);

            if (formularEntity == null)
            {
                return(0M);
            }

            string formularValue = formularEntity.CostFormularValue;

            if (string.IsNullOrWhiteSpace(formularValue) == false)
            {
                List <string> costElementList = StringHelper.GetPlaceHolderList(formularValue, "{", "}");
                foreach (string costElement in costElementList)
                {
                    string placeHolderContent = string.Empty;
                    switch (costElement)
                    {
                    case "NeedPaySalary":
                        placeHolderContent = salarySummary.SalaryNeedPayBeforeCost.ToString();
                        break;

                    case "RealPaySalary":
                        placeHolderContent = salarySummary.SalaryNeedPayToLabor.ToString();
                        break;

                    default:
                    {
                        BasicSettingEntity basicSettingEntity = CostList.Find(w => w.SettingKey == costElement);
                        if (basicSettingEntity != null)
                        {
                            placeHolderContent = basicSettingEntity.SettingValue;
                        }
                        break;
                    }
                    }

                    string placeHolder = "{" + costElement + "}";
                    formularValue = formularValue.Replace(placeHolder, placeHolderContent);
                }

                try
                {
                    RPN rpn = new RPN();
                    if (rpn.Parse(formularValue))
                    {
                        result = Convert.ToDecimal(rpn.Evaluate());
                    }
                }
                catch
                {
                    result = 0;
                }
            }

            return(result);
        }
 /// <summary>
 /// 通过一个实体给另外一个实体赋值
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="targetEntity"></param>
 private static void SetTargetEntityValue(CostFormularEntity originalEntity, ref CostFormularEntity targetEntity)
 {
     targetEntity.CanUsable         = originalEntity.CanUsable;
     targetEntity.CostFormularName  = originalEntity.CostFormularName;
     targetEntity.CostType          = originalEntity.CostType;
     targetEntity.CostKind          = originalEntity.CostKind;
     targetEntity.CostFormularDesc  = originalEntity.CostFormularDesc;
     targetEntity.CostFormularValue = originalEntity.CostFormularValue;
 }
        /// <summary>
        /// 对单条记录进行添加(或者修改)
        /// </summary>
        /// <param name="keyGuid"></param>
        /// <returns></returns>
        public ActionResult Item(string keyGuid)
        {
            CostFormularEntity entity = CostFormularEntity.Empty;

            if (string.IsNullOrWhiteSpace(keyGuid) == false)
            {
                entity = CostFormularBLL.Instance.Get(keyGuid);
            }

            return(View(entity));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="entity"></param>
 protected override void InnerLoad(IDataReader reader, ref CostFormularEntity entity)
 {
     if (reader != null && reader.IsClosed == false && entity != null)
     {
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularID"))
         {
             entity.CostFormularID = reader.GetInt32(reader.GetOrdinal("CostFormularID"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularGuid"))
         {
             entity.CostFormularGuid = reader.GetGuid(reader.GetOrdinal("CostFormularGuid"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularName"))
         {
             entity.CostFormularName = reader.GetString(reader.GetOrdinal("CostFormularName"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularValue"))
         {
             entity.CostFormularValue = reader.GetString(reader.GetOrdinal("CostFormularValue"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "EnterpriseKey"))
         {
             entity.EnterpriseKey = reader.GetString(reader.GetOrdinal("EnterpriseKey"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostType"))
         {
             entity.CostType = (CostTypes)reader.GetInt32(reader.GetOrdinal("CostType"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostKind"))
         {
             entity.CostKind = (CostKinds)reader.GetInt32(reader.GetOrdinal("CostKind"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "ReferanceGuid"))
         {
             entity.ReferanceGuid = reader.GetGuid(reader.GetOrdinal("ReferanceGuid"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CostFormularDesc"))
         {
             entity.CostFormularDesc = reader.GetString(reader.GetOrdinal("CostFormularDesc"));
         }
         if (DataReaderHelper.IsExistFieldAndNotNull(reader, "CanUsable"))
         {
             entity.CanUsable = (Logics)reader.GetInt32(reader.GetOrdinal("CanUsable"));
         }
     }
 }
        protected override void InnerPrepareParasAll(CostFormularEntity entity, ref List <TParameter> paraList)
        {
            List <TParameter> list = new List <TParameter>()
            {
                GenerateParameter("CostFormularID", entity.CostFormularID),
                GenerateParameter("CostFormularGuid", entity.CostFormularGuid),
                GenerateParameter("CostFormularName", entity.CostFormularName ?? String.Empty),
                GenerateParameter("CostFormularValue", entity.CostFormularValue ?? String.Empty),
                GenerateParameter("EnterpriseKey", entity.EnterpriseKey ?? String.Empty),
                GenerateParameter("CostType", entity.CostType),
                GenerateParameter("CostKind", entity.CostKind),
                GenerateParameter("ReferanceGuid", entity.ReferanceGuid),
                GenerateParameter("CostFormularDesc", entity.CostFormularDesc ?? String.Empty),
                GenerateParameter("CanUsable", entity.CanUsable)
            };

            paraList.AddRange(list);
        }
        public override bool Create(CostFormularEntity entity)
        {
            //在创建实体时如果实体的Guid尚未指定,那么给其赋初值
            if (entity.CostFormularGuid == Guid.Empty)
            {
                entity.CostFormularGuid = GuidHelper.NewGuid();
            }

            string commandText = string.Format(@"Insert Into [XQYCCostFormular] (
			        [CostFormularGuid],
			        [CostFormularName],
			        [CostFormularValue],
			        [EnterpriseKey],
			        [CostType],
			        [CostKind],
			        [ReferanceGuid],
			        [CostFormularDesc],
			        [CanUsable],
			        [PropertyNames],
			        [PropertyValues]
                ) 
                Values (
			        {0}CostFormularGuid,
			        {0}CostFormularName,
			        {0}CostFormularValue,
			        {0}EnterpriseKey,
			        {0}CostType,
			        {0}CostKind,
			        {0}ReferanceGuid,
			        {0}CostFormularDesc,
			        {0}CanUsable,
			        {0}PropertyNames,
			        {0}PropertyValues
                )", ParameterNamePrefix);

            TParameter[] sqlParas = PrepareParasAll(entity);

            bool isSuccessful = HelperExInstance.ExecuteSingleRowNonQuery(commandText, sqlParas);

            return(isSuccessful);
        }
        public override bool Update(CostFormularEntity entity)
        {
            string commandText = string.Format(@"Update [XQYCCostFormular] Set   
				    [CostFormularGuid] = {0}CostFormularGuid,
				    [CostFormularName] = {0}CostFormularName,
				    [CostFormularValue] = {0}CostFormularValue,
				    [EnterpriseKey] = {0}EnterpriseKey,
				    [CostType] = {0}CostType,
				    [CostKind] = {0}CostKind,
				    [ReferanceGuid] = {0}ReferanceGuid,
				    [CostFormularDesc] = {0}CostFormularDesc,
				    [CanUsable] = {0}CanUsable,
				    [PropertyNames] = {0}PropertyNames,
				    [PropertyValues] = {0}PropertyValues
            Where [CostFormularID] = {0}CostFormularID", ParameterNamePrefix);

            TParameter[] sqlParas = PrepareParasAll(entity);

            bool isSuccessful = HelperExInstance.ExecuteSingleRowNonQuery(commandText, sqlParas);

            return(isSuccessful);
        }
 /// <summary>
 /// 通过一个实体给另外一个实体赋值
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="targetEntity"></param>
 private static void SetTargetEntityValue(CostFormularEntity originalEntity, ref CostFormularEntity targetEntity)
 {
     targetEntity.CanUsable = originalEntity.CanUsable;
     targetEntity.CostFormularName = originalEntity.CostFormularName;
     targetEntity.CostType = originalEntity.CostType;
     targetEntity.CostKind = originalEntity.CostKind;
     targetEntity.CostFormularDesc = originalEntity.CostFormularDesc;
     targetEntity.CostFormularValue = originalEntity.CostFormularValue;
 }