Exemplo n.º 1
0
    protected void btnInterestNew_Click(object sender, EventArgs e)
    {
        if (txtInterstTitle != null && txtUrl != null && myEditor.InnerHtml != null)
        {
            using (var db = new HuXiuEntities())
            {
                Interest interest = new Interest();

                interest.interest_time = DateTime.Now;

                interest.interest_title = txtInterstTitle.Text;

                interest.interest_content = Server.HtmlDecode(myEditor.InnerHtml);

                interest.interest_url = txtUrl.Text;

                db.Interest.Add(interest);

                db.SaveChanges();
            }
            Response.Write("<script>alert('添加成功!');location=Interest_new.aspx</script>");
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 2
0
    protected void btnNewTopicSet_Click(object sender, EventArgs e)
    {
        if (txtJump2.Text != "" && imgbtnTopic.ImageUrl != "" && myEditor.InnerHtml != "")
        {
            using (var db = new HuXiuEntities())
            {
                Topic newTopic = new Topic();

                newTopic.topic_name = txtNewTopicName.Text;

                newTopic.topic_cover = imgbtnTopic.ImageUrl;

                newTopic.topic_content = Server.HtmlDecode(myEditor.InnerHtml);

                db.Topic.Add(newTopic);

                db.SaveChanges();
            }
            Response.Write("<script>alert('添加成功!');location='Activity_system.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 3
0
    protected void btnRumor_Click(object sender, EventArgs e)
    {
        if (txtRumorTitle.Text != "" && txtRumorTime.Text != "" && txtRumorHot.Text != "" && txtRumorState.Text != "" && myEditor.InnerHtml != "" && txtRumorLike.Text != "")
        {
            using (var db = new HuXiuEntities())
            {
                Rumor rumor = new Rumor();

                rumor.rumor_title = txtRumorTitle.Text;

                rumor.rumor_content = Server.HtmlDecode(myEditor.InnerHtml);

                rumor.rumor_hot = Convert.ToInt32(txtRumorHot.Text);

                rumor.rumor_like = Convert.ToInt32(txtRumorLike.Text);

                rumor.rumor_state = Convert.ToInt32(txtRumorState.Text);

                rumor.rumor_time = Convert.ToDateTime(txtRumorTime.Text);

                db.Rumor.Add(rumor);

                db.SaveChanges();
            }
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 4
0
    protected void btnInterest_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"].ToString());

        if (txtInterestTitle.Text != "" && txtLike.Text != "" && txtTime.Text != "" && txtUrl.Text != "" && myEditor.InnerHtml != "")
        {
            using (var db = new HuXiuEntities())
            {
                Interest interest = db.Interest.SingleOrDefault(a => a.interest_id == id);

                interest.interest_title = txtInterestTitle.Text;

                interest.interest_like = Convert.ToInt32(txtLike.Text);

                interest.interest_time = Convert.ToDateTime(txtTime.Text);

                interest.interest_url = txtUrl.Text;

                interest.interest_content = Server.HtmlDecode(myEditor.InnerHtml);

                db.SaveChanges();
            }
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 5
0
    protected void btnRumor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"].ToString());

        if (txtRumorTitle.Text != "" && txtRumorTime.Text != "" && txtRumorHot.Text != "" && txtRumorState.Text != "" && myEditor.InnerHtml != "" && txtRumorLike.Text != "")
        {
            using (var db = new HuXiuEntities())
            {
                Rumor rumor = db.Rumor.SingleOrDefault(a => a.rumor_id == id);

                rumor.rumor_title = txtRumorTitle.Text;

                rumor.rumor_content = Server.HtmlDecode(myEditor.InnerHtml);

                rumor.rumor_hot = Convert.ToInt32(txtRumorHot.Text);

                rumor.rumor_like = Convert.ToInt32(txtRumorLike.Text);

                rumor.rumor_state = Convert.ToInt32(txtRumorState.Text);

                rumor.rumor_time = Convert.ToDateTime(txtRumorTime.Text);

                db.SaveChanges();
            }
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 6
0
    //添加新专题
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        try
        {
            if (fup.PostedFile.FileName == "")
            {
                lblInfo.Text = "请选择文件!";
            }
            else
            {
                if (!IsAllowedExtension(fup) == false)
                {
                    lblInfo.Text = "上传文件格式不正确!";
                }
                if (IsAllowedExtension(fup) == true)
                {
                    string filepath   = fup.PostedFile.FileName;
                    string filename   = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string serverpath = Server.MapPath("picture/") + filename;
                    fup.PostedFile.SaveAs(serverpath);
                    serverpath = "picture/" + filename;

                    if (txtName.Text == "" || Server.HtmlDecode(myEditor.InnerHtml) == "")
                    {
                        Response.Write("<script>alert('输入不能为空!')</script>");
                    }
                    else
                    {
                        using (var db = new HuXiuEntities())
                        {
                            var column = new Column();
                            column.column_title   = txtName.Text;
                            column.column_content = Server.HtmlDecode(myEditor.InnerHtml);
                            column.column_cover   = serverpath;
                            column.column_time    = DateTime.Now;
                            db.Column.Add(column);
                            db.SaveChanges();
                        }

                        lblInfo.Text = "上传成功!";
                        Response.Write("<script>alert('添加成功!');location='Column_Add.aspx'</script>");
                    }
                }
                else
                {
                    lblInfo.Text = "请上传图片!";
                }
            }
        }
        catch (Exception ex)
        {
            lblInfo.Text = DateTime.Now.ToString() + "上传发生错误!原因是:" + ex.ToString();
        }
    }
Exemplo n.º 7
0
    //修改是否为首页
    protected void btnChangeTop_Click(object sender, EventArgs e)
    {
        int newsid = Convert.ToInt32(Request.QueryString["news_id"]);

        using (var db = new HuXiuEntities())
        {
            News news = db.News.SingleOrDefault(a => a.news_id == newsid);
            news.news_top = Convert.ToInt32(radlTop.SelectedValue);
            db.SaveChanges();
            Response.Write("<script>alert('修改成功!');location='News_Delete.aspx'</script>");
        }
    }
Exemplo n.º 8
0
    //修改分类资讯
    protected void btnChangeClass_Click(object sender, EventArgs e)
    {
        int newsid = Convert.ToInt32(Request.QueryString["news_id"]);

        using (var db = new HuXiuEntities())
        {
            News       news      = db.News.SingleOrDefault(a => a.news_id == newsid);
            News_class newsclass = db.News_class.SingleOrDefault(a => a.news_classname == dropClass.SelectedItem.ToString());
            news.news_id = newsclass.news_classid;
            db.SaveChanges();
            Response.Write("<script>alert('修改成功!');location='News_Delete.aspx'</script>");
        }
    }
Exemplo n.º 9
0
 //删除专题
 protected void rptColumn_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         int id = Convert.ToInt32(e.CommandArgument.ToString());
         using (var db = new HuXiuEntities())
         {
             Column column = db.Column.SingleOrDefault(a => a.column_id == id);
             db.Column.Remove(column);
             db.SaveChanges();
             Response.Write("<script>alert('删除成功!');location='Column_Delete.aspx'</script>");
         }
     }
 }
Exemplo n.º 10
0
 protected void rptNews_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     //将资讯添加到专题
     if (e.CommandName == "Add")
     {
         int id = Convert.ToInt32(e.CommandArgument.ToString());
         using (var db = new HuXiuEntities())
         {
             var news = db.News.SingleOrDefault(a => a.news_id == id);
             news.new_column = Convert.ToInt32(Request.QueryString["column_id"].ToString());
             db.SaveChanges();
             Response.Write("<script>alert('添加成功!');location='Column_Delete.aspx'</script>");
         }
     }
 }
Exemplo n.º 11
0
 protected void rptHave_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     //将已有资讯从专题中移出
     if (e.CommandName == "Delete")
     {
         int id = Convert.ToInt32(e.CommandArgument.ToString());
         using (var db = new HuXiuEntities())
         {
             News news = db.News.SingleOrDefault(a => a.news_id == id);
             news.new_column = 1;
             db.SaveChanges();
             Response.Write("<script>alert('修改成功!');location='Column_Delete.aspx'</script>");
             rptHave.DataBind();
         }
     }
 }
Exemplo n.º 12
0
    protected void rptActivity_topic_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument.ToString());

        if (e.CommandName == "Delete")
        {
            using (var db = new HuXiuEntities())
            {
                Activity activity = db.Activity.SingleOrDefault(a => a.activity_id == id);

                db.Activity.Remove(activity);

                db.SaveChanges();
            }
        }
    }
Exemplo n.º 13
0
    //删除资讯
    protected void rptNews_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            int newsid = Convert.ToInt32(e.CommandArgument.ToString());

            using (var db = new HuXiuEntities())
            {
                News del = db.News.SingleOrDefault(a => a.news_id == newsid);
                db.News.Remove(del);
                db.SaveChanges();
                //rptNews.DataBind();
                Response.Write("<script>alert('删除成功!');location='News_Delete.aspx'</script>");
            }
        }
    }
