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

📄 vote_ajax.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.Collections.Generic;
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.Content.Common;

public partial class survey_Vote_Ajax : NetCMS.Web.UI.BasePage
{
    private struct StFormTxt
    {
        public int id;
        public string value;
    }
    Survey sur = new Survey();
    protected void Page_Load(object sender, EventArgs e)
    {
        int tid = int.Parse(Request.Form["TID"]);
        string IID = string.Empty;
        if (Request.Form["SelVoteItems"] != null)
            IID = Request.Form["SelVoteItems"];
        IID = IID.Replace(" ", "");
        string[] TmpArr = IID.Split(',');
        string othercontent = string.Empty;
        if (Request.Form["TxtDefine"] != null && Request.Form["TxtDefine"].Trim() != string.Empty)
        {
            othercontent = Request.Form["TxtDefine"].Trim();
        }
        string strvip = NetCMS.Common.Public.getUserIP();
        DataTable dt_sys = new DataTable();
        dt_sys = sur.sel_voteInfo(1);
        int IPtime = 0;
        if (dt_sys.Rows[0]["IPtime"] != DBNull.Value)
            IPtime = Convert.ToInt32(dt_sys.Rows[0]["IPtime"]);//IP限制时间;
        int IsReg = 0;
        if (dt_sys.Rows[0]["IsReg"] != DBNull.Value)
            IsReg = Convert.ToInt32(dt_sys.Rows[0]["IsReg"]);//是否注册;
        string IpLimit = dt_sys.Rows[0]["IpLimit"].ToString();//IP地址限制;
        DateTime nowtime = DateTime.Now;
        DateTime timesy = nowtime;
        object lastm = null;
        if (IsReg == 1)
        {
            if (NetCMS.Global.Current.IsTimeout())//是否注册判断
            {
                Response.Write("对不起,您需要登录后才能投票");
                Response.End();
                return;
            }
            else
                lastm = sur.GetLastVoteTimeByIP(tid, strvip, NetCMS.Global.Current.UserNum);
        }
        else
        {
            lastm = sur.GetLastVoteTimeByIP(tid, strvip, null);
        }
        if (sur.sel_IP() == 1)
        {
            Response.Write("抱歉,您得IP被限制不能投票");
            Response.End();
            return;
        }
        if (IPtime > 0 && lastm != null && lastm != DBNull.Value)
        {
            timesy = (DateTime)lastm;
            TimeSpan st = nowtime - timesy;
            if (st.TotalMinutes < IPtime)
            {
                Response.Write("抱歉,请等待" + IPtime + "分钟后再进行投票");
                Response.End();
                return;
            }
        }
        List<int> iid = new List<int>();
        if (othercontent.Trim() != string.Empty)
            iid.Add(0);
        for (int i = 0; i < TmpArr.Length; i++)
        {
            if (TmpArr[i] != null && TmpArr[i].Trim() != string.Empty)
                iid.Add(int.Parse(TmpArr[i]));
        }
        if (iid.Count > 0)
        {
            try
            {
                sur.add_voteManage(iid.ToArray(), tid, othercontent, strvip, NetCMS.Global.Current.UserNum);
                Response.Write("投票成功!感谢您的投票!");
            }
            catch
            {
                Response.Write("投票错误!");
            }
        }
        else
        {
            Response.Write("您没有选中投票的选项!");
        }
        Response.End();
    }
}

⌨️ 快捷键说明

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