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

📄 survey.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 3 页
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using NetCMS.DALFactory;
using NetCMS.Model;
using System.Text.RegularExpressions;
using System.Text;
using System.Reflection;
using NetCMS.DALProfile;
using NetCMS.Config;
namespace NetCMS.DALSQLServer
{
    public class Survey : DbBase, ISurvey
    {
        #region ManageVote.aspx
        public DataTable sel_voteById(int idt, int flag)
        {
            #region
            string Sql = null;
            if (flag == 0)//setClass.aspx
            {
                Sql = "Select vid,ClassName,Description From " + Pre + "vote_Class where SiteID='" + NetCMS.Global.Current.SiteID + "' and vid=" + idt;
            }
            else if (flag == 1)//setClass.aspx
            {
                Sql = "Select TID From " + Pre + "Vote_Topic where vid=" + idt + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 2)//setItem.aspx
            {
                Sql = "Select TID,IID,ItemName,ItemMode,PicSrc,DisColor,VoteCount,ItemDetail From " + Pre + "vote_Item where IID=" + idt + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 3)//setSteps.aspx
            {
                Sql = "Select SID,TIDS,Steps,TIDU From " + Pre + "vote_Steps where SiteID='" + NetCMS.Global.Current.SiteID + "' and SID=" + idt;
            }
            return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
            #endregion
        }
        public string GetVoteTitle(int tid)
        {
            string Sql = "Select [Title] From " + Pre + "Vote_Topic where SiteID='" + NetCMS.Global.Current.SiteID + "' and TID=" + tid;
            return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
        }
        public IList<VoteItemInfo> GetItemsByTopic(int tid)
        {
            IList<VoteItemInfo> list = new List<VoteItemInfo>();
            string SiteID = "0";
            if (!NetCMS.Global.Current.IsTimeout())
            {
                SiteID = NetCMS.Global.Current.SiteID;
            }
            string Sql = "Select [IID],[TID],[ItemName],[ItemMode],[PicSrc],[DisColor],[VoteCount],[ItemDetail],[SiteID] From " + Pre + "vote_Item where TID = " + tid + " and SiteID='" + SiteID + "' order by IID asc";
            IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
            while (rd.Read())
            {
                VoteItemInfo info = new VoteItemInfo();
                info.IID = rd.GetInt32(0);
                info.TID = rd.GetInt32(1);
                if (!rd.IsDBNull(2)) info.ItemName = rd.GetString(2);
                if (!rd.IsDBNull(3)) info.ItemMode = rd.GetByte(3);
                if (!rd.IsDBNull(4)) info.PicSrc = rd.GetString(4);
                if (!rd.IsDBNull(5)) info.DisColor = rd.GetString(5);
                if (!rd.IsDBNull(6)) info.VoteCount = rd.GetInt32(6);
                if (!rd.IsDBNull(7)) info.ItemDetail = rd.GetString(7);
                if (!rd.IsDBNull(8)) info.SiteID = rd.GetString(8);
                list.Add(info);
            }
            rd.Close();
            return list;
        }
        public VoteTopicInfo GetTopic(int tid)
        {
            VoteTopicInfo info = new VoteTopicInfo();
            info.TID = 0;
            string SiteID = "0";
            if (!NetCMS.Global.Current.IsTimeout())
            {
                SiteID = NetCMS.Global.Current.SiteID;
            }
            string Sql = "Select [TID],[VID],[Title],[Type],[DisMode],[StartDate],[EndDate],[ItemMode],[SiteID],[AllowFillIn],[SeriesMode]";
            Sql += " From " + Pre + "Vote_Topic where TID = " + tid + " and SiteID='" + SiteID + "'";
            IDataReader rd = DbHelper.ExecuteReader(CommandType.Text, Sql, null);
            if (rd.Read())
            {
                info.TID = rd.GetInt32(0);
                info.VID = rd.GetInt32(1);
                info.Title = rd.GetString(2);
                if (!rd.IsDBNull(3)) info.Type = rd.GetByte(3);
                if (!rd.IsDBNull(5)) info.DisMode = rd.GetByte(4);
                if (!rd.IsDBNull(6)) info.StartDate = rd.GetDateTime(5);
                if (!rd.IsDBNull(7)) info.EndDate = rd.GetDateTime(6);
                if (!rd.IsDBNull(8)) info.ItemMode = rd.GetByte(7);
                if (!rd.IsDBNull(10)) info.SiteID = rd.GetString(8);
                info.AllowFillIn = rd.GetBoolean(9);
                info.SeriesMode = rd.GetByte(10);
            }
            rd.Close();
            return info;
        }
        public object GetLastVoteTimeByIP(int TID, string IPAddr, string UserNum)
        {
            string Sql = "select top 1 VoteTime from " + Pre + "vote_Manage where TID=" + TID + " and VoteIp=@VoteIp and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            SqlParameter[] Param;
            if (UserNum != null && UserNum.Trim() != string.Empty)
            {
                Sql += " and UserNumber=@UserNumber";
                Param = new SqlParameter[]{new SqlParameter("@VoteIp", IPAddr),new SqlParameter("@UserNumber", UserNum)};
            }
            else
            { 
                Param = new SqlParameter[]{new SqlParameter("@VoteIp", IPAddr)};
            }
            Sql += " order by VoteTime desc";
            return DbHelper.ExecuteScalar(CommandType.Text, Sql, Param);
        }
        public string GetVoteItemName(int iid)
        {
            string Sql = "Select ItemName From " + Pre + "vote_Item where IID=" + iid + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            return Convert.ToString(DbHelper.ExecuteScalar(CommandType.Text, Sql, null));
        }

