private void AnswerQuestions_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("确定退出?退出后您所做的改变将不会保留!", "确定退出?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { e.Cancel = true; } else { AnswerQuestionCollection.Dispose(); } }
/// <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("提交失败"); } }