/// <summary>
 /// 作者:Kylin
 /// 时间:2014.03.27
 /// 描述:添加产品级别配置设置提交
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public JsonResult CreateProductLevelConfig(ProductLevelConfig model)
 {
     if (model.Id > 0)
     {
         var addModel = ProductBLL.GetProductLevelConfigById(model.Id);
         addModel.Id = model.Id;
         addModel.ProductLevelId = model.ProductLevelId;
         addModel.IsOptional = model.IsOptional;
         addModel.Optional = model.Optional;
         addModel.UpdateTime = DateTime.Now;
         addModel.UpdateBy = LoginUserManager.CurrLoginUser.UserId;
         var updateResult = ProductBLL.UpdateProductLevelConfig(addModel, LoginUserManager.CurrLoginUser.UserId);
         return Json(new { status = updateResult, msg = "产品级别配置更新成功!", productLevelId = addModel.ProductLevelId });
     }
     else
     {
         model.CreateBy = LoginUserManager.CurrLoginUser.UserId;
         model.CreateTime = DateTime.Now;
         model.Status = CommonHelper.To<int>(StatusType.Active);
         var addResult = ProductBLL.CreateProductLevelConfig(model, LoginUserManager.CurrLoginUser.UserId).Id > 0;
         return Json(new { status = addResult, msg = "产品级别配置添加成功!", productLevelId = model.ProductLevelId });
     }
 }
Beispiel #2
0
        /// <summary>
        ///  作者:Kylin
        /// 时间:2014.03.27
        /// 描述:添加产品级别配置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static ProductLevelConfig CreateProductLevelConfig(ProductLevelConfig model, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    if (!edb.ProductLevelConfig.Any(p => p.BranchId == model.BranchId && p.ProductLevelId == model.ProductLevelId && p.Status == ConvertEnum.StatusTypeForActive))
                    {
                        var result = edb.ProductLevelConfig.Add(model);
                        edb.SaveChanges();

                        return result;
                    }
                    else
                    {
                        return null;
                    }
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("ProductBLL-AddProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return null;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 作者:Kylin
        /// 时间:2014.03.27
        /// 描述:更新产品级别配置        
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool UpdateProductLevelConfig(ProductLevelConfig model, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var modelObj = edb.ProductLevelConfig.FirstOrDefault(a => a.Id == model.Id && a.Status == ConvertEnum.StatusTypeForActive);
                    if (null == modelObj)
                        return false;

                    modelObj.Status = model.Status;
                    modelObj.UpdateBy = model.UpdateBy;
                    modelObj.UpdateTime = model.UpdateTime;
                    modelObj.ProductLevelId = model.ProductLevelId;
                    modelObj.IsOptional = model.IsOptional;
                    modelObj.Optional = model.Optional;

                    edb.Entry(modelObj).State = EntityState.Modified;
                    var result = edb.SaveChanges() > 0;

                    return result;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("ProductBLL-UpdateProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 作者:Primo
        /// 时间:2014.06.20
        /// 描述:重置产品级别配置
        /// </summary>
        /// <param name="productLevelConfigId"></param>
        /// <param name="productLevelId"></param>
        /// <param name="branchId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static bool ResetProductLevelConfig(int productLevelConfigId, int productLevelId, int branchId, int userId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var result = false;

                    //获取级别所属的原产品中心
                    var resetModelObjBranchId = edb.Product.Where(p => p.ProductLevel.Any(a => a.Id == productLevelId && p.Id == a.ProductId && a.Status == ConvertEnum.StatusTypeForActive) && p.Status == ConvertEnum.StatusTypeForActive).Select(s => s.BranchId).FirstOrDefault();

                    //获取该中心,该级别的复制对象
                    var resetModelObj = edb.ProductLevelConfig.FirstOrDefault(p => p.ProductLevelId == productLevelId && p.BranchId == resetModelObjBranchId && p.Status == ConvertEnum.StatusTypeForActive);
                    if (resetModelObj != null)
                    {
                        if (resetModelObjBranchId > 0)
                        {
                            //获取需要重置的对象
                            var modelObj = edb.ProductLevelConfig.FirstOrDefault(p => p.Id == productLevelConfigId);
                            if (null != modelObj)
                            {
                                modelObj.IsOptional = resetModelObj.IsOptional;
                                modelObj.Optional = resetModelObj.Optional;

                                edb.Entry(modelObj).State = EntityState.Modified;
                                result = edb.SaveChanges() > 0;
                            }
                        }
                        else
                        {
                            var productLevelConfig = new ProductLevelConfig()
                            {
                                BranchId = branchId,
                                ProductLevelId = productLevelId,
                                IsOptional = resetModelObj.IsOptional,
                                Optional = resetModelObj.Optional,
                                Status = ConvertEnum.StatusTypeForActive,
                                CreateTime = DateTime.Now,
                                UpdateTime = DateTime.Now
                            };
                            edb.Entry(productLevelConfig).State = EntityState.Added;
                            result = edb.SaveChanges() > 0;
                        }
                    }

                    return result;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("ProductBLL-ResetProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = userId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }