Exemplo n.º 1
0
    protected void sure_Click(object sender, EventArgs e)
    {
        Travel.Model.Tab_article tab_article = new Travel.Model.Tab_article();
        //if (string.IsNullOrEmpty(tab_article.U_emaile))
        //{
        //    Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('请先登录!')</script>");

        //}
        //else
        //{

        if (FileUpload1.HasFile && Path.GetExtension(FileUpload1.FileName).ToLower() == ".jpg")
        {
            string title     = biaoti.Text.Trim();
            string t_content = Editor1.Text.Trim();                        //获取编辑器里面的值

            tab_article.U_emaile  = Convert.ToString(Session["u_emaile"]); //从session中获取u_emaile
            tab_article.T_title   = title;
            tab_article.T_content = t_content;
            // Random R = new Random();
            tab_article.Art_illustration = "art_img\\" + Guid.NewGuid().ToString("D") + ".jpg";    //获取插图路径
            FileUpload1.SaveAs(Server.MapPath(tab_article.Art_illustration));
            //R.Next(1,1000)
            tab_article.UploadTime      = DateTime.Now;//获取当前时间
            tab_article.Art_ClickNumber = 0;

            if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(t_content))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('请先填写完整数据!')</script>");
            }
            else
            {
                if (Travel.BLL.ArticleBusiness.AddArticle(tab_article))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('编写游记成功!')</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('失败!请重新尝试!')</script>");
                }
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('请选择JPG图片!')</script>");
        }


        //}
    }
Exemplo n.º 2
0
    protected void Unnamed_ServerClick(object sender, EventArgs e)
    {
        Travel.Model.Tab_article tab_article = new Travel.Model.Tab_article();

        Travel.Model.Tab_collect tab_collect = new Travel.Model.Tab_collect();

        tab_collect.U_emaile = Convert.ToString(Session["u_emaile"]);//将session中的emaile交给
        //tab_collect.U_emaile = "*****@*****.**";
        string title = Convert.ToString(((System.Web.UI.HtmlControls.HtmlAnchor)sender).HRef);

        Session["t_title"] = title;
        //直接将文章的标题交给收藏
        tab_collect.U_collect = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).T_title;

        tab_collect.T_content = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).T_content;

        tab_collect.UploadTime = Travel.BLL.ArticleBusiness.GetArticleByTitle(Session["t_title"].ToString()).UploadTime;


        if (string.IsNullOrEmpty(tab_collect.U_emaile))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('请先登录!')</script>");
            //跳转到指定界面
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (string.IsNullOrEmpty(tab_collect.T_content) || string.IsNullOrEmpty(tab_collect.U_collect))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('数据错误!')</script>");
            }
            else
            {
                if (Travel.BLL.CollectBusiness.AddCollect(tab_collect))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('收藏成功!')</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('请重新尝试!')</script>");
                }
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 创建评论
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_sure_Click(object sender, EventArgs e)
    {
        string discuss = neirong.Text.Trim();//获取评论的内容

        Travel.Model.Tab_article tab_article = new Travel.Model.Tab_article();

        Travel.Model.Tab_discuss tab_discuss = new Travel.Model.Tab_discuss();
        tab_discuss.U_discuss  = discuss;
        tab_discuss.U_emaileA  = Travel.BLL.ArticleBusiness.GetArctileById(Convert.ToInt32(Session["u_id"])).U_emaile;
        tab_discuss.U_emaileB  = Convert.ToString(Session["u_emaile"]);
        tab_discuss.UploadTime = DateTime.Now;//获取当前时间
        if (string.IsNullOrEmpty(tab_discuss.U_emaileB))
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('请先登录!')</script>");
            //跳转到指定界面
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (string.IsNullOrEmpty(discuss))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('请先填写完整数据!')</script>");
            }
            else
            {
                if (Travel.BLL.DiscussBusiness.AddDiscuss(tab_discuss))
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('评论成功!')</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "info", "<script>alert('请重新尝试!')</script>");
                }
            }
        }
    }