Ejemplo n.º 1
0
        public IList <AllianceArticle> FindALLByHits()
        {
            List <AllianceArticle> list = new List <AllianceArticle>();

            sql = "select top 12 * from AllianceArticle order by hits desc";
            ds  = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    AllianceArticle a = new AllianceArticle();
                    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);
            }
        }
Ejemplo n.º 2
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (txtContent.Text.Trim().Length == 0)
            {
                Response.Write("<script>alert('内容不能为空!');</script>");
                return;
            }
            AllianceArticle    da = new AllianceArticle();
            AllianceArticleBLL alliancearticlebll = new AllianceArticleBLL();
            string             title  = Server.HtmlEncode(TxtTitle.Text.Trim());
            string             writer = Server.HtmlEncode(TxtWriter.Text.Trim());

            da.AddDate = Convert.ToDateTime(TxtDate.Text);
            da.Writer  = writer;
            da.Title   = title;
            da.Content = txtContent.Text;
            if (alliancearticlebll.Add(da))
            {
                Response.Write("<script>alert('添加成功');window.location.href='AllianceMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Ejemplo n.º 3
0
        public IList <AllianceArticle> FindALL(object cid, int num)//找到cid的类中前num的列表
        {
            List <AllianceArticle> list = new List <AllianceArticle>();

            if (cid != null && cid.ToString() != "")
            {
                sql = "select top " + num + " * from AllianceArticle where cid=" + cid + " order by id desc";
            }
            else
            {
                sql = "select top " + num + " * from AllianceArticle order by id desc";
            }


            ds = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    AllianceArticle a = new AllianceArticle();
                    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);
            }
        }
Ejemplo n.º 4
0
        public IList <AllianceArticle> Getlist(object num)//取AllianceArticle表中前num个记录,以列表的形式返回
        {
            List <AllianceArticle> list = new List <AllianceArticle>();

            if (num != null && num.ToString() != "")
            {
                sql = "select top " + num + " * from AllianceArticle order by id desc";
            }
            else
            {
                sql = "select * from AllianceArticle order by id desc";
            }
            ds = DbHelperSQL.GetDataSet(sql);
            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    AllianceArticle a = new AllianceArticle();
                    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);
            }
        }
Ejemplo n.º 5
0
 public bool Update(AllianceArticle a)
 {
     if (DbHelperSQL.Update(a))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 public bool Add(AllianceArticle a)
 {
     if (DbHelperSQL.Insert(a))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
        public void DateBind(object id)//绑定要修改的信息
        {
            AllianceArticleBLL alliancearticlebll = new AllianceArticleBLL();
            AllianceArticle    da = new AllianceArticle();

            da              = alliancearticlebll.GetNewsArticle(id);
            TxtTitle.Text   = da.Title;
            TxtWriter.Text  = da.Writer;
            TxtDate.Text    = da.AddDate.ToString("d");
            txtContent.Text = da.Content.ToString();
        }
Ejemplo n.º 8
0
        public AllianceArticle Find(object id)//从AllianceArticle找到该id的数据,返回一个AllianceArticle类生成的对象
        {
            a = new AllianceArticle();
            string sql = string.Format("select * from AllianceArticle 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();
                return(a);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 9
0
        public IList <AllianceArticle> search(string cid)//搜索该表中,所有与关键字匹配的记录,当cid为空时,搜索整个表
        {
            if (cid == "" || cid == null)
            {
                sql = "select * from AllianceArticle order by id desc";
                ds  = DbHelperSQL.GetDataSet(sql);
            }
            else
            {
                SqlParameter par = new SqlParameter("@titlesea", SqlDbType.NVarChar, 50);
                par.Value = cid;
                SqlParameter tablename = new SqlParameter("@tablename", SqlDbType.NVarChar, 50);
                tablename.Value = "AllianceArticle";
                SqlParameter[] cmdParms = { tablename, par };
                ds = DbHelperSQL.RunProcedure("AllianceSearch", cmdParms, "AllianceArticle");
            }

            List <AllianceArticle> list = new List <AllianceArticle>();

            if (ds == null)
            {
                return(null);
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    AllianceArticle a = new AllianceArticle();
                    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);
            }
        }
Ejemplo n.º 10
0
 public bool Update(AllianceArticle news)//更新数据
 {
     return(AllianceArticleDao.Update(news));
 }
Ejemplo n.º 11
0
 public bool Add(AllianceArticle news)//添加数据
 {
     return(AllianceArticleDao.Add(news));
 }