public ActionResult BeginTraining(string txtOrganizer, string txtVenue, string txtFromDate, string txtToDate, string hidCurCourse, string hidLectors) { ViewBag.Title = "Begin Training"; ViewBag.CurUrl = Url.Action("BeginTraining"); if (!ModelState.IsValid) { return(View()); } var msg = string.Empty; if (string.IsNullOrEmpty(txtVenue) || string.IsNullOrEmpty(txtFromDate) || string.IsNullOrEmpty(txtToDate) || string.IsNullOrEmpty(hidCurCourse) ) { msg = "课程,培训地点,起始时间,结束时间不能为空"; ModelState.AddModelError("", msg); return(View()); } List <tbl_lector> lectors = null; try { lectors = JsonConvert.DeserializeObject <List <tbl_lector> >(hidLectors); } catch (Exception ex) { LogHelper.WriteError(typeof(HomeController), ex); } if (string.IsNullOrEmpty(hidLectors) || lectors == null || lectors.Count == 0) { msg = "没有添加讲师"; ModelState.AddModelError("", msg); return(View()); } var courID = hidCurCourse; var sTmStart = txtFromDate.Trim(); var sTmEnd = txtToDate.Trim(); var dtStart = DateTime.Parse(sTmStart); //TODO copy from new change //var dtTemp = DateTime.Parse(sTmEnd); //var dtEnd = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, dtTemp.Hour, dtTemp.Minute, dtTemp.Second); var dtEnd = DateTime.Parse(sTmEnd); var cour = CourseInfo.GetByID(courID); if (null == cour) { msg = "找不到课程信息"; ModelState.AddModelError("", msg); return(View()); } var serr = string.Empty; var res = TrainingInfo.Insert(courID, lectors, txtOrganizer, txtVenue, dtStart, dtEnd, out serr); if (res.Item1) { SessionInfo.SetTrainingLectors(null); SessionInfo.SetCurTraining(res.Item2.ToString());//save current training ID return(RedirectToAction("LiveSigning")); } else { msg = "创建培训失败! " + serr; ModelState.AddModelError("", msg); return(View()); } }