Example #1
0
 public void CreateNews(News news)
 {
     using (SqlConnection connection = base.GetConnection())
     {
         SqlCommand command = new SqlCommand("_NewsUpdate", connection) {
             CommandType = CommandType.StoredProcedure
         };
         command.Parameters.AddWithValue("@Type", 0);
         command.Parameters.AddWithValue("@NewsID", 0);
         command.Parameters.AddWithValue("@CateNewsID", news.CateNewsID);
         command.Parameters.AddWithValue("@ParentNewsID", news.ParentNewsID);
         command.Parameters.AddWithValue("@Title", news.Title);
         command.Parameters.AddWithValue("@ShortDescribe", news.ShortDescribe);
         command.Parameters.AddWithValue("@FullDescribe", news.FullDescribe);
         command.Parameters.AddWithValue("@ImageThumb", news.ImageThumb);
         command.Parameters.AddWithValue("@ImageLarge", news.ImageLarge);
         command.Parameters.AddWithValue("@Author", news.Author);
         command.Parameters.AddWithValue("@PostDate", news.PostDate);
         command.Parameters.AddWithValue("@RelationTotal", news.RelationTotal);
         command.Parameters.AddWithValue("@Status", news.Status);
         command.Parameters.AddWithValue("@Language", news.Language);
         command.Parameters.AddWithValue("@Ishot", news.Ishot);
         command.Parameters.AddWithValue("@Isview", news.Isview);
         command.Parameters.AddWithValue("@Ishome", news.Ishome);
         command.Parameters.AddWithValue("@IsComment", news.IsComment);
         command.Parameters.AddWithValue("@ApprovalDate", news.ApprovalDate);
         command.Parameters.AddWithValue("@ApprovalUserName", news.ApprovalUserName);
         command.Parameters.AddWithValue("@IsApproval", news.IsApproval);
         command.Parameters.AddWithValue("@CreatedUserName", news.CreatedUserName);
         command.Parameters.AddWithValue("@CommentTotal", news.CommentTotal);
         command.Parameters.AddWithValue("@GroupCate", news.GroupCate);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("Kh\x00f4ng thể th\x00eam mới tin");
         }
         command.Dispose();
     }
 }
Example #2
0
 public void CreateNews(News news)
 {
     new NewsDAO().CreateNews(news);
 }
Example #3
0
 public void UpdateNews(News news)
 {
     new NewsDAO().UpdateNews(news);
 }
Example #4
0
        private void initControl(int Id)
        {
            AdminBSO adminBSO = new AdminBSO();
            ETO.Admin admin = new ETO.Admin();
            if (Id > 0)
            {
                btn_add.Visible = false;
                btn_edit.Visible = true;
                try
                {
                    News news = new News();
                    NewsBSO newsBSO = new NewsBSO();
                    news = newsBSO.GetNewsById(Id);
                    hddNewsID.Value = Convert.ToString(news.NewsID);
                    ddlCateNews.SelectedValue = Convert.ToString(news.CateNewsID);
                    hddParentNewsID.Value = Convert.ToString(news.ParentNewsID);
                    txtTitle.Text = news.Title;
                    txtRadShort.Html = news.ShortDescribe;
                    txtRadFull.Html = news.FullDescribe;
                    hddImageThumb.Value = news.ImageThumb;
                    hddImageLarge.Value = news.ImageLarge;
                    txtAuthor.Text = news.Author;
                    txtRadDate.SelectedDate = news.PostDate;
                    hddRelationTotal.Value = Convert.ToString(news.RelationTotal);
                    rdbStatus.SelectedValue = Convert.ToString(news.Status);
                    rdbIshot.SelectedValue = Convert.ToString(news.Ishot);
                    rdbIshome.SelectedValue = Convert.ToString(news.Ishome);


                    hddCommentTotal.Value = Convert.ToString(news.CommentTotal);
                    hddIsView.Value = Convert.ToString(news.Isview);
                    hddCreateUserName.Value = news.CreatedUserName;
                    hddApprovalUserName.Value = news.ApprovalUserName;
                    hddApprovalDate.Value = Convert.ToString(news.ApprovalDate);


                    rdbComment.SelectedValue = Convert.ToString(news.IsComment);

                    admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

                    if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                    {
                        rdbApproval.SelectedValue = Convert.ToString(news.IsApproval);
                        rdbApproval.Enabled = true;
                    }
                    else
                    {
                        rdbApproval.SelectedValue = Convert.ToString(news.IsApproval);
                        rdbApproval.Enabled = false;
                    }

                }
                catch (Exception ex)
                {
                    clientview.Text = ex.Message.ToString();
                }
            }
            else
            {
                txtRadDate.SelectedDate = DateTime.Now;
                btn_add.Visible = true;
                btn_edit.Visible = false;
                if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                {

                    rdbApproval.Enabled = true;
                }
                else
                {

                    rdbApproval.Enabled = false;
                }

            }
        }