Exemplo n.º 14
0
    protected void rptActivity_begin_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument.ToString());

        if (e.CommandName == "Delete")
        {
            using (var db = new HuXiuEntities())
            {
                Activity activity = db.Activity.SingleOrDefault(a => a.activity_id == id);

                db.Activity.Remove(activity);

                db.SaveChanges();
            }
            Response.Write("<script>alert('删除成功!');location='Activity_begin.aspx'</script>");
        }
    }
Exemplo n.º 15
0
    //删除资讯
    protected void rptNews_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Set")
        {
            int newsid = Convert.ToInt32(e.CommandArgument.ToString());

            int topid = Convert.ToInt32(Request.QueryString["top_id"]);

            using (var db = new HuXiuEntities())
            {
                Top top = db.Top.SingleOrDefault(a => a.top_id == topid);
                top.top_news = newsid;
                db.SaveChanges();
            }
            Response.Write("<script>alert('设置成功!');location='Top.aspx'</script>");
        }
    }
Exemplo n.º 16
0
    protected void rptRumor_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument.ToString());

        if (e.CommandName == "Delete")
        {
            using (var db = new HuXiuEntities())
            {
                Rumor rumor = db.Rumor.SingleOrDefault(a => a.rumor_id == id);

                db.Rumor.Remove(rumor);

                db.SaveChanges();
            }
            Response.Write("<script>alert('删除成功!');location='Rumor.aspx'</script>");
        }
    }
