Пример #1
0
 private void SelectSection_Load(object sender, EventArgs e)
 {
     string sqlString = "select * from ExamSection";
     DataTable dt = new Tool().ExecuteSqlQuery(sqlString);
     cbSection.DataSource = dt;
     cbSection.ValueMember = "id";
     cbSection.DisplayMember = "section";
 }
Пример #2
0
 private void EditSectionManage_Load(object sender, EventArgs e)
 {
     if (id != "")
     {
         string sqlString = "select * from ExamSection where id='" + id + "'";
         DataTable dt = new Tool().ExecuteSqlQuery(sqlString);
         txtName.Text = dt.Rows[0]["section"].ToString();
     }
 }
Пример #3
0
 private void EditExamSkillManage_Load(object sender, EventArgs e)
 {
     if (id != "")
     {
         string sqlString = "select name,details from ExamSkill where id = '"+id+"' ";
         DataTable dt = new Tool().ExecuteSqlQuery(sqlString);
         txtName.Text = dt.Rows[0]["name"].ToString();
         txtContent.Text = dt.Rows[0]["details"].ToString();
     }
 }
Пример #4
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     string username = txtName.Text.ToString();
     string password = txtpassword.Text.ToString();
     DataTable dt = new Tool().ExecuteSqlQuery("select * from ExamUser where name='"+username+"' and password='******'");
     if (dt != null && dt.Rows.Count == 1)
     {
         new Main(dt.Rows[0]["name"].ToString()).Show();
         this.Visible = false;
         USERID = dt.Rows[0]["id"].ToString();
     }
     else if(dt.Rows.Count<1)
     {
         MessageBoxEx.Show("密码或用户名错误,请仔细检查您的用户名和密码,或联系管理员");
     }
 }
Пример #5
0
        private void setData()
        {
            btnBack.Enabled = index > 0;
            if (index == dt.Rows.Count)
            {
                btnNext.Enabled = false;
                index--;
                if (checkAnswer())
                {
                    lblError.Text = "正确,该题已经是最后一题";
                }
                index++;
                return;
            }
            btnNext.Enabled = index<dt.Rows.Count;
            clearSelected();
            clearColor();
            if (this.random != "")
            {
                this.index = new Random().Next(0, dt.Rows.Count);
                this.btnBack.Enabled = false;
            }
            try
            {
                //首先判断该题是否有图片
                pic.Image = dt.Rows[this.index]["picture_name"].ToString() == "" ? null : new Bitmap(Application.StartupPath + "\\pic\\" + dt.Rows[index]["picture_name"].ToString()+".png");
            }catch
            {
                lblError.Text = "未找到图片";
            }

            //判断该题的类型是单选,判断,多选
            if (dt.Rows[this.index]["type"].ToString() == "多项选择题") //必是多选
            {

                this.checkBoxA.Visible = true;
                this.checkBoxB.Visible = true;
                this.checkBoxC.Visible = true;
                this.checkBoxD.Visible = true;
                this.radioA.Visible = false;
                this.radioB.Visible = false;
                this.radioC.Visible = false;
                this.radioD.Visible = false;

                this.checkBoxA.Text = "A." + dt.Rows[this.index]["option_a"].ToString().Replace("A","");
                this.checkBoxB.Text = "B." + dt.Rows[this.index]["option_b"].ToString().Replace("B","");
                this.checkBoxC.Text = "C." + dt.Rows[this.index]["option_c"].ToString().Replace("C","");
                this.checkBoxD.Text = "D." + dt.Rows[this.index]["option_d"].ToString().Replace("D","");
            }

            if (dt.Rows[this.index]["type"].ToString() == "单项选择题")//必是单选
            {
                this.checkBoxA.Visible = false;
                this.checkBoxB.Visible = false;
                this.checkBoxC.Visible = false;
                this.checkBoxD.Visible = false;
                this.radioA.Visible = true;
                this.radioB.Visible = true;
                this.radioC.Visible = true;
                this.radioD.Visible = true;

                this.radioA.Text = "A."+dt.Rows[this.index]["option_a"].ToString();
                this.radioB.Text = "B."+dt.Rows[this.index]["option_b"].ToString();
                this.radioC.Text = "C."+dt.Rows[this.index]["option_c"].ToString();
                this.radioD.Text = "D."+dt.Rows[this.index]["option_d"].ToString();
            }

            if (dt.Rows[this.index]["type"].ToString() == "判断题")
            {
                this.checkBoxA.Visible = false;
                this.checkBoxB.Visible = false;
                this.checkBoxC.Visible = false;
                this.checkBoxD.Visible = false;
                this.radioA.Visible = true;
                this.radioB.Visible = true;
                this.radioC.Visible = false;
                this.radioD.Visible = false;
                this.radioA.Text = "对";
                this.radioB.Text = "错";

            }

            string section = new Tool().ExecuteSqlQuery("select section from ExamSection where id = '" + dt.Rows[index]["section"].ToString() + "'").Rows[0]["section"].ToString();
            this.lblTopicContent.Text ="("+section+")"+ dt.Rows[index]["question"].ToString();
        }
