示例#1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //标题 内容 封面 作者 分类 不能为空
        if (title.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0 && Request.Form["lb"].Trim().Length > 0 && author.SelectedValue.Length > 0 && category.SelectedValue.Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                Passage passage = new Passage
                {
                    PassageTitle    = title.Text,
                    PassageBody     = UeditorHelper.change(editor.InnerHtml),
                    PassageImage    = "/File/" + Request.Form["lb"],
                    PassageCategory = Convert.ToInt32(category.SelectedValue),
                    PublishDate     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    AuthorId        = Convert.ToInt32(author.SelectedValue),
                    PageViews       = 0,
                    IsDel           = false
                };
                db.Passage.Add(passage);

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('添加成功');location='PassageList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空!')</script>");
        }
    }
示例#2
0
    private void DataBindToRepeater(int currentPage, List <Activity> datascore)
    {
        for (int i = 0; i < datascore.Count; i++)
        {
            datascore[i].ActivityWhat = UeditorHelper.NoHTML(datascore[i].ActivityWhat);
        }

        string a = datascore.GetType().ToString();

        PagedDataSource pds = new PagedDataSource();

        pds.AllowPaging = true;

        pds.PageSize = 5;

        pds.DataSource = datascore;

        lbTotal.Text = pds.PageCount.ToString();

        pds.CurrentPageIndex = currentPage - 1;

        Rpt.DataSource = pds;

        Rpt.DataBind();
    }
示例#3
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (title.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0 && link.Text.Trim().Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                News person = new News
                {
                    NewsTitle = title.Text.Trim(),
                    NewsBody  = UeditorHelper.change(editor.InnerHtml),
                    NewsDate  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), //发表时间
                    NewsLink  = link.Text.Trim(),
                    IsDel     = false
                };

                db.News.Add(person);

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('添加成功');location='NewsList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
示例#4
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        //标题 内容  不能为空
        if (title.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                Passage person = (from it in db.Passage where it.PassageId == id select it).FirstOrDefault();
                person.PassageTitle = title.Text;                             //标题
                person.PassageBody  = UeditorHelper.change(editor.InnerHtml); //内容
                if (Request.Form["lb"] != "")
                {
                    person.PassageImage = "~/File/" + Request.Form["lb"];
                }
                person.PassageCategory = Convert.ToInt32(category.SelectedValue);                        //资讯分类
                person.PublishDate     = Convert.ToDateTime(dates.Text).ToString("yyyy-MM-dd HH:mm:ss"); //时间
                person.AuthorId        = Convert.ToInt32(author.SelectedValue);                          //作者

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('编辑成功');location='PassageEditor.aspx?id=" + id + "'</script>");
                }
                else
                {
                    Response.Write("<script>alert('编辑失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int    id      = Convert.ToInt32(Request.QueryString["id"].ToString());
        string title   = txtTitle.Text;
        string summary = txtSummary.Text;
        string body    = UeditorHelper.Change(myEditor11.InnerHtml);

        if (title.Length == 0)
        {
            Response.Write("<script>alert('标题不能为空!');</script>");
        }
        else if (summary.Length == 0)
        {
            Response.Write("<script>alert('内容摘要不能为空!');</script>");
        }
        else if (body.Length == 0)
        {
            Response.Write("<script>alert('文章内容不能为空!');</script>");
        }
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                var src = (from it in db.EducateSource where it.id == id select it).FirstOrDefault();
                src.title        = title;
                src.body         = body;
                src.publish_time = pushlishTime.Value;
                src.summary      = summary;
                db.SaveChanges();
                Response.Write("<script>alert('修改成功!');location.href='EduSrcList.aspx';</script>");
            }
        }
    }
