コード例 #1
0
ファイル: BranchBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Vincen
 /// 时间:2014.03.28
 /// 描述:创建教室
 /// </summary>
 /// <param name="model"></param>
 /// <param name="createBy"></param>
 /// <returns></returns>
 public static bool CreateClassroom(Classroom model, int createBy)
 {
     using (var edb = new EmeEntities())
     {
         try
         {
             edb.Entry(model).State = EntityState.Added;
             var result = edb.SaveChanges() > 0;
             return result;
         }
         catch (Exception e)
         {
             Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
             {
                 ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
                 Message = string.Format("BranchBLL-CreateClassroom:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink),
                 IsTreat = false,
                 UserHostAddress = WebHelper.GetCurrentIpAddress(),
                 CreateBy = createBy,
                 CreateTime = DateTime.Now
             });
             return false;
         }
     }
 }
コード例 #2
0
ファイル: ReportBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.10.05
 /// 描述:授课质量排名
 /// </summary>
 /// <param name="areaId"></param>
 /// <param name="beginDate"></param>
 /// <param name="endDate"></param>
 /// <returns></returns>
 public static List<GetAllStudentScoreOfClassStat_Result> GetAllStudentScoreOfClassStat(int areaId, DateTime beginDate, DateTime endDate)
 {
     using (var edb = new EmeEntities(dbRead))
     {
         return edb.GetAllStudentScoreOfClassStat(areaId, beginDate, endDate).ToList();
     }
 }
コード例 #3
0
ファイル: ReportBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.11.21
 /// 描述:全国上课量汇总表			
 /// </summary>
 /// <param name="branchId"></param>
 /// <param name="beginDate"></param>
 /// <param name="endDate"></param>
 /// <param name="teacherType"></param>
 /// <returns></returns>
 public static List<GetAllTeachRecordStat_Result> GetAllTeacherRecordTotal(int branchId, DateTime beginDate, DateTime endDate, string teacherType)
 {
     using (var edb = new EmeEntities(dbRead))
     {
         return edb.GetAllTeachRecordStat(branchId, beginDate, endDate, teacherType).ToList();
     }
 }
コード例 #4
0
ファイル: ReferralBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Raymond
 /// 日期:2014-7-22
 /// 描述:是否存在报备信息
 /// </summary>
 /// <param name="crmReferralId"></param>
 /// <returns></returns>
 public static bool IsExistReferralByCrmId(int crmReferralId)
 {
     using (var edb = new EmeEntities(dbRead))
     {
         return edb.Referral.Any(p => p.V3Id == crmReferralId);
     }
 }
コード例 #5
0
ファイル: EmeBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.04.30
        /// 描述:创建消息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool CreateMessage(MessageModel model, int loginUserId)
        {
            try
            {
                using (var tran = new TransactionScope())
                {
                    using (var edb = new EmeEntities())
                    {
                        var msg = new Message()
                        {
                            MessageType = model.MessageType,
                            Subject = model.Subject,
                            MContent = model.MContent,
                            Receivers = model.Receiver.Count,
                            Openers = 0,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = model.CreateBy,
                            CreateTime = model.CreateTime
                        };

                        edb.Entry(msg).State = EntityState.Added;
                        edb.SaveChanges();

                        var receiver = from a in model.Receiver
                                       select new MessageReceiver()
                                           {
                                               MessageId = msg.Id,
                                               Receiver = a,
                                               IsRead = false,
                                               Status = ConvertEnum.StatusTypeForActive,
                                               CreateBy = model.CreateBy,
                                               CreateTime = model.CreateTime
                                           };
                        foreach (var messageReceiver in receiver)
                        {
                            edb.Entry(messageReceiver).State = EntityState.Added;
                        }

                        var result = edb.SaveChanges() > 0;

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

                return false;
            }
        }
コード例 #6
0
ファイル: CourseBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.04.01
        /// 描述:创建课程
        /// </summary>
        /// <param name="course"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static Course CreateCourse(Course course, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry(course).State = EntityState.Added;
                    edb.SaveChanges();
                    return course;
                }
                catch (Exception e)
                {
                    // 异常日志消息队列
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                        Message = string.Format("CourseBLL-CreateCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return null;
                }
            }
        }
コード例 #7
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;
                }
            }
        }
