/// <summary> /// Updates the poll specified by pollID. /// </summary> /// <param name="pollID">The ID of the poll to update.</param> /// <param name="text">The text of the question of the poll.</param> /// <param name="startDate">The date and time on which the poll will start.</param> /// <param name="voteMode">The selection mode of the poll, single or multiple.</param> /// <param name="enabled">Whether the poll is enabled or not.</param> /// <param name="allowWriteIns">Whether the poll allows write-in votes.</param> /// <param name="category">The category of the poll.</param> protected internal override void UpdatePoll(Int32 pollID, String text, DateTime startDate, VoteSelectionMode voteMode, Boolean enabled, Boolean allowWriteIns, String category) { if (text == null) { throw new ArgumentNullException("text"); } if (!Enum.IsDefined(typeof(VoteSelectionMode), voteMode)) { throw new System.ComponentModel.InvalidEnumArgumentException("voteMode", (Int32)voteMode, typeof(VoteSelectionMode)); } if (category == null) { category = String.Empty; } SqlCommand cmd = new SqlCommand(); cmd.CommandText = "UPDATE " + PollsTable + " SET Text = @Text, StartDate = @StartDate, VoteMode = @VoteMode, Enabled = @Enabled, AllowWriteIns = @AllowWriteIns, Category = @Category WHERE (PollID = @PollID)"; cmd.Parameters.Add("@Text", SqlDbType.NVarChar, 255).Value = text; cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = startDate; cmd.Parameters.Add("@VoteMode", SqlDbType.NVarChar).Value = voteMode.ToString(); cmd.Parameters.Add("@Enabled", SqlDbType.Bit).Value = enabled; cmd.Parameters.Add("@AllowWriteIns", SqlDbType.Bit).Value = allowWriteIns; cmd.Parameters.Add("@Category", SqlDbType.NVarChar, 255).Value = category; cmd.Parameters.Add("@PollID", SqlDbType.Int).Value = pollID; ExecuteNonQuery(cmd); }
/// <summary> /// Adds a new poll with the given properties. /// </summary> /// <param name="text">The text of the question of the poll.</param> /// <param name="startDate">The date and time on which the poll will start.</param> /// <param name="voteMode">The selection mode of the poll, single or multiple.</param> /// <param name="enabled">Whether the poll is enabled or not.</param> /// <param name="allowWriteIns">Whether the poll allows write-in votes.</param> /// <param name="category">The category of the poll.</param> /// <returns>The ID assigned to the poll.</returns> protected internal override void InsertPoll(String text, DateTime startDate, VoteSelectionMode voteMode, Boolean enabled, Boolean allowWriteIns, String category) { if (text == null) { throw new ArgumentNullException("text"); } if (!Enum.IsDefined(typeof(VoteSelectionMode), voteMode)) { throw new System.ComponentModel.InvalidEnumArgumentException("voteMode", (Int32)voteMode, typeof(VoteSelectionMode)); } if (category == null) { category = String.Empty; } SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO " + PollsTable + " (Text, StartDate, VoteMode, Enabled, AllowWriteIns, Category) VALUES (@Text, @StartDate, @VoteMode, @Enabled, @AllowWriteIns, @Category)"; cmd.Parameters.Add("@Text", SqlDbType.NVarChar, 255).Value = text; cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = startDate; cmd.Parameters.Add("@VoteMode", SqlDbType.NVarChar).Value = voteMode.ToString(); cmd.Parameters.Add("@Enabled", SqlDbType.Bit).Value = enabled; cmd.Parameters.Add("@AllowWriteIns", SqlDbType.Bit).Value = allowWriteIns; cmd.Parameters.Add("@Category", SqlDbType.NVarChar, 255).Value = category; ExecuteNonQuery(cmd); }
/// <summary> /// Updates the poll specified by pollID. /// </summary> /// <param name="pollID">The ID of he poll to update.</param> /// <param name="text">The text of the question of the poll.</param> /// <param name="startDate">The date and time on which the poll will start.</param> /// <param name="voteMode">The selection mode of the poll, single or multiple.</param> /// <param name="enabled">Whether the poll is enabled or not.</param> /// <param name="allowWriteIns">Whether the poll will allow write-in votes.</param> /// <param name="category">The category of the poll.</param> protected internal override void UpdatePoll(Int32 pollID, String text, DateTime startDate, VoteSelectionMode voteMode, Boolean enabled, Boolean allowWriteIns, String category) { if (text == null) { throw new ArgumentNullException("text"); } if (!Enum.IsDefined(typeof(VoteSelectionMode), voteMode)) { throw new System.ComponentModel.InvalidEnumArgumentException("voteMode", (Int32)voteMode, typeof(VoteSelectionMode)); } if (category == null) { category = String.Empty; } OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = "UPDATE " + PollsTable + " SET [Text] = ?, StartDate = ?, VoteMode = ?, Enabled = ?, AllowWriteIns = ?, Category = ? WHERE (PollID = ?)"; cmd.Parameters.Add("@Question", OleDbType.VarWChar, 255, "Question").Value = text; cmd.Parameters.Add("@StartDate", OleDbType.Date, 8, "StartDate").Value = startDate; cmd.Parameters.Add("@VoteMode", OleDbType.VarWChar, 10, "VoteMode").Value = voteMode.ToString(); cmd.Parameters.Add("@Enabled", OleDbType.Boolean, 1, "Enabled").Value = enabled; cmd.Parameters.Add("@AllowWriteIns", OleDbType.Boolean, 1, "AllowWriteIns").Value = allowWriteIns; cmd.Parameters.Add("@Category", OleDbType.VarWChar, 255, "Category").Value = category; cmd.Parameters.Add("@Original_PollID", OleDbType.Integer, 4, "PollID").Value = pollID; ExecuteNonQuery(cmd); }