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

📄 survey.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 3 页
字号:
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
            }
        }
        #endregion

        #region setSteps.aspx
        public int sel_Str_CheckSql(string Str_vote_CNameSe, string Str_vote_CNameUse)
        {
            string Sql = "Select count(*) From " + Pre + "vote_Steps Where TIDS='" + Str_vote_CNameSe + "' and TIDU='" + Str_vote_CNameUse + "' and SiteID='" + NetCMS.Global.Current.SiteID + "'";
            return (int)DbHelper.ExecuteScalar(CommandType.Text, Sql, null);
        }
        public int Add_Str_InSql(string Str_vote_CNameSe, string Str_vote_CNameUse, string Str_StepsN, string SiteID)
        {
            string Sql = "Insert into " + Pre + "vote_Steps (TIDS,TIDU,Steps,SiteID) Values('" + Str_vote_CNameSe + "','" + Str_vote_CNameUse + "','" + Str_StepsN + "','" + SiteID + "')";
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
        }

        public int update_voteSteps(string Str_votecnameEditse, string Str_votecnameEditue, string Str_NumEdit, int SID)
        {
            string Sql = "Update " + Pre + "vote_Steps Set TIDS='" + Str_votecnameEditse + "',TIDU='" + Str_votecnameEditue + "',Steps='" + Str_NumEdit + "'  where SiteID='" + NetCMS.Global.Current.SiteID + "' and sid=" + SID;
            return DbHelper.ExecuteNonQuery(CommandType.Text, Sql, null);
        }
        #endregion

        #region setTitle.aspx
        public int EditTopic(VoteTopicInfo info)
        {
            SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
            cn.Open();
            try
            {
                string Sql = "select count(TID) from " + Pre + "Vote_Topic where Title=@Title";
                if (info.TID > 0)
                {
                    Sql += " and TID<>" + info.TID;
                }
                SqlParameter Pm = new SqlParameter("@Title", info.Title);
                int n = (int)DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Pm);
                if (n > 0)
                    throw new Exception("该投票标题已经存在!");
                Sql = "Insert into " + Pre + "Vote_Topic (VID,Title,Type,DisMode,StartDate,EndDate,ItemMode,SiteID,AllowFillIn,SeriesMode) ";
                Sql += " Values (@VID,@Title,@Type,@DisMode,@StartDate,@EndDate,@ItemMode,@SiteID,@AllowFillIn,@SeriesMode)";
                if (info.TID > 0)
                {
                    Sql = "Update " + Pre + "Vote_Topic Set VID=@VID,Title=@Title,Type=@Type,DisMode=@DisMode,";
                    Sql += "StartDate=@StartDate,EndDate=@EndDate,ItemMode=@ItemMode,AllowFillIn=@AllowFillIn,SeriesMode=@SeriesMode where SiteID='" + NetCMS.Global.Current.SiteID + "' and tid=" + info.TID;
                }
                SqlParameter[] Param = new SqlParameter[10];
                Param[0] = new SqlParameter("@VID", SqlDbType.Int);
                Param[0].Value = info.VID;
                Param[1] = new SqlParameter("@Title", SqlDbType.NVarChar, 50);
                Param[1].Value = info.Title;
                Param[2] = new SqlParameter("@Type", SqlDbType.TinyInt);
                Param[2].Value = info.Type;
                Param[3] = new SqlParameter("@SeriesMode", SqlDbType.TinyInt);
                Param[3].Value = info.SeriesMode;
                Param[4] = new SqlParameter("@DisMode", SqlDbType.TinyInt);
                Param[4].Value = info.DisMode;
                Param[5] = new SqlParameter("@StartDate", SqlDbType.DateTime);
                Param[5].Value = info.StartDate;
                Param[6] = new SqlParameter("@EndDate", SqlDbType.DateTime);
                Param[6].Value = info.EndDate;
                Param[7] = new SqlParameter("@ItemMode", SqlDbType.TinyInt);
                Param[7].Value = info.ItemMode;
                Param[8] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
                Param[8].Value = info.SiteID;
                Param[9] = new SqlParameter("@AllowFillIn", SqlDbType.Bit);
                if (info.AllowFillIn)
                    Param[9].Value = 1;
                else
                    Param[9].Value = 0;
                return DbHelper.ExecuteNonQuery(cn, CommandType.Text, Sql, Param);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
            }
        }
        #endregion
        public void add_voteManage(int[] SelIID, int tid, string othercontent, string strvip, string UserNum)
        {
            string Sql;
            SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
            cn.Open();
            if (othercontent.Trim() != string.Empty)
            {
                Sql = "select Type,AllowFillIn from " + Pre + "Vote_Topic where TID=" + tid;
                IDataReader rd = DbHelper.ExecuteReader(cn, CommandType.Text, Sql, null);
                if (rd.Read())
                {
                    if (!rd.GetBoolean(1))
                        othercontent = string.Empty;
                    if (rd.GetByte(0) == 0 && SelIID.Length > 0)
                        othercontent = string.Empty;
                }
                rd.Close();
            }
            SqlTransaction tran = cn.BeginTransaction();
            try
            {
                foreach (int id in SelIID)
                {
                    if (id == 0 && othercontent.Trim() == string.Empty)
                        continue;
                    Sql = "Insert into " + Pre + "vote_Manage (IID,TID,OtherContent,VoteIp,VoteTime,UserNumber,SiteID) Values (@IID,@TID,@OtherContent,@VoteIp,'" + DateTime.Now + "',@UserNumber,@SiteID)";
                    SqlParameter[] Param = new SqlParameter[6];
                    Param[0] = new SqlParameter("@IID", SqlDbType.Int);
                    Param[0].Value = id;
                    Param[1] = new SqlParameter("@TID", SqlDbType.Int);
                    Param[1].Value = tid;
                    Param[2] = new SqlParameter("@OtherContent", SqlDbType.NVarChar, 50);
                    if (othercontent.Trim() == string.Empty)
                        Param[2].Value = DBNull.Value;
                    else
                        Param[2].Value = othercontent;
                    Param[3] = new SqlParameter("@VoteIp", SqlDbType.NVarChar, 15);
                    Param[3].Value = strvip;
                    Param[4] = new SqlParameter("@UserNumber", SqlDbType.NVarChar, 15);
                    if (UserNum == null || UserNum.Trim() == string.Empty)
                        Param[4].Value = DBNull.Value;
                    else
                        Param[4].Value = UserNum;
                    Param[5] = new SqlParameter("@SiteID", SqlDbType.NVarChar, 12);
                    if (NetCMS.Global.Current.IsTimeout())
                        Param[5].Value = DBNull.Value;
                    else
                        Param[5].Value = NetCMS.Global.Current.SiteID;
                    DbHelper.ExecuteNonQuery(CommandType.Text, Sql, Param);
                }
                tran.Commit();
            }
            catch
            {
                tran.Rollback();
                throw;
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
            }
        }
        public int sel_IP()
        {
            int PageError = 0;
            string IPLIST = "";
            string LoginIP = NetCMS.Global.Current.ClientIP;
            string IPSQL = "select IpLimit from " + Pre + "vote_Param";
            object IPDT = DbHelper.ExecuteScalar(CommandType.Text, IPSQL, null);
            if (IPDT != null && IPDT != DBNull.Value)
            {
                IPLIST = IPDT.ToString();
                if (IPLIST != "" && IPLIST != null)
                {
                    int IPTF = 0;
                    string[] arrIP = IPLIST.Split(new Char[] { '|' });
                    for (int i = 0; i < arrIP.Length; i++)
                    {
                        if (arrIP[i].IndexOf('*') >= 0)
                        {
                            string strIP = arrIP[i];
                            string[] IPR = strIP.Split(new Char[] { '.' });
                            string[] IPR1 = LoginIP.Split(new Char[] { '.' });
                            if (IPR[2] == "*")
                            {
                                if (IPR1[0] + IPR1[1] == IPR[0] + IPR[1])
                                {
                                    IPTF = 1;
                                }
                            }
                            else if (IPR[3] == "*")
                            {
                                if (IPR1[0] + IPR1[1] + IPR1[2] == IPR[0] + IPR[1] + IPR[2])
                                {
                                    IPTF = 1;
                                }
                            }
                        }
                        else
                        {
                            if (arrIP[i].ToString() == LoginIP.ToString())
                            {
                                IPTF = 1;
                            }
                        }
                    }
                    if (IPTF == 1)
                    {
                        PageError = 1;
                    }
                }

            }
            return PageError;
        }

        public DataTable GetVoteStat(int tid, out int totalvote)
        {
            totalvote = 0;
            SqlConnection cn = new SqlConnection(DBConfig.CmsConString);
            cn.Open();
            try
            {
                string SiteID = "0";
                try
                {
                    SiteID = NetCMS.Global.Current.SiteID;
                }
                catch
                {

                }
                string Sql = "select count(rid) from " + Pre + "vote_Manage where tid=" + tid;
                totalvote = Convert.ToInt32(DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null));
                Sql = "select sum(VoteCount) from " + Pre + "vote_Item where tid=" + tid;
                object obj = DbHelper.ExecuteScalar(cn, CommandType.Text, Sql, null);
                if (obj != null && obj != DBNull.Value)
                    totalvote += (int)obj;
                Sql = "SELECT a.TID, a.IID, a.ItemName, a.ItemMode, a.PicSrc, a.DisColor,";
                Sql += "a.VoteCount, a.ItemDetail, COUNT(b.RID) AS Result FROM " + Pre + "vote_Item a LEFT OUTER JOIN ";
                Sql += Pre + "vote_manage b ON a.TID = b.TID AND a.IID = b.IID where a.tid=" + tid;
                Sql += " GROUP BY a.TID, a.IID, a.ItemName, a.ItemMode, a.PicSrc, a.DisColor,a.VoteCount, a.ItemDetail";
                return DbHelper.ExecuteTable(cn, CommandType.Text, Sql, null);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                    cn.Close();
            }
        }
    }
}
/*

*/

⌨️ 快捷键说明

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