コード例 #8
0
ファイル: StudentBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.07.18
        /// 描述:检查合同详情
        /// </summary>
        /// <returns></returns>
        public static bool CheckContractDetail()
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    foreach (var detail in
                            edb.ContractDetail.Where(
                                p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now && p.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute))
                    {
                        // 更新结束的合同为结束状态
                        detail.ContractStatusType = ConvertEnum.ContractStatusTypeForOver;
                        edb.Entry(detail).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("StudentBLL-CheckContractDetail:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = null,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }
コード例 #9
0
ファイル: ReferralBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Raymond
 /// 日期:2014-6-27
 /// 描述:新增报备
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool CreateReferral(Referral model)
 {
     using (var edb = new EmeEntities())
     {
         edb.Entry(model).State = EntityState.Added;
         return edb.SaveChanges() > 0;
     }
 }
コード例 #10
0
ファイル: DataBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2013.12.27
        /// 描述:获取复习资料,通过产品经别编号
        /// </summary>
        /// <param name="productLevelId"></param>
        /// <returns></returns>
        public static List<Model.Eme.ReviewForProductLevel> GetReviewListByProductLevelId(int productLevelId)
        {
            var Db = new EmeEntities(dbRead);

            return Db.ReviewForProductLevel.Where(p => p.ProductLevelId == productLevelId && p.Status == ConvertEnum.StatusTypeForActive)
                 .OrderBy(p => p.Review.ReviewType).ThenBy(p => p.Review.CName)
                 .ToList();
        }
コード例 #11
0
ファイル: McBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2013.11.18 PM
        /// 描述:获取MC推荐资源列表(指出显示个数),通过产品级别编号
        /// </summary>
        /// <param name="productLevelId"></param>
        /// <param name="showNum"></param>
        /// <returns></returns>
        public static List<McRecommendation> GetMcRecommendationListByProductLevelId(int productLevelId, int showNum)
        {
            var Db = new EmeEntities(dbRead);

            return Db.McRecommendation.Where(p =>
                p.Status == ConvertEnum.StatusTypeForActive &&
                p.ProductLevelId == productLevelId).OrderByDescending(p => p.CreateTime).Distinct().Take(showNum).ToList();
        }
コード例 #12
0
ファイル: FollowBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Kylin
        /// 时间:2014.03.21 PM
        /// 描述:(学员)Follow Up (批量)发送
        /// </summary>
        /// <param name="model"></param>
        /// <param name="followDetailLst"></param>
        /// <param name="followAttachmentLst"></param>
        /// <returns></returns>
        public static bool CreateFollow(Follow model, List<FollowDetail> followDetailLst, List<FollowAttachment> followAttachmentLst)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry<Follow>(model).State = EntityState.Added;
                    foreach (var item in followDetailLst)
                    {
                        item.FollowId = model.Id;
                        edb.Entry<FollowDetail>(item).State = EntityState.Added;

                        var student = edb.Student.SingleOrDefault(p => p.Id == item.StudentId);
                        if (student != null)
                        {
                            var studentUserId = student.UserId;
                            // 发送队列消息
                            //EmeBLL.CreateMessageForSFollowUp(studentUserId, model.CreateBy);
                            var msg = new MessageModel()
                            {
                                MessageType = CommonHelper.To<int>(MessageType.System),
                                Subject = "Follow Up 查看提醒",
                                MContent = string.Format("您有SA新发送的FU,请注意查收;"),
                                Receiver = new List<int>(),
                                CreateBy = model.CreateBy,
                                CreateTime = DateTime.Now
                            };
                            msg.Receiver.Add(studentUserId);

                            // 将消息加入队列
                            Common.MSMQ.QueueManager.AddSystemMessage(msg);
                        }
                    }
                    foreach (var attachment in followAttachmentLst)
                    {
                        attachment.FollowId = model.Id;
                        edb.Entry(attachment).State = EntityState.Added;
                    }

                    var result = edb.SaveChanges() > 0;

                    return result;
                }
                catch (Exception ex)
                {
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
                        Message = string.Format("FollowBLL-CreateFollow:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink),
                        IsTreat = false,
                        CreateBy = model.CreateBy,
                        CreateTime = DateTime.Now
                    });
                    return false;
                }
            }
        }
