コード例 #1
0
ファイル: EditNews.aspx.cs プロジェクト: haimon74/Easy-Fixup
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!HasWriteAccess)
                return;

            News news;
            int language = Convert.ToInt32(ddLanguage.SelectedItem.Value);

            if (EditedNewsID.HasValue)

                news = new News(EditedNewsID.Value, language);
            else
                news = new News();

            news.LanguageId = language;
            //if (htmlEditor != null)
            news.Text = txtEditor.Text;// htmlEditor.Content;
            //if (ckeditor != null)
            //    news.Text = ckeditor.Text;
            news.PublishDate = DateTime.Now;// Calendar.SelectedDate;
            news.Title = txtNewsTitle.Text;
            news.Save();
            txtNewsTitle.Text = String.Empty;
            txtEditor.Text = String.Empty;

            MessageBox.Show(Lang.TransA("News saved successfully!"), Misc.MessageType.Success);
            PopulateDataGrid();
            pnlAddEditNews.Visible = false;
            btnAddNews.Visible = true;
        }
コード例 #2
0
ファイル: News.cs プロジェクト: haimon74/Easy-Fixup
        /// <summary>
        /// Fetches specified number of news with specified id and language. For Example:
        /// when id is -1 and newsCount is Int32.MaxValue it fetches all news.
        /// </summary>
        /// <param name="id">Represents news id.</param>
        /// <param name="newsCount">Represents number of news to fetch.</param>
        /// <param name="languageID">The language ID.</param>
        /// <returns></returns>
        private static News[] FetchNews(int id, int newsCount, int languageID)
        {
            using (SqlConnection conn = Config.DB.Open())
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(conn, "FetchNews", id, newsCount, languageID);

                List<News> lNews = new List<News>();

                while (reader.Read())
                {
                    News news = new News();
                    news.id = (int) reader["NID"];
                    news.Text = (string) reader["Text"];
                    news.PublishDate = (DateTime) reader["Date"];
                    news.Title = (string) reader["Title"];

                    lNews.Add(news);
                }

                return lNews.ToArray();
            }
        }