예제 #1
0
        //主题内容

        public List <Themeinfo> GetTheme()
        {
            List <Themeinfo> list = new List <Themeinfo>();
            Themeinfo        info = null;

            //SqlParameter[] parm = new SqlParameter[]
            //{
            //    new SqlParameter("@UserId",UserId)
            //};
            using (SqlDataReader dr = Helper.ExecuteReader("GetTheme", CommandType.StoredProcedure, null))
            {
                while (dr.Read())
                {
                    info         = new Themeinfo();
                    info.ThemeId = Convert.ToInt32(dr["ThemeId"].ToString());
                    //info.UserId = Convert.ToInt32(dr["UserId"].ToString());
                    info.Title = dr["Title"].ToString();
                    //info.UserName = dr["UserName"].ToString();
                    info.T_PublishTime = dr["T_PublishTime"] == DBNull.Value ? DateTime.Now : Convert.ToDateTime(dr["T_PublishTime"]);
                    //info.T_Content = dr["T_Content"].ToString();
                    info.Spot = dr["Spot"] == DBNull.Value ? 0 : Convert.ToInt32(dr["Spot"]);
                    list.Add(info);
                }
            }
            return(list);
        }
예제 #2
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //查找需要更新的控件
        TextBox tName    = GridView1.Rows[e.RowIndex].FindControl("TextBox3") as TextBox;
        TextBox tTime    = GridView1.Rows[e.RowIndex].FindControl("TextBox4") as TextBox;
        TextBox tContent = GridView1.Rows[e.RowIndex].FindControl("TextBox5") as TextBox;
        //查找对应的的键值
        string ThemeId = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
        //给实体赋值
        Themeinfo info = new Themeinfo();

        info.ThemeId       = Convert.ToInt32(ThemeId);
        info.Title         = Convert.ToString(tName.Text);
        info.T_PublishTime = Convert.ToDateTime(tTime.Text);
        info.Spot          = Convert.ToInt32(tContent.Text);

        //更新数据
        if (bll.UpdateTheme(info))
        {
            GridView1.EditIndex = -1;
            BindTheme();
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!')</script>");
        }
    }
예제 #3
0
        //获取对应文章
        public List <Themeinfo> GetListById(string ThemeId)
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@ThemeId", ThemeId)
            };
            List <Themeinfo> list = new List <Themeinfo>();
            Themeinfo        info = null;

            using (SqlDataReader rd = Helper.ExecuteReader("Theme_GetList", CommandType.StoredProcedure, param))
            {
                while (rd.Read())
                {
                    info = new Themeinfo();
                    //info.Id = (int)rd["Id"];

                    info.Title         = (string)rd["Title"];
                    info.UserId        = (string)rd["UserId"];
                    info.T_PublishTime = (DateTime)rd["T_PublishTime"];
                    info.T_Content     = (string)rd["T_Content"];
                    info.Spot          = (int)rd["Spot"];
                    list.Add(info);
                }
            }
            return(list);
        }
예제 #4
0
        public Themeinfo GetArticleById(int id)
        {
            UserSerice    us  = new UserSerice();
            string        sql = "SELECT * FROM Theme WHERE Id = @Id";
            int           ThemeId;
            SqlDataReader reader = Helper.GetReader(sql, new SqlParameter("@Id", id));

            if (reader.Read())
            {
                Themeinfo article = new Themeinfo();
                article.Id            = (int)reader["Id"];
                article.Title         = (string)reader["Title"];
                article.T_Content     = (string)reader["T_Content"];
                article.T_PublishTime = (DateTime)reader["T_PublishTime"];
                article.Counts        = (int)reader["Counts"];
                ThemeId = (int)reader["ThemeId"]; //FK
                reader.Close();
                article.Anthor = us.GetUserById(ThemeId);
                return(article);
            }
            else
            {
                reader.Close();
                return(null);
            }
        }