コード例 #13
0
ファイル: StudentBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Primo
 /// 日期:2015.02.26
 /// 描述:判断学员选课是否存在已经上过超过一节的课了 
 /// </summary>
 /// <param name="studentId"></param>
 /// <param name="productLevelCourseTypeId"></param>
 /// <returns></returns>
 public static bool CheckArrangeCourseForProductLevelCourseTypeSelected(int studentId, int productLevelCourseTypeId)
 {
     var db = new EmeEntities(dbRead);
     var bookRecordCount = db.BookRecord.Where(a => a.StudentId == studentId
         && a.ArrangeCourse.ProductLevelCourseTypeCourse.ProductLevelCourseTypeId == productLevelCourseTypeId
         && a.IsUnBook == false
         && a.PassStatusType != ConvertEnum.PassStatusTypeForRepeat
         && a.Status == ConvertEnum.StatusTypeForActive).Count();
     var result = bookRecordCount > 1 ? true : false;
     return result;
 }
コード例 #14
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.07.15
        /// 描述:检查合同冻结详情
        /// </summary>
        /// <returns></returns>
        public static bool CheckContractFrozenDetail()
        {
            try
            {
                using (var edb = new EmeEntities())
                {
                    using (var tran = new TransactionScope())
                    {
                        foreach (var detail in
                                edb.ContractFrozenDetail.Where(
                                    p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now))
                        {
                            // 更新合同详情信息
                            var contractDetail = detail.ContractDetail;
                            contractDetail.ContractStatusType = (contractDetail.EndDate < DateTime.Now) ? ConvertEnum.ContractStatusTypeForOver : ConvertEnum.ContractStatusTypeForExcute;
                            edb.Entry(contractDetail).State = EntityState.Modified;

                            // 更新冻结详情信息 ( 将处理完的数据设为无效 )
                            detail.UpdateTime = DateTime.Now;
                            detail.Remark = "系统自动解冻";
                            detail.Status = ConvertEnum.StatusTypeForInactive;
                            edb.Entry(detail).State = EntityState.Modified;
                        }

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

                return false;
            }
        }
コード例 #15
0
ファイル: TrainBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Kylin
        /// 时间:2015.01.05
        /// 描述: check update training schedule for speaker is validate
        /// </summary>
        /// <param name="trainSchedule"></param>
        /// <param name="checkEnable"></param>
        /// <returns></returns>
        public static int CheckTrainingScheduleIsValidate(TrainSchedule trainSchedule, bool checkEnable)
        {
            using (var edb = new EmeEntities())
            {
                if (!checkEnable)
                {
                    if (
                edb.UserSchedule.Any(
                    p => p.BeginTime < trainSchedule.EndTime && p.EndTime > trainSchedule.BeginTime
                         && p.Status == ConvertEnum.StatusTypeForActive
                         && p.UserId == trainSchedule.SpeakerId))
                    {
                        return 101; //已存在其他安排
                    }
                    if (
                        edb.TrainSchedule.Any(
                            p => p.BeginTime < trainSchedule.EndTime && p.EndTime > trainSchedule.BeginTime
                                 && p.SpeakerId == trainSchedule.SpeakerId &&
                                 p.Status == ConvertEnum.StatusTypeForActive))
                    {
                        return 103; //已存在其他培训
                    }
                    if (edb.TrainRecord.Any(p =>
                        p.TrainSchedule.BeginTime < trainSchedule.EndTime &&
                        p.TrainSchedule.EndTime > trainSchedule.BeginTime
                        && p.Status == ConvertEnum.StatusTypeForActive
                        && p.UserId == trainSchedule.SpeakerId))
                    {
                        return 104; //主讲人已预订其他培训
                    }
                }
                else
                {
                    return 0;
                }

            }

            return -1;
        }
コード例 #16
0
ファイル: ReferralBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Raymond
 /// 日期:2014-7-22
 /// 描述:更加crm报备Id获取报备对象
 /// </summary>
 /// <param name="crmReferralId"></param>
 /// <returns></returns>
 public static Referral GetReferralByCrmId(int crmReferralId)
 {
     using (var edb = new EmeEntities())
     {
         try
         {
             var referral = edb.Referral.FirstOrDefault(p => p.V3Id == crmReferralId);
             return referral;
         }
         catch (Exception ex)
         {
             Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
             {
                 ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                 Message = string.Format("ReferralBLL-GetReferralByCrmId:{0};{1};{2}", ex.Message, ex.InnerException.Message, ex.HelpLink),
                 IsTreat = false,
                 CreateBy = -1,
                 CreateTime = DateTime.Now
             });
             return null;
         }
     }
 }
コード例 #17
0
ファイル: CourseBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Primo
        /// 时间:2014.07.02
        /// 描述:创建课程附件
        /// </summary>
        /// <param name="courseware"></param>
        /// <param name="coursewareDetail"></param>
        /// <returns></returns>
        public static bool CreateCourseware(Courseware courseware, CoursewareDetail coursewareDetail)
        {
            using (var tran = new TransactionScope())
            {
                using (var edb = new EmeEntities())
                {
                    try
                    {
                        edb.Entry(courseware).State = EntityState.Added;
                        edb.SaveChanges();
                        coursewareDetail.CoursewareId = courseware.Id;
                        edb.Entry(coursewareDetail).State = EntityState.Added;
                        var 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("CourseBLL-CreateCourseware:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                            IsTreat = false,
                            CreateBy = courseware.CreateBy,
                            CreateTime = DateTime.Now
                        });

                        return false;
                    }
                }
            }
        }
