예제 #1
0
파일: Bank.cs 프로젝트: iranEdu/irQm
      private void Qitem_CheckedChange(UCQuestionListItem item, IQuestion question)
      {
          if (item.Checked)
          {
              var q     = question.Clone();
              var qitem = new UCQuestionListItem(q, question.RegisterTime.ToLocalTime().ToPrettyTime(), flpSelectedQuestions.Controls.Count + 1);
              qitem.HasRemoveButton  = false;
              qitem.Width            = multiTabPage.Width - 50;
              qitem.RightToLeft      = RightToLeft.Yes;
              qitem.Anchor           = AnchorStyles.Right | AnchorStyles.Left;
              qitem.Resize          += (s, ev) => { qitem.MaximumSize = new Size(Width - 50, 0); };
              qitem.Name             = question.Id;
              qitem.Checked          = true;
              qitem.CheckedChange   += SelectedQitem_CheckedChange;
              qitem.MouseDown       += (s, ev) => { qitem.DoDragDrop(qitem, DragDropEffects.Move); };
              qitem.QuestionEdited  += Qitem_QuestionEdited;
              qitem.CausesValidation = false;
              qitem.Cursor           = Cursors.Hand;
              item.Tag = q;
              //qitem.AllowDrop = true;
              flpSelectedQuestions.Controls.Add(qitem);
              selectedQuestions.Add(q);

              list.Add(qitem);
          }
          else if (selectedQuestions.Contains((IQuestion)item.Tag))
          {
              var q        = (IQuestion)item.Tag;
              var controls = flpSelectedQuestions.Controls;
              controls.Remove(controls.Find(question.Id, false)[0]);
              selectedQuestions.Remove(q);
              item.Tag = null;
              RefreshNumberInFlpSelected();
          }
      }
예제 #2
0
파일: Bank.cs 프로젝트: iranEdu/irQm
 private void Qitem_Removed(UCQuestionListItem item, IQuestion question)
 {
     if (MessageBox.Show("آیا میخواهید این پرسش از پایگاه پرسشها حذف شود؟", "حذف پرسشها", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         question.DeleteFromDb();
         search();
         if (item.Checked)
         {
             var controls = flpSelectedQuestions.Controls;
             controls.Remove(controls.Find(question.Id, false)[0]);
             selectedQuestions.Remove(question);
             RefreshNumberInFlpSelected();
         }
     }
 }
예제 #3
0
파일: Bank.cs 프로젝트: iranEdu/irQm
      public void search()
      {
          if (toDate != null)
          {
              toDate.Value.AddHours(-1 * toDate.Value.Hour).AddHours(24);
          }
          System.Diagnostics.Debug.WriteLine(PersianDateConverter.ToMiladi(fdpTo.SelectedDateTime).Year);

          using (var db = new irQmDbContext())
          {
              IQuestion[]     questions = null;
              FlowLayoutPanel target    = null;

              switch (tabControl1.SelectedIndex)
              {
              case 0:


                  questions = db.MultiChoicesQuestions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                             tags.All(tg => db.TagInMultichoices.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Options).Include(q => q.Tags).ToArray();
                  target = flpMultiOptionsQuestions;
                  break;

              case 1:

                  questions = db.TFQuestions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                   tags.All(tg => db.TagInTfQuestion.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Tags).ToArray();
                  target = flpTFQuestions;
                  break;

              case 2:

                  questions = db.PuzzleQuestions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                       tags.All(tg => db.TagInPuzzle.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Pairs).Include(q => q.Tags).ToArray();
                  target = flpPuzzleQuestions;
                  break;

              case 3:

                  questions = db.ShortAnswerQustions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                           tags.All(tg => db.TagInShortAnswer.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Answer).Include(q => q.Tags).ToArray();
                  target = flpShortQuestions;
                  break;

              case 4:

                  questions = db.LongAnswerQuestions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                           tags.All(tg => db.TagInLongAnswer.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Tags).ToArray();
                  target = flpLongQuestions;
                  break;

              case 5:

                  questions = db.PracticalQuestions.Where(q => (string.IsNullOrWhiteSpace(lessonName) ? true : q.LessonName == lessonName) && (fromDate != null ? q.RegisterTime >= fromDate : true) && (toDate != null ? q.RegisterTime <= toDate : true) &&
                                                          tags.All(tg => db.TagInPractical.Any(t => t.QuestionId == q.Id && t.Tag.Value == tg)) && richContains(q.Face, searchExpr)).Include(q => q.Tags).Include(q => q.CheckList).ToArray();
                  target = flpPracticalQuestions;
                  break;

              case 6:
                  return;
              }


              int i = 1;
              target.Controls.Clear();
              foreach (var q in questions.OrderBy(q => q.Face))
              {
                  var qitem = new UCQuestionListItem(q, q.RegisterTime.ToLocalTime().ToPrettyTime(), i);
                  qitem.Width          = multiTabPage.Width - 50;
                  qitem.RightToLeft    = RightToLeft.Yes;
                  qitem.Anchor         = AnchorStyles.Right | AnchorStyles.Left;
                  qitem.Resize        += (s, ev) => { qitem.MaximumSize = new Size(Width - 50, 0); };
                  qitem.Removed       += Qitem_Removed;
                  qitem.CheckedChange += Qitem_CheckedChange;
                  qitem.Name           = q.Id;
                  if (selectedQuestions.Contains(q))
                  {
                      qitem.Checked = true;
                  }
                  target.Controls.Add(qitem);
                  qitem.QuestionEdited += Qitem_QuestionEdited;
                  list.Add(qitem);
                  i++;
              }
          }
      }
예제 #4
0
파일: Bank.cs 프로젝트: iranEdu/irQm
      private void SelectedQitem_CheckedChange(UCQuestionListItem item, IQuestion question)
      {
          if (item.Checked)
          {
              return;
          }
          if (MessageBox.Show("آیا میخواهید این پرسش از فهرست انتخاب ‌‌شده‌ها حذف شود؟", "حذف از فهرست", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
          {
              flpSelectedQuestions.Controls.Remove(item);
              selectedQuestions.Remove(question);
              RefreshNumberInFlpSelected();
              if (question is TFQuestion)
              {
                  var controls = flpTFQuestions.Controls;
                  var f        = controls.Find(item.Name, false);

                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
              else if (question is MultiChoices)
              {
                  var controls = flpMultiOptionsQuestions.Controls;
                  var f        = controls.Find(item.Name, false);
                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
              else if (question is Puzzle)
              {
                  var controls = flpPuzzleQuestions.Controls;
                  var f        = controls.Find(item.Name, false);
                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
              else if (question is ShortAnswer)
              {
                  var controls = flpShortQuestions.Controls;
                  var f        = controls.Find(item.Name, false);
                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
              else if (question is LongAnswer)
              {
                  var controls = flpLongQuestions.Controls;
                  var f        = controls.Find(item.Name, false);
                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
              else if (question is Practical)
              {
                  var controls = flpPracticalQuestions.Controls;
                  var f        = controls.Find(item.Name, false);
                  if (f.Length > 0)
                  {
                      var c = ((UCQuestionListItem)f[0]);
                      c.Checked = false;
                      c.Tag     = null;
                  }
              }
          }
          else
          {
              item.Checked = true;
          }
      }
예제 #5
0
파일: Bank.cs 프로젝트: iranEdu/irQm
 private void Qitem_QuestionEdited(UCQuestionListItem item, IQuestion question)
 {
     item.init(question.RegisterTime.ToLocalTime().ToPrettyTime());
 }