public ActionResult Edit(News NewsEdit, string trangthai, int id) { NewsEdit.NewsID = id; if (ModelState.IsValid) { NewsDAO newsDAO = new NewsDAO(); if (trangthai == "Khóa") { NewsEdit.Status = false; } else { NewsEdit.Status = true; } NewsEdit.ModifiedBy = BaseController.NguoiDungHienTai.UserAccount; int checksuccess = newsDAO.EditNews(NewsEdit); if (checksuccess > 0) { TempData["msg"] = MessageBox.Show("Edit Thành Công"); return(RedirectToAction("Index", "News")); } else { ModelState.AddModelError("", "Edit Không Thành Công"); } } return(View("Edit", "News", new { @NewsEditID = NewsEdit.NewsID })); }
protected void submitButton_Click(object sender, EventArgs e) { string idString = Request.QueryString["id"]; int idInt = Convert.ToInt32(idString); if (null == idString || idString.Equals(string.Empty) || 1 > idInt) { UtilFunctions.AlertBox("请输入正确的请求代号!", Page); return; } string title = TitleTextBox.Text; string article = ArticleTextBox.Text; NewsDAO newsDao = new NewsDAO(); int categoryId = Convert.ToInt32(this.CategoryDropDownList.SelectedValue); if (1 > categoryId) { UtilFunctions.AlertBox("请选择正确的文章类型!", Page); return; } if (-1 == newsDao.EditNews(idInt, categoryId, title, article)) { UtilFunctions.AlertBox("修改失败!", Page); } else { UtilFunctions.AlertBox("修改成功!", Page); } }