コード例 #18
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Primo
 /// 时间:2015.03.12
 /// 描述:获取新SC可选课程
 /// </summary>
 /// <param name="productId"></param>
 /// <param name="productLevelId"></param>
 /// <returns></returns>
 public static List<GetNewScProductCourseType_Result> GetNewScProductCourseType(int productId, int productLevelId, int branchId)
 {
     var db = new EmeEntities(dbRead);
     return db.GetNewScProductCourseType(productId, productLevelId, branchId).ToList();
 }
コード例 #19
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Ark
        /// 日期:2014-7-16
        /// 描述:根据学员Id获取 学员当前级别明细
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns></returns>
        public static List<ProductLevel> GetCurrProductLevelListByStudentId(int studentId)
        {
            var Db = new EmeEntities(dbRead);

            var query = from c in Db.ProductLevel
                        join d in Db.ContractLevel.Where(l => l.IsCurrent) on c.Id equals d.ProductLevelId
                        join a in Db.ContractDetail on d.ContractDetailId equals a.Id
                        join b in Db.Contract on a.ContractId equals b.Id
                        where b.StudentId == studentId && a.Status == ConvertEnum.StatusTypeForActive && b.Status == ConvertEnum.StatusTypeForActive
                        orderby b.Id, a.Id, d.Id
                        select c;
            return query.ToList();
        }
コード例 #20
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:Primo
 /// 日期:2015.03.06
 /// 描述:是否存在这个关系
 /// </summary>
 /// <param name="productLevelId"></param>
 /// <param name="productLevelCourseTypeId"></param>
 /// <param name="branchId"></param>
 /// <returns></returns>
 public static bool ExistProductLevelCourseTypeForForbidden(int productLevelId, int productLevelCourseTypeId, int branchId)
 {
     var edb = new EmeEntities();
     var result = edb.ProductLevelCourseTypeForForbidden.Any(a => a.ProductLevelId == productLevelId
         && a.ProductLevelCourseTypeId == productLevelCourseTypeId
         && a.BranchId == branchId
         && a.Status == ConvertEnum.StatusTypeForActive);
     return result;
 }
コード例 #21
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-3-28
        /// 描述:逻辑删除产品课节
        /// </summary>
        /// <param name="pLevelCourseTypeCourseId"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool DeleteProductLevelCourseTypeCourseById(int pLevelCourseTypeCourseId, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var pLevelCourseTypeCourse = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourseId && p.Status == ConvertEnum.StatusTypeForActive);

                    if (null == pLevelCourseTypeCourse)
                        return false;

                    var course = edb.Course.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.CourseId && p.Status == ConvertEnum.StatusTypeForActive);

                    pLevelCourseTypeCourse.Status = ConvertEnum.StatusTypeForDelete;
                    if (course != null)
                    {
                        course.Status = ConvertEnum.StatusTypeForDelete;
                        edb.Entry(course).State = EntityState.Modified;
                    }
                    edb.Entry(pLevelCourseTypeCourse).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-DeleteProductLevelCourseTypeCourseById:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }
