public void Delete(NewsSort model) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@"DELETE FROM [dbo].[News_Sort] WHERE ID=@ID"); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", model.ID) }; sh.ExecuteNonQuery(sql.ToString(), pars); }
private void UpdateSort() { int id = Convert.ToInt32(Request["id"]); NewsSort ns = new NewsSort { ID = id, NewsSortName = txtSort.Text.Trim(), CreatedTime = DateTime.Now }; nsm.Update(ns); Response.Write("<script>alert('保存成功!')</script>"); Response.Write("<script>window.location.href='NewsSortList.aspx';</script>"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string sortName = Convert.ToString(context.Request["SortName"]); NewsSort model = new NewsSort { NewsSortName = sortName }; var newsList = new NewsSortMgr().Select2(model); string jsonStr = new JavaScriptSerializer().Serialize(newsList); context.Response.Write(jsonStr); }
public void Update(NewsSort model) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@"UPDATE [dbo].[News_Sort] SET [NewsSortName] = @NewsSortName ,[CreatedTime] = @CreatedTime WHERE ID=@ID"); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@NewsSortName", model.NewsSortName), new SqlParameter("@CreatedTime", model.CreatedTime), new SqlParameter("@ID", model.ID) }; sh.ExecuteNonQuery(sql.ToString(), pars); }
public DataSet Select2(NewsSort model) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@"select NewsTitle ,News_Datail.CreatedTime from News_Datail inner join News_Sort on News_Datail.NewsSortId = News_Sort.ID where News_Sort.ID = @ID "); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", model.ID) }; DataSet ds = sh.ExecuteQuery(sql.ToString(), pars); return(ds); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["id"] != null) { int id = Convert.ToInt32(Request["id"]); NewsSort ns = new NewsSort() { ID = id }; DataSet ds = nsm.Select(ns); var text = ds.Tables[0].Rows[0]["NewsSortName"]; txtSort.Text = text.ToString(); } } }
public DataSet Select(NewsSort model) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@"SELECT [ID] ,[NewsSortName] ,[CreatedTime] FROM [dbo].[News_Sort] where ID = @ID "); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@ID", model.ID) }; DataSet ds = sh.ExecuteQuery(sql.ToString(), pars); return(ds); }
public void Insert(NewsSort model) { StringBuilder sql = new StringBuilder(); sql.AppendLine(@"INSERT INTO [dbo].[News_Sort] ([NewsSortName] ,[CreatedTime]) VALUES (@NewsSortName ,@CreatedTime)"); SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@NewsSortName", model.NewsSortName), new SqlParameter("@CreatedTime", model.CreatedTime) }; new SqlHelper().ExecuteNonQuery(sql.ToString(), paras); }
private void AddSort() { if (txtSort.Text != null && txtSort.Text != "") { NewsSort ns = new NewsSort() { NewsSortName = txtSort.Text.Trim(), CreatedTime = DateTime.Now }; nsm.Insert(ns); Response.Write("<script>alert('保存成功!')</script>"); Response.Write("<script>window.location.href='NewsSortList.aspx';</script>"); } else { Response.Write("<script>alert('请填写要保存的分类名称!!')</script>"); } }
public List <News_Datail> SelectTitleInf(NewsSort model) { var list = new List <News_Datail>(); DataSet ds = new DalNewsSort().Select2(model); DataTable dt = new DataTable(); if (ds != null && ds.Tables.Count > 0) { dt = ds.Tables[0]; } foreach (DataRow dr in dt.Rows) { var mod = new News_Datail(); mod.NewsTitle = Convert.ToString(dr["NewsTitle"]); mod.CreatedTime = Convert.ToDateTime(dr["CreatedTime"]); list.Add(mod); } return(list); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { var user = (UserInfo)Session["User"]; if (user == null) { Response.Redirect("Login.aspx"); } int id = Convert.ToInt32(gvNewSort.Rows[e.RowIndex].Cells[1].Text); NewsSort ns = new NewsSort() { ID = id }; nsm.Delete(ns); newsBind(); Response.Write("<script>alert('删除成功!')</script>"); e.Cancel = true; }
public List <NewsSort> Select() { var list = new List <NewsSort>(); var ds = dns.Select(); var dt = new DataTable(); if (ds != null && ds.Tables.Count > 0) { dt = ds.Tables[0]; } foreach (DataRow dr in dt.Rows) { var model = new NewsSort(); model.ID = Convert.ToInt32(dr["ID"]); model.NewsSortName = Convert.ToString(dr["NewsSortName"]); model.CreatedTime = Convert.ToDateTime(dr["CreatedTime"]); list.Add(model); } return(list); }
public void Update(NewsSort model) { dns.Update(model); }
public DataSet Select(NewsSort model) { return(dns.Select(model)); }
public void Delete(NewsSort model) { dns.Delete(model); }
public void Insert(NewsSort model) { dns.Insert(model); }