private void GetContent() { zs.BLL.Tbl_Video bll = new zs.BLL.Tbl_Video(); string id = ApplicationMethod.decript(Request.QueryString["id"]); zs.Model.Tbl_Video model = bll.GetModelByCache(int.Parse(id)); this.lb_title.Text = model.title; conts = model.conts; videourl = model.videourl; this.Repeater1.DataSource = bll.GetList(5, "", "newid()"); this.Repeater1.DataBind(); }
/// <summary> /// 获得数据列表 /// </summary> public List <zs.Model.Tbl_Video> DataTableToList(DataTable dt) { List <zs.Model.Tbl_Video> modelList = new List <zs.Model.Tbl_Video>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { zs.Model.Tbl_Video model; for (int n = 0; n < rowsCount; n++) { model = new zs.Model.Tbl_Video(); 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]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["videourl"] != null && dt.Rows[n]["videourl"].ToString() != "") { model.videourl = dt.Rows[n]["videourl"].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); }
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_Video model = bll.GetModel(int.Parse(ids)); model.title = this.tb_title.Text.Trim(); model.author = this.tb_author.Text.Trim(); model.videourl = this.tb_videourl.Text.Trim(); if (this.fu_thumb.HasFile) { model.thumb = UploadImage(this.fu_thumb); } 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_Video model = new zs.Model.Tbl_Video(); model.title = this.tb_title.Text.Trim(); model.author = this.tb_author.Text.Trim(); model.videourl = this.tb_videourl.Text.Trim(); if (this.fu_thumb.HasFile) { model.thumb = UploadImage(this.fu_thumb); } model.leiid = int.Parse(this.ddl_leiid.SelectedValue); model.addtime = DateTime.Now; model.conts = Request.Form["myValue"].ToString(); bll.Add(model); } } }
private void BindData() { zs.BLL.Tbl_Guide bllg = new zs.BLL.Tbl_Guide(); this.ddl_leiid.DataSource = bllg.GetModelList("type='video'"); 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_Video model = bll.GetModel(int.Parse(ids)); this.tb_title.Text = model.title; this.tb_author.Text = model.author; this.tb_videourl.Text = model.videourl; this.ddl_leiid.SelectedItem.Value = model.leiid.Value.ToString(); cont = model.conts; this.btn_add.Text = "修改"; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(zs.Model.Tbl_Video model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(zs.Model.Tbl_Video model) { return(dal.Add(model)); }