Ejemplo n.º 1
0
        public int addOnlyExam(Examination exam)
        {
            string strSql = "insert into ex_examination(EXAM_CAT, EXAM_NAME, START_TIME, TOTAL_MINS, SCORES, EX_TYPE,NUM,EX_TYPE_LX) values(?examCat, ?examName, ?startTime, ?totalMins, ?scores, ?exType, ?Num,?exType_lx); select last_insert_id();";
            MySqlParameter[] parames = new MySqlParameter[] {
                new MySqlParameter("?examCat", MySqlDbType.VarChar),
                new MySqlParameter("?examName", MySqlDbType.VarChar),
                new MySqlParameter("?startTime", MySqlDbType.VarChar),
                new MySqlParameter("?totalMins", MySqlDbType.Int32),
                new MySqlParameter("?scores", MySqlDbType.VarChar),
                new MySqlParameter("?exType", MySqlDbType.VarChar),
                new MySqlParameter("?Num", MySqlDbType.Int32),
                new MySqlParameter("?exType_lx", MySqlDbType.VarChar)
            };
            parames[0].Value = exam.ExamCat;
            parames[1].Value = exam.ExamName;
            parames[2].Value = exam.StartTime;
            parames[3].Value = exam.TotalMins;
            parames[4].Value = exam.Scores;
            parames[5].Value = "1";
            parames[6].Value = exam.Num;
            parames[7].Value = exam.ExType_lx;//选题方式

            int examId = Convert.ToInt32(MySqlHelper.ExecuteScalar(strSql, parames));
            exam.ExaminationId = examId;
            return examId;
        }
Ejemplo n.º 2
0
        public AddExam(Examination examination_in)
        {
            if (examination_in!=null)
            {
                examination = examination_in;
            }

            InitializeComponent();

            topicCategory.Items.Clear();
            topicCategory.DataSource = Constant.getTopicType();
            topicCategory.DisplayMember = "name";
            topicCategory.ValueMember = "id";

            exType.Items.Clear();
            exType.DataSource = Constant.getExamType();
            exType.DisplayMember = "name";
            exType.ValueMember = "id";
            exType.SelectedIndex = 0;

            button1.BackColor = Color.FromArgb(255, 80, 151, 228);
            button2.BackColor = Color.FromArgb(255, 80, 151, 228);

            button1.ForeColor = Color.White;
            button2.ForeColor = Color.White;
        }
Ejemplo n.º 3
0
 public int addOnlyExam(Examination exam)
 {
     int examId = exam.ExaminationId;
     int flag = 0;
     if (examId < 1)
     {
         flag = examDao.addOnlyExam(exam);
         examId = exam.ExaminationId;
     }
     else
     {
         flag = examDao.updateOnlyExam(exam);
         //examDetailDao.deleteExamDetail(exam.ExaminationId);
     }
     return flag;
 }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        public static chooseTopics createForm(Examination exam_in)
        {
            exam = exam_in;
            //if (instance == null || instance.IsDisposed)
            //{
            instance = new chooseTopics();
            //}
            if (topicService == null)
            {
                topicService = TopicService.getInstance();
            }
            if (examService == null)
            {
                examService = ExamService.getInstance();
            }
            if (strWheres == null)
            {
                strWheres = new Dictionary<string, string>();
            }

            return instance;
        }
Ejemplo n.º 6
0
 public int updateOnlyExam(Examination exam)
 {
     string strSql = "update ex_examination set EXAM_CAT =?examCat, EXAM_NAME = ?examName, START_TIME = ?startTime, TOTAL_MINS = ?totalMins, EX_TYPE = ?exType, NUM = ?Num where examination_id = ?examId";
     MySqlParameter[] parames = new MySqlParameter[] {
         new MySqlParameter("?examCat", MySqlDbType.VarChar),
         new MySqlParameter("?examName", MySqlDbType.VarChar),
         new MySqlParameter("?startTime", MySqlDbType.VarChar),
         new MySqlParameter("?totalMins", MySqlDbType.Int32),
         new MySqlParameter("?exType", MySqlDbType.VarChar),
         new MySqlParameter("?examId", MySqlDbType.Int32),
         new MySqlParameter("?Num", MySqlDbType.Int32)
     };
     parames[0].Value = exam.ExamCat;
     parames[1].Value = exam.ExamName;
     parames[2].Value = exam.StartTime;
     parames[3].Value = exam.TotalMins;
     parames[4].Value = exam.ExType;
     parames[5].Value = exam.ExaminationId;
     parames[6].Value = exam.Num;
     return Convert.ToInt32(MySqlHelper.ExecuteNonQuery(strSql, parames));
 }