示例#6
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        if (title.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0 && link.Text.Trim().Length > 0)
        {
            using (var db = new huxiuEntities())//修改短趣
            {
                News person = (from it in db.News where it.NewsId == id select it).FirstOrDefault();

                person.NewsTitle = title.Text.Trim();                      //标题
                person.NewsBody  = UeditorHelper.change(editor.InnerHtml); //内容
                                                                           //  person.NewsDate = Convert.ToDateTime(dates.Text);//发布时间不做修改
                person.NewsLink = link.Text.Trim();                        //超链接
                                                                           //  person.IsDel = false;//是否删除

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('编辑成功');location='NewsEditor.aspx?id=" + id + "'</script>");
                }
                else
                {
                    Response.Write("<script>alert('编辑失败请重试')</script>");
                }
            }
        }

        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
 protected void lbtnSubmit_Click(object sender, EventArgs e)
 {
     if (UpLoadFile() == false)
     {
         Response.Write("<script>alert('请上传项目文件!');</script>");
     }
     else
     {
         int project_id = Convert.ToInt32(Request.QueryString["id"]);
         int stage      = Convert.ToInt32(Request.QueryString["stage"]);
         using (var db = new TeachingCenterEntities())
         {
             var          project  = (from it in db.ProjectStage where it.project_id == project_id && it.stage == stage select it).FirstOrDefault();
             ProjectStage newStage = new ProjectStage();
             newStage.project_id      = project_id;
             newStage.project_content = UeditorHelper.Change(myEditor11.InnerHtml);
             newStage.project_file    = "file/" + FileUp.PostedFile.FileName;
             newStage.stage           = stage + 1;
             newStage.time            = DateTime.Now.ToString("yyyy-MM-dd");
             newStage.is_pass         = -2;
             db.ProjectStage.Add(newStage);
             db.SaveChanges();
             Response.Write("<script>location.href='MyProject.aspx?pageNumber=1';</script>");
         }
     }
 }
    protected void btnSub_Click(object sender, EventArgs e)
    {
        int    id              = Convert.ToInt32(Request.QueryString["id"].ToString());
        string name            = txtName.Text;
        string project_file    = UpLoadFile();
        string project_content = UeditorHelper.Change(myEditor11.InnerHtml);
        string time            = txtTime.Text;
        string judge_time      = txtJudgeTime.Text;
        string summary         = txtSummary.Text;

        if (name.Length == 0)
        {
            Response.Write("<script>alert('项目类型名称不能为空!');</script>");
        }
        else if (summary.Length == 0)
        {
            Response.Write("<script>alert('内容摘要不能为空!');</script>");
        }
        else if (UpLoadFile() == "wrong")
        {
            Response.Write("<script>alert('请选择正确的文件!');</script>");
        }
        else if (time == "" || judge_time == "")
        {
            Response.Write("<script>alert('截止时间不能为空!');</script>");
        }
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                var pro_category = (from it in db.ProjectCategory where it.id == id select it).FirstOrDefault();
                pro_category.name = name;
                if (project_file != "")
                {
                    pro_category.project_file = "file/" + project_file;
                }
                pro_category.project_content = project_content;
                pro_category.end_time        = time;
                pro_category.publish_time    = pushlishTime.Value;
                pro_category.judge_end_time  = judge_time;

                pro_category.summary = summary;
                db.SaveChanges();
                Server.Transfer("ProCategoryList.aspx");
                //Response.Write("<script>alert('修改成功!');location.href='ProCategoryList.aspx';</script>");
            }
        }
    }
    protected void btnSub_Click(object sender, EventArgs e)
    {
        string name            = txtName.Text;
        string project_file    = UpLoadFile();
        string project_content = UeditorHelper.Change(myEditor11.InnerHtml);
        string time            = txtTime.Text;
        string judge_time      = txtJudgeTime.Text;
        string summary         = txtSummary.Text;

        if (name.Length == 0)
        {
            Response.Write("<script>alert('项目类型名称不能为空!');</script>");
        }
        else if (summary.Length == 0)
        {
            Response.Write("<script>alert('内容摘要不能为空!');</script>");
        }
        else if (UpLoadFile() == "")
        {
            Response.Write("<script>alert('请选择正确的文件!');</script>");
        }
        else if (time == "" || judge_time == "")
        {
            Response.Write("<script>alert('截止时间不能为空!');</script>");
        }
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                ProjectCategory pro_category = new ProjectCategory();
                pro_category.name            = name;
                pro_category.category        = getId(dropCategory.SelectedValue);
                pro_category.project_file    = "file/" + project_file;
                pro_category.project_content = project_content;
                pro_category.stage           = 0;
                pro_category.end_time        = time;
                pro_category.judge_end_time  = judge_time;
                pro_category.is_deleted      = 0;
                pro_category.publish_time    = DateTime.Now.ToString("yyyy-MM-dd");
                pro_category.summary         = summary;
                db.ProjectCategory.Add(pro_category);
                db.SaveChanges();
                //Response.Write("<script>alert('提交成功!');location.href='ProCategoryList.aspx';</script>");
                Server.Transfer("ProCategoryList.aspx");
            }
        }
    }