예제 #5
0
 /// 修改文章
 public bool UpdateTheme(Themeinfo info)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter("@ThemeId", info.ThemeId),
         new SqlParameter("@Title", info.Title),
         //new SqlParameter("@UserName",info.UserName ),
         new SqlParameter("@T_PublishTime", info.T_PublishTime),
         new SqlParameter("@Spot", info.Spot)
     };
     return(Helper.ExecuteNonQuery("UpdateTheme", CommandType.StoredProcedure, param));
 }
예제 #6
0
 //发表文章
 public Boolean Insert_Article(Themeinfo info)
 {
     SqlParameter[] parm = new SqlParameter[]
     {
         //new SqlParameter("@ThemeId",info.ThemeId),
         new SqlParameter("@Title", info.Title),
         new SqlParameter("@T_PublishTime", info.T_PublishTime),
         new SqlParameter("@T_Content", info.T_Content),
         new SqlParameter("@Spot", info.Spot)
     };
     return(Helper.ExecuteNonQuery("Theme_InsertArticle", CommandType.StoredProcedure, parm));
 }
예제 #7
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Themeinfo    info = new Themeinfo();
        ThemeManager tm   = new ThemeManager();

        info.Title         = this.TextBox1.Text.ToString();
        info.T_Content     = this.FreeTextBox1.Text.ToString();
        info.Anthor        = user;
        info.Spot          = 0;
        info.T_PublishTime = DateTime.Now;

        if (tm.Insert_Article(info) != null)
        {
            Response.Redirect("~/refresh.aspx?msg=" + "恭喜你,发表成功!");
        }
        else
        {
            this.lblMsg.Text = "很遗憾,发表失败,请重新尝试!";
        }
    }
예제 #8
0
        private IList <Themeinfo> GetArticlesBySql(string sql, params SqlParameter[] values)
        {
            UserSerice       ui    = new UserSerice();
            List <Themeinfo> list  = new List <Themeinfo>();
            DataTable        table = Helper.GetDataSet(sql, values);

            foreach (DataRow row in table.Rows)
            {
                Themeinfo article = new Themeinfo();

                article.Id            = (int)row["Id"];
                article.Title         = (string)row["Title"];
                article.T_Content     = (string)row["T_Content"];
                article.T_PublishTime = (DateTime)row["T_PublishTime"];
                article.Spot          = (int)row["Spot"];
                article.Anthor        = ui.GetUserById((int)row["Id"]); //FK
                list.Add(article);
            }
            return(list);
        }
예제 #9
0
        //热门文章
        public List <Themeinfo> GetModelById()
        {
            List <Themeinfo> list = new List <Themeinfo>();
            Themeinfo        info = null;

            //SqlParameter[] parm = new SqlParameter[]
            //{
            //    //new SqlParameter("@ProductId",productId)
            //};
            using (SqlDataReader dr = Helper.ExecuteReader("GetThemeby", CommandType.StoredProcedure, null))
            {
                while (dr.Read())
                {
                    info       = new Themeinfo();
                    info.Title = dr["Title"].ToString();
                    info.Spot  = dr["Spot"] == DBNull.Value ? 0 : Convert.ToInt32(dr["Spot"]);
                    list.Add(info);
                }
            }
            return(list);
        }
예제 #10
0
        //用户列表
        public List <Themeinfo> GetUsers()
        {
            List <Themeinfo> list = new List <Themeinfo>();
            Themeinfo        info = null;

            //SqlParameter[] parm = new SqlParameter[]
            //{
            //    //new SqlParameter("@ProductId",productId)
            //};
            using (SqlDataReader dr = Helper.ExecuteReader("GetUsers", CommandType.StoredProcedure, null))
            {
                while (dr.Read())
                {
                    info = new Themeinfo();

                    info.UserName = dr["UserName"].ToString();
                    info.Counts   = Convert.ToInt32(dr["Counts"]); //== DBNull.Value ? 0 : Convert.ToInt32(dr["Counts"]);
                    list.Add(info);
                }
            }
            return(list);
        }
예제 #11
0
 /// 修改文章
 public bool UpdateTheme(Themeinfo info)
 {
     return(th.UpdateTheme(info));
 }
예제 #12
0
 //发表文章
 public Boolean Insert_Article(Themeinfo info)
 {
     return(th.Insert_Article(info));
 }