private void CourseAdd_Click(object sender, EventArgs e)//添加按钮功能 { Course course = new Course() { cno = Cno.Text, cname = Cname.Text, credit = Credit.Text, category = Category.Text, deptno = Deptno.Text }; CourseBLL courseBLL = new CourseBLL(); #region 添加 if (CourseAdd.Text.Equals("添加")) { if (courseBLL.Add(course)) { MessageBox.Show("添加成功"); LoadCourseList(); } else { MessageBox.Show("添加失败"); } } #endregion #region 修改 else { if (courseBLL.Edit(course)) { MessageBox.Show("修改成功"); LoadCourseList(); Cno.ReadOnly = false; CourseAdd.Text = "添加"; } else { MessageBox.Show("修改失败"); } } #endregion Cno.Text = ""; Cname.Text = ""; Credit.Text = ""; Category.Text = ""; Deptno.Text = ""; }
public ActionResult CourseEntry(CourseCreateForView model) { if (_courseBll.GetAll().Any(e => e.Name == model.Name)) { ModelState.AddModelError("Name", "Course is Already Assign"); } var msg = "Failed"; if (ModelState.IsValid) { var course = Mapper.Map <Course>(model); bool isAdded = _courseBll.Add(course); if (isAdded) { ViewBag.SMsg = "Saved"; return(RedirectToAction("CourseInfo", new { id = course.Id })); } else { ViewBag.EMsg = "Failed";; } } else { ViewBag.EMsg = msg; } var coursemodel = new CourseCreateForView(); coursemodel.OrganitionSelectListItem = _organizationBll .GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }).ToList(); //coursemodel.OrganizationList = _courseEntryBll.GetAll(); return(View(coursemodel)); }
public IActionResult Add([FromBody] CourseModel.CourseUpdateModel model) { var response = logicBll.Add(model); return(StatusCode((int)response.Message.Status, response)); }