public ActionResult CancellBount(int courseId, int typeId, int businId) { var result = new resultData(); result.status = "-1"; var boundDataAll = configureTypeService.GetCTypeByCId(courseId); //绑定关系的数据 var boundData = configureTypeService.GetCTypeByCourseIdOrTypeId(courseId, typeId, businId); //绑定的唯一数据 var courseDate = courseInfoService.GetCourseInfoById(new EntityDto <long>() { Id = courseId }); //课程数据 if (boundData != null) { //删除关系 string sqlcc = "delete from px_course_bound_configure where Id=" + boundData.Id; var rcc = _sqlExecuter.Execute(sqlcc); if (rcc > 0 && typeId == (int)ConfigureType.Class) { configureTypeService.SetCourseCountReduce(boundData.BusinessId); } result.msg = ""; //获取课程下的所有人员 var coursePersom = cbPersonnelService.GetCouPerByCourseAll(courseId); if (coursePersom.Any()) { //删除课程下的所有人员 string deleteIds = string.Join(",", coursePersom.Select(v => v.Id).ToList()); string sqlcp = "delete from px_course_bound_personnel where Id in(" + deleteIds + ")"; var rcp = _sqlExecuter.Execute(sqlcp); } var bound = boundDataAll.Where(c => c.BusinessId != businId).ToList(); if (bound.Any()) { var resultDate = AddUser(bound, courseId); if (resultDate.Any()) { //插入剩余关系下的所有用户 foreach (var itemuser in resultDate) { CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto(); cbp.CourseId = courseId; cbp.CourseName = courseDate.CourseName; cbp.AccountSysNo = itemuser.SysNO; cbp.AccountUserName = itemuser.DisplayName; cbPersonnelService.CreateCourseBoundPersonnel(cbp); } } } result.status = "0"; } return(Content(Serialize(result))); }