⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collection.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using NetCMS.Model;

public partial class user_info_collection : NetCMS.Web.UI.UserPage
{
    Ghistory inf = new Ghistory();
    Mycom rd = new Mycom();
    protected void Page_Load(object sender, EventArgs e)
    {
        this.PageNavigator1.OnPageChange += new PageChangeHandler(PageNavigator1_PageChange);
        string APIID = "";
        if (Request.QueryString["APIID"]!=null && Request.QueryString["APIID"]!="")
        {
            APIID = Request.QueryString["APIID"];
        }
        Response.CacheControl = "no-cache";
        if (!IsPostBack)
        {
            
        }
        StartLoad(1, APIID);
        string Type = Request.QueryString["Type"];  //取得操作类型
        string ID = null;
        if(Request.QueryString["ID"]!=null&&Request.QueryString["ID"]!="")
        {
            ID =Request.QueryString["ID"];  //取得需要操作的稿件ID
        }
        int ChID = 0;
        if (Request.QueryString["ChID"] != null && Request.QueryString["ChID"] != string.Empty&&NetCMS.Common.Input.IsInteger(Request.QueryString["ChID"]))
        {
            ChID = int.Parse(Request.QueryString["ChID"]);
        }
        switch (Type)
        {
            case "del":          //删除
                del(ID);
                break;
            case "PDel":            //批量删除
                PDel();
                break;
            case "Add":
                AddTo(Request.QueryString["id"].ToString(), ChID);
                break;
            default:
                break;
        }

    }

    protected void PageNavigator1_PageChange(object sender, int PageIndex)
    {
        string APIID = null;
        if (Request.QueryString["APIID"] != null && Request.QueryString["APIID"] != "")
        {
            APIID =Request.QueryString["APIID"];
        }     
        StartLoad(PageIndex, APIID);
    }

    protected void StartLoad(int PageIndex,string Api)
    {
        int i, j; 
        DataTable dt = null;
        if (Api != "0" && Api != null&& Api != "")
        {
            dt = NetCMS.Content.Pagination.GetPage("user_info_collection_1_aspx", PageIndex, 10, out i, out j, null);
        }
        SQLConditionInfo sts = new SQLConditionInfo("@UserNum", NetCMS.Global.Current.UserNum);
        dt = NetCMS.Content.Pagination.GetPage("user_info_collection_2_aspx", PageIndex, 10, out i, out j, sts);
        this.PageNavigator1.PageCount = j;
        this.PageNavigator1.PageIndex = PageIndex;
        this.PageNavigator1.RecordCount = i;
        no.InnerHtml = "";
        if (dt != null&&dt.Rows.Count > 0)
        {
            dt.Columns.Add("Operation", typeof(string));
            dt.Columns.Add("titleUrl", typeof(string));
            foreach (DataRow h in dt.Rows)
            {
                if (h["ChID"].ToString() != "0")
                {
                    Channel frd = new Channel();
                    h["titleUrl"] = frd.getfUrl(int.Parse(h["FID"].ToString()), int.Parse(h["ChID"].ToString()));
                }
                else
                {
                    h["titleUrl"] = rd.sel_newsClass(h["FID"].ToString(), "" + NetCMS.Config.UIConfig.dataRe + "news");
                }
                h["Operation"] = "<a href=\"javascript:del('" + h["FID"].ToString() + "');\" class=\"list_link\">删除</a>┆<input name=\"Checkbox1\" type=\"checkbox\" value=\"" + h["ID"].ToString() + "\" /></td>";
            }
            DataList1.Visible = true;
        }      
        else
        {
            no.InnerHtml = show_no();
            sc.InnerHtml = Show_sc();
            this.PageNavigator1.Visible = false;
        }
        DataList1.DataSource = dt;
        DataList1.DataBind();
        DataList1.Dispose();
        sc.InnerHtml = Show_scs();
    }
    string show_no()
    {
        
        string nos = "<table border=0 width='98%' align=center cellpadding=5 cellspacing=1 class='table'>";
        nos = nos + "<tr class='TR_BG_list'>";
        nos = nos + "<td class='navi_link'>没有数据</td>";
        nos = nos + "</tr>";
        nos = nos + "</table>";
        DataList1.Visible = false;
        return nos;
    }

    protected void AddTo(string NewsID,int ChID)
    {
        if (inf.addTo(NewsID,ChID))
        {
            PageRight("收藏成功", "collection.aspx");
        }
        else
        {
            PageError("您已经收藏了此信息", "collection.aspx");
        }
    }

    protected void PDel()
    {
        string checkboxq = Request.Form["Checkbox1"];
        if (checkboxq == null || checkboxq == String.Empty)
        {
            PageError("请先选择要删除的收藏!", "collection.aspx");
        }
        else
        {
            string[] chSplit = checkboxq.Split(',');
            for (int i = 0; i < chSplit.Length; i++)
            {
                if (chSplit[i] != "on")
                {
                    if (inf.del_userInfo(chSplit[i],1) == 0)
                    {
                        PageError("批量删除失败,可能你没有选择", "collection.aspx");
                        break;
                    }
                }
            }
            PageRight("批量删除成功", "collection.aspx");
        }

    }
    protected void del(string ID)
    {
        if (inf.del_userInfo(ID,1) == 0)
        {
            PageError("批量删除失败", "collection.aspx");
        }
        else
        {
            PageRight("删除成功!", "collection.aspx");
        }
    }
    string Show_scs()
    {
        string scs = "<a href=\"javascript:API(0);\" class=\"topnavichar\">全部收藏</a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:PDel();\" class=\"topnavichar\">批量删除</a>";
        return scs;
    }
    string Show_sc()
    {
        string sc = "<a href=\"javascript:API();\" class=\"topnavichar\">全部收藏</a>";
        return sc;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -