protected void btn_add_Click(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { string ids = Request.QueryString["id"].ToString(); if (ids != "0") { zs.Model.Tbl_News model = bll.GetModel(int.Parse(ids)); model.title = this.tb_title.Text.Trim(); model.author = this.tb_author.Text.Trim(); model.leiid = int.Parse(this.ddl_leiid.SelectedValue); model.addtime = DateTime.Now; model.conts = Request.Form["myValue"].ToString(); bll.Update(model); BindData(); } else { zs.Model.Tbl_News model = new zs.Model.Tbl_News(); model.title = this.tb_title.Text.Trim(); model.author = this.tb_author.Text.Trim(); model.leiid = int.Parse(this.ddl_leiid.SelectedValue); model.addtime = DateTime.Now; model.conts = Request.Form["myValue"].ToString(); bll.Add(model); } } }
private void GetContent() { zs.BLL.Tbl_News bll = new zs.BLL.Tbl_News(); string id = ApplicationMethod.decript(Request.QueryString["id"]); zs.Model.Tbl_News model = bll.GetModelByCache(int.Parse(id)); this.lb_title.Text = model.title; this.lb_Cont.Text = model.conts; tags = "浙江树人大学,招生网,树大招生," + model.title; desc = ApplicationMethod.NoHtmlCode(model.conts, 80); Page.Title = model.title + " - 浙江树人大学招生网"; }
private void BindData() { zs.BLL.Tbl_Guide bllg = new zs.BLL.Tbl_Guide(); this.ddl_leiid.DataSource = bllg.GetModelList("type='news'"); this.ddl_leiid.DataTextField = "name"; this.ddl_leiid.DataValueField = "id"; this.ddl_leiid.DataBind(); if (Request.QueryString["id"] != null) { string ids = Request.QueryString["id"].ToString(); if (ids != "0") { zs.Model.Tbl_News model = bll.GetModel(int.Parse(ids)); this.tb_title.Text = model.title; this.tb_author.Text = model.author; this.ddl_leiid.SelectedItem.Value = model.leiid.Value.ToString(); cont = model.conts; this.btn_add.Text = "修改"; } } }
/// <summary> /// 获得数据列表 /// </summary> public List <zs.Model.Tbl_News> DataTableToList(DataTable dt) { List <zs.Model.Tbl_News> modelList = new List <zs.Model.Tbl_News>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { zs.Model.Tbl_News model; for (int n = 0; n < rowsCount; n++) { model = new zs.Model.Tbl_News(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["conts"] != null && dt.Rows[n]["conts"].ToString() != "") { model.conts = dt.Rows[n]["conts"].ToString(); } if (dt.Rows[n]["addtime"] != null && dt.Rows[n]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(dt.Rows[n]["addtime"].ToString()); } if (dt.Rows[n]["author"] != null && dt.Rows[n]["author"].ToString() != "") { model.author = dt.Rows[n]["author"].ToString(); } if (dt.Rows[n]["leiid"] != null && dt.Rows[n]["leiid"].ToString() != "") { model.leiid = int.Parse(dt.Rows[n]["leiid"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(zs.Model.Tbl_News model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(zs.Model.Tbl_News model) { return(dal.Add(model)); }