Example #5
0
        private News ReceiveHtml()
        {
            ConfigBSO configBSO = new ConfigBSO();
            Config config = configBSO.GetAllConfig(Language.language);
            int thumb_w = Convert.ToInt32(config.New_thumb_w);
            int thumb_h = Convert.ToInt32(config.New_thumb_h);

            commonBSO commonBSO = new commonBSO();
            string path_thumb = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/News/NewsThumb/";
            string image_thumb = commonBSO.UploadImage(file_image_thumb, path_thumb, thumb_w, thumb_h);

            int large_w = Convert.ToInt32(config.New_large_w);
            int large_h = Convert.ToInt32(config.New_large_h);
            string path_large = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/News/NewsLarge/";
            string image_large = commonBSO.UploadImage(file_image_large, path_large, large_w, large_h);

            News news = new News();
            news.NewsID = (hddNewsID.Value != "") ? Convert.ToInt32(hddNewsID.Value) : 0;
            news.CateNewsID = Convert.ToInt32(ddlCateNews.SelectedValue);
            news.ParentNewsID = (hddParentNewsID.Value != "") ? Convert.ToInt32(hddParentNewsID.Value) : 0;
            news.Title = txtTitle.Text;
            news.ShortDescribe = txtRadShort.Html;
            news.FullDescribe = txtRadFull.Html;
            news.ImageThumb = (image_thumb != "") ? image_thumb : hddImageThumb.Value;
            news.ImageLarge = (image_large != "") ? image_large : hddImageLarge.Value;
            news.Author = txtAuthor.Text;
            news.PostDate = txtRadDate.SelectedDate.Value;
            news.RelationTotal = (hddRelationTotal.Value != "") ? Convert.ToInt32(hddRelationTotal.Value) : 0;
            news.Status = Convert.ToBoolean(rdbStatus.SelectedItem.Value);
            news.Language = Language.language;
            news.Ishot = Convert.ToBoolean(rdbIshot.SelectedValue);
            news.Ishome = Convert.ToBoolean(rdbIshome.SelectedValue);
            news.IsComment = Convert.ToBoolean(rdbComment.SelectedValue);

            news.Isview = (hddIsView.Value != "") ? Convert.ToInt32(hddIsView.Value) : 0;
            news.CommentTotal = (hddCommentTotal.Value != "") ? Convert.ToInt32(hddCommentTotal.Value) : 0;

            news.CreatedUserName = (hddCreateUserName.Value != "") ? hddCreateUserName.Value : Session["Admin_UserName"].ToString();

            news.GroupCate = 1;

            news.IsApproval = Convert.ToBoolean(rdbApproval.SelectedValue);
            if (hddApprovalUserName.Value != "")
            {
                news.ApprovalUserName = hddApprovalUserName.Value;
                news.ApprovalDate = Convert.ToDateTime(hddApprovalDate.Value);
            }
            else
                if (Convert.ToBoolean(rdbApproval.SelectedValue))
                {
                    news.ApprovalUserName = Session["Admin_UserName"].ToString();
                    news.ApprovalDate = DateTime.Now;
                }
                else
                {
                    news.ApprovalUserName = "";
                    news.ApprovalDate = DateTime.Now;
                }


            return news;

        }