//Model转换
        public CRM_CompanyLadderPrice_Audit GetModel(CRM_CompanyLadderPrice item)
        {
            CRM_CompanyLadderPrice_Audit model = new CRM_CompanyLadderPrice_Audit();
            object value;

            if (item != null)
            {
                string[]       arrField   = new string[] { "CRM_Company_ID", "PRD_Product_ID", "SinglePrice", "EndLadder", "BeginLadder" };
                Type           t1         = typeof(CRM_CompanyLadderPrice);
                PropertyInfo[] propertys1 = t1.GetProperties();
                Type           t2         = typeof(CRM_CompanyLadderPrice_Audit);
                PropertyInfo[] propertys2 = t2.GetProperties();

                foreach (PropertyInfo pi in propertys2)
                {
                    string name = pi.Name;
                    if (arrField.Contains(name))
                    {
                        value = t1.GetProperty(name).GetValue(item, null);
                        t2.GetProperty(name).SetValue(model, value, null);
                    }
                }
                model.CRM_CompanyLadderPrice_ID = item.ID;
                model.CreateTime     = DateTime.Now;
                model.CreateUserID   = LoginInfo.UserID;
                model.CreateUserName = LoginInfo.RealName;
                model.BranchID       = LoginInfo.BranchID;
                model.OperateStatus  = 1; //待处理
                model.OperateNode    = 2; //质控
            }
            return(model);
        }
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post([FromBody] CRM_CompanyLadderPrice_Audit entity)
        {
            Common.ClientResult.Result      result = new Common.ClientResult.Result();
            IBLL.ICRM_CompanyLadderPriceBLL bll    = new CRM_CompanyLadderPriceBLL();
            if (entity != null && ModelState.IsValid)
            {
                int    currentPerson     = LoginInfo.UserID;
                string currentPersonName = LoginInfo.RealName;
                int    intBranchID       = LoginInfo.BranchID;
                entity.CreateTime     = DateTime.Now;
                entity.CreateUserID   = currentPerson;
                entity.CreateUserName = currentPersonName;
                entity.BranchID       = intBranchID;
                entity.OperateStatus  = 1; //待处理
                entity.OperateNode    = 2; //质控

                if (!bll.CheckRange(Convert.ToInt32(entity.CRM_Company_ID), entity.PRD_Product_ID, Convert.ToInt32(entity.BeginLadder), Convert.ToInt32(entity.EndLadder), intBranchID, null))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价信息", "客户_企业阶梯报价信息_启用"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "请检查阶梯报价范围!";
                    return(result); //提示更新失败
                }

                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_企业阶梯报价_待审核的信息的Id为" + entity.ID, "客户_企业阶梯报价_待审核"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.InsertSucceed;
                    return(result); //提示创建成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_企业阶梯报价_待审核的信息," + returnValue, "客户_企业阶梯报价_待审核"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
 /// <summary>
 /// 创建一个客户_企业阶梯报价_待审核
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个客户_企业阶梯报价_待审核</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, CRM_CompanyLadderPrice_Audit entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
        // PUT api/<controller>/5
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Common.ClientResult.Result Put([FromBody] CRM_CompanyLadderPrice entity)
        {
            Common.ClientResult.Result      result = new Common.ClientResult.Result();
            IBLL.ICRM_CompanyLadderPriceBLL bll    = new CRM_CompanyLadderPriceBLL();
            if (entity != null && ModelState.IsValid)
            {
                //数据校验
                if (!bll.CheckRange(entity.CRM_Company_ID, entity.PRD_Product_ID, Convert.ToInt32(entity.BeginLadder), Convert.ToInt32(entity.EndLadder), LoginInfo.BranchID, entity.ID))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价信息的Id为" + entity.ID, "客户_企业阶梯报价"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "请检查阶梯报价范围!";
                    return(result); //提示更新失败
                }

                CRM_CompanyLadderPrice_Audit model = GetModel(entity);

                string returnValue = string.Empty;
                if (m_BLL.ModifyLadderPrice(ref validationErrors, model))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",客户_企业阶梯报价信息的Id为" + entity.ID, "客户_企业阶梯报价_待审批"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.UpdateSucceed;
                    return(result); //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价_待审批信息的Id为" + entity.ID + "," + returnValue, "客户_企业阶梯报价_待审批"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.UpdateFail + returnValue;
                    return(result); //提示更新失败
                }
            }
            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
            return(result); //提示输入的数据的格式不对
        }
        // 获取企业阶梯报价
        public List <CRM_CompanyLadderPrice_Audit> GetLadderPriceList(string ladderPrice)
        {
            List <CRM_CompanyLadderPrice_Audit> list = new List <CRM_CompanyLadderPrice_Audit>();

            if (!string.IsNullOrEmpty(ladderPrice))
            {
                string[] arrGroup = ladderPrice.Split('^');
                string[] arrItem;
                for (int i = 0; i < arrGroup.Length; i++)
                {
                    CRM_CompanyLadderPrice_Audit model = new CRM_CompanyLadderPrice_Audit();
                    arrItem = arrGroup[i].Split('&');
                    model.PRD_Product_ID = int.Parse(arrItem[0]);
                    if (!string.IsNullOrEmpty(arrItem[2]))
                    {
                        model.SinglePrice = Convert.ToDecimal(arrItem[2]);
                    }
                    if (!string.IsNullOrEmpty(arrItem[3]))
                    {
                        model.BeginLadder = Convert.ToInt32(arrItem[3]);
                    }
                    if (!string.IsNullOrEmpty(arrItem[4]))
                    {
                        model.EndLadder = Convert.ToInt32(arrItem[4]);
                    }
                    if (!string.IsNullOrEmpty(arrItem[5]))
                    {
                        model.CRM_Company_ID = Convert.ToInt32(arrItem[5]);
                    }

                    model.CreateTime     = DateTime.Now;
                    model.CreateUserID   = LoginInfo.UserID;
                    model.CreateUserName = LoginInfo.RealName;
                    model.BranchID       = LoginInfo.BranchID;
                    model.OperateStatus  = 1;
                    model.OperateNode    = 2;

                    list.Add(model);
                }
            }
            return(list);
        }
        /// <summary>
        /// 根据ID获取数据模型
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns></returns>
        public CRM_CompanyLadderPrice_Audit Get(int id)
        {
            CRM_CompanyLadderPrice_Audit item = m_BLL.GetById(id);

            return(item);
        }