コード例 #22
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Raymond
        /// 日期:2014-3-5
        /// 描述:新增课程级别 、明细 
        /// </summary>
        /// <param name="pLevel"></param>
        /// <param name="requiredCourse"></param>
        /// <param name="electiveCourse"></param>
        /// <param name="createBy"></param>
        /// <returns></returns>
        public static bool AddProductLevel(ProductLevel pLevel, string requiredCourse, string electiveCourse, int createBy)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    edb.Entry(pLevel).State = EntityState.Added;
                    var flag = edb.SaveChanges() > 0;

                    if (flag)
                    {
                        var productLevelId = pLevel.Id;
                        //处理必修课
                        if (requiredCourse.Length > 0)
                        {
                            var rList = requiredCourse.Split('&');
                            foreach (var item in rList)
                            {
                                var rListDetail = item.Split('^');
                                var pCourseTypeId = CommonHelper.To<int>(rListDetail[1]);
                                var courses = CommonHelper.To<int>(rListDetail[2]);
                                var students = CommonHelper.To<int>(rListDetail[3]);
                                var pLevelCourseType = new ProductLevelCourseType()
                                {
                                    ProductLevelId = productLevelId,
                                    ProductCourseTypeId = pCourseTypeId,
                                    SelectivityType = CommonHelper.To<int>(SelectivityType.Required),
                                    Courses = courses,
                                    Students = students,
                                    Status = CommonHelper.To<int>(StatusType.Active),
                                    CreateBy = createBy,
                                    CreateTime = DateTime.Now
                                };
                                edb.Entry(pLevelCourseType).State = EntityState.Added;
                            }
                        }
                        //处理选修课
                        if (electiveCourse.Length > 0)
                        {
                            var eList = electiveCourse.Split('&');
                            if (eList.Any())
                            {
                                foreach (var item in eList)
                                {
                                    var eListDetail = item.Split('^');
                                    var pCourseTypeId = CommonHelper.To<int>(eListDetail[1]);
                                    var courses = CommonHelper.To<int>(eListDetail[2]);
                                    var students = CommonHelper.To<int>(eListDetail[3]);
                                    var pLevelCourseType = new ProductLevelCourseType()
                                    {
                                        ProductLevelId = productLevelId,
                                        ProductCourseTypeId = pCourseTypeId,
                                        SelectivityType = CommonHelper.To<int>(SelectivityType.Elective),
                                        Courses = courses,
                                        Students = students,
                                        Status = CommonHelper.To<int>(StatusType.Active),
                                        CreateBy = createBy,
                                        CreateTime = DateTime.Now
                                    };
                                    edb.Entry(pLevelCourseType).State = EntityState.Added;
                                }
                            }
                        }
                    }
                    return edb.SaveChanges() > 0;
                }
                catch
                {
                    return false;
                }
            }
        }
コード例 #23
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
 /// <summary>
 /// 作者:beta
 /// 时间:2015.03.05
 /// 描述:根据排课编号获取ProductLevelid
 /// </summary>
 /// <param name="arrangeCourseId"></param>
 /// <returns></returns>
 public static ProductLevel GetPorductLevelListForArrangeCourseId(int arrangeCourseId)
 {
     var Db = new EmeEntities(dbRead);
     var arrangecourseInfo = StudyBLL.GetArrangeCourseById(arrangeCourseId);
     var query = Db.ProductLevel.FirstOrDefault(p => p.ProductLevelCourseType.Any(c => c.ProductLevelCourseTypeCourse.Any(b => b.ArrangeCourse.Any(a => a.ProductLevelCourseTypeCourseId == arrangecourseInfo.ProductLevelCourseTypeCourseId))) && p.Status == ConvertEnum.StatusTypeForActive);
     return query;
 }
コード例 #24
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Primo
        /// 日期:2015.03.06
        /// 描述:如果是存在,则修改,不存在则添加
        /// </summary>
        /// <param name="plctff"></param>
        /// <returns></returns>
        public static bool CreateProductLevelCourseTypeForForbidden(ProductLevelCourseTypeForForbidden plctff)
        {
            var edb = new EmeEntities();
            try
            {
                var result = false;
                //根据条件获取ProductLevelCourseTypeForForbidden
                var model = edb.ProductLevelCourseTypeForForbidden.SingleOrDefault(a => a.ProductLevelId == plctff.ProductLevelId
                    && a.ProductLevelCourseTypeId == plctff.ProductLevelCourseTypeId
                    && a.BranchId == plctff.BranchId
                    && a.Status == ConvertEnum.StatusTypeForActive);

                if (model != null)//不等于空的时候则更新
                {
                    model.ProductLevelId = plctff.ProductLevelId;
                    model.ProductLevelCourseTypeId = plctff.ProductLevelCourseTypeId;
                    model.BranchId = plctff.BranchId;
                    model.IsForbidden = plctff.IsForbidden;
                    model.CreateBy = plctff.CreateBy;
                    model.CreateTime = plctff.CreateTime;
                    model.UpdateBy = plctff.UpdateBy;
                    model.UpdateTime = plctff.UpdateTime;
                    model.Status = plctff.Status;
                    edb.Entry(model).State = EntityState.Modified;
                }
                else//等于空的时候则添加
                {
                    edb.Entry(plctff).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-CreateProductLevelCourseTypeForForbidden:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                    IsTreat = false,
                    CreateBy = plctff.UpdateBy,
                    CreateTime = DateTime.Now
                });
                return false;
            }
        }
