/// <summary>
 /// Copies the elements of the specified <see cref="PollOptionInfo">PollOptionInfo</see> array to the end of the collection.
 /// </summary>
 /// <param name="value">An array of type <see cref="PollOptionInfo">PollOptionInfo</see> containing the Components to add to the collection.</param>
 public void AddRange(PollOptionInfo[] value)
 {
     for (int i = 0; (i < value.Length); i = (i + 1))
     {
         this.Add(value[i]);
     }
 }
예제 #2
0
파일: Polls.cs 프로젝트: Vinna/DeepInSummer
 /// <summary>
 /// 通过主题ID获取相应的投票信息
 /// </summary>
 /// <param name="tid">主题id</param>
 /// <returns>投票选项集合</returns>
 public static List<PollOptionInfo> GetPollOptionInfoCollection(int tid)
 {
     List<PollOptionInfo> pollOptionInfoList = new List<PollOptionInfo>();
     IDataReader idatareader = DatabaseProvider.GetInstance().GetPollOptionList(tid);
     PollOptionInfo polloptioninfo;
     while (idatareader.Read())
     {
         polloptioninfo = new PollOptionInfo();
         polloptioninfo.Polloptionid = TypeConverter.ObjectToInt(idatareader["polloptionid"], 0);
         polloptioninfo.Displayorder = TypeConverter.ObjectToInt(idatareader["displayorder"], 0);
         polloptioninfo.Pollid = TypeConverter.ObjectToInt(idatareader["pollid"], 0);
         polloptioninfo.Polloption = idatareader["polloption"].ToString().Trim();
         polloptioninfo.Tid = TypeConverter.ObjectToInt(idatareader["tid"], 0);
         polloptioninfo.Voternames = idatareader["voternames"].ToString().Trim();
         polloptioninfo.Votes = TypeConverter.ObjectToInt(idatareader["votes"], 0);
         pollOptionInfoList.Add(polloptioninfo);
     }
     idatareader.Close();
     return pollOptionInfoList;
 }
예제 #3
0
파일: Polls.cs 프로젝트: ichari/ichari
        /// <summary>
        /// 创建一个投票
        /// </summary>
        /// <param name="tid">关联的主题id</param>
        /// <param name="multiple">投票类型, 0为单选, 1为多选</param>
        /// <param name="itemcount">投票项总数</param>
        /// <param name="itemnamelist">投票项目列表</param>
        /// <param name="itemvaluelist">投票项目结果列表</param>
        /// <param name="usernamelist">用户名列表</param>
        /// <param name="enddatetime">截止日期</param>
        /// <param name="userid">用户id</param>
        /// <param name="maxchoices">最多可选项数</param>
        /// <param name="visible">提交投票后结果才可见, 0为可见, 1为投票后可见</param>
        /// <returns>成功则返回true, 否则返回false</returns>
        public static bool CreatePoll(int tid, int multiple, int itemcount, string itemnamelist, string itemvaluelist, string enddatetime, int userid, int maxchoices, int visible)
        {
            string[] itemname = Utils.SplitString(itemnamelist, "\r\n");
            string[] itemvalue = Utils.SplitString(itemvaluelist, "\r\n");
            if ((itemname.Length != itemcount) || (itemvalue.Length != itemcount))
            {
                return false;
            }

            PollInfo pollinfo = new PollInfo();
            pollinfo.Displayorder = 0;
            pollinfo.Expiration = Utils.GetStandardDateTime(enddatetime);
            pollinfo.Maxchoices = maxchoices;
            pollinfo.Multiple = multiple;
            pollinfo.Tid = tid;
            pollinfo.Uid = userid;
            pollinfo.Visible = visible;

            int pollid = DatabaseProvider.GetInstance().CreatePoll(pollinfo);

            if (pollid > 0)
            {
                for (int i = 0; i < itemcount; i++)
                {
                    PollOptionInfo polloptioninfo = new PollOptionInfo();
                    polloptioninfo.Displayorder = i + 1;
                    polloptioninfo.Pollid = pollid;
                    polloptioninfo.Polloption = Utils.GetSubString(itemname[i], 80, "");
                    polloptioninfo.Tid = tid;
                    polloptioninfo.Voternames = "";
                    polloptioninfo.Votes = 0;
                    DatabaseProvider.GetInstance().CreatePollOption(polloptioninfo);
                }
                return true;
            }
            else
            {
                return false;
            }
        }
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(PollOptionInfo value)
 {
     return this.List.IndexOf(value);
 }