Ejemplo n.º 7
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (xz == 0 && feib == 0 && fub == 0)
            {
                MessageBox.Show("请选择题目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                Examination exam = new Examination();
                exam.ExamCat = Convert.ToString(addExam.topicCategory.SelectedValue);
                exam.ExamName = addExam.txtExamName.Text;
                exam.StartTime = addExam.startTime.Text;
                exam.TotalMins = Convert.ToInt32(addExam.totalMins.Text);
                exam.ExType = "1";
                exam.ExaminationId = Convert.ToInt32(addExam.labExamId.Text == "" ? "0" : addExam.labExamId.Text);

                string topicIds = getRandomTopicIds(xz, xzList);
                topicIds += getRandomTopicIds(feib, feibList);
                topicIds += getRandomTopicIds(fub, fubList);

                int result = examService.addExam(exam, topicIds);
                if (result > 0)
                {
                    MessageBox.Show("保存成功");
                    bodyExam.btnQuery_Click(sender, e);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败,请联系管理员");
                }
            }
        }
Ejemplo n.º 8
0
        private void button2_Click(object sender, EventArgs e)
        {
            //必须选中一行
            if (pageCtrl.dg.CurrentRow == null)
            {
                MessageBox.Show("请选择一条记录");
            }
            else
            {

                //获取选中行的信息 填充到对象中

                Examination exam = new Examination();
                exam.ExamCat = Convert.ToString(pageCtrl.dg.CurrentRow.Cells[2].Value.ToString());
                exam.ExamName = pageCtrl.dg.CurrentRow.Cells[1].Value.ToString();
                exam.StartTime = pageCtrl.dg.CurrentRow.Cells[3].Value.ToString();
                exam.TotalMins = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[4].Value.ToString());
                exam.ExType = "1";
                exam.ExaminationId = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[0].Value.ToString());
                exam.Num = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[6].Value.ToString());
                exam.ExType_lx = Convert.ToString(pageCtrl.dg.CurrentRow.Cells[7].Value.ToString());

                AddExam addExam = new AddExam(exam);
                addExam.bodyExam = this;
                addExam.ShowDialog();

            }
        }
 public Boolean ScheduleExamunation(Model.Examination examination)
 {
     // TODO: implement
     return(false);
 }