Exemplo n.º 17
0
 protected void btnSub_Click(object sender, EventArgs e)
 {
     if (txtClass.Text == "")
     {
         Response.Write("<script>alert('输入不能为空!')</script>");
     }
     else
     {
         using (var db = new HuXiuEntities())
         {
             News_class newsclass = new News_class();
             newsclass.news_classname = txtClass.Text;
             db.News_class.Add(newsclass);
             Response.Write("<script>alert('添加成功!');location='Newsclass_Add.aspx'</script>");
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 18
0
 //修改名字
 protected void btnName_Click(object sender, EventArgs e)
 {
     using (var db = new HuXiuEntities())
     {
         if (txtName.Text == "")
         {
             Response.Write("<script>alert('输入不能为空!')</script>");
         }
         else
         {
             int    id     = Convert.ToInt32(Request.QueryString["column_id"].ToString());
             Column column = db.Column.SingleOrDefault(a => a.column_id == id);
             column.column_title = txtName.Text;
             db.SaveChanges();
             Response.Write("<script>alert('修改成功!');location='Column_Delete.aspx'</script>");
         }
     }
 }
Exemplo n.º 19
0
 //修改内容
 protected void btnContent_Click(object sender, EventArgs e)
 {
     if (myEditor.InnerText == "")
     {
         Response.Write("<script>alert('输入不能为空!')</script>");
     }
     else
     {
         using (var db = new HuXiuEntities())
         {
             int    id     = Convert.ToInt32(Request.QueryString["column_id"].ToString());
             Column column = db.Column.SingleOrDefault(a => a.column_id == id);
             column.column_content = Server.HtmlDecode(myEditor.InnerHtml);
             db.SaveChanges();
             Response.Write("<script>alert('修改成功!');location='Column_Delete.aspx'</script>");
         }
     }
 }
Exemplo n.º 20
0
    //修改封面
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        try
        {
            if (fup.PostedFile.FileName == "")
            {
                lblInfo.Text = "请选择文件!";
            }
            else
            {
                if (!IsAllowedExtension(fup) == false)
                {
                    lblInfo.Text = "上传文件格式不正确!";
                }
                if (IsAllowedExtension(fup) == true)
                {
                    string filepath   = fup.PostedFile.FileName;
                    string filename   = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string serverpath = Server.MapPath("picture/") + filename;
                    fup.PostedFile.SaveAs(serverpath);
                    serverpath = "picture/" + filename;

                    using (var db = new HuXiuEntities())
                    {
                        int    id     = Convert.ToInt32(Request.QueryString["column_id"].ToString());
                        Column column = db.Column.SingleOrDefault(a => a.column_id == id);
                        column.column_cover = serverpath;
                        db.SaveChanges();
                    }

                    lblInfo.Text = "上传成功!";
                    Response.Write("<script>alert('修改成功!');location='Column_Delete.aspx'</script>");
                }
                else
                {
                    lblInfo.Text = "请上传图片!";
                }
            }
        }
        catch (Exception ex)
        {
            lblInfo.Text = DateTime.Now.ToString() + "上传发生错误!原因是:" + ex.ToString();
        }
    }
Exemplo n.º 21
0
    //修改资讯内容
    protected void btnChangeContent_Click(object sender, EventArgs e)
    {
        int newsid = Convert.ToInt32(Request.QueryString["news_id"]);

        if (Server.HtmlDecode(myEditor.InnerHtml) == "")
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            using (var db = new HuXiuEntities())
            {
                News news = db.News.SingleOrDefault(a => a.news_id == newsid);
                news.news_content = Server.HtmlDecode(myEditor.InnerHtml);
                db.SaveChanges();
                Response.Write("<script>alert('修改成功!');location='News_Delete.aspx'</script>");
            }
        }
    }
Exemplo n.º 22
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["news_classid"]);

        if (txtName.Text == "")
        {
            Response.Write("<script>alert('输入不能为空!')</script>");
        }
        else
        {
            using (var db = new HuXiuEntities())
            {
                News_class newsclass = db.News_class.SingleOrDefault(a => a.news_classid == id);
                newsclass.news_classname = txtName.Text;
                db.SaveChanges();
                Response.Write("<script>alert('修改成功!');location='Newsclass_Delete.aspx'</script>");
            }
        }
    }
