コード例 #1
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-4-22
        /// 描述:新增中心产品
        /// </summary>
        /// <param name="pBranch"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool AddProductBranch(ProductBranch pBranch, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry(pBranch).State = EntityState.Added;
                    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-AddProductBranch:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }
コード例 #2
0
ファイル: ProductController.cs プロジェクト: kylin589/EmePro
        public JsonResult CreateProduct(FormCollection collection)
        {
            var cName = collection["CName"];
            var eName = collection["EName"];
            var sCode = collection["SCode"];
            var levels = CommonHelper.To<int>(collection["Levels"]);
            var onLine = CommonHelper.To<int>(collection["Online"]);
            var offLine = CommonHelper.To<int>(collection["Offline"]);
            var description = collection["Description"];
            var branchId = CommonHelper.To<int>(collection["hidBranchId"]);
            var isVip = (CommonHelper.To<int>(collection["IsVip"]) == 1 ? true : false);
            var isOc = (CommonHelper.To<int>(collection["IsOc"]) == 1 ? true : false);

            var tip = string.Empty;
            var result = true;
            var productId = string.Empty;
            var model = new Eme.Model.Eme.Product()
                {
                    CName = cName,
                    EName = eName,
                    SCode = sCode,
                    Levels = levels,
                    IsVip = isVip,
                    IsOc = isOc,
                    Online = onLine,
                    Offline = offLine,
                    BranchId = branchId,
                    Status = CommonHelper.To<int>(StatusType.Active),
                    ProcessStatus = CommonHelper.To<int>(ProcessStatusType.Awaiting),
                    Description = description,
                    CreateTime = DateTime.Now,
                    CreateBy = WebCommon.LoginUserManager.CurrLoginUser.UserId
                };
            var product = ProductBLL.CreateProduct(model, LoginUserManager.CurrLoginUser.UserId);
            result = (product != null);

            /*新增产品时,增加总部产品信息*/
            var status = CommonHelper.To<int>(StatusType.Active);
            var headBranchId = 1;
            try
            {
                headBranchId = BranchBLL.GetBranchListByBranchType(BranchType.Headquarters).FindLast(p => p.Status == status).Id;
            }
            catch
            {
                headBranchId = 1;
            }
            var pBranch = new ProductBranch()
            {
                ProductId = product.Id,
                BranchId = headBranchId,
                Status = ConvertEnum.StatusTypeForActive,
                CreateBy = LoginUserManager.CurrLoginUser.UserId,
                CreateTime = DateTime.Now
            };
            result = ProductBLL.AddProductBranch(pBranch, LoginUserManager.CurrLoginUser.UserId);

            if (headBranchId != branchId)
            {
                /*添加当前中心产品信息*/
                var pBranchConfig = new ProductBranch()
                {
                    ProductId = product.Id,
                    BranchId = branchId,
                    Status = ConvertEnum.StatusTypeForActive,
                    CreateBy = LoginUserManager.CurrLoginUser.UserId,
                    CreateTime = DateTime.Now
                };
                result = ProductBLL.AddProductBranch(pBranchConfig, LoginUserManager.CurrLoginUser.UserId);
            }

            var msg = result == true ? "创建成功!" : "创建失败!";
            return Json(new { states = result, msg = msg });
        }
コード例 #3
0
ファイル: ProductController.cs プロジェクト: kylin589/EmePro
        public JsonResult CreateProductBranch(int productId, string branchIdList, int branchId)
        {
            var strList = branchIdList.Trim('-').Trim().Split('-').ToList();

            List<ProductBranch> list = new List<ProductBranch>();

            foreach (var str in strList)
            {
                //不可以为空
                if (str == "")
                    continue;

                var modelObj = new ProductBranch()
                {
                    BranchId = CommonHelper.To<int>(str),
                    ProductId = productId,
                    OrderNum = 0,
                    Status = ConvertEnum.StatusTypeForActive,
                    UpdateBy = Eme.WebCommon.LoginUserManager.CurrLoginUser.UserId,
                    UpdateTime = DateTime.Now,
                    CreateBy = Eme.WebCommon.LoginUserManager.CurrLoginUser.UserId,
                    CreateTime = DateTime.Now
                };
                list.Add(modelObj);
            }

            var result = ProductBLL.CreateProductBranch(list, productId, branchId, LoginUserManager.CurrLoginUser.UserId);

            var msg = result ? "提交成功!" : "提交失败!";

            return Json(new { msg = msg, status = result }, JsonRequestBehavior.DenyGet);
        }