示例#1
0
        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);
        }
示例#2
0
        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>");
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
 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();
         }
     }
 }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
 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>");
     }
 }
示例#10
0
        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);
        }
示例#11
0
        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;
        }
示例#12
0
        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);
        }
示例#13
0
 public void Update(NewsSort model)
 {
     dns.Update(model);
 }
示例#14
0
 public DataSet Select(NewsSort model)
 {
     return(dns.Select(model));
 }
示例#15
0
 public void Delete(NewsSort model)
 {
     dns.Delete(model);
 }
示例#16
0
 public void Insert(NewsSort model)
 {
     dns.Insert(model);
 }