Exemplo n.º 23
0
    protected void btnnewpwd_Click(object sender, EventArgs e)
    {
        if (RequiredFieldValidator1.IsValid == true && RequiredFieldValidator2.IsValid == true && CompareValidator1.IsValid == true)
        {
            string username = Session["name2"].ToString();

            string EnPswdStr = myfind.md5(txtPwd.Text, 16);

            string password = EnPswdStr;

            using (var db = new HuXiuEntities())
            {
                Admin admin = db.Admin.SingleOrDefault(a => a.username == username);

                admin.password = password;

                db.SaveChanges();

                Response.Write("<script>alert('修改成功!');location='../Login/Login.aspx'</script>");
            }
        }
    }
Exemplo n.º 24
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (FileUpload1.PostedFile.FileName == "")
            {
                Label1.Text = "请选择文件!";
            }
            else
            {
                if (IsAllowedExtension(FileUpload1) == true)
                {
                    string filepath   = FileUpload1.PostedFile.FileName;
                    string filename   = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string serverpath = Server.MapPath("picture/") + filename;
                    FileUpload1.PostedFile.SaveAs(serverpath);
                    serverpath = "picture/" + filename;

                    using (var db = new HuXiuEntities())
                    {
                        int topid = Convert.ToInt32(Request.QueryString["top_id"]);
                        Top top   = db.Top.SingleOrDefault(a => a.top_id == topid);
                        top.top_cover = serverpath;
                        db.SaveChanges();
                    }
                    Response.Write("<script>alert('上传成功!');location='Top.aspx'</script>");
                }
                else
                {
                    Label1.Text = "请上传图片!";
                }
            }
        }
        catch (Exception ex)
        {
            Label1.Text = DateTime.Now.ToString() + "上传发生错误!原因是:" + ex.ToString();
        }
    }
