Esempio n. 1
0
        protected void PollAnswerInsert_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            PollChoiceInfo choice = new PollChoiceInfo {PollId = Convert.ToInt32(Request.QueryString["pid"])};
            TextBox text = (TextBox) PollAnswerInsert.FindControl("NewPollAnswerDisplayText");
            TextBox order = (TextBox)PollAnswerInsert.FindControl("NewPollAnswerSortOrder");
            choice.DisplayText = text.Text;
            choice.Order = Convert.ToInt32(order.Text);
            Snitz.BLL.Polls.AddChoice(choice);

            Response.Redirect(Request.RawUrl);
        }
Esempio n. 2
0
 public void AddChoice(PollChoiceInfo pollChoice)
 {
     string strSql = "INSERT INTO " + Config.ForumTablePrefix + "POLLANSWERS (PollID,DisplayText,SortOrder) VALUES (@PollId,@Answer,@Order); SELECT SCOPE_IDENTITY();";
     List<SqlParameter> parms = new List<SqlParameter>
         {
             new SqlParameter("@PollID", SqlDbType.Int) {Value = pollChoice.PollId},
             new SqlParameter("@Order", SqlDbType.Int) {Value = pollChoice.Order},
             new SqlParameter("@Answer", SqlDbType.NVarChar) {Value = pollChoice.DisplayText}
         };
     SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
 }
Esempio n. 3
0
 public void AddChoice(PollChoiceInfo pollChoice)
 {
     string strSql = "INSERT INTO " + Config.ForumTablePrefix + "POLLANSWERS (PollID,DisplayText,SortOrder) VALUES (@PollId,@Answer,@Order)";
     List<OleDbParameter> parms = new List<OleDbParameter>
         {
             new OleDbParameter("@PollID", OleDbType.Numeric) {Value = pollChoice.PollId},
             new OleDbParameter("@Order", OleDbType.Numeric) {Value = pollChoice.Order},
             new OleDbParameter("@Answer", OleDbType.VarChar) {Value = pollChoice.DisplayText}
         };
     SqlHelper.ExecuteInsertQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
 }
Esempio n. 4
0
        public static void AddTopicPoll(int postid, string question, SortedList<int, string> choices)
        {
            IPoll dal = Factory<IPoll>.Create("Poll");
            PollInfo poll = new PollInfo {TopicId = postid, DisplayText = question};

            foreach (var choice in choices)
            {
                PollChoiceInfo pollchoice = new PollChoiceInfo {DisplayText = choice.Value, Order = choice.Key};
                poll.AddChoice(pollchoice);
            }
            dal.Add(poll);
        }
Esempio n. 5
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int choiceid = GridView1.GetNewValue<int>(e.RowIndex, 1);
            int pollid = Convert.ToInt32(Request.QueryString["pid"]);
            string displayText = GridView1.GetNewValue<string>(e.RowIndex, 2);
            int order = GridView1.GetNewValue<int>(e.RowIndex, 3);

            PollChoiceInfo choice = new PollChoiceInfo
            {
                Id = choiceid,
                DisplayText = displayText,
                PollId = pollid,
                Order = order
            };
            Snitz.BLL.Polls.UpdatePollAnswer(choice);
        }
Esempio n. 6
0
 public static void AddChoice(PollChoiceInfo choice)
 {
     IPoll dal = Factory<IPoll>.Create("Poll");
     dal.AddChoice(choice);
 }
Esempio n. 7
0
 public static void UpdatePollAnswer(PollChoiceInfo choice)
 {
     IPoll dal = Factory<IPoll>.Create("Poll");
     dal.UpdateChoice(choice);
 }
Esempio n. 8
0
        public void UpdateChoice(PollChoiceInfo pollChoice)
        {
            string strSql = "UPDATE " + Config.ForumTablePrefix + "POLLANSWERS SET PollID = @PollId,DisplayText = @Answer,SortOrder = @Order WHERE PollAnswerID=@Id";
            List<OleDbParameter> parms = new List<OleDbParameter>
                {
                    new OleDbParameter("@PollID", OleDbType.Numeric) {Value = pollChoice.PollId},
                    new OleDbParameter("@Order", OleDbType.Numeric) {Value = pollChoice.Order},
                    new OleDbParameter("@Answer", OleDbType.VarChar) {Value = pollChoice.DisplayText},
                    new OleDbParameter("@Id", OleDbType.Numeric) {Value = pollChoice.Id}
                };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
        }
Esempio n. 9
0
        public void Update(PollInfo poll)
        {
            string pollSql = "UPDATE " + Config.ForumTablePrefix + "POLLS SET DisplayText=@Question WHERE PollId=@PollId";
            List<OleDbParameter> parms = new List<OleDbParameter>
                {
                    new OleDbParameter("@PollId", OleDbType.Numeric) {Value = poll.Id},
                    new OleDbParameter("@Question", OleDbType.VarChar) {Value = poll.DisplayText}
                };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, pollSql, parms.ToArray());
            if (poll.Choices == null)
                return;
            var choices = GetPollChoices(poll.Id).ToArray();
            int currentchoicecount = choices.Length;
            int newchoicecount = poll.Choices.Count;

            for (int ch = 0; ch < choices.Count(); ch++)
            {
                if (ch < newchoicecount)
                {
                    choices[ch].DisplayText = poll.Choices[ch].DisplayText;
                    choices[ch].Order = poll.Choices[ch].Order;
                    UpdateChoice(choices[ch]);
                }
                else
                {
                    break;
                }
            }
            if (newchoicecount > currentchoicecount)
            {
                for (int i = currentchoicecount; i < newchoicecount; i++)
                {
                    PollChoiceInfo choice = new PollChoiceInfo
                        {
                            DisplayText = poll.Choices[i].DisplayText,
                            PollId = poll.Id,
                            Order = poll.Choices[i].Order
                        };
                    AddChoice(choice);
                }
            }
            else if (newchoicecount < currentchoicecount)
            {
                for (int i = newchoicecount; i < currentchoicecount; i++)
                {
                    DeleteChoice(choices[i].Id);
                }
            }
        }
Esempio n. 10
0
 public IEnumerable<PollChoiceInfo> GetPollChoices(int pollId)
 {
     string strSql = "SELECT PollAnswerId,DisplayText,SortOrder FROM " + Config.ForumTablePrefix + "POLLANSWERS WHERE PollId=@PollId ORDER BY SortOrder";
     List<PollChoiceInfo> answers = new List<PollChoiceInfo>();
     using (OleDbDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@PollID", OleDbType.Numeric) { Value = pollId }))
     {
         while (rdr.Read())
         {
             PollChoiceInfo answer = new PollChoiceInfo
                 {
                     Id = rdr.GetInt32(0),
                     DisplayText = rdr.SafeGetString(1),
                     Order = rdr.GetInt32(2),
                     PollId = pollId
                 };
             answers.Add(answer);
         }
     }
     return answers;
 }
Esempio n. 11
0
 public void AddChoice(PollChoiceInfo choiceInfo)
 {
     choiceInfo.PollInfo = this;
     Choices.Add(choiceInfo);
 }
Esempio n. 12
0
 public void AddChoice(PollChoiceInfo choiceInfo)
 {
     choiceInfo.PollInfo = this;
     Choices.Add(choiceInfo);
 }