Exemple #1
0
        public NewsApprovedComment GetNewsApprovedCommentById(int commentID)
        {
            NewsApprovedComment newsApprovedComment = null;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_NewsApprovedCommentGetById", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@ApprovedCommentNewsID", commentID);
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (reader.Read())
                    {
                        newsApprovedComment = NewsApprovedCommentReader(reader);
                    }
                    else
                    {
                        throw new DataAccessException("khong ton tai newsApprovedComment");
                    }
                }
                command.Dispose();
            }
            return(newsApprovedComment);
        }
Exemple #2
0
        public void UpdateNewsApprovedComment(NewsApprovedComment newsApprovedComment)
        {
            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_NewsApprovedCommentUpdate", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 1);
                command.Parameters.AddWithValue("@ApprovedCommentNewsID", newsApprovedComment.ApprovedCommentNewsID);
                command.Parameters.AddWithValue("@NewsID", newsApprovedComment.NewsID);
                command.Parameters.AddWithValue("@Content", newsApprovedComment.Content);
                command.Parameters.AddWithValue("@DateCreated", newsApprovedComment.DateCreated);
                command.Parameters.AddWithValue("@Actived", newsApprovedComment.Actived);
                command.Parameters.AddWithValue("@UserName", newsApprovedComment.UserName);

                connection.Open();
                if (command.ExecuteNonQuery() <= 0)
                {
                    throw new DataAccessException("Lỗi không thể tao moi");
                }
                else
                {
                    command.Dispose();
                }
            }
        }
Exemple #3
0
        public int CreateNewsApprovedCommentGet(NewsApprovedComment newsApprovedComment)
        {
            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_NewsApprovedCommentInsert", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Type", 0);
                command.Parameters.AddWithValue("@ApprovedCommentNewsID", 0);
                command.Parameters.AddWithValue("@NewsID", newsApprovedComment.NewsID);
                command.Parameters.AddWithValue("@Content", newsApprovedComment.Content);
                command.Parameters.AddWithValue("@DateCreated", newsApprovedComment.DateCreated);
                command.Parameters.AddWithValue("@Actived", newsApprovedComment.Actived);
                command.Parameters.AddWithValue("@UserName", newsApprovedComment.UserName);

                SqlParameter sp = new SqlParameter("@pReturnValue", SqlDbType.Int);
                sp.Direction = ParameterDirection.Output;
                command.Parameters.Add(sp);

                connection.Open();
                command.ExecuteNonQuery();

                int id = Convert.ToInt32(sp.Value.ToString());

                return(id);
            }
        }
    protected NewsApprovedComment ReceiveHtml()
    {
        NewsApprovedComment newsApprovedComment = new NewsApprovedComment();

        newsApprovedComment.ApprovedCommentNewsID = 0;
        newsApprovedComment.NewsID      = Convert.ToInt32(txtNewsGroupID.Value);
        newsApprovedComment.Content     = txtContent.Text;
        newsApprovedComment.DateCreated = DateTime.Now;
        newsApprovedComment.Actived     = true;
        newsApprovedComment.UserName    = Session["Admin_UserName"].ToString();

        return(newsApprovedComment);
    }
Exemple #5
0
        private NewsApprovedComment NewsApprovedCommentReader(SqlDataReader reader)
        {
            NewsApprovedComment newsApprovedComment = new NewsApprovedComment();

            newsApprovedComment.ApprovedCommentNewsID = (int)reader["ApprovedCommentNewsID"];
            newsApprovedComment.NewsID      = (int)reader["NewsID"];
            newsApprovedComment.Content     = (string)reader["Content"];
            newsApprovedComment.DateCreated = (DateTime)reader["DateCreated"];
            newsApprovedComment.Actived     = (bool)reader["Actived"];
            newsApprovedComment.UserName    = (string)reader["UserName"];

            return(newsApprovedComment);
        }
    protected void Send_Click(object sender, EventArgs e)
    {
        NewsApprovedComment newsApprovedComment = ReceiveHtml();

        if (txtCapcha.Text.ToLower() == Session["Random"].ToString().ToLower())
        {
            NewsApprovedCommentBSO newsApprovedCommentBSO = new NewsApprovedCommentBSO();
            newsApprovedCommentBSO.CreateNewsApprovedComment(newsApprovedComment);

            GetNewsCommentById(Convert.ToInt32(txtNewsGroupID.Value));

            //ConfigBSO configBSO = new ConfigBSO();
            //Config config = configBSO.GetAllConfig(Language.language);

            //string strBody = Resources.resource.T_ApprovedComment_email_title + config.WebName + " (" + config.WebDomain + ") : <br>";
            //strBody += "<b>" + Resources.resource.T_ApprovedComment_Title + ": </b> " + newsApprovedComment.Title + "<br>";
            //strBody += "<b>" + Resources.resource.T_ApprovedComment_Name + " : </b> " + newsApprovedComment.FullName + "<br>";

            //strBody += "<b>" + Resources.resource.T_ApprovedComment_Email + " : </b> " + newsApprovedComment.Email + "<br>";
            //strBody += "<b>" + Resources.resource.T_ApprovedComment_ID + " : </b> " + newsApprovedComment.NewsID + "<br>";
            //strBody += "<b>" + Resources.resource.T_ApprovedComment_Content + " : </b> <br>" + newsApprovedComment.Content + "<br>";

            //NewsGroupBSO newsBSO = new NewsGroupBSO();
            //NewsGroup news = newsBSO.GetNewsGroupById(newsApprovedComment.NewsID);

            //strBody += "<b>Title : </b>  <a href='" + config.WebDomain + "/d4/news/" + GetString(news.Title) + "-" + hddGroupCate.Value + "-" + newsApprovedComment.NewsID + ".aspx'>" + news.Title + "</a><br>";

            //MailBSO mailBSO = new MailBSO();
            //mailBSO.EmailFrom = newsApprovedComment.Email;


            //mailBSO.EmailFrom = config.Email_from;

            //string strObj = Resources.resource.T_ApprovedComment_email_title + config.WebName + " (" + config.WebDomain + ") - Date: " + DateTime.Now.ToString("dd:MM:yyyy");
            //mailBSO.SendMail(config.Email_to, strObj, strBody);



            //int Id = Convert.ToInt32(txtNewsGroupID.Value);
            //Response.Redirect("~/d5/news/" + GetString(news.Title) + "-" + hddGroupCate.Value + "-" + Id + "-2.aspx");
        }
    }
Exemple #7
0
        public void UpdateNewsApprovedComment(NewsApprovedComment newsApprovedComment)
        {
            NewsApprovedCommentDAO newsApprovedCommentDAO = new NewsApprovedCommentDAO();

            newsApprovedCommentDAO.UpdateNewsApprovedComment(newsApprovedComment);
        }
Exemple #8
0
        public int CreateNewsApprovedCommentGet(NewsApprovedComment newsApprovedComment)
        {
            NewsApprovedCommentDAO newsApprovedCommentDAO = new NewsApprovedCommentDAO();

            return(newsApprovedCommentDAO.CreateNewsApprovedCommentGet(newsApprovedComment));
        }