Exemplo n.º 25
0
    protected void rptInteresting_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            int id = Convert.ToInt32(e.CommandArgument.ToString());

            using (var db = new HuXiuEntities())
            {
                Interest interest = db.Interest.SingleOrDefault(a => a.interest_id == id);

                db.Interest.Remove(interest);

                db.SaveChanges();
            }
            Response.Write("<script>alert('删除成功!');location='Interesting.aspx'</script>");
        }
        if (e.CommandName == "URL")
        {
            string url = e.CommandArgument.ToString();
            //有待改正
            Response.Redirect(url);
        }
    }
Exemplo n.º 26
0
    protected void btnupload_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"].ToString());

        Boolean fileOk = false;
        //指定文件路径,pic是项目下的一个文件夹;~表示当前网页所在的文件夹
        String path = Server.MapPath("../Images/");             //物理文件路径

        int length = this.FileUpload1.PostedFile.ContentLength; //获取图片大小,以字节为单位


        //文件上传控件中如果已经包含文件
        if (FileUpload1.HasFile)
        {
            //得到文件的后缀
            String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();

            //允许文件的后缀
            String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg", ".bmp" };

            //看包含的文件是否是被允许的文件的后缀
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOk = true;
                }
            }
        }
        if (fileOk)
        {
            try
            {
                //文件另存在服务器的指定目录下
                string name = FileUpload1.FileName;//获取上传的文件名

                path = "../Images/" + name;

                ibtnChangeiamge.ImageUrl = path;

                FileUpload1.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));

                using (var db = new HuXiuEntities())
                {
                    Activity activity = db.Activity.SingleOrDefault(a => a.activity_id == id);

                    activity.activity_cover = path;

                    db.SaveChanges();
                }

                panel.Visible = false;

                Response.Write("<script>alert('文件上传成功!');</script>");
            }
            catch
            {
                Response.Write("<script>alert('文件上传失败!');</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('只能上传png,jpg,bmp图象文件!');</script>");
        }
    }
