Пример #1
0
    /// <summary>
    /// 绑定数据
    /// </summary>
    /// <returns></returns>
    private bool BindData()
    {
        try
        {
            using (var db = new huxiuEntities())
            {
                var displayHead = from it in db.Headline
                                  where it.HisDisplay == true
                                  select new MyDataInfo {
                    Id = it.Id, HId = it.HId, Htitle = it.Htitle, Himg = it.Himg, Hdeadline = it.Hdeadline, HisDisplay = it.HisDisplay
                };
                var queueHead = from it in db.Headline
                                where it.HisDisplay == false
                                select new MyDataInfo {
                    Id = it.Id, HId = it.HId, Htitle = it.Htitle, Himg = it.Himg, Hdeadline = it.Hdeadline, HisDisplay = it.HisDisplay
                };
                DataTable dt_head  = transToDataTable(displayHead);
                DataTable dt_queue = transToDataTable(queueHead);

                RptDisplaying.DataSource = dt_head;
                rptQueue.DataSource      = dt_queue;

                RptDisplaying.DataBind();
                rptQueue.DataBind();
            }
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (name.Text.Trim().Length > 0)
     {
         using (var db = new huxiuEntities())
         {
             PassageCategory person = new PassageCategory
             {
                 CategoryName = name.Text.Trim()
             };
             db.PassageCategory.Add(person);
             if (db.SaveChanges() == 1)
             {
                 Response.Write("<script>alert('添加成功');location='PassageList.aspx'</script>");
             }
             else
             {
                 Response.Write("<script>alert('添加失败请重试')</script>");
             }
         }
     }
     else
     {
         Response.Write("<script>alert('不能为空!')</script>");
     }
 }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Regex r = new Regex("^[1-9]d*|0$");

        if (Session["AdminID"] == null)
        {
            Response.Write("<script>alert('账户过期请重新登录!');location='login.aspx'</script>");
        }

        else if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null && r.IsMatch(Request.QueryString["id"]))//要把是否为空放前面
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                using (var db = new huxiuEntities())
                {
                    PassageCategory person = (from it in db.PassageCategory where it.PCategoryId == id select it).FirstOrDefault();

                    if (person != null)
                    {
                        name.Text = person.CategoryName;
                    }
                    else
                    {
                        Response.Write("<script>alert('地址栏有误');location='/PCategoryList.aspx'</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('地址栏有误');location='/PCategoryList.aspx'</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>");
        }
    }
Пример #5
0
    protected string imgUrl;        //= "./images/icon-eg.jpeg";
    protected void Page_Load(object sender, EventArgs e)
    {
        //登陆后,用seesion 初始化
        //AdminName 的名字和postUrl,网址跳转管理


        if (Session["AdminID"] == null)
        {
            Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='login.aspx';</script>");
        }

        else if (!IsPostBack)
        {
            int adId = Convert.ToInt32(Session["AdminID"].ToString().Trim());
            try
            {
                using (var db = new huxiuEntities())
                {
                    Admin ad = db.Admin.SingleOrDefault(a => a.AdminId == adId);
                    name   = ad.AdminName;
                    imgUrl = ad.AdminImage;
                }
            }
            catch
            {
                Response.Write("<script>alert('账户过期请重新登录!';location.href='login.aspx')</script>");
            }
        }
    }
Пример #6
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>");
        }
    }
Пример #7
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        if (name.Text.Trim().Length > 0)
        {
            using (var db = new huxiuEntities())
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                PassageCategory person = (from it in db.PassageCategory where it.PCategoryId == id select it).FirstOrDefault();

                person.CategoryName = name.Text.Trim();

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('修改成功');location='/PCategoryList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
Пример #8
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>");
        }
    }