예제 #5
0
파일: Polls.cs 프로젝트: Vinna/DeepInSummer
 /// <summary>
 /// 删除指定的投票项
 /// </summary>
 /// <param name="pollInfoOption">投票项</param>
 /// <returns></returns>
 public static bool DeletePollOption(PollOptionInfo pollInfoOption)
 {
     return DatabaseProvider.GetInstance().DeletePollOption(pollInfoOption);
 }
예제 #6
0
 public void Insert(int index, PollOptionInfo value)
 {
     List.Insert(index, value);
 }
예제 #7
0
 public int CreatePollOption(PollOptionInfo pollOptionInfo)
 {
     DbParameter[] parms = {
                                DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,pollOptionInfo.Tid),
                                DbHelper.MakeInParam("@pollid",(DbType)SqlDbType.Int,4,pollOptionInfo.Pollid),
                                DbHelper.MakeInParam("@votes",(DbType)SqlDbType.Int,4,pollOptionInfo.Votes),
                                DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.Int,4,pollOptionInfo.Displayorder),
                                DbHelper.MakeInParam("@polloption",(DbType)SqlDbType.VarChar,80,pollOptionInfo.Polloption),
                                DbHelper.MakeInParam("@voternames",(DbType)SqlDbType.NText,0,pollOptionInfo.Voternames)
                            };
     string commandText = string.Format("INSERT INTO [{0}polloptions] ([tid] ,[pollid] ,[votes] ,[displayorder] ,[polloption] ,[voternames] ) VALUES (@tid, @pollid, @votes, @displayorder, @polloption, @voternames);SELECT SCOPE_IDENTITY()  AS 'polloptionid'",
                                         BaseConfigs.GetTablePrefix);
     return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms), -1);
 }
 /// <summary>
 /// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
 /// <param name="index">The index of the array at which to begin inserting.</param>
 public void CopyTo(PollOptionInfo[] array, int index)
 {
     this.List.CopyTo(array, index);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see> class containing the specified array of <see cref="PollOptionInfo">PollOptionInfo</see> Components.
 /// </summary>
 /// <param name="value">An array of <see cref="PollOptionInfo">PollOptionInfo</see> Components with which to initialize the collection. </param>
 public PollOptionInfoCollection(PollOptionInfo[] value)
 {
     this.AddRange(value);
 }
예제 #10
0
파일: Polls.cs 프로젝트: wenysky/dnt31-lite
        /// <summary>
        /// 更新一个投票
        /// </summary>
        /// <param name="tid">关联的主题id</param>
        /// <param name="multiple">投票类型, 0为单选, 1为多选</param>
        /// <param name="itemcount">投票项总数</param>
        /// <param name="polloptionidlist">投票项id列表</param> 
        /// <param name="itemnamelist">投票项目列表</param>
        /// <param name="itemdisplayorderlist">投票项目排列顺序列表</param>
        /// <param name="enddatetime">截止日期</param>
        /// <param name="maxchoices">最多可选项数</param>
        /// <param name="visible">提交投票后结果才可见, 0为可见, 1为投票后可见</param>
        /// <returns>成功则返回true, 否则返回false</returns>
        public static bool UpdatePoll(int tid, int multiple, int itemcount, string polloptionidlist, string itemnamelist, string itemdisplayorderlist, string enddatetime, int maxchoices, int visible)
        {
            string[] itemname = Utils.SplitString(itemnamelist, "\r\n");
            string[] itemdisplayorder = Utils.SplitString(itemdisplayorderlist, "\r\n");
            string[] polloptionid = Utils.SplitString(polloptionidlist, "\r\n");

            if ((itemname.Length != itemcount) || (itemdisplayorder.Length != itemcount))
                return false;

            PollInfo pollinfo = Discuz.Data.Polls.GetPollInfo(tid);
            pollinfo.Expiration = Utils.GetStandardDateTime(enddatetime);
            pollinfo.Maxchoices = maxchoices;
            pollinfo.Multiple = multiple;
            pollinfo.Tid = tid;
            pollinfo.Visible = visible;

            bool result = false;
            if (pollinfo.Pollid > 0)
                result = Discuz.Data.Polls.UpdatePoll(pollinfo);

            if (result)
            {
                List<PollOptionInfo> pollOptionInfoList = Discuz.Data.Polls.GetPollOptionInfoCollection(pollinfo.Tid);
                int i = 0;

                //先作已存在的投票选项更新及新添加选项的添加操作
                bool optionexist;
                foreach (string optionid in polloptionid)
                {
                    optionexist = false;
                    foreach (PollOptionInfo polloptioninfo in pollOptionInfoList)
                    {
                        if (optionid == polloptioninfo.Polloptionid.ToString())
                        {
                            polloptioninfo.Pollid = pollinfo.Pollid;
                            polloptioninfo.Polloption = Utils.GetSubString(itemname[i], 80, "");
                            polloptioninfo.Displayorder = Utils.StrIsNullOrEmpty(itemdisplayorder[i]) ? i + 1 : Utils.StrToInt(itemdisplayorder[i], 0);
                            Discuz.Data.Polls.UpdatePollOption(polloptioninfo);
                            optionexist = true;
                            break;
                        }
                    }
                    if (!optionexist) //如果当前选项不存在,表示该选项为新添选项
                    {
                        PollOptionInfo polloptioninfo = new PollOptionInfo();
                        polloptioninfo.Displayorder = Utils.StrIsNullOrEmpty(itemdisplayorder[i]) ? i + 1 : Utils.StrToInt(itemdisplayorder[i], 0);
                        polloptioninfo.Pollid = pollinfo.Pollid;
                        polloptioninfo.Polloption = Utils.GetSubString(itemname[i], 80, "");
                        polloptioninfo.Tid = tid;
                        polloptioninfo.Voternames = "";
                        polloptioninfo.Votes = 0;
                        Discuz.Data.Polls.CreatePollOption(polloptioninfo);
                    }
                    i++;
                }

                foreach (PollOptionInfo polloptioninfo in pollOptionInfoList)
                {
                    //下面代码用于删除已去除的投票项
                    if (("\r\n" + polloptionidlist + "\r\n").IndexOf("\r\n" + polloptioninfo.Polloptionid + "\r\n") < 0)
                        Discuz.Data.Polls.DeletePollOption(polloptioninfo);
                }
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #11
0
파일: Polls.cs 프로젝트: ichari/ichari
 /// <summary>
 /// 通过主题ID获取相应的投票信息
 /// </summary>
 /// <param name="tid">主题id</param>
 /// <returns>投票选项集合</returns>
 public static PollOptionInfoCollection GetPollOptionInfoCollection(int tid)
 {
     PollOptionInfoCollection pollinfocoll = new PollOptionInfoCollection();
     IDataReader idatareader = DatabaseProvider.GetInstance().GetPollOptionList(tid);
     PollOptionInfo polloptioninfo;
     while (idatareader.Read())
     {
         polloptioninfo = new PollOptionInfo();
         polloptioninfo.Polloptionid = Utils.StrToInt(idatareader["polloptionid"], 0);
         polloptioninfo.Displayorder = Utils.StrToInt(idatareader["displayorder"], 0);
         polloptioninfo.Pollid = Utils.StrToInt(idatareader["pollid"], 0);
         polloptioninfo.Polloption = idatareader["polloption"].ToString().Trim();
         polloptioninfo.Tid = Utils.StrToInt(idatareader["tid"], 0);
         polloptioninfo.Voternames = idatareader["voternames"].ToString().Trim();
         polloptioninfo.Votes = Utils.StrToInt(idatareader["votes"], 0);
         pollinfocoll.Add(polloptioninfo);
     }
     idatareader.Close();
     return pollinfocoll;
 }
예제 #12
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(PollOptionInfo value)
 {
     return(this.List.Contains(value));
 }
예제 #13
0
 public int Add(PollOptionInfo value)
 {
     return(this.List.Add(value));
 }
예제 #14
0
 public void Remove(PollOptionInfo value)
 {
     List.Remove(value);
 }
예제 #15
0
 public void Insert(int index, PollOptionInfo value)
 {
     List.Insert(index, value);
 }
예제 #16
0
 public void Remove(PollOptionInfo value)
 {
     List.Remove(value);
 }
예제 #17
0
 public int CreatePollOption(PollOptionInfo polloptioninfo)
 {
     DbParameter[] parms = {
                                DbHelper.MakeInParam("@tid",DbType.Int32,4,polloptioninfo.Tid),
                                DbHelper.MakeInParam("@pollid",DbType.Int32,4,polloptioninfo.Pollid),
                                DbHelper.MakeInParam("@votes",DbType.Int32,4,polloptioninfo.Votes),
                                DbHelper.MakeInParam("@displayorder",DbType.Int32,4,polloptioninfo.Displayorder),
                                DbHelper.MakeInParam("@polloption",DbType.AnsiString,80,polloptioninfo.Polloption),
                                DbHelper.MakeInParam("@voternames",DbType.String,0,polloptioninfo.Voternames)
                            };
     string sql = "INSERT INTO [" + BaseConfigs.GetTablePrefix + "polloptions] ([tid] ,[pollid] ,[votes] ,[displayorder] ,[polloption] ,[voternames] ) VALUES (@tid, @pollid, @votes, @displayorder, @polloption, @voternames);SELECT SCOPE_IDENTITY()  AS 'polloptionid'";
     return Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, sql, parms), -1);
 }
예제 #18
0
 public int Add(PollOptionInfo value)
 {
     return this.List.Add(value);
 }
예제 #19
0
 public bool UpdatePollOption(PollOptionInfo polloptioninfo)
 {
     DbParameter[] parms = {
                                DbHelper.MakeInParam("@tid",DbType.Int32,4,polloptioninfo.Tid),
                                DbHelper.MakeInParam("@pollid",DbType.Int32,4,polloptioninfo.Pollid),
                                DbHelper.MakeInParam("@votes",DbType.Int32,4,polloptioninfo.Votes),
                                DbHelper.MakeInParam("@displayorder",DbType.Int32,4,polloptioninfo.Displayorder),
                                DbHelper.MakeInParam("@polloption",DbType.AnsiString,80,polloptioninfo.Polloption),
                                DbHelper.MakeInParam("@voternames",DbType.String,0,polloptioninfo.Voternames),
                                DbHelper.MakeInParam("@polloptionid",DbType.Int32,4,polloptioninfo.Polloptionid)
                            };
     string sql = "UPDATE [" + BaseConfigs.GetTablePrefix + "polloptions] set [tid] = @tid, [pollid] = @pollid, [votes] = @votes, [displayorder] = @displayorder, [polloption] = @polloption, [voternames] = @voternames WHERE [polloptionid] = @polloptionid";
     return DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms) > 0;
 }
