private void btnAutoSetQuestionConfirm_Click(object sender, EventArgs e) { //MessageBox.Show(nudSelectNum.Tag.ToString()); if (!checkInput()) { return; } if (pNameDialog.ShowDialog() == DialogResult.OK) { Paper paper = new Paper(); paper.name = pNameDialog.paperName; paper.publishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); paper.major = UserInfoForm.getMajorByMajorId(UserHelper.currentMajorId); paper.teacherName = UserHelper.user.name; if (extractQuestion() == null) { MessageBox.Show("题库中没有足够的题目,详情请联系管理员···", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (addPaper(paper, extractQuestion())) { MessageBox.Show("试卷 ”" + paper.name + "“ 添加失败···", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("试卷 ”" + paper.name + "“ 添加成功!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Information); showAllPapers(); paperInfoPanel.Show(); autoSetQuestionPanel.Hide(); } }
private void cboMajorsInit() { cboMajors.Items.Clear(); DBHelper db = new DBHelper(); string sql = "select * from majors where id in(" + UserInfoForm.convertPermission(UserHelper.user.permission) + ")"; try { DbCommand cmd = db.GetSqlStringCommand(sql); using (DbDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { Major major = new Major(); major.id = (int)reader["id"]; major.name = (string)reader["name"]; cboMajors.Items.Add(major); } } cboMajors.Text = UserInfoForm.getMajorByMajorId(UserHelper.currentMajorId); } catch (Exception ex) { throw ex; } }
public static Role readerToRole(DbDataReader reader) { Role role = new Role(); role.id = (int)reader["id"]; role.name = reader["name"].ToString(); role.major = UserInfoForm.getMajorByMajorId((int)reader["majorId"]); role.sceneId = (int)reader["VR_scene_id"]; role.isRobot = (bool)reader["isRobot"]; return(role); }
public static Question readerToQuestion(DbDataReader reader) { Question question = new Question(); question.id = (int)reader["id"]; question.question = (string)reader["question"]; question.answer = (string)reader["answer"]; question.difficulty = (reader["difficulty"] is DBNull) ? null : ((string)reader["difficulty"]); question.major = UserInfoForm.getMajorByMajorId((int)reader["majorId"]); question.type = getTypeByTypeId((int)reader["typeId"]); question.optionA = (reader["OptionA"] is DBNull) ? null : ((string)reader["OptionA"]); question.optionB = (reader["OptionB"] is DBNull) ? null : ((string)reader["OptionB"]); question.optionC = (reader["OptionC"] is DBNull) ? null : ((string)reader["OptionC"]); question.optionD = (reader["OptionD"] is DBNull) ? null : ((string)reader["OptionD"]); return(question); }