示例#10
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        if (title.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0 && where.Text.Length > 0 && tips.Text.Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                Activity person = (from it in db.Activity where it.ActivityId == id select it).FirstOrDefault();

                person.ActivityTitle = title.Text;

                person.ActivityWhat = UeditorHelper.change(editor.InnerHtml);//富文本编辑器里的内容

                if (Request.Form["lb"] != "")
                {
                    person.ActivityImage = "~/File/" + Request.Form["lb"];
                }

                if (requestedDeliveryDateTextBox.Text.Trim().Length > 0)
                {
                    person.ActivityWhen = requestedDeliveryDateTextBox.Text;
                }

                person.ActivityWhere = where.Text;

                person.ActivityTips = tips.Text;

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('编辑成功');location='ActivityEditor.aspx?id=" + id + "'</script>");
                }
                else
                {
                    Response.Write("<script>alert('编辑失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
示例#11
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string name       = txtName.Text;
        int    teacher_id = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString());
        string fund       = txtMoney.Text;
        Regex  numRegex   = new Regex(@"^\d+$");
        string filePath   = FileUp.PostedFile.FileName;

        if (name.Length == 0)
        {
            Response.Write("<script>alert('项目名称不能为空!');</script>");
        }
        else if (fund.Length == 0)
        {
            Response.Write("<script>alert('资助金额不能为空!');</script>");
        }
        else if (!numRegex.IsMatch(fund))
        {
            Response.Write("<script>alert('请输入正确的资助金额!');</script>");
        }
        //else if (UpLoadFile() == false)
        //Response.Write("<script>alert('请上传项目文件!');</script>");
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                int     project_id = Convert.ToInt32(Request.QueryString["id"]);
                Project project    = (from it in db.Project where it.project_id == project_id select it).FirstOrDefault();
                project.name = name;
                project.fund = fund;
                db.SaveChanges();

                ProjectStage project_stage = (from it in db.ProjectStage where it.project_id == project_id orderby it.stage descending select it).FirstOrDefault();
                project_stage.project_content = UeditorHelper.Change(myEditor11.InnerHtml);
                if (UpLoadFile() == true)
                {
                    project_stage.project_file = "file/" + FileUp.PostedFile.FileName;
                }
                db.SaveChanges();
                Response.Redirect("MyProject.aspx?pageNumber=1");
            }
        }
    }
示例#12
0
    private void DataBindToRepeater(int currentPage, List <News> datascore)
    {
        for (int i = 0; i < datascore.Count; i++)
        {
            datascore[i].NewsBody = UeditorHelper.NoHTML(datascore[i].NewsBody);//把内容的html标签全部去除
        }
        PagedDataSource pds = new PagedDataSource();

        pds.AllowPaging = true;

        pds.PageSize = 5;

        pds.DataSource = datascore;

        lbTotal.Text = pds.PageCount.ToString();

        pds.CurrentPageIndex = currentPage - 1;

        Rpt.DataSource = pds;

        Rpt.DataBind();
    }
示例#13
0
    protected void btnSub_Click(object sender, EventArgs e)
    {
        string title   = txtTitle.Text;
        string summary = txtSummary.Text;
        string body    = UeditorHelper.Change(myEditor11.InnerHtml);

        if (title.Length == 0)
        {
            Response.Write("<script>alert('标题不能为空!');</script>");
        }
        else if (summary.Length == 0)
        {
            Response.Write("<script>alert('内容摘要不能为空!');</script>");
        }
        else if (body.Length == 0)
        {
            Response.Write("<script>alert('文章内容不能为空!');</script>");
        }
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                EducateSource src = new EducateSource();
                src.title = title;
                string cat = dropCategory.SelectedValue;
                src.category     = getId(cat);
                src.body         = body;
                src.publisher    = "系统管理员";
                src.publish_time = DateTime.Now.ToString("yyyy-MM-dd");
                src.view_times   = 0;
                src.is_deleted   = 0;
                src.summary      = summary;
                db.EducateSource.Add(src);
                db.SaveChanges();
                Server.Transfer("EduSrcList.aspx");
                //                Response.Write("<script>alert('提交成功!');location.href='EduSrcList.aspx';</script>");
            }
        }
    }