Ejemplo n.º 10
0
 private void button7_Click(object sender, EventArgs e)
 {
     if (topicType == null)
     {
         MessageBox.Show("请选择测试类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else if (xz == 0 && feib == 0 && fub == 0)
     {
         MessageBox.Show("请选择题目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         Examination exam = new Examination();
         exam.ExamCat = topicType;
         DateTime dt = DateTime.Now;
         exam.ExamName = dt.ToString("yyyy-MM-dd HH:mm:ss") + LoginRoler.username + "的自我测试";
         exam.ExType = "2";
         exam.StartTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
         exam.Num = Convert.ToInt32(xz) + Convert.ToInt32(feib) + Convert.ToInt32(fub);
         string topicIds = getRandomTopicIds(xz, xzList);
         topicIds += getRandomTopicIds(feib, feibList);
         topicIds += getRandomTopicIds(fub, fubList);
         int result = examService.addExam(exam, topicIds);
         if (result > 0)
         {
             mainFrame.panel6.Controls.Clear();
             mainFrame.panel6.Controls.AddRange(mainFrame.items.ToArray());
             BodySelfTest3 self3 = new BodySelfTest3();
             self3.TopLevel = false;
             self3.selfTest2 = this;
             self3.examId = exam.ExaminationId;
             self3.FormBorderStyle = FormBorderStyle.None;
             self3.Dock = System.Windows.Forms.DockStyle.Fill;
             mainFrame.panel6.Controls.Add(self3);
             self3.Show();
         }
         else
         {
             MessageBox.Show("选题失败,请联系管理员");
         }
     }
 }
Ejemplo n.º 11
0
 private void button7_Click(object sender, EventArgs e)
 {
     DataTable dt = (DataTable) examDetail.DataSource;
     string topicIds = "";
     foreach (DataRow dr in dt.Rows)
     {
         object topicId = dr.ItemArray[0];
         topicIds += topicId + ",";
     }
     if (topicIds == "")
     {
         MessageBox.Show("试卷不能没有题目");
     }
     else
     {
         Examination exam = new Examination();
         exam.ExamCat = Convert.ToString(addExam.topicCategory.SelectedValue);
         exam.ExamName = addExam.txtExamName.Text;
         exam.StartTime = addExam.startTime.Text;
         exam.TotalMins = Convert.ToInt32(addExam.totalMins.Text);
         exam.ExType = "1";
         exam.ExaminationId = Convert.ToInt32(addExam.labExamId.Text == "" ? "0" : addExam.labExamId.Text);
         int result = examService.addExam(exam, topicIds);
         if (result > 0)
         {
             MessageBox.Show("保存成功");
             bodyExam.btnQuery_Click(sender, e);
             this.Close();
         }
         else
         {
             MessageBox.Show("保存失败,请联系管理员");
         }
     }
 }
Ejemplo n.º 12
0
        // private int xz;
        private void button1_Click(object sender, EventArgs e)
        {
            object categoryValue = topicCategory.SelectedValue;
            if ((string)categoryValue == "")
            {
                MessageBox.Show("请选择种类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (txtExamName.Text == "")
            {
                MessageBox.Show("考试名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (totalMins.Text == "")
            {
                MessageBox.Show("考试时长不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {

                if (1==2)
                {//此处为原先代码
                    string exTypeValue = "";
                    exTypeValue = Convert.ToString(exType.SelectedValue);
                    if (exTypeValue == "1")
                    {
                        //随机
                        this.Hide();
                        AddExam3 addExam3 = new AddExam3();
                        addExam3.addExam = this;
                        addExam3.bodyExam = this.bodyExam;
                        addExam3.ShowDialog();
                    }
                    else if (exTypeValue == "2")
                    {
                        //手动
                        this.Hide();
                        AddExam2 addExam2 = new AddExam2();
                        addExam2.addExam = this;
                        addExam2.bodyExam = this.bodyExam;
                        addExam2.ShowDialog();
                    }
                }
                else//修改处
                {
                        //先保存试卷基础信息,然后手动或者自动添加试题到试卷上面
                        Examination exam = new Examination();
                        exam.ExamCat = Convert.ToString(this.topicCategory.SelectedValue);
                        exam.ExamName = this.txtExamName.Text;
                        exam.StartTime = this.startTime.Text;
                        exam.TotalMins = Convert.ToInt32(this.totalMins.Text);

                        if (examination!=null)
                        {
                            exam.ExaminationId = examination.ExaminationId;
                        }
                        else
                        {
                            exam.ExType_lx = this.exType.Text;
                            exam.ExaminationId = Convert.ToInt32(this.labExamId.Text == "" ? "0" : this.labExamId.Text);
                        }
                        exam.Num = Convert.ToInt32(this.questionsNum.Text);
                        int result = examService.addOnlyExam(exam);
                        if (result > 0)
                        {

                        if (examination == null)
                        {
                            string exTypeValue = Convert.ToString(exType.SelectedValue);
                            if (exTypeValue == "1")
                            {
                                //随机题目保存数据到表ex_examination_detail
                                //获取题目数量  确定随机题目数量
                                int Num = Convert.ToInt32(this.questionsNum.Text);
                                if (examService.randomTopic(Num, exam.ExaminationId))
                                {
                                    //MessageBox.Show("保存成功");
                                    //bodyExam.btnQuery_Click(sender, e);
                                    //this.Close();

                                }
                                else
                                {
                                    //随机选题发生系统问题,请联系管理员.
                                    MessageBox.Show("随机选题发生系统问题,请联系管理员");
                                }
                            }
                        }
                        //刷新数据
                        bodyExam.btnQueryClick();

                        this.Hide();
                        //跳转到  考题列表进行选择
                        chooseTopics cTopics = chooseTopics.createForm(exam);
                        cTopics.ShowDialog();
                    }
                        else
                        {
                            MessageBox.Show("保存失败,请联系管理员");
                        }
                }
            }
        }