private void AnswerQuestions_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MessageBox.Show("确定退出?退出后您所做的改变将不会保留!", "确定退出?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
     {
         e.Cancel = true;
     }
     else
     {
         AnswerQuestionCollection.Dispose();
     }
 }
Пример #2
0
        private void Init()
        {
            EndTime = DateTime.Parse(questionnairesDataTable.Rows[0][5].ToString());

            l_QuestionnaireName.Text = questionnairesDataTable.Rows[0][2].ToString();
            l_Introduce.Text         = questionnairesDataTable.Rows[0][3].ToString();
            l_StartDate.Text         = DateTime.Parse(questionnairesDataTable.Rows[0][4].ToString()).ToString();
            l_EndDate.Text           = EndTime.ToString();

            AnswerQuestionCollection answerQuestion = new AnswerQuestionCollection(questionnaireID, this);

            l_QuestionCount.Text = $"{AnswerQuestionCollection.QuestionsCount}个问题";
        }
        /// <summary>
        /// 提交问卷
        /// </summary>
        private void Submit()
        {
            try
            {
                for (int i = 0; i < AnswerQuestionCollection.answerQuestionList.Count; i++)
                {
                    if (AnswerQuestionCollection.answerQuestionList[i].answers[1] > 4)//多选内容
                    {
                        string astr = AnswerQuestionCollection.answerQuestionList[i].answers[1].ToString();
                        for (int j = 0; j < astr.Length; j++)
                        {
                            UserAnswerTable.InsertQuery(LoggedInfo.ID, AnswerQuestionCollection.QuestionnaireID, AnswerQuestionCollection.answerQuestionList[i].answers[0], astr[j].ToString(), DateTime.Now);
                        }
                    }
                    else
                    {
                        UserAnswerTable.InsertQuery(LoggedInfo.ID, AnswerQuestionCollection.QuestionnaireID, AnswerQuestionCollection.answerQuestionList[i].answers[0], AnswerQuestionCollection.answerQuestionList[i].answers[1].ToString(), DateTime.Now);
                    }
                }
                #region old

                /*for (int i = 0; i < AnswerQuestionCollection.AnswerList.Count; i++)
                 * {
                 *  if (AnswerQuestionCollection.AnswerList[i][1] > 4)//多选内容
                 *  {
                 *      string astr = AnswerQuestionCollection.AnswerList[i][1].ToString();
                 *      for (int j = 0; j < astr.Length; j++)
                 *      {
                 *          UserAnswerTable.InsertQuery(LoggedInfo.ID, AnswerQuestionCollection.QuestionnaireID, AnswerQuestionCollection.AnswerList[i][0], astr[j].ToString(), DateTime.Now);
                 *      }
                 *  }
                 *  else
                 *  {
                 *      UserAnswerTable.InsertQuery(LoggedInfo.ID, AnswerQuestionCollection.QuestionnaireID, AnswerQuestionCollection.AnswerList[i][0], AnswerQuestionCollection.AnswerList[i][1].ToString(), DateTime.Now);
                 *  }
                 * }*/
                #endregion
                MessageBox.Show("提交成功!");
                AnswerQuestionCollection.Dispose();
            }
            catch
            {
                MessageBox.Show("提交失败");
            }
        }