示例#14
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (title.Text.Trim().Length > 0 && Request.Form["lb"].Length > 0 && requestedDeliveryDateTextBox.Text.Trim().Length > 0 && editor.InnerHtml.Trim().Length > 0 && where.Text.Trim().Length > 0 && tips.Text.Trim().Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                Activity person = new Activity
                {
                    ActivityTitle = title.Text,

                    ActivityWhat = UeditorHelper.change(editor.InnerHtml),

                    ActivityImage = "~/File/" + Request.Form["lb"],//活动封面

                    ActivityWhen = requestedDeliveryDateTextBox.Text,

                    ActivityWhere = where.Text,

                    ActivityTips = tips.Text
                };

                db.Activity.Add(person);

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('添加成功');location='ActivityList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
示例#15
0
    public static string Format(string originFileName, string pathFormat)
    {
        if (String.IsNullOrWhiteSpace(pathFormat))
        {
            pathFormat = "{filename}{rand:6}";
        }

        var invalidPattern = new Regex(@"[\\\/\:\*\?\042\<\>\|]");

        originFileName = invalidPattern.Replace(originFileName, "");

        string extension = Path.GetExtension(originFileName);
        string filename  = Path.GetFileNameWithoutExtension(originFileName);

        pathFormat = pathFormat.Replace("{filename}", filename);
        pathFormat = new Regex(@"\{rand(\:?)(\d+)\}", RegexOptions.Compiled).Replace(pathFormat, new MatchEvaluator(delegate(Match match)
        {
            var digit = 6;
            if (match.Groups.Count > 2)
            {
                digit = Convert.ToInt32(match.Groups[2].Value);
            }
            //var rand = new Random();
            var rand = new Random(UeditorHelper.GetRandomSeed());//防止图片命名格式化时,随机数出现重复,导致已上传的图片被下一个图片覆盖掉
            return(rand.Next((int)Math.Pow(10, digit), (int)Math.Pow(10, digit + 1)).ToString());
        }));

        pathFormat = pathFormat.Replace("{time}", DateTime.Now.Ticks.ToString());
        pathFormat = pathFormat.Replace("{yyyy}", DateTime.Now.Year.ToString());
        pathFormat = pathFormat.Replace("{yy}", (DateTime.Now.Year % 100).ToString("D2"));
        pathFormat = pathFormat.Replace("{mm}", DateTime.Now.Month.ToString("D2"));
        pathFormat = pathFormat.Replace("{dd}", DateTime.Now.Day.ToString("D2"));
        pathFormat = pathFormat.Replace("{hh}", DateTime.Now.Hour.ToString("D2"));
        pathFormat = pathFormat.Replace("{ii}", DateTime.Now.Minute.ToString("D2"));
        pathFormat = pathFormat.Replace("{ss}", DateTime.Now.Second.ToString("D2"));

        return(pathFormat + extension);
    }
示例#16
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string          name        = txtName.Text;
        int             teacher_id  = TeacherHelper.getTeacherIDByNumber(Session["TeacherNumber"].ToString());
        string          submit_time = DateTime.Now.ToString("yyyy-MM-dd");
        string          fund        = txtMoney.Text;
        Regex           numRegex    = new Regex(@"^\d+$");
        string          filePath    = FileUp.PostedFile.FileName;
        HtmlInputHidden category    = FindControl("Selected") as HtmlInputHidden;

        if (category.Value == "")
        {
            Response.Write("<script>alert('项目类型不能为空!');</script>");
        }
        else if (name.Length == 0)
        {
            Response.Write("<script>alert('项目名称不能为空!');</script>");
        }
        else if (fund.Length == 0)
        {
            Response.Write("<script>alert('资助金额不能为空!');</script>");
        }
        else if (!numRegex.IsMatch(fund))
        {
            Response.Write("<script>alert('请输入正确的资助金额!');</script>");
        }
        else if (filePath.Length == 0)
        {
            Response.Write("<script>alert('申请文档不能为空!');</script>");
        }
        else if (UpLoadFile() == "wrong")
        {
            Response.Write("<script>alert('请上传正确的项目文件!');</script>");
        }
        else
        {
            using (var db = new TeachingCenterEntities())
            {
                Project project = new Project();
                project.name        = name;
                project.category    = Convert.ToInt32(category.Value);
                project.teacher_id  = teacher_id;
                project.submit_time = DateTime.Now.ToString("yyyy-MM-dd");
                project.fund        = fund;
                project.is_deleted  = 0;
                db.Project.Add(project);
                db.SaveChanges();

                ProjectStage project_stage = new ProjectStage();
                project_stage.project_id      = project.project_id;
                project_stage.project_file    = "file/" + UpLoadFile();
                project_stage.project_content = UeditorHelper.Change(myEditor11.InnerHtml);
                project_stage.stage           = 0;
                project_stage.time            = DateTime.Now.ToString("yyyy-MM-dd");
                project_stage.is_pass         = -2;
                db.ProjectStage.Add(project_stage);
                db.SaveChanges();
                //Server.Transfer("MyProject.aspx?pageNumber=1");
                Response.Write("<script>location.href='MyProject.aspx?pageNumber=1';</script>");
            }
        }
    }