public ActionResult Add() { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); ViewBag.TrainingObjectData = bll.GetTraningObject(); ViewBag.SubjectData = bll.GetSubject(); ViewBag.StudyLevelData = bll.GetStudyLevel(); ViewBag.TrainingFormData = bll.GetTrainingForm(); ViewBag.TeacherTitleData = bll.GetTeacherTitle(); ViewBag.TrainingFeildData = bll.GetTrainingField("Delflag=0 and IsSpec=0", ""); ViewBag.OutCourseTypeData = bll.GetOutCourseType("Delflag=0", ""); Organ_Detail otypeModel = new Organ_DetailBLL().GetModel(Code.SiteCache.Instance.ManageOrganId); ViewBag.OTypeId = otypeModel == null ? 0 : Convert.ToInt32(otypeModel.OType); return View(); }
public ActionResult Edit(int id) { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); NationalAbility_CourseBLL nationalAbility_CourseBLL = new NationalAbility_CourseBLL(); Traning_Detail model = bll.GetTrainingDetail(Convert.ToInt32(id), "Delflag=0 and (Status=1 or Status=4 or CanEdit=1)"); if (model == null) { return Content("<script>setTimeout(function () { window.location.href = '/Prepare/TrainingApply/List' }, 3000);</script>操作失败,3秒后自动返回到列表!"); } ViewBag.TrainingObjectData = bll.GetTraningObject(); ViewBag.SubjectData = bll.GetSubject(); ViewBag.StudyLevelData = bll.GetStudyLevel(); ViewBag.TrainingFormData = bll.GetTrainingForm(); ViewBag.TeacherTitleData = bll.GetTeacherTitle(); ViewBag.TrainingFeildData = bll.GetTrainingField("Delflag=0 and IsSpec=0", ""); ViewBag.TrainingCategoryData = bll.GetTrainingCategory("Delflag=0 and Field=" + model.TraingField, ""); ViewBag.TrainingTopicData = bll.GetTrainingTopic("Delflag=0 and CategoryId=" + model.TraingCategory, ""); ViewBag.NationalCoursData = nationalAbility_CourseBLL.GetList2("Delflag=0 and TCategoryId=" + model.TraingCategory, ""); ViewBag.AttachData = bll.GetAttachTable("Delflag=0 and TraningId=" + id, ""); ViewBag.OutCourseTypeData = bll.GetOutCourseType("Delflag=0", ""); Organ_Detail otypeModel = new Organ_DetailBLL().GetModel(Code.SiteCache.Instance.ManageOrganId); ViewBag.OTypeId = otypeModel == null ? 0 : Convert.ToInt32(otypeModel.OType); return View(model); }
public ActionResult Add(Traning_Detail model) { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); ViewBag.TrainingObjectData = bll.GetTraningObject(); ViewBag.SubjectData = bll.GetSubject(); ViewBag.StudyLevelData = bll.GetStudyLevel(); ViewBag.TrainingFormData = bll.GetTrainingForm(); ViewBag.TeacherTitleData = bll.GetTeacherTitle(); ViewBag.OutCourseTypeData = bll.GetOutCourseType("Delflag=0", ""); Organ_Detail otypeModel = new Organ_DetailBLL().GetModel(Code.SiteCache.Instance.ManageOrganId); ViewBag.OTypeId = otypeModel == null ? 0 : Convert.ToInt32(otypeModel.OType); if (model.TraingCategory == 0) { TempData["Msg"] = "课程小类不能为空!"; return View(model); } if (model.TraingTopic == null || model.TraingTopic == 0) { TempData["Msg"] = "课程主题不能为空!"; return View(model); } if (string.IsNullOrEmpty(model.TeacherName)) { TempData["Msg"] = "请输入讲师名称!"; return View(model); } if (string.IsNullOrEmpty(model.TeacherFrom)) { TempData["Msg"] = "请输入讲师来自什么地方!"; return View(model); } string msg = ""; if (model.Title == null) model.Title = ""; else model.Title = model.Title.Trim(); model.OrganId = Code.SiteCache.Instance.ManageOrganId; //if (bll.CheckExists(model.Title.Replace("'", "''"), Convert.ToInt32(model.OrganId), model.Id)) //{ // TempData["Msg"] = "课程名称已存在"; // return View(model); //} int picType = Code.ExtendHelper.ToInt(Request["PicType"]); if (picType == 0) { TempData["Msg"] = "请选择图片!"; return View(model); } else if (picType == 1)//选择提供的图片 { model.Pic = Request["PicValue"]; } else if (picType == 2)//选择上传的图片 { HttpPostedFileBase pic = Request.Files["Pic"]; string picPath = Code.UploadCore.UploadImage(pic, ref msg); if (picPath == "") { TempData["Msg"] = msg; return View(model); } model.Pic = picPath; } HttpPostedFileBase teacherPic = Request.Files["TeacherPic"]; string teacherPicPath = Code.UploadCore.UploadImage(teacherPic, ref msg); if (teacherPicPath == "") { TempData["Msg"] = msg; return View(model); } model.TeacherPic = teacherPicPath; model.CreateDate = DateTime.Now; model.Creater = Code.SiteCache.Instance.ManagerId; model.PartitionId = Code.SiteCache.Instance.LoginInfo.PartitionId; if (model.Range == 1)//区级时更新上级机构Id model.ParentOrganId = bll.GetParentOrganId(Convert.ToInt32(model.OrganId)); if (model.Range == 2)//市级 model.ParentOrganId = null; int outCourseType = Code.ExtendHelper.ToInt(Request["OutCourseType"]); if (model.OutSideType == -1)//内部平台 { model.OutSideLink = null; model.OutSideContent = null; } else//外部平台 { model.OutSideType = outCourseType; } if (Request["submit"] == "保存") model.Status = 1; if (Request["submit"] == "保存并提交") model.Status = 2; model.Display = true; using (TransactionScope trans = new TransactionScope()) { try { //新增培训信息 bll.AddTrainingDetail(model); //更新附件 if (!string.IsNullOrEmpty(Request["AttachPathList"])) { DataTable dt = bll.GetAttachTable("1=0", ""); foreach (string s in Request["AttachPathList"].Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)) { DataRow row = dt.NewRow(); string[] file = s.Split('|'); row["Id"] = file[0]; row["TraningId"] = model.Id; row["Title"] = file[1].Replace("'", "''"); row["Link"] = file[2]; row["Sort"] = 50; row["Display"] = 1; row["Delflag"] = 0; row["CreateDate"] = DateTime.Now; dt.Rows.Add(row); } bll.BatchAttach(dt); } if (model.Status == 2)//保存并提交时,新增一条申请流程记录 { Traning_ApplyApplication apply = new Traning_ApplyApplication(); apply.TraningId = model.Id; apply.Status = 1; apply.Remark = "提交审核"; apply.Creater = model.Creater; apply.OrganId = model.OrganId; apply.Delflag = false; apply.CreateDate = DateTime.Now; bll.AddTrainingApply(apply); } trans.Complete(); return RedirectToAction("List"); } catch (Exception) { TempData["Msg"] = "保存失败!"; return View(model); } } }
public ActionResult Details(int id) { PrepareTrainingApplyBLL bll = new PrepareTrainingApplyBLL(); Traning_Detail model = bll.GetTrainingDetail(id, "Delflag=0"); if (model == null) { return Content("<script>setTimeout(function () { window.location.href = '/Prepare/TrainingApply/List' }, 3000);</script>操作失败,3秒后自动返回到列表!"); } ViewBag.TrainingObjectData = bll.GetTraningObject(); ViewBag.SubjectData = bll.GetSubject(); ViewBag.StudyLevelData = bll.GetStudyLevel(); ViewBag.TrainingFormData = bll.GetTrainingForm(); ViewBag.TeacherTitleData = bll.GetTeacherTitle(); ViewBag.TrainingFeildData = bll.GetTrainingField("Delflag=0 and IsSpec=0", ""); ViewBag.TrainingCategoryData = bll.GetTrainingCategory("Delflag=0 and Field=" + model.TraingField, ""); ViewBag.TrainingTopicData = bll.GetTrainingTopic("Delflag=0 and CategoryId=" + model.TraingCategory, ""); ViewBag.AttachData = bll.GetAttachTable("Delflag=0 and TraningId=" + id, ""); ViewBag.OutCourseTypeData = bll.GetOutCourseType("Delflag=0", ""); ViewBag.NationalCoursData = new NationalAbility_CourseBLL().GetList2("Delflag=0 and TCategoryId=" + model.TraingCategory, ""); return View(model); }