Exemplo n.º 27
0
    protected void BtnRegister_Click(object sender, EventArgs e)
    {
        Class1 register = new Class1();

        string question1 = DropDownList.SelectedValue;

        string answer1 = txtanswer.Text;

        string question2 = DropDownList1.Text;

        string answer2 = txtanswer1.Text;

        string question3 = DropDownList2.Text;

        string answer3 = txtanswer2.Text;

        if (((((((CompareValidator1.IsValid == true && RequiredFieldValidator2.IsValid == true) && RequiredFieldValidator3.IsValid == true) && RequiredFieldValidator4.IsValid == true) && RequiredFieldValidator5.IsValid == true) && RequiredFieldValidator6.IsValid == true) && RequiredFieldValidator7.IsValid == true) && RequiredFieldValidator9.IsValid == true)
        {
            if (txtPwd.Text.IndexOf(" ") >= 0)
            {
                Response.Write("<script>alert('密码请不要输入空格!')</script>");
            }
            else
            {
                if (question1 == question2 || question2 == question3 || question3 == question1)
                {
                    Response.Write("<script>alert('问题不能选择一样!')</script>");
                }
                else
                {
                    using (var db = new HuXiuEntities())
                    {
                        Admin admin = new Admin();

                        Admin ad = db.Admin.SingleOrDefault(a => a.username == txtusername.Text);

                        if (ad == null)
                        {
                            admin.username = txtusername.Text;

                            admin.nickname = txtnickname.Text;

                            admin.password = register.md5(txtPwd.Text, 16);

                            admin.email = txtmailbox.Text;

                            admin.photo = "../ Images / t011f6933a23bb6faeb.png";

                            db.Admin.Add(admin);

                            db.SaveChanges();

                            Admin ad1 = db.Admin.SingleOrDefault(a => a.username == txtusername.Text);

                            int id = ad1.id;

                            Question thisquestion1 = new Question();
                            Question thisquestion2 = new Question();
                            Question thisquestion3 = new Question();

                            thisquestion1.user_id     = id;
                            thisquestion1.question_id = 1;
                            thisquestion2.user_id     = id;
                            thisquestion2.question_id = 2;
                            thisquestion3.user_id     = id;
                            thisquestion3.question_id = 3;

                            thisquestion1.question1 = question1;
                            thisquestion2.question1 = question2;
                            thisquestion3.question1 = question3;

                            thisquestion1.answer = answer1;
                            db.Question.Add(thisquestion1);
                            thisquestion2.answer = answer2;
                            db.Question.Add(thisquestion2);
                            thisquestion3.answer = answer3;
                            db.Question.Add(thisquestion3);

                            db.SaveChanges();
                            Response.Write("<script>alert('注册成功!')</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('用户名已经存在!')</script>");
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 28
0
    //添加资讯
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int newsclassid;

        try
        {
            if (fup.PostedFile.FileName == "")
            {
                lblInfo.Text = "请选择文件!";
            }
            else
            {
                if (!IsAllowedExtension(fup) == false)
                {
                    lblInfo.Text = "上传文件格式不正确!";
                }
                if (IsAllowedExtension(fup) == true)
                {
                    string filepath   = fup.PostedFile.FileName;
                    string filename   = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string serverpath = Server.MapPath("picture/") + filename;
                    fup.PostedFile.SaveAs(serverpath);
                    serverpath = "picture/" + filename;

                    using (var db = new HuXiuEntities())
                    {
                        var news = new News();
                        if (txtTitle.Text == "")
                        {
                            Response.Write("<script>alert('输入不能为空!')</script>");
                        }
                        else if (Server.HtmlDecode(myEditor.InnerHtml) == "")
                        {
                            Response.Write("<script>alert('输入不能为空!')</script>");
                        }
                        else if (txtAuthor.Text == "")
                        {
                            Response.Write("<script>alert('输入不能为空!')</script>");
                        }
                        else
                        {
                            news.news_title   = txtTitle.Text;
                            news.news_content = Server.HtmlDecode(myEditor.InnerHtml);
                            news.news_time    = DateTime.Now;
                            int cout;
                            using (var dd = new HuXiuEntities())
                            {
                                var topcount = from it in db.News where it.news_top == 1 select it;
                                cout = topcount.ToList().Count;
                            }
                            if (Convert.ToInt16(radlTop.SelectedValue) == 1 && cout > 2)
                            {
                                Response.Write("<script>alert('已有三条头条,不能再设置头条了!');location='News_Add.aspx'</script>");
                            }

                            else
                            {
                                news.news_top = Convert.ToInt16(radlTop.SelectedValue);

                                news.news_cover = serverpath;
                                using (var db_0 = new HuXiuEntities())
                                {
                                    string     dropclass  = dropClass.SelectedValue.ToString();
                                    News_class news_class = db_0.News_class.SingleOrDefault(a => a.news_classname == dropclass);
                                    newsclassid = news_class.news_classid;
                                }
                                news.news_class = newsclassid;
                                news.new_column = 1;
                                news.new_author = txtAuthor.Text;
                                db.News.Add(news);
                                db.SaveChanges();
                            }
                            lblInfo.Text = "上传成功!";
                            Response.Write("<script>alert('添加成功!');location='News_Add.aspx'</script>");
                        }
                    }
                }
                else
                {
                    lblInfo.Text = "请上传图片!";
                }
            }
        }
        catch (Exception ex)
        {
            lblInfo.Text = DateTime.Now.ToString() + "上传发生错误!原因是:" + ex.ToString();
        }
    }
Exemplo n.º 29
0
    protected void btnNewActivity_Click(object sender, EventArgs e)
    {
        string topic_id = null;

        using (var db1 = new HuXiuEntities())
        {
            if (txtTopicName.Text != null)
            {
                Topic topicname = db1.Topic.SingleOrDefault(a => a.topic_name == txtTopicName.Text);

                if (topicname == null)
                {
                    Response.Write("<script>alert('该系列不存在,请确认无误再填写')</script>");
                }
                else
                {
                    topic_id = topicname.topic_id.ToString();
                }
            }
        }
        if (txtTitle.Text != "" && txtCoverLabel.Text != "" && myEditor.InnerHtml != "" && ibtnChangeiamge.ImageUrl != "" && txtActivityBeginTime.Text != "" && txtActivityEndTime.Text != "")
        {
            int class1;
            if (activityKind.SelectedValue == "虎嗅活动")
            {
                class1 = 1;
            }
            else if (activityKind.SelectedValue == "活动频道")
            {
                class1 = 2;
            }
            else
            {
                class1 = 3;
            }
            using (var db = new HuXiuEntities())
            {
                Activity newActivity = new Activity();

                newActivity.activity_name = txtTitle.Text;

                newActivity.activity_topicid = Convert.ToInt32(topic_id);

                newActivity.activity_topicname = txtTopicName.Text;

                newActivity.activity_coverlable = txtCoverLabel.Text;

                newActivity.activity_content = Server.HtmlDecode(myEditor.InnerHtml);

                newActivity.activity_cover = ibtnChangeiamge.ImageUrl;

                newActivity.activity_class = class1;

                newActivity.activity_start = Convert.ToDateTime(txtActivityBeginTime.Text);

                newActivity.activity_end = Convert.ToDateTime(txtActivityEndTime.Text);

                db.Activity.Add(newActivity);

                db.SaveChanges();

                Response.Write("<script>alert('添加成功!');location='Activity_new.aspx'</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('请填写完全!')</script>");
        }
    }
Exemplo n.º 30
0
    protected void btnActivity_Click(object sender, EventArgs e)
    {
        string topic_id = null;

        int id = Convert.ToInt32(Request.QueryString["id"].ToString());

        using (var db1 = new HuXiuEntities())
        {
            if (txtTopicName.Text != null)
            {
                Topic topicname = db1.Topic.SingleOrDefault(a => a.topic_name == txtTopicName.Text);

                if (topicname == null)
                {
                    Response.Write("<script>alert('该系列不存在,请确认无误再填写')</script>");
                }
                else
                {
                    topic_id = topicname.topic_id.ToString();
                }
            }
            if (txtTitle.Text != "" && myEditor.InnerHtml != "" && txtTopicName.Text != "" && txtCoverLabel.Text != "" && txtActivityBeginTime.Text != "" && txtActivityEndTime.Text != "")
            {
                int class1;
                if (activityKind.SelectedValue == "虎嗅活动")
                {
                    class1 = 1;
                }
                else if (activityKind.SelectedValue == "活动频道")
                {
                    class1 = 2;
                }
                else
                {
                    class1 = 3;
                }
                using (var db = new HuXiuEntities())
                {
                    Activity new_activity = db.Activity.SingleOrDefault(a => a.activity_id == id);

                    new_activity.activity_name = txtTitle.Text;

                    new_activity.activity_content = Server.HtmlDecode(myEditor.InnerHtml);

                    new_activity.activity_topicid = Convert.ToInt32(topic_id);

                    new_activity.activity_topicname = txtTopicName.Text;

                    new_activity.activity_class = class1;

                    new_activity.activity_start = Convert.ToDateTime(txtActivityBeginTime.Text);

                    new_activity.activity_end = Convert.ToDateTime(txtActivityEndTime.Text);

                    new_activity.activity_coverlable = txtCoverLabel.Text;

                    db.SaveChanges();

                    Response.Write("<script>alert('修改成功!')</script>");
                }
            }
        }
    }