예제 #20
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(PollOptionInfo value)
 {
     return this.List.Contains(value);
 }
예제 #21
0
 public bool DeletePollOption(PollOptionInfo polloptioninfo)
 {
     DbParameter[] parms = {
                                DbHelper.MakeInParam("@polloptionid",DbType.Int32,4,polloptioninfo.Polloptionid)
                            };
     string sql = "DELETE FROM [" + BaseConfigs.GetTablePrefix + "polloptions] WHERE [polloptionid] = @polloptionid";
     return DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms) > 0;
 }
예제 #22
0
 public bool UpdatePollOption(PollOptionInfo pollOptionInfo)
 {
     DbParameter[] parms = {
                                DbHelper.MakeInParam("@tid",(DbType)SqlDbType.Int,4,pollOptionInfo.Tid),
                                DbHelper.MakeInParam("@pollid",(DbType)SqlDbType.Int,4,pollOptionInfo.Pollid),
                                DbHelper.MakeInParam("@votes",(DbType)SqlDbType.Int,4,pollOptionInfo.Votes),
                                DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.Int,4,pollOptionInfo.Displayorder),
                                DbHelper.MakeInParam("@polloption",(DbType)SqlDbType.VarChar,80,pollOptionInfo.Polloption),
                                DbHelper.MakeInParam("@voternames",(DbType)SqlDbType.NText,0,pollOptionInfo.Voternames),
                                DbHelper.MakeInParam("@polloptionid",(DbType)SqlDbType.Int,4,pollOptionInfo.Polloptionid)
                            };
     string commandText = string.Format("UPDATE [{0}polloptions] set [tid] = @tid, [pollid] = @pollid, [votes] = @votes, [displayorder] = @displayorder, [polloption] = @polloption, [voternames] = @voternames WHERE [polloptionid] = @polloptionid",
                                         BaseConfigs.GetTablePrefix);
     return DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms) > 0;
 }
예제 #23
0
파일: Polls.cs 프로젝트: Vinna/DeepInSummer
 /// <summary>
 /// 创建投票项
 /// </summary>
 /// <param name="polloptioninfocoll">投票项</param>
 /// <returns></returns>
 public static void CreatePollOption(PollOptionInfo polloptioninfo)
 {
     DatabaseProvider.GetInstance().CreatePollOption(polloptioninfo);
 }
예제 #24
0
 public bool DeletePollOption(PollOptionInfo pollOptionInfo)
 {
     string commandText = string.Format("DELETE FROM [{0}polloptions] WHERE [polloptionid] = {1}",
                                         BaseConfigs.GetTablePrefix,
                                         pollOptionInfo.Polloptionid);
     return DbHelper.ExecuteNonQuery(CommandType.Text, commandText) > 0;
 }
예제 #25
0
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="PollOptionInfoCollection">PollOptionInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(PollOptionInfo value)
 {
     return(this.List.IndexOf(value));
 }