Ejemplo n.º 1
0
        /// <summary>
        /// 删除友情链接
        /// </summary>
        public void DeleteFriendLink(int id)
        {
            var manager = new FriendLinkManager();
            var link    = manager.QueryFriendLink(id);

            manager.DeleteFriendLink(link);

            _cacheLinkList.Clear();
        }
Ejemplo n.º 2
0
        public void UpdateFriendLink(int id, int indexLink, string linkUrl, string innerText)
        {
            var manager = new FriendLinkManager();
            var entity  = manager.QueryFriendLink(id);

            entity.IndexLink = indexLink;
            entity.LinkUrl   = linkUrl;
            entity.InnerText = innerText;

            manager.UpdateFriendLink(entity);
            _cacheLinkList.Clear();
        }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Now_User.now_user == "")
        {
            Label3.Text += "游客";
        }
        else
        {
            Label3.Text += Now_User.now_user == "admin"?"管理员":Now_User.now_user;
        }
        fl = FriendLinkManager.GetAllLinkList();
        bool flag = Now_User.now_user == "admin" ? true : false;    //如果当前用户是管理员账户:账号admin,密码:admin则可进行删除

        if (fl.Count > 0)
        {
            for (int i = 0; i < fl.Count; ++i)
            {
                HyperLink hl = new HyperLink();
                hl.NavigateUrl = string.Format(fl[i].Lhref);
                hl.Text        = (i + 1).ToString() + ": " + fl[i].Ltitle;
                hl.Target      = "_blank";
                hl.Height      = 40;
                Master.Rows.Add(new TableRow());
                Master.Rows[i].Cells.Add(new TableCell());
                Master.Rows[i].Cells[0].Controls.Add(hl);
                if (flag)
                {
                    Button bt = new Button();
                    bt.Text     = "删除该友链";
                    bt.Click   += btn_Click;
                    bt.ID       = i.ToString();
                    bt.CssClass = "submit";
                    Master.Rows[i].Cells.Add(new TableCell());
                    Master.Rows[i].Cells[1].Controls.Add(bt);
                }
                else
                {
                    Button bt = new Button();
                    bt.Text     = "只有管理员可以删除哦";
                    bt.Click   += btn_Tourist_Click;
                    bt.CssClass = "submit";
                    bt.Width    = 150;
                    Master.Rows[i].Cells.Add(new TableCell());
                    Master.Rows[i].Cells[1].Controls.Add(bt);
                }
            }
        }
        else
        {
            Header.Text += "抱歉啊,本站还没有友链..要不你来加点啊?";
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        ///  添加友情链接
        /// </summary>
        public void AddFriendLink(int indexLink, string linkUrl, string innerText, bool isfriendship)
        {
            var manager = new FriendLinkManager();

            manager.AddFriendLinks(new FriendLinks()
            {
                IndexLink    = indexLink,
                LinkUrl      = linkUrl,
                InnerText    = innerText,
                Isfriendship = isfriendship,
                CreateTime   = DateTime.Now,
            });
            _cacheLinkList.Clear();
        }
Ejemplo n.º 5
0
    public void btn_Click(object sender, EventArgs e)
    {
        int delid = Convert.ToInt32((sender as Button).ID);//待删除友链在fl中的index,控件中的ID
        int lid   = fl[delid].Lid;

        if (FriendLinkManager.DeleteLinkById(lid))
        {
            Response.Write("<script>alert('您好," + urluid() + ",您已删除友链成功!');" +
                           "window.location.href='BeFriendly.aspx';</script>");
        }
        else
        {
            Response.Write("<script>alert('您好," + urluid() + ",您删除友链失败.');" +
                           "window.location.href='BeFriendly.aspx';</script>");
        }
    }
Ejemplo n.º 6
0
        public FriendLinksInfooCollection QueryLinks(bool Isfriendship)
        {
            var result = new FriendLinksInfooCollection();

            var cache = _cacheLinkList.Where(p => p.IsFriendShip == Isfriendship).ToList();

            if (cache.Count != 0)
            {
                result.AddRange(cache);
            }
            else
            {
                var news = new FriendLinkManager().QueryYQLinks(Isfriendship);
                result.AddRange(news);
                _cacheLinkList.AddRange(news);
            }
            return(result);
        }
Ejemplo n.º 7
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text == "" || TextBox2.Text == "")
     {
         Response.Write("<script>alert('您好," + urluid() + ",填写错误!');</script>");
     }
     else
     {
         if (FriendLinkManager.AddNewFLink(TextBox1.Text, TextBox2.Text))
         {
             Response.Write("<script>alert('您好," + urluid() + ",您已添加友链成功!');" +
                            "window.location.href='BeFriendly.aspx';</script>");
         }
         else
         {
             Response.Write("<script>alert('您好," + urluid() + ",您添加友链失败.');" +
                            "window.location.href='BeFriendly.aspx';</script>");
         }
     }
 }