예제 #1
0
 public Leibie getbyid(int aid)
 {
     con.Open();
     cmd = new SqlCommand("select * from leibietable where id=" + aid, con);
     SqlDataReader dr = cmd.ExecuteReader();
     Leibie lb = null;
     while (dr.Read())
     {
         lb = new Leibie(dr);
     }
     con.Close();
     return lb;
 }
예제 #2
0
    public Leibie getbyid(int aid)
    {
        con.Open();
        cmd = new SqlCommand("select * from leibietable where id=" + aid, con);
        SqlDataReader dr = cmd.ExecuteReader();
        Leibie        lb = null;

        while (dr.Read())
        {
            lb = new Leibie(dr);
        }
        con.Close();
        return(lb);
    }
예제 #3
0
    public List <Article> viewAll()
    {
        List <Article> list = new List <Article>();

        con.Open();
        cmd = new SqlCommand("select * from newstable order by time desc", con);
        SqlDataReader  sdr = cmd.ExecuteReader();
        Article        ac;
        Leibie         lb  = null;
        LeibieOperater lbo = null;

        while (sdr.Read())
        {
            lb        = new Leibie();
            lbo       = new LeibieOperater();
            ac        = new Article();
            ac.id     = sdr["id"].ToString();
            ac.liebie = Convert.ToInt32(sdr["leibie"]);
            int i = ac.liebie;
            lb           = lbo.getbyid(i);
            ac.leibiestr = lb.leibie.ToString();
            ac.title     = sdr["title"].ToString();
            ac.content   = sdr["content"].ToString();
            if (ac.content.Length > 200)
            {
                ac.content = ac.content.Substring(0, 200);
            }
            ac.postdatetime = Convert.ToDateTime(sdr["time"]);
            ac.gentieCount  = Convert.ToInt32(sdr["GentieCount"]);
            ac.readcount    = Convert.ToInt32(sdr["times"]);//读了多少次
            ac.author       = sdr["author"].ToString();
            list.Add(ac);
        }
        sdr.Close();
        con.Close();
        return(list);
    }
예제 #4
0
 public List<Article> viewAllByleibie(int leibie)
 {
     List<Article> list = new List<Article>();
     con.Open();
     cmd = new SqlCommand("select * from newstable where [leibie]="+leibie+"order by time desc", con);
     SqlDataReader sdr = cmd.ExecuteReader();
     Article ac;
     Leibie lb = null;
     LeibieOperater lbo = null;
     while (sdr.Read())
     {
         lb = new Leibie();
         lbo = new LeibieOperater();
         ac = new Article();
         ac.id = sdr["id"].ToString();
         ac.liebie = Convert.ToInt32(sdr["leibie"]);
         int i = ac.liebie;
         lb = lbo.getbyid(i);
         ac.leibiestr = lb.leibie.ToString();
         ac.title = sdr["title"].ToString();
         ac.content = sdr["content"].ToString();
         if (ac.content.Length > 200)
         {
             ac.content = ac.content.Substring(0, 200);
         }
         ac.postdatetime = Convert.ToDateTime(sdr["time"]);
         ac.gentieCount = Convert.ToInt32(sdr["GentieCount"]);
         ac.readcount = Convert.ToInt32(sdr["times"]);//读了多少次
         ac.author = sdr["author"].ToString();
         list.Add(ac);
     }
     sdr.Close();
     con.Close();
     return list;
 }