Пример #6
0
        private void init()
        {
            pic.MouseHover += new System.EventHandler(this.pictureBoxMouseOn);
            pic.MouseLeave += new System.EventHandler(this.pictureBoxMouseOut);
            string sqlString = "select * from ExamUser where id= '"+Login.USERID+"'";
            DataTable dtable = new Tool().ExecuteSqlQuery(sqlString);
            lblname.Text = dtable.Rows[0]["real_name"].ToString();
            lbluser.Text = dtable.Rows[0]["name"].ToString();
            this.checkBoxIsNext.Checked = true;
            for (int i = 0; i < 100; i++)
            {
                Label lbl = new Label();
                lbl.Text = "" + (i + 1);
                lbl.Name = "lbl" + (i + 1);
                lbl.Width = 40;
                lbl.Height = 30;
                flowLayoutPanel1.Controls.Add(lbl);
                totalLbl[i] = lbl;
                lbl.BorderStyle = BorderStyle.FixedSingle;
                lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                lbl.Click += new System.EventHandler(this.lbl_Click);
                this.MaximumSize = new System.Drawing.Size(this.Width, this.Height);
                this.MinimumSize = new System.Drawing.Size(this.Width, this.Height);
            }

            timerExam.Start();
        }
Пример #7
0
        /// <summary>
        /// 根据比例考试数据共100条
        /// </summary>
        private void getExamData()
        {
            string sqlString = "";
            try
            {
                List<int> saveNumber = new List<int>();//保存使用过的图片number
                List<string> saveId = new List<string>();//保存已经用过的Id
                DataTable data;
                string newSectionId = new Tool().ExecuteSqlQuery("select id from ExamSection where section = '新规新题'").Rows[0]["id"].ToString();
                string[] sixSectionId = new string[6];
                string[] sevenSectionId = new string[7];
                string[] eightSectionId = new string[8];

                data = new Tool().ExecuteSqlQuery("select id from ExamSection where section <> '新规新题'");
                List<string> allSectionId = new List<string>();

                for (int i = 0; i < data.Rows.Count; i++)
                {
                    allSectionId.Add(data.Rows[i]["id"].ToString());
                }
                //赋值
                data = new Tool().ExecuteSqlQuery("select id from ExamSection where section = '道路交通安全法律法规' or section = '道路运输法律法规' or section = '教育学.教育心理学及其应用' or section='教学方法及规范化教学' or section='车辆结构与安全性能' or section='环保与节能驾驶'");

                for (int i = 0; i < data.Rows.Count; i++)
                {
                    sixSectionId[i] = data.Rows[i]["id"].ToString();
                }

                data = new Tool().ExecuteSqlQuery("select id from ExamSection where section = '道路交通安全法律法规' or section = '道路运输法律法规' or section = '教育学.教育心理学及其应用' or section='教学方法及规范化教学' or section='车辆结构与安全性能' or section='环保与节能驾驶' or section = '教学手段'");
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    sevenSectionId[i] = data.Rows[i]["id"].ToString();
                }

                data = new Tool().ExecuteSqlQuery("select id from ExamSection where section = '道路交通安全法律法规' or section = '道路运输法律法规' or section = '教育学.教育心理学及其应用' or section='教学方法及规范化教学' or section='车辆结构与安全性能' or section='应急驾驶' or section = '驾驶员培训教学大纲' or section = '教案的编写'");
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    eightSectionId[i] = data.Rows[i]["id"].ToString();
                }

                #region 装载判断
                //先获取难题中的两道图片题
                sqlString = "select * from ExamSubject where problem = '难题强化' and not picture_name is null and picture_name <>'' and type='判断题' and section <>'"+newSectionId+"'";
                data = new Tool().ExecuteSqlQuery(sqlString);
                List<int> list = new List<int>();
                list = getRandom(data, 2);

                for (int i = 0; i < list.Count; i++)
                {
                    listNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                    saveNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                    saveId.Add(data.Rows[list[i]]["section"].ToString());
                }
                //获取剩下的13道判断难题
                allSectionId = getCurrentId(allSectionId, saveId);

                for (int i = 0; i < 13; i++)
                {
                    sqlString = "select * from ExamSubject where problem = '难题强化' and type='判断题' and section='" + allSectionId[i] + "' and random_number <>'"+saveNumber[0]+"' and random_number <> '"+saveNumber[1]+"'";
                    data = new Tool().ExecuteSqlQuery(sqlString);
                    list = getRandom(data, 1);
                    listNumber.Add(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString()));
                }
                //判断难题装载完毕

                saveNumber.Clear();
                //装载判断 各一题
                for (int i = 0; i < sixSectionId.Length; i++)
                {
                    sqlString = "select a.* from ExamSubject a left join ExamSection b on a.section = b.id  where a.type = '判断题' and b.id = '"+sixSectionId[i]+"' and a.problem ='难题强化'";
                    data = new Tool().ExecuteSqlQuery(sqlString);
                    list = getRandom(data, 1);
                    int a = Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString());

                    if (!listNumber.Contains(a))
                    {
                        listNumber.Add(a);
                    }
                    else
                    {
                        i--;
                    }
                }

                //装载9道新题新规
                sqlString = "select a.* from ExamSubject a left join ExamSection b on a.section = b.id  where a.type = '判断题' and b.id = '" + newSectionId + "'";
                data = new Tool().ExecuteSqlQuery(sqlString);
                list = getRandom(data, 9);

                for (int i = 0; i < list.Count; i++)
                {
                    listNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                }

                //判断题装载完毕
                #endregion

                #region 装载单选
                //装载5道图片题
                allSectionId = getAllId(allSectionId, saveId);
                saveId.Clear();
                sqlString = "select * from ExamSubject where problem = '难题强化' and not picture_name is null and picture_name <>'' and type='单项选择题'";
                data = new Tool().ExecuteSqlQuery(sqlString);
                list = getRandom(data, 5);
                for (int i = 0; i < list.Count; i++)
                {
                    listNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                    saveId.Add(data.Rows[list[i]]["section"].ToString());
                    saveNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                }

                allSectionId = getCurrentId(allSectionId, saveId);
                //装载剩下的11道难题

                for (int i = 0; i < 11; i++)
                {
                    sqlString = "select * from ExamSubject where problem = '难题强化' and type='单项选择题' and section='" + allSectionId[i] + "' and random_number <>'"+saveNumber[0]+"' and random_number <> '"+saveNumber[1]+"' and random_number <> '"+saveNumber[2]+"' and random_number <> '"+saveNumber[3]+"' and random_number <> '"+saveNumber[4]+"'";
                    data = new Tool().ExecuteSqlQuery(sqlString);
                    list = getRandom(data, 1);
                    listNumber.Add(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString()));
                }

                saveNumber.Clear();
                //装载各章节各两题

                for (int i = 0; i < sevenSectionId.Length; i++)
                {
                    for (int j = 0; j < 2; j++)
                    {
                        sqlString = "select a.* from ExamSubject a left join ExamSection b on a.section = b.id  where a.type = '单项选择题' and b.id = '" + sevenSectionId[i] + "' and a.problem = '难题强化'";
                        data = new Tool().ExecuteSqlQuery(sqlString);
                        list = getRandom(data, 1);

                        if (!listNumber.Contains(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString())))
                        {
                            listNumber.Add(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString()));
                        }
                        else
                        {
                            j--;
                        }

                    }
                }
                #endregion

                #region 装载多选
                allSectionId = getAllId(allSectionId,saveId);
                saveId.Clear();
                //先获取难题中的3道图片题
                sqlString = "select * from examsubject where problem = '难题强化' and not picture_name is null and picture_name <>'' and type='多项选择题'";
                data = new Tool().ExecuteSqlQuery(sqlString);
                list = getRandom(data, 3);
                for (int i = 0; i < list.Count; i++)
                {
                    listNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                    saveId.Add(data.Rows[list[i]]["section"].ToString());
                    saveNumber.Add(Convert.ToInt16(data.Rows[list[i]]["random_number"].ToString()));
                }

                //装载剩下的13道难题
                allSectionId = getCurrentId(allSectionId, saveId);
                for (int i = 0; i < 13; i++)
                {
                    sqlString = "select * from ExamSubject where problem = '难题强化' and type='多项选择题' and section = '"+allSectionId[i]+"' and random_number <> '"+saveNumber[0]+"' and random_number <> '"+saveNumber[1]+"' and random_number <> '"+saveNumber[2]+"'";
                    data = new Tool().ExecuteSqlQuery(sqlString);
                    list = getRandom(data, 1);
                    listNumber.Add(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString()));
                }

                //装载各章节各3题

                for (int i = 0; i < eightSectionId.Length; i++)
                {

                    for (int j = 0; j < 3; j++)
                    {
                        sqlString = "select a.* from ExamSubject a left join ExamSection b on a.section = b.id  where a.type = '多项选择题' and b.id = '" + eightSectionId[i] + "' and a.problem = '难题强化' ";
                        data = new Tool().ExecuteSqlQuery(sqlString);
                        list = getRandom(data, 1);
                        if (!listNumber.Contains(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString())))
                        {
                            listNumber.Add(Convert.ToInt16(data.Rows[list[0]]["random_number"].ToString()));
                        }
                        else
                        {
                            j--;
                        }
                    }

                }
                #endregion
            }
            catch (Exception e)
            {
                //Console.WriteLine(sqlString);
                MessageBox.Show(e.Message.ToString());
            }
        }
