Beispiel #1
0
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.06.24
        /// 描述:新增产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <param name="course"></param>
        /// <returns></returns>
        public static bool CreateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                using (var tran = new TransactionScope())
                {
                    try
                    {
                        var result = false;
                        var modelCourse = edb.Course.FirstOrDefault(p => p.CName == course.CName && p.Status == ConvertEnum.StatusTypeForActive);
                        var courseId = 0;

                        edb.Entry(course).State = EntityState.Added;
                        result = edb.SaveChanges() > 0;
                        courseId = course.Id;

                        pLevelCourseTypeCourse.CourseId = courseId;
                        edb.Entry(pLevelCourseTypeCourse).State = EntityState.Added;
                        result = edb.SaveChanges() > 0;
                        tran.Complete();
                        return result;
                    }
                    catch (Exception e)
                    {
                        tran.Dispose();
                        // 异常日志消息队列
                        Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                        {
                            ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                            Message = string.Format("ProductBLL-CreateProductLevelCourseTypeCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                            IsTreat = false,
                            CreateBy = loginUserId,
                            CreateTime = DateTime.Now
                        });
                        return false;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-3-27
        /// 描述:新增产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <returns></returns>
        public static ProductLevelCourseTypeCourse CreateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry(pLevelCourseTypeCourse).State = EntityState.Added;
                    edb.SaveChanges();

                    return pLevelCourseTypeCourse;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("ProductBLL-CreateProductLevelCourseTypeCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });
                    return null;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-3-28
        /// 描述:更改产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <returns></returns>
        public static bool UpdateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse)
        {
            using (var edb = new EmeEntities())
            {
                var model = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.Id);
                if (null == model)
                    return false;

                model.BranchId = pLevelCourseTypeCourse.BranchId;
                model.ProductLevelCourseTypeId = pLevelCourseTypeCourse.ProductLevelCourseTypeId;
                model.Coding = pLevelCourseTypeCourse.Coding;
                model.CourseId = pLevelCourseTypeCourse.CourseId;
                model.ClassHour = pLevelCourseTypeCourse.ClassHour;
                model.Stage = pLevelCourseTypeCourse.Stage;
                model.IsSystem = pLevelCourseTypeCourse.IsSystem;
                model.Status = pLevelCourseTypeCourse.Status;
                model.OrderNum = pLevelCourseTypeCourse.OrderNum;
                model.UpdateBy = pLevelCourseTypeCourse.UpdateBy;
                model.UpdateTime = pLevelCourseTypeCourse.UpdateTime;
                model.Remark = pLevelCourseTypeCourse.Remark;

                edb.Entry(model).State = EntityState.Modified;
                return edb.SaveChanges() > 0;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.06.10
        /// 描述:更改产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourse"></param>
        /// <param name="course"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool UpdateProductLevelCourseTypeCourseAndCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var courseObj = edb.Course.FirstOrDefault(p => p.Id == course.Id);
                    if (null != courseObj)
                    {
                        courseObj.CName = course.CName;
                        courseObj.EName = course.EName;
                        courseObj.ClassTime = course.ClassTime;
                        courseObj.Description = course.Description;
                        courseObj.StudyTypeId = course.StudyTypeId;
                        courseObj.UpdateBy = course.UpdateBy;
                        courseObj.UpdateTime = course.UpdateTime;
                        edb.Entry(courseObj).State = EntityState.Modified;
                    }

                    var pLevelCourseTypeCourseObj = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.Id);
                    if (null != pLevelCourseTypeCourseObj)
                    {
                        pLevelCourseTypeCourseObj.ClassHour = pLevelCourseTypeCourse.ClassHour;
                        pLevelCourseTypeCourseObj.Stage = pLevelCourseTypeCourse.Stage;
                        pLevelCourseTypeCourseObj.Coding = pLevelCourseTypeCourse.Coding;
                        pLevelCourseTypeCourseObj.OrderNum = pLevelCourseTypeCourse.OrderNum;
                        pLevelCourseTypeCourseObj.UpdateBy = pLevelCourseTypeCourse.UpdateBy;
                        pLevelCourseTypeCourseObj.UpdateTime = pLevelCourseTypeCourse.UpdateTime;

                        edb.Entry(pLevelCourseTypeCourseObj).State = EntityState.Modified;
                    }

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

                    return false;
                }
            }
        }
        public JsonResult CreateProductLevelCourseTypeCourse(FormCollection collection)
        {
            var result = false;
            var productId = CommonHelper.To<int>(collection["addProductId"]);
            var branchId = CommonHelper.To<int>(collection["hiddenAddBranchId"]);
            var cName = collection["AddCName"];
            var eName = collection["EName"];
            var coding = collection["AddCoding"];
            var classTime = CommonHelper.To<int>(collection["ClassTime"]);
            var orderNum = CommonHelper.To<int>(collection["OrderNum"]);
            var studyType = CommonHelper.To<int>(collection["studyType"]);
            var classHour = CommonHelper.To<int>(collection["ClassHour"]);
            var stage = CommonHelper.To<int>(collection["Stage"]);
            var productLevelId = CommonHelper.To<int>(collection["addProductLevel"]);
            var productCourseTypeId = CommonHelper.To<int>(collection["addProductCourseType"]);

            var description = collection["Description"];
            var pLevelCourseType = ProductBLL.GetProductLevelCourseType(productLevelId, productCourseTypeId);
            var productLevelCourseTypeId = pLevelCourseType.Id;
            var course = new Model.Eme.Course()
            {
                CName = cName,
                EName = eName,
                Description = description,
                ClassTime = classTime,
                StudyTypeId = studyType,
                OrderNum = orderNum,
                Status = CommonHelper.To<int>(StatusType.Active),
                CreateBy = LoginUserManager.CurrLoginUser.UserId,
                CreateTime = DateTime.Now
            };

            var productModel = ProductBLL.GetProductById(productId);
            var isSystem = (productModel.BranchId == branchId ? true : false);

            var productLevelCourseTypeCourse = new ProductLevelCourseTypeCourse()
            {
                ProductLevelCourseTypeId = productLevelCourseTypeId,
                ClassHour = classHour,
                BranchId = branchId,
                Stage = stage,
                Coding = coding,
                OrderNum = orderNum,
                IsSystem = isSystem,
                Status = CommonHelper.To<int>(StatusType.Active),
                CreateBy = LoginUserManager.CurrLoginUser.UserId,
                CreateTime = DateTime.Now
            };

            result = ProductBLL.CreateProductLevelCourseTypeCourse(productLevelCourseTypeCourse, course, LoginUserManager.CurrLoginUser.UserId);
            var msg = result ? "新增产品操作完成!" : "新增产品操作失败!";
            return Json(new { msg = msg, status = result, productLevelId = productLevelId }, JsonRequestBehavior.DenyGet);
        }