コード例 #1
0
        public static IEnumerable<UserResponsResult> GetPollUserResponse(PollQuestion Question, out long? TotalUserResp)
        {
            using (var ctx = new BMIKidsEntities(ConnectionString))
            {
                TotalUserResp = ctx.PollUserResponses.LongCount(o => (long?)o.QuestionId == Question.QuestionId);


                var q = from m in ctx.PollUserResponses.Where(o => o.QuestionId == Question.QuestionId).GroupBy(o => o.ResponseItemId)
                        select new UserResponsResult
                        {
                            itemId = m.Key,
                            count = m.Count(),

                        };

                return q.ToList();
            }
        }
コード例 #2
0
 public static long SavePoll(PollQuestion p)
 {
     using (var ctx = new BMIKidsEntities(ConnectionString))
     {
         try
         {
             ctx.PollQuestions.ApplyChanges(p);
             ctx.SaveChanges();
             return p.QuestionId;
         }
         catch (Exception ex)
         {
             LogUtility.WriteEntryEventLog("Poll_DataProvider_SavePoll", ex, EventLogEntryType.Information);
             if (ex.InnerException != null)
                 throw ex.InnerException;
             throw;
         }
     }
 }
コード例 #3
0
        private void showPostResult(PollQuestion q)
        {
            long? TotalUserResp;
            var userResp = Poll_DataProvider.GetPollUserResponse(q, out TotalUserResp);

            tblrseult.Text = "<table>";
            tblrseult.Text += "<tr><td colspan=2 dir=rtl></td></tr>";

            foreach (var ri in userResp)
            {
                tblrseult.Text += "<tr>";
                tblrseult.Text += "<td><font class='normalTextSmall' >" + q.PollResponseItems.FirstOrDefault(o => o.ItemId == ri.itemId).ItemText + "</font></td>";

                tblrseult.Text += "<td><font class='normalTextSmall'>" + Math.Round((ri.count / (double)TotalUserResp.Value) * 100, 2) + "%</font></td>";
                tblrseult.Text += "</tr>";

            }
            tblrseult.Text += "<tr><td align=center class=normaltextSmall> تعداد آراء " + TotalUserResp.ToString() + " راي</td></tr>";
            tblrseult.Text += "</table>";


        }
コード例 #4
0
     private void FixupPollQuestion(PollQuestion previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.PollResponseItems.Contains(this))
         {
             previousValue.PollResponseItems.Remove(this);
         }
 
         if (PollQuestion != null)
         {
             if (!PollQuestion.PollResponseItems.Contains(this))
             {
                 PollQuestion.PollResponseItems.Add(this);
             }
 
             PollQuestionsId = PollQuestion.QuestionId;
         }
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("PollQuestion")
                 && (ChangeTracker.OriginalValues["PollQuestion"] == PollQuestion))
             {
                 ChangeTracker.OriginalValues.Remove("PollQuestion");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("PollQuestion", previousValue);
             }
             if (PollQuestion != null && !PollQuestion.ChangeTracker.ChangeTrackingEnabled)
             {
                 PollQuestion.StartTracking();
             }
         }
     }
コード例 #5
0
        private void showPostResult(PollQuestion qu)
        {
            if (qu != null)
            {
                string cookName = coockiPrefix + qu.QuestionId;
                if (Request.Cookies[cookName] != null)
                {
                    try
                    {
                        tdResult.Visible = true;
                        HttpCookie cook = Request.Cookies[cookName];

                        string QuestionResponse = qu.PollResponseItems.FirstOrDefault(o => o.ItemId == Convert.ToInt32(cook.Value)).ItemText;


                        lblrseult.CssClass = "normalTextSmall";
                        lblrseult.Text = string.Format("  پاسخ شما به سوال فوق گزينه  <font color=blue>{0}</font> مي باشد", QuestionResponse);
                        //tblrseult.Text += "</font>" ;
                        if (qu.UsersCanViewResult)
                        {
                            ucShowPollResults.ActiveQuestion = qu;
                            ucShowPollResults.Visible = true;
                        }
                    }
                    catch
                    {
                        lblrseult.Text += "<br><font class='normalTextSmall' >پاسخ شما به اين سوال مشخص نيست";
                        lblrseult.Text += "</font>";

                    }

                }

            }



        }
コード例 #6
0
        private PollQuestion GetPollInfoFromSkin()
        {
            PollQuestion p = new PollQuestion
                {
                    Title = TitleCtrl.Text,
                    UsersCanViewResult = chkBoxResultViewStatus.Checked,
                    CreateDateTime = DateTime.Now,
                    HasScore = chkHasScore.Checked,
                    IsActive = chkIsActive.Checked
                };

            return p;

        }