Beispiel #1
0
        protected void Save_Click(object sender, EventArgs e)
        {
            if (txtContent.Text.Trim().Length == 0)
            {
                Response.Write("<script>alert('内容不能为空!');</script>");
                return;
            }
            object           id = Request.QueryString["id"];//有待改善不安全
            WorkdtArticle    da = new WorkdtArticle();
            WorkdtArticleBLL workdtarticlebll = new WorkdtArticleBLL();

            da.AddDate = Convert.ToDateTime(TxtDate.Text);
            da.Writer  = Server.HtmlEncode(TxtWriter.Text.Trim());
            da.Title   = Server.HtmlEncode(TxtTitle.Text.Trim());
            da.Id      = id;
            da.Content = txtContent.Text.Trim();
            string name = this.Image1.ImageUrl.Substring(14);

            if (workdtarticlebll.Update(da))
            {
                Response.Write("<script>alert('修改成功');window.location.href='WorkdtMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('更新失败');history.back();</script>");
            }
        }
Beispiel #2
0
        public IList <WorkdtArticle> FindALLByHits()
        {
            List <WorkdtArticle> list = new List <WorkdtArticle>();

            sql = "select top 12 * from WorkdtArticle order by hits desc";
            ds  = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    WorkdtArticle a = new WorkdtArticle();
                    a.AddDate = Convert.ToDateTime(dr["addDate"].ToString());
                    a.Content = dr["Content"].ToString();
                    a.Id      = dr["id"];
                    a.Title   = dr["Title"].ToString();
                    a.Writer  = dr["Writer"].ToString();
                    a.Url     = dr["Url"].ToString();
                    list.Add(a);
                }
                return(list);
            }
        }
Beispiel #3
0
        public IList <WorkdtArticle> FindALL(object cid, int num)//找到cid的类中前num的列表
        {
            List <WorkdtArticle> list = new List <WorkdtArticle>();

            if (cid != null && cid.ToString() != "")
            {
                sql = "select top " + num + " * from WorkdtArticle where cid=" + cid + " order by id desc";
            }
            else
            {
                sql = "select top " + num + " * from WorkdtArticle order by id desc";
            }
            ds = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    WorkdtArticle a = new WorkdtArticle();
                    a.AddDate = Convert.ToDateTime(dr["addDate"].ToString());
                    a.Content = dr["Content"].ToString();
                    a.Id      = dr["id"];
                    a.Title   = dr["Title"].ToString();
                    a.Writer  = dr["Writer"].ToString();
                    a.Url     = dr["Url"].ToString();
                    list.Add(a);
                }
                return(list);
            }
        }
Beispiel #4
0
        public IList <WorkdtArticle> Getlist(object num)//取WorkdtArticle表中前num个记录,以列表的形式返回
        {
            List <WorkdtArticle> list = new List <WorkdtArticle>();

            if (num != null && num.ToString() != "")
            {
                sql = "select top " + num + " * from WorkdtArticle order by id desc";
            }
            else
            {
                sql = "select * from WorkdtArticle order by id desc";
            }
            ds = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    WorkdtArticle a = new WorkdtArticle();
                    a.AddDate = Convert.ToDateTime(dr["addDate"].ToString());
                    a.Content = dr["Content"].ToString();
                    a.Id      = dr["id"];
                    a.Title   = dr["Title"].ToString();
                    a.Writer  = dr["Writer"].ToString();
                    a.Url     = dr["Url"].ToString();
                    list.Add(a);
                }
                return(list);
            }
        }
Beispiel #5
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (txtContent.Text.Trim().Length == 0)
            {
                Response.Write("<script>alert('内容不能为空,请填写内容!');</script>");
                return;
            }
            WorkdtArticle    da = new WorkdtArticle();
            WorkdtArticleBLL workdtarticlebll = new WorkdtArticleBLL();
            string           newname          = "";

            da.Url     = newname;
            da.AddDate = Convert.ToDateTime(TxtDate.Text);
            da.Writer  = Server.HtmlEncode(TxtWriter.Text.Trim());
            da.Title   = Server.HtmlEncode(TxtTitle.Text.Trim());
            da.Content = txtContent.Text;
            if (workdtarticlebll.Add(da))
            {
                Response.Write("<script>alert('添加成功');window.location.href='WorkdtMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Beispiel #6
0
 public bool Update(WorkdtArticle a)
 {
     if (DbHelperSQL.Update(a))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #7
0
 public bool Add(WorkdtArticle a)
 {
     if (DbHelperSQL.Insert(a))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #8
0
        public void DateBind(object id)//绑定要修改的信息
        {
            WorkdtArticleBLL workdtarticlebll = new WorkdtArticleBLL();
            WorkdtArticle    da = new WorkdtArticle();

            da                   = workdtarticlebll.GetNewsArticle(id);
            TxtTitle.Text        = da.Title;
            TxtWriter.Text       = da.Writer;
            TxtDate.Text         = da.AddDate.ToString("d");
            txtContent.Text      = da.Content.ToString();
            this.Image1.ImageUrl = "~/IndexImages/" + da.Url;
        }
Beispiel #9
0
        public WorkdtArticle Find(object id)//从WorkdtArticle找到该id的数据,返回一个WorkdtArticle类生成的对象
        {
            a = new WorkdtArticle();
            string sql = string.Format("select * from WorkdtArticle where id='{0}'", id);

            dr = DbHelperSQL.GetDateRow(sql);
            try
            {
                a.AddDate = Convert.ToDateTime(dr["AddDate"].ToString());
                a.Content = dr["Content"].ToString();
                a.Id      = dr["id"];
                a.Title   = dr["Title"].ToString();
                a.Writer  = dr["Writer"].ToString();
                a.Url     = dr["Url"].ToString();
                return(a);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #10
0
        public IList <WorkdtArticle> search(string cid)//搜索该表中,所有与关键字匹配的记录,当cid为空时,搜索整个表
        {
            if (cid == "" || cid == null)
            {
                sql = "select * from WorkdtArticle order by id desc";
                ds  = DbHelperSQL.GetDataSet(sql);
            }
            else
            {
                sql = "select * from WorkdtArticle where title like '%" + cid + "%' order by id desc";

                SqlParameter par = new SqlParameter("@titlesea", SqlDbType.NVarChar, 50);
                par.Value = cid;
                SqlParameter tablename = new SqlParameter("@tablename", SqlDbType.NVarChar, 50);
                tablename.Value = "WorkdtArticle";
                SqlParameter[] cmdParms = { tablename, par };
                ds = DbHelperSQL.RunProcedure("WorkdtSearch", cmdParms, "WorkdtArticle");
            }
            List <WorkdtArticle> list = new List <WorkdtArticle>();

            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    WorkdtArticle a = new WorkdtArticle();
                    a.AddDate = Convert.ToDateTime(dr["addDate"].ToString());
                    a.Content = dr["Content"].ToString();
                    a.Id      = dr["id"];
                    a.Title   = dr["Title"].ToString();
                    a.Writer  = dr["Writer"].ToString();
                    list.Add(a);
                }
                return(list);
            }
        }
Beispiel #11
0
 public bool Update(WorkdtArticle news)//更新数据
 {
     return(WorkdtArticleDao.Update(news));
 }
Beispiel #12
0
 public bool Add(WorkdtArticle news)//加数据
 {
     return(WorkdtArticleDao.Add(news));
 }