Пример #9
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string content = txtSearch.Text;

        using (var db = new huxiuEntities())
        {
            var datascore = from it in db.Author orderby it.AuthorName select it;

            if (content.Length != 0)
            {
                datascore = from it in db.Author where it.AuthorName.IndexOf(content) >= 0 orderby it.AuthorName select it;
            }

            var ds = datascore.ToList();

            if (ds.Count == 0)
            {
                Response.Write("<script>alert('很抱歉,没有找到相关内容!')</script>");
            }

            Session["ds"] = ds;

            DataBindToRepeater(1, ds);

            lbNow.Text = "1";
        }
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminID"] == null)
        {
            Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='login.aspx';</script>");
        }

        else if (!IsPostBack)
        {
            using (var db = new huxiuEntities())
            {
                List <PassageCategory> pcategory = (from it in db.PassageCategory select it).ToList();

                for (int i = 0; i < pcategory.Count; i++)
                {
                    string idc = pcategory[i].PCategoryId.ToString();

                    string categoryc = pcategory[i].CategoryName.ToString();

                    category.Items.Add(new ListItem(categoryc, idc));//循环动态绑定分类
                }

                List <Author> authorlist = (from it in db.Author select it).ToList();

                for (int i = 0; i < authorlist.Count; i++)
                {
                    string idc = authorlist[i].AuthorId.ToString();

                    string categoryc = authorlist[i].AuthorName.ToString();

                    author.Items.Add(new ListItem(categoryc, idc));//循环动态绑定作者
                }
            }
        }
    }
