Ejemplo n.º 1
0
 /// <summary>
 /// Load news
 /// </summary>
 private void LoadData()
 {
     News news = new News();
     news = NewsBLL.GetNewsByID(Request.QueryString["ID"].ToString())[0];
     txtTitle.Text = news.Title;
     txtSubject.Text = news.Subject;
     ftbBody.Text = news.Content;
     cbActive.Checked =Convert.ToBoolean(news.Active);
     lblReport.Text = "";
 }
Ejemplo n.º 2
0
        private void LoadData()
        {
            News news =new News();
            news = NewsBLL.GetNewsByID(Request.QueryString["ID"].ToString())[0];

            lblTitle.Text = news.Title;
            ltrSubject.Text = news.Subject;
            ltrContent.Text = news.Content;
            lblCreateDate.Text = "Page last updated at: " + Convert.ToDateTime(news.CreateDate).ToLongDateString();
        }
Ejemplo n.º 3
0
 public News NewsIDatareader(IDataReader dr)
 {
     News obj = new News();
     obj.ID = (dr["ID"] is DBNull) ? string.Empty : dr["ID"].ToString();
     obj.Title = (dr["Title"] is DBNull) ? string.Empty : dr["Title"].ToString();
     obj.Subject = (dr["Subject"] is DBNull) ? string.Empty : dr["Subject"].ToString();
     obj.Content = (dr["Content"] is DBNull) ? string.Empty : dr["Content"].ToString();
     obj.CreateDate = (dr["CreateDate"] is DBNull) ? string.Empty : dr["CreateDate"].ToString();
     obj.Active = (dr["Active"] is DBNull) ? string.Empty : dr["Active"].ToString();
     return obj;
 }
Ejemplo n.º 4
0
        public bool InsertNews(News news)
        {
            using (SqlCommand cmd = GetCommand("insertNews", CommandType.StoredProcedure))
            {
                AddParameter(cmd, "@Title", news.Title);
                AddParameter(cmd, "@Subject", news.Subject);
                AddParameter(cmd, "@Content", news.Content);

                int result = ExeNonQuery(cmd);
                return result > 0;
            }
        }
Ejemplo n.º 5
0
 public List<News> GetAllNews()
 {
     List<News> list = new List<News>();
     using (SqlCommand cmd = GetCommand("getAllNews", CommandType.StoredProcedure))
     {
         News news = new News();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(news.NewsIDatareader(dr));
                 }
             }
         }
         news = null;
     }
     return list;
 }
Ejemplo n.º 6
0
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         News news = new News();
         news.Title = txtTitle.Text;
         news.Subject = txtSubject.Text;
         news.Content = ftbBody.Text;
         bool result = NewsBLL.InsertNews(news);
         if (result)
         {
             lblReport.Text = "Create new News Successful!";
             Response.AddHeader("REFRESH", "2;URL=NewsManagement.aspx");
         }
         else
         {
             lblReport.Text = "Insert Eror!";
         }
     }
 }
Ejemplo n.º 7
0
 public List<News> GetNewsByID(string id)
 {
     List<News> list = new List<News>();
     using (SqlCommand cmd = GetCommand("getNewsByID", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@ID", Convert.ToInt32(id));
         News news = new News();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(news.NewsIDatareader(dr));
                 }
             }
         }
         news = null;
     }
     return list;
 }
Ejemplo n.º 8
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         News news = new News();
     news = NewsBLL.GetNewsByID(Request.QueryString["ID"].ToString())[0];
     news.Title = txtTitle.Text;
     news.Subject = txtSubject.Text;
     news.Content = ftbBody.Text;
     news.Active = (cbActive.Checked) ? "1" : "0";
     bool result = NewsBLL.UpdateNews(news);
     if (result)
     {
         lblReport.Text = "Update News Successful!";
         Response.AddHeader("REFRESH", "2;URL=NewsManagement.aspx");
     }
     else
     {
         lblReport.Text = "Update Eror!";
     }
     }
 }
Ejemplo n.º 9
0
 public List<News> SearchNewsByTitle(string title)
 {
     List<News> list = new List<News>();
     using (SqlCommand cmd = GetCommand("SearchNewsByTitle", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@Title", title);
         News news = new News();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(news.NewsIDatareader(dr));
                 }
             }
         }
         news = null;
     }
     return list;
 }
Ejemplo n.º 10
0
 public static bool UpdateNews(News news)
 {
     return db.UpdateNews(news);
 }
Ejemplo n.º 11
0
 public static bool InsertNews(News news)
 {
     return db.InsertNews(news);
 }