//批量安排教师 public ActionResult AjaxBatchSelectTeacher(int trainingId, string ids) { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); List<string> list = new List<string>(); if (!string.IsNullOrEmpty(ids)) { list.AddRange(ids.Split(',')); } DataTable dt = new Traning_TeacherBLL().GetTable("Delflag=0 and TraningId=" + trainingId, ""); int count = 0; foreach (string s in list) { if (dt.Select("PlatformManagerId=" + s).Count() == 0) { DataRow row = dt.NewRow(); row["Id"] = 0; row["TraningId"] = trainingId; row["PlatformManagerId"] = Convert.ToInt32(s); row["Status"] = 1; row["Delflag"] = 0; row["CreateDate"] = DateTime.Now; dt.Rows.Add(row); count++; } } foreach (DataRow row in dt.Rows) { if (!list.Exists(t => t == row["PlatformManagerId"].ToString())) { row.Delete(); count++; } } if (count == 0) { return Json(new { Result = false, Msg = "请勾选或移除教师!" }, JsonRequestBehavior.AllowGet); } using (TransactionScope trans = new TransactionScope()) { try { bll.BatchSelectTeacher(dt); trans.Complete(); return Json(new { Result = true, Msg = "提交成功!" }, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(new { Result = false, Msg = "提交失败!" }, JsonRequestBehavior.AllowGet); } } }