Пример #11
0
    }/// <summary>

    /// 绑定主页图片切换
    /// </summary>
    /// <returns></returns>
    bool bindTurnImg()
    {
        //只能显示四条,一位前台只能绑定四条记录
        try
        {
            using (var db = new huxiuEntities())
            {
                var qurey = from it in db.Headline
                            where it.HisDisplay == true
                            select it;

                PagedDataSource pds = new PagedDataSource();
                pds.AllowPaging       = true;
                pds.PageSize          = 4;
                pds.DataSource        = qurey.ToList();
                pds.CurrentPageIndex  = 0;
                rptTurnImg.DataSource = pds;
                rptTurnImg.DataBind();
            }
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #12
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (name.Text.Trim().Length > 0 && Request.Form["lb"].Trim().Length > 0 && summary.Text.Trim().Length > 0)
     {
         using (var db = new huxiuEntities())
         {
             Author person = new Author
             {
                 AuthorName    = name.Text,
                 AuthorSex     = sex.SelectedValue == "1" ? true : false,
                 AuthorImage   = "~/File/" + Request.Form["lb"],
                 AuthorSummary = summary.Text
             };
             db.Author.Add(person);
             if (db.SaveChanges() == 1)
             {
                 Response.Write("<script>alert('添加作者成功');location='AuthorList.aspx'</script>");
             }
             else
             {
                 Response.Write("<script>alert('添加失败请重试')</script>");
             }
         }
     }
     else
     {
         Response.Write("<script>alert('不能为空')</script>");
     }
 }
Пример #13
0
 /// <summary>
 /// 本函数实现标记资讯, 短趣,活动 删除列,并且把记录写在 DeleteLog 中
 /// </summary>
 /// <param name="CategoryId"></param>   参数解释:待删除 ID 的所在分类   1 资讯 ; 2 活动; 3 短趣
 /// <param name="DelId"></param>        参数解释:待删除 ID
 /// <param name="OperatorId"></param>   参数解释:本次操作的管理员 ID
 /// <returns></returns>
 public bool delItem()
 {
     try
     {
         //记录准备删除的那条记录
         if (!recordDelFlag(true))
         {
             return(false);
         }
         using (var db = new huxiuEntities())
         {
             //new 一个 delelog 对象,进行添加操作
             DeleteLog addDelLog = new DeleteLog();
             addDelLog.DelAdminId = OperatorId;
             addDelLog.DelTime    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             addDelLog.Category   = CategoryId;
             addDelLog.LogId      = DelId;
             //添加记录表中
             db.DeleteLog.Add(addDelLog);
             //保存更改
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #14
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>");
        }
    }
Пример #15
0
    /// <summary>
    /// 记录原始数据项的删除标记
    /// </summary>
    /// <param name="yes_or_no"></param>
    /// <returns>返回bool类型</returns>
    private bool recordDelFlag(bool yes_or_no)
    {
        try
        {
            using (var db = new huxiuEntities())
            {
                switch (CategoryId)
                {
                case 1:    //查找资讯
                    Passage delPassage = db.Passage.SingleOrDefault(a => a.PassageId == DelId);
                    delPassage.IsDel = yes_or_no;
                    break;

                case 2:    //查找活动
                    Activity delActivty = db.Activity.SingleOrDefault(a => a.ActivityId == DelId);
                    delActivty.IsDel = yes_or_no;
                    break;

                case 3:    //查找短趣
                    News delnews = db.News.SingleOrDefault(a => a.NewsId == DelId);
                    delnews.IsDel = yes_or_no;
                    break;
                }
                db.SaveChanges();
            }
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #16
0
 /// <summary>
 /// 恢复删除
 /// </summary>
 /// <returns></returns>
 public bool recoverDel()
 {
     try
     {
         //把原来表里面的数据删除标志位 置 0
         if (!recordDelFlag(false))
         {
             return(false);
         }
         //删除记录表中的数据
         using (var db = new huxiuEntities())
         {
             DeleteLog del = (from it in db.DeleteLog
                              where it.Category == CategoryId && it.LogId == DelId
                              select it).FirstOrDefault();
             db.DeleteLog.Remove(del);
             db.SaveChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #17
0
    /// <summary>
    /// 本函数删除相应分类下面的某一条
    /// </summary>
    /// <param name="completeCate"> 相应分类</param>
    /// <param name="completeId"> 分类下面的id </param>
    /// <returns>返回 bool</returns>
    private bool delSourceData(int completeCate, int completeId)
    {
        try
        {
            using (var db = new huxiuEntities())
            {
                switch (completeCate)
                {
                case 1:    //查找资讯
                    Passage delPassage = db.Passage.SingleOrDefault(a => a.PassageId == completeId);
                    db.Passage.Remove(delPassage);
                    break;

                case 2:    //查找活动
                    Activity delActivty = db.Activity.SingleOrDefault(a => a.ActivityId == completeId);
                    db.Activity.Remove(delActivty);
                    break;

                case 3:    //查找短趣
                    News delnews = db.News.SingleOrDefault(a => a.NewsId == completeId);
                    db.News.Remove(delnews);
                    break;
                }
                db.SaveChanges();
            }
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Пример #18
0
    /// <summary>
    /// 在大的资讯分类里面筛选出小的资讯分类
    /// </summary>
    /// <param name="PassageLable"></param>
    /// <returns>返回一个 DataTable 进行分页操作</returns>
    protected DataTable SelectPassageLable(string PassageLable)
    {
        int PassageLableId = 1;

        //遍历资讯分类表,得到分类名的id
        using (var db = new huxiuEntities())
        {
            var IdList = from it in db.PassageCategory
                         select it;
            foreach (var item in IdList)
            {
                if (item.CategoryName == PassageLable)
                {
                    PassageLableId = item.PCategoryId;
                }
            }
        }
        // 复制一个分类下建立好的 DataTable ,方便之后换了分类继续使用
        DataTable copy_dt   = new DataTable();
        string    filterStr = "PassageCate=" + PassageLableId.ToString();

        DataRow[] rows = _DT.Select(filterStr);     //筛选符合条件的数据
        copy_dt = _DT.Clone();                      //克隆 _DT 的结构
        foreach (DataRow row in rows)
        {
            copy_dt.ImportRow(row);                 //复制行数据到 copy_dt 中
        }
        return(copy_dt);
    }
Пример #19
0
 /// <summary>
 /// 删除头条
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool delItem(int id)
 {
     try
     {
         using (var db = new huxiuEntities())
         {
             Headline delHead = db.Headline.SingleOrDefault(a => a.Id == id);
             if (!delHead.HisDisplay)            //如果删除队列中的项目,队列数量减一
             {
                 queueSize--;
             }
             else if (displayCount <= 4)         //最少头条保留4条
             {
                 return(false);
             }
             db.Headline.Remove(delHead);
             db.SaveChanges();
         }
         displayCount--;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var db = new huxiuEntities())
     {
         var datascore = from it in db.PassageCategory select it;
         Rpt.DataSource = datascore.ToList();
         Rpt.DataBind();
     }
 }
Пример #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Regex r = new Regex("^[1-9]d*|0$");


        if (Request.QueryString["id"] != null && r.IsMatch(Request.QueryString["id"]))
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            using (var db = new huxiuEntities())
            {
                Activity person = (from it in db.Activity where it.ActivityId == id select it).FirstOrDefault();

                if (person != null)
                {
                    title.Text = person.ActivityTitle;                                                              //标题

                    what.Text = person.ActivityWhat;                                                                //内容

                    img.ImageUrl = person.ActivityImage;                                                            //封面

                    when.Text = person.ActivityWhen.ToString();                                                     //时间

                    where.Text = person.ActivityWhere;                                                              //地点

                    tips.Text = person.ActivityTips;                                                                //备注

                    List <Activity> people = (from it in db.Activity where it.ActivityId != id select it).ToList(); //相关活动

                    title1.Text = people[0].ActivityTitle;

                    image1.ImageUrl = people[0].ActivityImage;

                    image1.PostBackUrl = "/ActivityContent.aspx?id=" + people[0].ActivityId;

                    title2.Text = people[1].ActivityTitle;

                    image2.ImageUrl = people[1].ActivityImage;

                    image2.PostBackUrl = "/ActivityContent.aspx?id=" + people[1].ActivityId;

                    title3.Text = people[2].ActivityTitle;

                    image3.ImageUrl = people[2].ActivityImage;

                    image3.PostBackUrl = "/ActivityContent.aspx?id=" + people[2].ActivityId;
                }
                else
                {
                    Response.Write("<script>alert('地址栏有误');location='/ActivityList.aspx'</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('地址栏有误');location='/ActivityList.aspx'</script>");
        }
    }
Пример #22
0
    /// <summary>
    /// 生成第一个大分类下的所有删除的项目
    /// </summary>
    /// <param name="Categroy"></param>
    /// <returns>返回一个 DataTable 进行分页操作</returns>
    protected DataTable RptRecoverListBind(string Categroy)
    {   //1为资讯,2为活动,3为短趣
        using (var db = new huxiuEntities())
        {
            //结果:   资讯标题(id 绑定到跳转链接) 资讯下面的小分类  删除时间  管理员姓名(绑定id到跳转管理员界面)
            if (Categroy == "资讯")
            {
                var ans = from it in db.DeleteLog                            //在删除记录表中查找大类
                          where it.Category == 1
                          orderby it.DelTime descending                      //降序排序
                          join disId in db.Passage                           //联合查询,显示资讯 Id Title
                          on it.LogId equals disId.PassageId
                          join adminInfo in db.Admin                         //联合查询,显示管理员的名字和 Id
                          on it.DelAdminId equals adminInfo.AdminId
                          select new MyDataInfo {
                    Id = disId.PassageId, Title = disId.PassageTitle, PassageCate = disId.PassageCategory, Time = it.DelTime, AdminName = adminInfo.AdminName, AdminId = it.DelAdminId, Link = "#", DelCate = 1
                };

                return(transToDataTable(ans));
            }
            //结果:   活动标题(id 绑定到跳转链接)  删除时间  管理员姓名(绑定id到跳转管理员界面)
            if (Categroy == "活动")
            {
                var ans = from it in db.DeleteLog                            //在删除记录中查找大类
                          where it.Category == 2
                          orderby it.DelTime descending                      //降序排列
                          join disId in db.Activity
                          on it.LogId equals disId.ActivityId                //联合查询,显示活动 id Title
                          join adminInfo in db.Admin
                          on it.DelAdminId equals adminInfo.AdminId          //联合查询,显示管理员的名字和 Id
                          select new MyDataInfo {
                    Id = disId.ActivityId, Title = disId.ActivityTitle, Time = it.DelTime, AdminName = adminInfo.AdminName, AdminId = it.DelAdminId, PassageCate = -1, Link = "#", DelCate = 2
                };

                return(transToDataTable(ans));
            }
            //结果:   短趣标题( 绑定 link 到跳转链接)  删除时间  管理员姓名(绑定id到跳转管理员界面)
            else
            {
                var ans = from it in db.DeleteLog                            //在删除记录中查找大类
                          where it.Category == 3
                          orderby it.DelTime descending                      //降序排列
                          join disId in db.News
                          on it.LogId equals disId.NewsId                    //联合查询,显示短趣 id Title
                          join adminInfo in db.Admin
                          on it.DelAdminId equals adminInfo.AdminId          //联合查询,显示管理员的名字和 Id
                          select new MyDataInfo {
                    Id = disId.NewsId, Title = disId.NewsTitle, Link = disId.NewsLink, Time = it.DelTime, AdminName = adminInfo.AdminName, AdminId = it.DelAdminId, PassageCate = -1, DelCate = 3
                };

                return(transToDataTable(ans));
            }
        }
    }
Пример #23
0
    protected void lbtLogin_Click(object sender, EventArgs e)
    {
        string username = txtUserName.Text.Trim();
        string pwd      = txtpwd.Text.Trim();
        string captcha  = txtCaptcha.Text.Trim();
        string trueVali = Session["Vnum"].ToString();

        System.Text.RegularExpressions.Regex numberReg = new System.Text.RegularExpressions.Regex("^[0-9]+$");
        if (username == "" || pwd == "" || captcha == "")
        {
            Response.Write("<script>alert('输入不能有空值!');</script>");
        }
        else
        {
            pwd = Security.SHA1_Hash(Security.MD5_hash(pwd));
            if (numberReg.IsMatch(captcha))
            {
                if (captcha == trueVali)
                {
                    try
                    {
                        using (var db = new huxiuEntities())
                        {
                            Admin ad = db.Admin.SingleOrDefault(a => a.AdminName == username && a.AdminPassword == pwd);
                            if (ad == null)
                            {
                                Response.Write("<script>alert('用户名或密码错误,请重新输入!');location.href='login.aspx';</script>");
                            }
                            else
                            {
                                Session["AdminID"] = ad.AdminId;
                                Response.Write("<script>alert('登录成功!');location.href='huxiu-backstage.html';</script>");
                            }
                        }
                    }
                    catch
                    {
                        Response.Write("<script>alert('网络阻塞,刷新重试!');location.href='login.aspx';</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('验证码不正确,请重新输入!');location.href='login.aspx';</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('验证码输入不合法!');location.href='login.aspx';</script>");
            }
        }
    }
Пример #24
0
 protected void Rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "delete")
     {
         int authorId = Convert.ToInt32(e.CommandArgument);
         using (var db = new huxiuEntities())
         {
             Author au = db.Author.SingleOrDefault(a => a.AuthorId == authorId);
             db.Author.Remove(au);
             db.SaveChanges();
             Response.Write("<script>alert('作者删除成功!');location='AuthorList.aspx';</script>");
         }
     }
 }
Пример #25
0
 protected void Rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "delete")
     {
         int pcId = Convert.ToInt32(e.CommandArgument);
         using (var db = new huxiuEntities())
         {
             PassageCategory pc = db.PassageCategory.SingleOrDefault(a => a.PCategoryId == pcId);
             db.PassageCategory.Remove(pc);
             db.SaveChanges();
             Response.Write("<script>alert('分类删除成功!');location='PCategoryList.aspx';</script>");
         }
     }
 }
Пример #26
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        if (title.Text.Trim().Length > 0 && content.Text.Trim().Length > 0 && link.Text.Trim().Length > 0)
        {
            //string Pattern = @"^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&amp;%\$#\=~_\-@]*)*$";
            string Pattern = @"(http|https)://[^\s]*";
            Regex  r       = new Regex(Pattern);
            if (r.IsMatch(link.Text.Trim()))
            {
                using (var db = new huxiuEntities())//修改短趣
                {
                    News person = (from it in db.News where it.NewsId == id select it).FirstOrDefault();

                    if (person.NewsTitle == title.Text.Trim() && person.NewsBody == content.Text && person.NewsLink == link.Text.Trim())
                    {
                        Response.Write("<script>alert('未修改');location='NewsEditor.aspx?id=" + id + "'</script>");
                    }
                    else
                    {
                        person.NewsTitle = title.Text.Trim(); //标题
                        person.NewsBody  = content.Text;      //内容
                                                              //  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>");
            }
        }

        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
Пример #27
0
    protected void DplistCategory_TextChanged(object sender, EventArgs e)
    {
        if (DplistCategory.SelectedValue != "-- > 请选择类别 < --")
        {
            if (DplistCategory.SelectedValue == "资讯")
            {
                //绑定数据
                _DT    = RptRecoverListBind("资讯");
                pds_dt = _DT.Copy();
                JumpPage(pds_dt, 1);
                //显示资讯下面的详细标签
                using (var db = new huxiuEntities())
                {
                    var DptDataSource = from it in db.DeleteLog
                                        where it.Category == 1
                                        join disId in db.Passage
                                        on it.LogId equals disId.PassageId
                                        join itOk in db.PassageCategory
                                        on disId.PassageCategory equals itOk.PCategoryId
                                        select itOk.CategoryName;
                    HashSet <string> hs = new HashSet <string>(DptDataSource);//去出重复字符串

                    DplistPassageLable.DataSource = hs.ToList();
                    DplistPassageLable.DataBind();
                }
                DplistPassageLable.Visible = true;
                ListItem lt = new ListItem();
                lt.Text     = "-->请选择类别<--";
                lt.Selected = true;
                DplistPassageLable.Items.Add(lt);
            }
            else
            {
                //绑定数据
                _DT    = RptRecoverListBind(DplistCategory.SelectedValue);
                pds_dt = _DT.Copy();
                JumpPage(pds_dt, 1);
                DplistPassageLable.Visible = false;
            }
        }
        else  //请选默认显示 资讯 类
        {
            //绑定数据
            pds_dt = RptRecoverListBind("资讯");
            JumpPage(pds_dt, 1);
            DplistPassageLable.Visible = false;
        }
    }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Regex r = new Regex("^[1-9]d*|0$");

        if (Session["AdminID"] == null)
        {
            Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='login.aspx';</script>");
        }

        else if (!IsPostBack)
        {
            if (Request.QueryString["id"] != null && r.IsMatch(Request.QueryString["id"])) //要把是否为空放前面
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);                       //获取id

                using (var db = new huxiuEntities())
                {
                    Activity person = (from it in db.Activity where it.ActivityId == id select it).FirstOrDefault();

                    if (person != null)
                    {
                        title.Text = person.ActivityTitle;                                  //标题

                        content.Text = person.ActivityWhat;                                 //内容

                        image.ImageUrl = person.ActivityImage;                              //封面

                        when.Text = person.ActivityWhen.ToString();                         //时间

                        requestedDeliveryDateTextBox.Text = person.ActivityWhen.ToString(); //时间

                        where.Text = person.ActivityWhere;                                  //地点

                        tips.Text = person.ActivityTips;                                    //备注
                    }
                    else
                    {
                        Response.Write("<script>alert('地址栏有误');location='ActivityList.aspx'</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('地址栏有误');location='ActivityList.aspx'</script>");
            }
        }
    }
Пример #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["AdminID"] != null)
            {
                using (var db = new huxiuEntities())
                {
                    var datascore = from it in db.PassageInformation where it.IsDel == false orderby it.PublishDate descending select it;

                    var ds = datascore.ToList();

                    Session["ds"] = ds;

                    DataBindToRepeater(1, ds);
                }

                using (var db = new huxiuEntities())
                {
                    var datascore = from it in db.PassageCategory select it;

                    this.DropDownList.DataSource = datascore.ToList();

                    this.DropDownList.DataValueField = "PCategoryId";

                    this.DropDownList.DataTextField = "CategoryName";

                    this.DropDownList.DataBind();

                    ListItem item = new ListItem();

                    item.Text = "全部";

                    item.Value = "0";

                    this.DropDownList.Items.Insert(0, item);
                }
            }
            else
            {
                Response.Write("<script>alert('账户过期请重新登录!');window.parent.location.href='login.aspx';</script>");
            }
        }
    }
Пример #30
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (title.Text.Trim().Length > 0 && content.Text.Trim().Length > 0 && link.Text.Trim().Length > 0)
        {
            //(http|https)://[^\s]*
            //string Pattern = @"^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.[a-zA-Z]{2,4})(\:[0-9]+)?(/[^/][a-zA-Z0-9\.\,\?\'\\/\+&amp;%\$#\=~_\-@]*)*$";
            string Pattern = @"(http|https)://[^\s]*";

            Regex r = new Regex(Pattern);
            if (r.IsMatch(link.Text.Trim()))
            {
                using (var db = new huxiuEntities())
                {
                    News person = new News
                    {
                        NewsTitle = title.Text.Trim(),
                        NewsBody  = content.Text.Trim(),
                        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>");
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }