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

📄 ads.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 3 页
字号:

        }
        public DataTable adsClassDt(string classid)
        {
            string str_Sql = "";
            if (classid != null && classid != "" && classid != string.Empty)
            {
                Recyle rc = new Recyle();
                string idstr = rc.getIDStr(classid, "AcID,ParentID", "ads_class");
                str_Sql = "Select AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "' And AcID in (" + idstr + ")";
            }
            else
                str_Sql = "Select AcID From " + Pre + "ads_class Where SiteID='" + SiteID + "'";

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

        /// <summary>
        /// 删除广告分类
        /// </summary>
        /// <param name="classid"></param>
        public void DelPAdsClass(string classid)
        {
            Recyle rc = new Recyle();
            string idstr = rc.getIDStr(classid, "AcID,ParentID", "ads_class");
            string str_Sql = "Delete From " + Pre + "adstxt Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(" + idstr + "))";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
            string str_Sql1 = "Delete From " + Pre + "ads_stat Where AdID In (Select AdID From " + Pre + "ads Where ClassID In(" + idstr + "))";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
            string str_Sql2 = "Delete From " + Pre + "ads Where ClassID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql2, null);
            string str_Sql3 = "Delete From " + Pre + "ads_class Where SiteID='" + SiteID + "' And AcID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql3, null);
        }

        /// <summary>
        /// 增加广告分类
        /// </summary>
        /// <param name="aci"></param>
        /// <returns></returns>
        public int AddClass(NetCMS.Model.AdsClassInfo aci)
        {
            string checkSql = "";
            int recordCount = 0;
            string AcID = NetCMS.Common.Rand.Number(12);
            while (true)
            {
                checkSql = "select count(*) from " + Pre + "ads_class where AcID='" + AcID + "'";
                recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
                if (recordCount < 1)
                    break;
                else
                    AcID = NetCMS.Common.Rand.Number(12, true);
            }
            checkSql = "select count(*) from " + Pre + "ads_class where Cname='" + aci.Cname + "'";
            recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
            if (recordCount > 0)
            {
                throw new Exception("分类名称重复,请重新添加!");
            }
            string Sql = "insert into " + Pre + "ads_class (AcID,Cname,ParentID,creatTime,SiteID,Adprice";
            Sql += ") values ('" + AcID + "',";
            Sql += "@Cname,@ParentID,@creatTime,@SiteID,@Adprice)";
            SqlParameter[] param = GetClassParameters(aci);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
        }

        /// <summary>
        /// 编辑分类
        /// </summary>
        /// <param name="aci"></param>
        /// <returns></returns>
        public int EditClass(NetCMS.Model.AdsClassInfo aci)
        {
            string checkSql = "select count(*) from " + Pre + "ads_class Where AcID!='" + aci.AcID + "' And Cname='" + aci.Cname + "'";
            int recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
            if (recordCount > 0)
            {
                throw new Exception("分类名称重复,请重新修改!");
            }
            string Sql = "Update " + Pre + "ads_class Set Cname=@Cname,Adprice=@Adprice Where AcID=@AcID";
            SqlParameter[] param = GetClassParameters(aci);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
        }

        public DataTable getAdsClassInfo(string classid)
        {
            SqlParameter param = new SqlParameter("@ClassId",classid);
            string str_Sql = "Select Cname,ParentID,Adprice From " + Pre + "ads_class Where AcID=@ClassId";
            return DbHelper.ExecuteTable(CommandType.Text, str_Sql, param);
        }

        public void statDelAll()
        {
            string str_Sql = "Delete From " + Pre + "ads_stat Where AdID In(Select AdID From " + Pre + "ads Where SiteID='" + SiteID + "')";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
            string str_Sql1 = "Update " + Pre + "ads Set ClickNum=0,ShowNum=0 Where SiteID='" + SiteID + "'";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
        }

        public void statDel(string idstr)
        {
            string str_Sql = "Delete From " + Pre + "ads_stat Where AdID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql, null);
            string str_Sql1 = "Update " + Pre + "ads Set ClickNum=0,ShowNum=0 Where SiteID='" + SiteID + "' And  AdID In(" + idstr + ")";
            DbHelper.ExecuteNonQuery(CommandType.Text, str_Sql1, null);
        }

        public DataTable getAdsClassList()
        {
            string str_Sql = "Select AcID,Cname,ParentID,Adprice From " + Pre + "ads_class Where SiteID='" + SiteID + "'";
            return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
        }
        public DataTable getAdsList(string id)
        {
            string str_Sql = "";
            if (id != null && id != "" && id != string.Empty)
                str_Sql = "Select AdID,adName From " + Pre + "ads Where SiteID='" + SiteID + "' And isLock=0 And adType!=11 And AdID!='" + id + "'";
            else
                str_Sql = "Select AdID,adName From " + Pre + "ads Where SiteID='" + SiteID + "' And isLock=0 And adType!=11";
            return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);
        }

        public string adsAdd(NetCMS.Model.AdsInfo ai)
        {
            string AdID = "";
            string checkSql = "";
            int recordCount = 0;
            AdID = NetCMS.Common.Rand.Number(15);
            while (true)
            {
                checkSql = "select count(*) from " + Pre + "ads where AdID='" + AdID + "'";
                recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
                if (recordCount < 1)
                    break;
                else
                    AdID = NetCMS.Common.Rand.Number(15, true);
            }
            checkSql = "select count(*) from " + Pre + "ads where adName='" + ai.adName + "'";
            recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
            if (recordCount > 0)
            {
                throw new Exception("广告名称重复,请重新添加!");
            }
            string Sql = "Insert Into " + Pre + "ads(AdID,adName,ClassID,CusID,adType,leftPic,rightPic,leftSize,rightSize," +
                         "LinkURL,CycTF,CycAdID,CycSpeed,CycDic,ClickNum,ShowNum,CondiTF,maxShowClick,TimeOutDay,maxClick," +
                         "creatTime,AdTxtNum,isLock,SiteID) Values('" + AdID + "',@adName,@ClassID,@CusID,@adType,@leftPic," +
                         "@rightPic,@leftSize,@rightSize,@LinkURL,@CycTF,@CycAdID,@CycSpeed,@CycDic,@ClickNum,@ShowNum," +
                         "@CondiTF,@maxShowClick,@TimeOutDay,@maxClick,@creatTime,@AdTxtNum,@isLock,@SiteID)";
            if (ai.adType == 11)
            {
                string[] arr_Content = ai.AdTxtContent.Split(',');
                string[] arr_Css = ai.AdTxtCss.Split(',');
                string[] arr_Link = ai.AdTxtLink.Split(',');
                string str_txtSql = "";
                for (int i = 0; i < arr_Content.Length; i++)
                {
                    str_txtSql = "Insert Into " + Pre + "adstxt(AdID,AdTxt,AdCss,AdLink) Values('" + AdID + "','" + arr_Content[i].ToString() + "','" + arr_Css[i].ToString() + "','" + arr_Link[i].ToString() + "')";
                    DbHelper.ExecuteNonQuery(CommandType.Text, str_txtSql, null);
                }
            }
            SqlParameter[] param = GetAdsParameters(ai);
            DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
            return AdID;
        }

        public int adsEdit(NetCMS.Model.AdsInfo ai)
        {
            string checkSql = "";
            int recordCount = 0;
            checkSql = "select count(*) from " + Pre + "ads Where AdID!='" + ai.AdID + "' And adName='" + ai.adName + "'";
            recordCount = (int)DbHelper.ExecuteScalar(CommandType.Text, checkSql, null);
            if (recordCount > 0)
            {
                throw new Exception("广告名称重复,请重新修改!");
            }

            string Sql = "";

            if (ai.adType == 11)
            {
                Sql = "Update " + Pre + "ads Set adName=@adName,ClassID=@ClassID,adType=@adType,leftPic='',rightPic=''," +
                      "leftSize='',rightSize='',LinkURL='',CondiTF=@CondiTF,maxShowClick=@maxShowClick,TimeOutDay=@TimeOutDay," +
                      "maxClick=@maxClick,AdTxtNum=@AdTxtNum,isLock=@isLock Where AdID=@AdID";

                string str_DeltxtSql = "Delete From " + Pre + "adstxt Where AdID='" + ai.AdID + "'";
                DbHelper.ExecuteNonQuery(CommandType.Text, str_DeltxtSql, null);

                string[] arr_Content = ai.AdTxtContent.Split(',');
                string[] arr_Css = ai.AdTxtCss.Split(',');
                string[] arr_Link = ai.AdTxtLink.Split(',');
                string str_txtSql = "";
                for (int i = 0; i < arr_Content.Length; i++)
                {
                    str_txtSql = "Insert Into " + Pre + "adstxt(AdID,AdTxt,AdCss,AdLink) Values('" + ai.AdID + "','" + arr_Content[i].ToString() + "','" + arr_Css[i].ToString() + "','" + arr_Link[i].ToString() + "')";
                    DbHelper.ExecuteNonQuery(CommandType.Text, str_txtSql, null);
                }
            }
            else
            {
                Sql = "Update " + Pre + "ads Set adName=@adName,ClassID=@ClassID,adType=@adType,leftPic=@leftPic," +
                      "rightPic=@rightPic,leftSize=@leftSize,rightSize=@rightSize,LinkURL=@LinkURL,CondiTF=@CondiTF," +
                      "maxShowClick=@maxShowClick,TimeOutDay=@TimeOutDay,maxClick=@maxClick,AdTxtNum=0,isLock=@isLock," +
                      "CycTF=@CycTF,CycAdID=@CycAdID,CycSpeed=@CycSpeed,CycDic=@CycDic Where AdID=@AdID";
            }

            SqlParameter[] param = GetAdsParameters(ai);
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, param);
        }

        public DataTable getAdsDomain()
        {
            string str_Sql = "";
            if (SiteID == "0")
                str_Sql = "Select SiteDomain From " + Pre + "sys_Param";
            else
                str_Sql = "Select [Domain] From " + Pre + "news_site Where ChannelID='" + SiteID + "'";

            return DbHelper.ExecuteTable(CommandType.Text, str_Sql, null);

⌨️ 快捷键说明

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