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

📄 recyle.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 3 页
字号:
        {
            DataTable dt = getNewsTable();
            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string tbname = dt.Rows[i][0].ToString();
                    string Sql = "Delete From " + tbname + " Where SiteID='" + SiteID + "' And isRecyle=1 And NewsID In(" + idstr + ")";
                    DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
                }
                dt.Clear(); dt.Dispose();
            }
        }
        public void PDCList(string idstr)
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                DataTable dt = getNewsTable();
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string tbname = dt.Rows[i][0].ToString();

                        string str_Sql = "Delete From " + Pre + "API_commentary Where InfoID In(" +
                                         "Select NewsID From " + tbname + " Where SiteID In(" +
                                         "Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + ")))";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);

                        string str_Sql1 = "Delete From " + tbname + " Where SiteID In(" +
                                          "Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);

                        string str_Sql2 = "Delete From " + Pre + "news_Class Where SiteID In(" +
                                          "Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql2, null);

                        string str_Sql5 = "Delete From " + Pre + "special_news Where SpecialID In (Select SpecialID From "+
                                          "" + Pre + "news_special Where SiteID In(Select ChannelID From " + Pre + " news_site "+
                                          "Where isRecyle=1 And ChannelID In(" + idstr + ")))";
                        DbHelper.ExecuteNonQuery(tran,CommandType.Text, str_Sql5, null);

                        string str_Sql3 = "Delete From " + Pre + "news_special Where SiteID In(" +
                                          "Select ChannelID From " + Pre + " news_site Where isRecyle=1 And ChannelID In(" + idstr + "))";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql3, null);

                        string str_Sql4 = "Delete From " + Pre + "news_site Where isRecyle=1 And ChannelID In(" + idstr + ")";
                        DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql4, null);

                    }
                    tran.Commit();
                }
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public void PDSList(string idstr)
        {
            idstr = getIDStr(idstr, "SpecialID,ParentID", "news_special");
            string Sql = "Delete From " + Pre + "special_news Where SpecialID In (" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);

            Sql = "Delete From " + Pre + "news_special where SpecialID in(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
        }
        public void PDStCList(string idstr)
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where ClassID In (" + idstr + ") And SiteID='" + SiteID + "' And isRecyle=1";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
                string str_Sql1 = "Delete From " + Pre + "sys_styleclass Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + ")";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
                tran.Commit();
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public void PDStList(string idstr)
        {
            string str_Sql = "Delete From " + Pre + "sys_LabelStyle Where SiteID='" + SiteID + "' And isRecyle=1";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void PDLCList(string idstr)
        {
            SqlConnection Conn = new SqlConnection(DBConfig.CmsConString);
            Conn.Open();
            SqlTransaction tran = Conn.BeginTransaction();
            try
            {
                string str_Sql = "Delete From " + Pre + "sys_Label Where ClassID In (" + idstr + ") And SiteID='" + SiteID + "' And isRecyle=1";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql, null);
                string str_Sql1 = "Delete From " + Pre + "sys_LabelClass Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + idstr + ")";
                DbHelper.ExecuteNonQuery(tran, CommandType.Text, str_Sql1, null);
                tran.Commit();
                Conn.Close();
            }
            catch (SqlException e)
            {
                tran.Rollback();
                Conn.Close();
                throw e;
            }
        }
        public void PDLList(string idstr)
        {
            string str_Sql = "Delete From " + Pre + "sys_Label Where isRecyle=1 And SiteID='" + SiteID + "' And LabelID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        public void PDPSFList(string idstr)
        {
            string str_Sql = "Delete From " + Pre + "sys_PSF Where isRecyle=1 And SiteID='" + SiteID + "' And psfID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }
        //---------------------------------------------------------------------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------------------------------------------------
        public DataTable getNewsTable()
        {
            string str_Sql = "Select TableName From " + Pre + "sys_NewsIndex";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }
        public DataTable getNewsClass(string idstr)
        {
            string str_Sql = "";
            if (idstr != null && idstr != "" && idstr != string.Empty)
                str_Sql = "Select ClassID,SavePath,SaveClassframe From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1 And ClassID In(" + getIDStr(idstr, "ClassID,ParentID", "news_Class") + ")";
            else
                str_Sql = "Select ClassID,SavePath,SaveClassframe From " + Pre + "news_Class Where SiteID='" + SiteID + "' And isRecyle=1";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }
        public DataTable getNews(string classid, string tbname)
        {
            string str_Sql = "";
            if (classid != null && classid != "" && classid != string.Empty)
                str_Sql = "Select NewsID,ClassID,SavePath,FileName,FileEXName From " + tbname + " Where isRecyle=1 And" +
                          " SiteID='" + SiteID + "' And ClassID='" + classid + "'";
            else
                str_Sql = "Select NewsID,ClassID,SavePath,FileName,FileEXName From " + tbname + " Where isRecyle=1 And SiteID='" + SiteID + "'";

            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }
        public DataTable getSpeaciList(string idstr)
        {
            string str_Sql = "";
            if (idstr != "" && idstr != null & idstr != string.Empty)
                str_Sql = "Select SpecialID,SavePath,specialEName,saveDirPath,FileName,FileEXName From " + Pre + "news_special Where " +
                          "isRecyle=1 And SiteID='" + SiteID + "' And SpecialID In(" + getIDStr(idstr, "SpecialID,ParentID", "news_special") + ")";
            else
                str_Sql = "Select SpecialID,SavePath,specialEName,saveDirPath,FileName,FileEXName From " +
                          "" + Pre + "news_special Where isRecyle=1 And SiteID='" + SiteID + "'";

            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }
        public DataTable getSite(string idstr)
        {
            string str_Sql = "";
            if (idstr != "" && idstr != null & idstr != string.Empty)
                str_Sql = "Select ChannelID,EName From " + Pre + "news_site Where isRecyle=1 And ParentID='0' And ChannelID In(" + idstr + ") And SiteID='" + SiteID + "'";
            else
                str_Sql = "Select ChannelID,EName From " + Pre + "news_site Where isRecyle=1 And ParentID='0' And SiteID='" + SiteID + "'";

            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            return dt;
        }



        protected string getChildId(string id, string col, string tbname)
        {
            string str_Sql = "Select " + col + " From " + Pre + tbname + " Where SiteID='" + SiteID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            string idstr = "'" + id + "'," + getRecursion(dt, id);
            return idstr;
        }

        protected string getRecursion(DataTable dt, string PID)
        {
            DataRow[] row = null;
            string idstr = "";
            row = dt.Select("ParentID='" + PID + "'");
            if (row.Length < 1)
                return idstr;
            else
            {
                foreach (DataRow r in row)
                {
                    idstr += "'" + r[0].ToString() + "',";
                    idstr += getRecursion(dt, r[0].ToString());
                }
            }
            return idstr;
        }

        public string getIDStr(string id, string col, string tbname)
        {
            string[] arr_id = id.Split(',');
            string temp_id = "";
            string temp_id1 = "";
            for (int i = 0; i < arr_id.Length; i++)
            {
                temp_id = arr_id[i].Replace("'", "");
                temp_id1 += getChildId(temp_id, col, tbname);
            }
            temp_id1 = NetCMS.Common.Input.CutComma(temp_id1);
            return temp_id1;
        }

        public void raDComment(string NewsID, bool isDel)
        {
            string str_Sql = "";
            if (isDel == true)
                str_Sql = "Delete From " + Pre + "API_commentary Where InfoID='" + NewsID + "'";
            else
                str_Sql = "Update " + Pre + "API_commentary Set isRecyle=0 Where InfoID='" + NewsID + "'";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
        }

        protected bool checkParIsDel(string classid, string tbname)
        {
            bool rtf = true;
            string str_Sql = "Select isRecyle From " + Pre + tbname + " Where ClassID='" + classid + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0][0].ToString() != "1")
                        rtf = false;
                }
                dt.Clear(); dt.Dispose();
            }
            return rtf;
        }

        protected bool getParentlockTf(string ID, string tbname, string classid)
        {
            bool LockTf = false;
            ID = getParentID(ID, tbname, classid);
            string Str_Sql = "Select ParentID,isRecyle From " + Pre + tbname + " where " + classid + "='" + ID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, Str_Sql, null);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["isRecyle"].ToString() == "1")
                        LockTf = true;
                    else
                        LockTf = getParentlockTf(dt.Rows[0]["ParentID"].ToString(), tbname, classid);
                }
                dt.Clear(); dt.Dispose();
            }
            return LockTf;
        }
        protected string getParentID(string ID, string tbname, string classid)
        {
            string strparentid = ID;
            string str_Sql = "Select ParentID,isRecyle From " + Pre + tbname + " where " + classid + "='" + ID + "'";
            DataTable dt = DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                    strparentid = dt.Rows[0]["ParentID"].ToString();
                dt.Clear(); dt.Dispose();
            }
            return strparentid;
        }
    }
}

⌨️ 快捷键说明

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