Example #1
0
 public int addExamDetail(ExaminationDetail examDetail)
 {
     string strSql = "insert into ex_examination_detail(EXAMINATION_ID, TOPIC_ID, TOPIC_ORDER) values(?examId, ?topicId, ?topicOrder)";
     MySqlParameter[] parames = new MySqlParameter[] {
         new MySqlParameter("?examId", MySqlDbType.Int32),
         new MySqlParameter("?topicId", MySqlDbType.Int32),
         new MySqlParameter("?topicOrder", MySqlDbType.Int32)
     };
     parames[0].Value = examDetail.ExaminationId;
     parames[1].Value = examDetail.TopicId;
     parames[2].Value = examDetail.TopicOrder;
     return Convert.ToInt32(MySqlHelper.ExecuteScalar(strSql, parames));
 }
Example #2
0
        public int addExam(Examination exam, string topicIds)
        {
            int examId = exam.ExaminationId;
            int flag = 0;
            if (examId < 1)
            {
                flag = examDao.addExam(exam);
                examId = exam.ExaminationId;
            }
            else
            {
                flag = examDao.updateExam(exam);
                examDetailDao.deleteExamDetail(exam.ExaminationId);
            }

            if (topicIds.IndexOf(",") > -1)                  //多个题目时
            {
                topicIds = topicIds.Substring(0, topicIds.Length - 1);
                string[] ids = topicIds.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    ExaminationDetail examDetail = new ExaminationDetail();
                    examDetail.ExaminationId = examId;
                    examDetail.TopicId = Convert.ToInt32(ids[i]);
                    examDetail.TopicOrder = i + 1;
                    examDetailDao.addExamDetail(examDetail);
                }
            }
            else
            {
                ExaminationDetail examDetail = new ExaminationDetail();
                examDetail.ExaminationId = examId;
                examDetail.TopicId = Convert.ToInt32(topicIds == "" ? "0" : topicIds);
                examDetail.TopicOrder = 1;
                examDetailDao.addExamDetail(examDetail);
            }

            return flag;
        }