private void AddData(HttpContext context) { var msg = ""; var courseId = context.Request["CourseId"]; var isAll = context.Request["IsAll"]; if (!string.IsNullOrEmpty(isAll)) //全选 { if (isAll == "1") { var questionBll = new BLL.Questionnaire(); var result = questionBll.SaveQuestionsForAll(courseId); if (!result) { msg = "保存失败!"; } } else //全不选 { var questionBll = new BLL.Questionnaire(); var result = questionBll.DeletCourseStudentbyCourseId(courseId); if (!result) { msg = "保存失败!"; } } } else { var stuids = context.Request["StuIds"]; var unstuids = context.Request["UnStuIds"]; if (!string.IsNullOrEmpty(stuids)) { if (!string.IsNullOrEmpty(unstuids)) { var unid = unstuids.Split('|'); if (unid.Length > 0) { foreach (var uid in unid) { if (!string.IsNullOrEmpty(uid)) { stuids = stuids.Replace(uid, ""); } } } } var stu = stuids.Split('|'); var stuList = new List<string>(); foreach (var sid in stu) { if (!string.IsNullOrEmpty(sid)) { if (!stuList.Contains(sid)) { stuList.Add(sid); } } } var questionBll = new BLL.Questionnaire(); var result = questionBll.SaveQuestions(stuList.ToArray(), courseId); if (!result) { msg = "保存失败!"; } } else { var questionBll = new BLL.Questionnaire(); var result = questionBll.SaveQuestions(null, courseId); if (!result) { msg = "保存失败!"; } } } context.Response.Write(msg); }