public JsonResult CreateProductLevel(FormCollection collection) { var createBy = LoginUserManager.CurrLoginUser.UserId; var cName = collection["CName"]; var eName = collection["EName"]; var sCode = collection["SCode"]; var coding = collection["Coding"]; var orderNum = collection["OrderNum"] == "" ? 0 : CommonHelper.To<int>(collection["OrderNum"]); var description = collection["Description"]; var remark = collection["Remark"]; var productId = CommonHelper.To<int>(collection["productId"]); var pLevel = new ProductLevel() { ProductId = productId, CName = cName, EName = eName, SCode = sCode, Coding = coding, OrderNum = orderNum, Description = description, Status = CommonHelper.To<int>(StatusType.Active), CreateBy = createBy, CreateTime = DateTime.Now }; var result = ProductBLL.CreateProductLevel(pLevel, LoginUserManager.CurrLoginUser.UserId); var msg = result ? "新增成功!" : "新增失败!"; return Json(new { status = result, msg = msg }, JsonRequestBehavior.DenyGet); }
/// <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; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-4-22 /// 描述:新增级别,并返回新增的对象 /// </summary> /// <param name="pLevel"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool CreateProductLevel(ProductLevel pLevel, int loginUserId) { using (var edb = new EmeEntities()) { try { edb.Entry(pLevel).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-CreateProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-3-5 /// 描述:更新产品级别,不含产品必修、选修信息 /// </summary> /// <param name="pLevel"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductLevel(ProductLevel pLevel, int loginUserId) { using (var edb = new EmeEntities()) { try { var pLevelObj = edb.ProductLevel.FirstOrDefault(p => p.Id == pLevel.Id); if (null == pLevelObj) return false; pLevelObj.CName = pLevel.CName; pLevelObj.EName = pLevel.EName; pLevelObj.SCode = pLevel.SCode; if (pLevel.OrderNum.HasValue) pLevelObj.OrderNum = pLevel.OrderNum.Value; pLevelObj.Description = pLevel.Description; pLevelObj.Remark = pLevel.Remark; pLevelObj.UpdateBy = pLevel.UpdateBy; pLevelObj.UpdateTime = pLevel.UpdateTime; edb.Entry(pLevelObj).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-UpdateProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Primo /// 时间:2014.04.29 /// 描述:普通学员模式窗体展示 /// /// 作者:Primo /// 时间:2015.06.13 /// 描述:改造,提高速度 /// </summary> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public ActionResult BookRequirementModalContenList(int branchId, DateTime startTime, DateTime endTime, bool isVip) { //获取已经存好的时间提报 var modelList = Session["GetStudentBookRequirementList"] as List<GetBookRequirementList_Result>; //筛选符合条件的学员 var studentList = (from a in modelList where a.BranchId == branchId && a.BookStartTime == startTime && a.BookEndTime == endTime && a.IsVip == isVip select a.StudentId).ToList(); //获取这些学员的所有订课退订课记录,获取的都是 var modelBookRecordList = StudyBLL.GetStudentBookRecordList(studentList, isVip); //获取级别 var modelProductLevelList = (from a in modelBookRecordList select new { a.ProductLevelId, a.EName }).Distinct().ToList(); var productLevelList = new List<ProductLevel>(); foreach (var item in modelProductLevelList) { var model = new ProductLevel(); model.Id = item.ProductLevelId; model.EName = item.EName; productLevelList.Add(model); } //这个时间段的学员的当前级别 ViewData["ProductLevelList"] = productLevelList.OrderBy(a => a.Id).ToList(); //这个时间段的学员的订课记录 Session["BookRecordList"] = modelBookRecordList; //记录打开模态框的那个课程开始时间 Session["SetStartTime"] = startTime; return PartialView("_ModalList", productLevelList.OrderBy(a => a.Id).ToList()); }