private void doPost() { light.BLL.news bll = new light.BLL.news(); model = bll.GetModel(int.Parse(ViewState["nid"].ToString())); model.categoryid =int.Parse(Request["categoryid"].ToString()); model.description =Request["description"]; if(Request["isopen"]=="on") { model.isopen =1; } else { model.isopen = 0; } if(Request["isrecommend"]=="on") { model.isrecommend =1; } else { model.isrecommend = 0; } model.title = Request["title"]; bll.Update(model); Response.Redirect("edit.aspx?nid=" + ViewState["nid"].ToString()); }
private void doPost() { light.Model.news model = new light.Model.news(); model.addtime = DateTime.Now; model.categoryid =int.Parse(Request["categoryid"].ToString()); model.description =Request["description"]; if(Request["isopen"]=="on") { model.isopen =1; } else { model.isopen = 0; } if(Request["isrecommend"]=="on") { model.isrecommend =1; } else { model.isrecommend = 0; } model.title = Request["title"]; light.BLL.news bll = new light.BLL.news(); bll.Add(model); light.Common.WebMessageBox.ShowMessageBox("添加成功", this); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int nid = light.Common.DNTRequest.GetQueryInt("nid", 0); if (nid > 0) { model = new light.BLL.news().GetModel(nid); ViewState["nid"] = nid.ToString(); } } else { doPost(); } }