protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string ID = Convert.ToString(Request["id"]); NEW.Model.Trends ts = new QPS.NEW.Model.Trends(); QPS.NEW.BLL.Trends Bts = new QPS.NEW.BLL.Trends(); ts = Bts.GetModel(Convert.ToInt32(ID)); this.txtTitle.Text = ts.Title; this.Content.Text = ts.Content; } }
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { string ID = Convert.ToString(Request["id"]); NEW.Model.Trends ts = new QPS.NEW.Model.Trends(); QPS.NEW.BLL.Trends Bts = new QPS.NEW.BLL.Trends(); ts = Bts.GetModel(Convert.ToInt32(ID)); this.txtTitle.Text =ts.Title; this.Content.Text=ts.Content; } }
// void Bind() { int currentpage = Convert.ToInt32(Request["CurrentPage"]); int check = 1; currentpage = (currentpage < 1) ? 1 : currentpage; if (this.Pager1.CurrentIndex > 0) { currentpage = this.Pager1.CurrentIndex; } int pageSize = this.Pager1.PageSize; QPS.NEW.BLL.Trends ts = new QPS.NEW.BLL.Trends(); ds =ts.Select(pageSize,currentpage); dgExamProj.DataSource = ds; this.Pager1.ItemCount = ts.GetCount(); dgExamProj.DataBind(); }
protected void dgExamProj_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "delete")//删除 { string ID = e.CommandArgument.ToString(); QPS.NEW.BLL.Trends ts = new QPS.NEW.BLL.Trends(); if (ts.Delete(int.Parse(ID))) { Response.Write("<script>alert('删除成功!');</script>"); } Bind(); } if (e.CommandName == "LinkTo")//查看 { string ID = e.CommandArgument.ToString(); Server.Transfer("TrendsListXQ.aspx?id=" + ID); } }
// void Bind() { int currentpage = Convert.ToInt32(Request["CurrentPage"]); int check = 1; currentpage = (currentpage < 1) ? 1 : currentpage; if (this.Pager1.CurrentIndex > 0) { currentpage = this.Pager1.CurrentIndex; } int pageSize = this.Pager1.PageSize; QPS.NEW.BLL.Trends ts = new QPS.NEW.BLL.Trends(); ds = ts.Select(pageSize, currentpage); dgExamProj.DataSource = ds; this.Pager1.ItemCount = ts.GetCount(); dgExamProj.DataBind(); }
//修改 protected void bntUpdate_Click(object sender, EventArgs e) { string id = Request["ID"].ToString(); string title = this.txtTitle.Text; string con = this.Content.Text; NEW.Model.Trends Mts = new QPS.NEW.Model.Trends(); Mts.Id = Convert.ToInt32(id); Mts.Title = title; Mts.Content = con; Mts.Time = DateTime.Now.ToString(); QPS.NEW.BLL.Trends Bts = new QPS.NEW.BLL.Trends(); if (Bts.Update(Mts)) { Response.Write("<script>alert('修改成功!!');window.location.href = 'TrendsList.aspx';</script>"); } else { Response.Write("<script>alert('修改失败!!');</script>"); } }
//添加 protected void bntInsert_Click(object sender, EventArgs e) { string title = this.txtTitle.Text; string con = this.Content.Text; NEW.Model.Trends Mts = new QPS.NEW.Model.Trends(); Mts.Title = title; Mts.Content = con; Mts.Time = DateTime.Now.ToString(); QPS.NEW.BLL.Trends Bts = new QPS.NEW.BLL.Trends(); int i = Bts.Add(Mts); if (i > 0) { Response.Write("<script>alert('添加成功!!');window.location.href = 'TrendsList.aspx';</script>"); } else { Response.Write("<script>alert('添加失败!!');</script>"); } }
//修改 protected void bntUpdate_Click(object sender, EventArgs e) { string id = Request["ID"].ToString(); string title = this.txtTitle.Text; string con = this.Content.Text; NEW.Model.Trends Mts = new QPS.NEW.Model.Trends(); Mts.Id = Convert.ToInt32(id); Mts.Title=title; Mts.Content = con; Mts.Time = DateTime.Now.ToString(); QPS.NEW.BLL.Trends Bts = new QPS.NEW.BLL.Trends(); if (Bts.Update(Mts)) { Response.Write("<script>alert('修改成功!!');window.location.href = 'TrendsList.aspx';</script>"); } else { Response.Write("<script>alert('修改失败!!');</script>"); } }