コード例 #25
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <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;
                    }
                }
            }
        }
コード例 #26
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Beta
        /// 时间:2014.07.22
        /// 描述:根据ID 查询产品级别  (重读:查询学员所购有效级别)
        /// </summary>
        /// <param name="productLevelId"></param>
        /// <returns></returns>
        public static List<ProductLevel> GetPorductLevelListById(int productLevelId)
        {
            var Db = new EmeEntities(dbRead);

            var query = Db.ProductLevel.Where(p => p.Id == productLevelId && p.Status == ConvertEnum.StatusTypeForActive);
            return query.OrderBy(p => p.OrderNum).ToList();
        }
コード例 #27
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.05.23
        /// 描述:获取产品级别(For排课)
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="arrangeCourseId"></param>
        /// <returns></returns>
        public static List<ProductLevel> GetPorductLevelListForArrangeCourse(int productId, int arrangeCourseId)
        {
            var Db = new EmeEntities();
            var query = Db.ProductLevel.Where(p => p.ProductId == productId && p.Status == ConvertEnum.StatusTypeForActive);
            query =
                query.Where(
                               p =>
                                   Db.ArrangeCourse.Any(
                                       a =>
                                           a.Id == arrangeCourseId &&
                                           a.TeachRecord.Any(
                                               r =>
                                                   r.Status == ConvertEnum.StatusTypeForActive &&
                                                   r.Teacher.TeachRange.Any(
                                                       t => t.Status == ConvertEnum.StatusTypeForActive && t.ProductLevelId == p.Id))));

            return query.OrderBy(p => p.OrderNum).ToList();
        }
コード例 #28
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.06.24
        /// 描述:新增夸产品课节
        /// </summary>
        /// <param name="productLevelCourseTypeId"></param>
        /// <param name="list"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool CreateProductLevelCourseTypeForProductLevel(int productLevelCourseTypeId, List<ProductLevelCourseTypeForProductLevel> list, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var result = false;
                    var model = edb.ProductLevelCourseTypeForProductLevel.Where(p => p.ProductLevelCourseTypeId == productLevelCourseTypeId);
                    foreach (var item in model)
                    {
                        edb.Entry(item).State = EntityState.Deleted;
                    }

                    foreach (var item in list)
                    {
                        edb.Entry(item).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-CreateProductLevelCourseTypeForProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });
                    return false;
                }
            }
        }
コード例 #29
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Primo
        /// 日期:2014.07.29
        /// 描述:根据BranchId获取ProductBranch集合
        /// </summary>
        /// <param name="branchId"></param>
        /// <returns></returns>
        public static List<ProductBranch> GetProductBranchListByBranchId(int branchId)
        {
            var Db = new EmeEntities(dbRead);

            var model = Db.ProductBranch.Where(p => p.Status == ConvertEnum.StatusTypeForActive && p.BranchId == branchId);
            return model.ToList();
        }
コード例 #30
0
ファイル: ProductBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Raymond
        /// 时间:2013-11-28
        /// 描述:通过Id,逻辑删除产品相关信息,更改Status的状态为Delete
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool DeleteProductById(int productId, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                var product = edb.Product.FirstOrDefault(p => p.Id == productId);

                try
                {
                    if (product != null)
                    {
                        foreach (var pLevel in product.ProductLevel)
                        {
                            pLevel.Status = ConvertEnum.StatusTypeForDelete;
                            edb.Entry(pLevel).State = EntityState.Modified;
                        }
                        foreach (var pNode in product.ProductNode)
                        {
                            pNode.Status = ConvertEnum.StatusTypeForDelete;
                            edb.Entry(pNode).State = EntityState.Modified;
                        }
                        foreach (var pCourseType in product.ProductCourseType)
                        {
                            pCourseType.Status = ConvertEnum.StatusTypeForDelete;
                            edb.Entry(pCourseType).State = EntityState.Modified;
                        }
                        product.Status = ConvertEnum.StatusTypeForDelete;
                    }
                    var result = edb.SaveChanges() > 0;

                    return result;
                }
                catch (Exception ex)
                {
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
                        Message = string.Format("ProductBLL-DeleteProductById:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });
                    return false;
                }
            }
        }