        public DataTable sel_voteByStr(string str, int flag)
        {
            #region
            string Sql = null;
            if (flag == 0)
            {
                Sql = "Select Title,TID From " + Pre + "Vote_Topic where Title like '%" + str + "%' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 1)
            {
                Sql = "Select TID From " + Pre + "Vote_Topic where vid in(" + str + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 2)
            {
                Sql = "Select ClassName,VID From " + Pre + "vote_Class where ClassName like '%" + str + "%' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            return DbHelper.ExecuteTable(CommandType.Text, Sql, null);
            #endregion
        }

        public int Del_voteManage(int RID, int flag)
        {
            #region
            string Sql = null;
            if (flag == 0)
            {
                Sql = "Delete From " + Pre + "vote_Manage where SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 1)
            {
                Sql = "Delete From " + Pre + "vote_Manage where rid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 2)
            {
                Sql = "Delete From " + Pre + "vote_Item where iid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 3)
            {
                Sql = "Delete From " + Pre + "vote_Steps where sid=" + RID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
            #endregion
        }

        public bool Del_voteSql(int VID, int flag)
        {
            #region 删除Vote相关信息
            string Sql = null;
            if (flag == 0)
            {
                Sql = "Delete From " + Pre + "vote_Class where vid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 1)
            {
                Sql = "Delete From " + Pre + "Vote_Topic where vid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 2)
            {
                Sql = "Delete From " + Pre + "vote_Item where TID=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 3)
            {
                Sql = "Delete From " + Pre + "vote_Steps where TIDS=" + VID + " or TIDU=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 4)
            {
                Sql = "Delete From " + Pre + "vote_Manage where TID=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 5)
            {
                Sql = "Delete From " + Pre + "Vote_Topic where tid=" + VID + " and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }

            int i = DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
            if (i == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
            #endregion
        }

        public void del_voteInfoSql(string CheckboxArray, bool flag)
        {
            #region
            string Sql = null;
            if (flag)
            {
                Sql = "Delete From " + Pre + "vote_Class where vid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else
            {
                Sql = "Delete From " + Pre + "Vote_Topic where vid in(" + CheckboxArray + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
            #endregion
        }

        public void del_strVoteSql(int tid, int flag)
        {
            #region
            string Sql = null;
            if (flag == 0)
            {
                Sql = "Delete From " + Pre + "vote_Item where TID in(" + tid + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }
            else if (flag == 1)
            {
                Sql = "Delete From " + Pre + "vote_Steps where TIDS in(" + tid + ") or TIDU in(" + tid + ") and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            }

⌨️ 快捷键说明

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