Пример #8
0
 private DataTable getCurrentSubject()
 {
     if (index == 100)
     {
         index = 99;
     }
     SubjectString = "select * from ExamSubject where random_number = '" + listNumber[index] + "'";
     DataTable dt = new Tool().ExecuteSqlQuery(SubjectString);
     return dt;
 }
Пример #9
0
 private void LoadDefault()
 {
     string sqlString = "select * from ExamSection";
     cbSectionType.DataSource = new Tool().ExecuteSqlQuery(sqlString);
     cbSectionType.ValueMember = "id";
     cbSectionType.DisplayMember = "section";
     cbSubjectType.SelectedIndex = 0;
     cbTopic.SelectedIndex = 0;
     if (id != "")
     {
         sqlString = sqlString = "select a.id,b.section as 章节类别,topic as 题目主题,type as 题目类型,question as 题目问题,picture_name as 图片名称,option_a as 选项A,option_b as 选项B,option_c as 选项C,option_d as 选项D,answer as 答案,error_detail as 题目详解, problem as 题目难度 from ExamSubject a left join ExamSection b on a.section = b.id where a.id='" + id + "'";
         DataTable dt = new Tool().ExecuteSqlQuery(sqlString);
         txtA.Text = dt.Rows[0]["选项A"].ToString();
         txtB.Text = dt.Rows[0]["选项B"].ToString();
         txtC.Text = dt.Rows[0]["选项C"].ToString();
         txtD.Text = dt.Rows[0]["选项D"].ToString();
         cbSectionType.Text = dt.Rows[0]["章节类别"].ToString();
         cbTopic.Text = dt.Rows[0]["题目主题"].ToString();
         cbSubjectType.Text = dt.Rows[0]["题目类型"].ToString();
         txtAnswer.Text = dt.Rows[0]["答案"].ToString();
         txtQuestion.Text = dt.Rows[0]["题目问题"].ToString();
         txtpicName.Text = dt.Rows[0]["图片名称"].ToString();
         txtDetail.Text = dt.Rows[0]["题目详解"].ToString();
         checkBoxIsDifficult.Checked = dt.Rows[0]["题目难度"].ToString()=="难题强化";
     }
 }
Пример #10
0
 private void EditUserManager_Load(object sender, EventArgs e)
 {
     if(id!="")
     {
         string sqlString= "select * from ExamUser where id='"+id+"'";
         DataTable dt = new Tool().ExecuteSqlQuery(sqlString);
         txtName.Text = dt.Rows[0]["name"].ToString();
         if (txtName.Text == "admin")
         {
             txtName.Enabled = false;
         }
         txtRealName.Text = dt.Rows[0]["real_name"].ToString();
         txtPassword.Text = dt.Rows[0]["password"].ToString();
     }
 }