Ejemplo n.º 1
0
        //实现右键修改选中选择题的功能
        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int             MMid = Convert.ToInt32(dataGridView1.SelectedCells[0].Value); //获取选择试题的ID值
            string          sql  = "select * from TestInfo where ID=" + MMid + "";
            OleDbConnection con  = DataClass.DBCon();

            con.Open();
            OleDbCommand    com = new OleDbCommand(sql, con);
            OleDbDataReader re  = com.ExecuteReader();

            re.Read();
            //传递选择题数据
            ComVal.TeID = MMid;
            ComVal.seTi = re[2].ToString();
            ComVal.seR  = re[3].ToString();
            ComVal.seA  = re[4].ToString();
            ComVal.seB  = re[5].ToString();
            ComVal.seC  = re[6].ToString();
            ComVal.seD  = re[7].ToString();
            re.Close();
            con.Close();
            //选择题窗体出现
            AltSel se = new AltSel();

            se.Show();
            this.Hide();    //隐藏本窗体
        }
Ejemplo n.º 2
0
        //修改
        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ComVal.StuNA = dataGridView1.SelectedCells[0].Value.ToString(); //获取考生姓名
            string          sql = "select * from UserInfo where userName='******'";
            OleDbConnection con = DataClass.DBCon();

            con.Open();
            OleDbCommand    com = new OleDbCommand(sql, con);
            OleDbDataReader re  = com.ExecuteReader();

            if (re.Read())
            {
                //传递选中考生数据
                ComVal.StuSex  = re[7].ToString();
                ComVal.StuID   = re[3].ToString();
                ComVal.Iste    = Convert.ToInt32(re[5].ToString());
                ComVal.StuPw   = re[4].ToString();
                ComVal.PicPath = re[6].ToString();
                re.Close();
                con.Close();
                //修改窗体出现

                SthInf st = new SthInf();
                st.Show();
                this.Hide();//隐藏本窗体
            }
        }
Ejemplo n.º 3
0
 //查询按钮
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "" || textBox1.Text == "")
     {
         MessageBox.Show("请输入完整数据!");
     }
     else
     {
         string sql;
         if (comboBox1.Text == "姓名")
         {
             sql = "select userName as 考生姓名,userID as 准考证号 ,selRes as 选择题,judRes as 判断题,allRes as 总分 from ExamResult where userName like'%" + textBox1.Text + "%'";
         }
         else
         {
             sql = "select userName as 考生姓名,userID as 准考证号 ,selRes as 选择题,judRes as 判断题,allRes as 总分 from ExamResult where userID='" + textBox1.Text + "'";
         }
         OleDbConnection con = DataClass.DBCon();
         con.Open();
         OleDbCommand    com = new OleDbCommand(sql, con);
         OleDbDataReader re  = com.ExecuteReader();
         //re.Read();
         if (re.Read() == false)
         {
             MessageBox.Show("没有查询结果");
             con.Close();
         }
         else
         {
             DataClass.DataGridViewBing(dataGridView1, sql);
         }
     }
 }
Ejemplo n.º 4
0
        //提交函数
        private void Handin()
        {
            //提交选择题
            string stuAns = "";

            for (int aa = 0; aa < StudentAns.Length; aa++)  //获取考生答案
            {
                stuAns += StudentAns[aa].ToString();
            }
            for (int i = 0; i < xzflag; i++)
            {
                //将考生答案与正确答案做比较
                if (RightAns.Substring(i, 1).Equals(stuAns.Substring(i, 1)))
                {
                    StuScore += xzFz; //如果答案正确加分
                }
            }
            //提交判断题
            string pdstuAns = "";

            for (int aa = 0; aa < StudentAns1.Length; aa++) //获取考生答案
            {
                pdstuAns += StudentAns1[aa].ToString();
            }
            for (int i = 0; i < pdflag; i++)
            {
                //将考生答案与正确答案做比较
                if (RightAns1.Substring(i, 1).Equals(pdstuAns.Substring(i, 1)))
                {
                    StuScore1 += pdFz; //如果答案正确加分
                }
            }
            int allscore = StuScore + StuScore1;  //计算总分

            //将考试分数上传数据库
            _conn.Open();
            _cmd = new OleDbCommand("update ExamResult set selRes='" + StuScore + "',judRes='" + StuScore1 + "', allRes='" + allscore + "' where userID='" + _studentNum + "'", _conn);

            if (_cmd.ExecuteNonQuery() > 0)
            {
                _conn.Close();
            }
            else
            {
                _cmd = new OleDbCommand("insert into ExamResult(userID,selRes,judRes,allRes,userName) values('"
                                        + _studentNum + "','" + StuScore + "','" + StuScore1 + "','" + allscore + "','" + label2.Text + "')", _conn);
                _cmd.ExecuteNonQuery();
                _conn.Close();
            }
            string          sql  = "update UserInfo set IsTest=1 where userAcc='" + _studentNum + "'";
            OleDbConnection conn = DataClass.DBCon();

            conn.Open();
            OleDbCommand cmd = new OleDbCommand(sql, conn);

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Ejemplo n.º 5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {//如果没有选中考生,禁用右键
                contextMenuStrip1.Enabled = false;
            }
            else
            {
                contextMenuStrip1.Enabled = true;

                StuNA = dataGridView1.SelectedCells[0].Value.ToString(); //获取考生姓名
                string          sql = "select * from UserInfo where userName='******'";
                OleDbConnection con = DataClass.DBCon();
                con.Open();
                OleDbCommand    com = new OleDbCommand(sql, con);
                OleDbDataReader re  = com.ExecuteReader();
                if (re.Read())
                {
                    //传递选中考生数据
                    label1.Text = re[2].ToString();
                    if (re[6].ToString() != "")
                    {
                        pictureBox1.ImageLocation = re[6].ToString();
                    }
                    else
                    {
                        switch (label1.Text)
                        {
                        case "段隆婵":

                            pictureBox1.Image = global::StudentTest.Properties.Resources.IMG_20170621_231841; break;

                        case "武嘉敏":
                            pictureBox1.Image = global::StudentTest.Properties.Resources.IMG_20170621_231946; break;

                        case "邵美琪":
                            pictureBox1.Image = global::StudentTest.Properties.Resources.img_c47071d89f960255ae10e2015ccdfc52; break;

                        case "潘昱荣":
                            pictureBox1.Image = global::StudentTest.Properties.Resources.img_3215a9af47ca2c38584ba19b2ca72599; break;

                        default: pictureBox1.Image = null; break;
                        }
                    }

                    re.Close();
                    con.Close();
                }
            }
        }
Ejemplo n.º 6
0
        //实现右键删除考生信息的功能
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string          MMid = dataGridView1.SelectedCells[0].Value.ToString(); //获取考生姓名
            OleDbConnection con  = DataClass.DBCon();

            con.Open();
            OleDbCommand com = new OleDbCommand("delete * from ExamResult where userName='******'", con);

            com.ExecuteNonQuery();                                                //如果该考生有成绩记录,则一起删除
            con.Close();
            string sql = "delete * from UserInfo where userName='******' "; //声明SQL语句用于删除

            DataClass.OperaData(sql);                                             //调用DeleteData方法
            StuManage_Load(sender, e);                                            //刷新当前窗体
        }
Ejemplo n.º 7
0
        //读取原本的数据
        private void ExSet_Load(object sender, EventArgs e)
        {
            label9.BackColor = Color.Transparent;
            OleDbConnection con = DataClass.DBCon();

            con.Open();
            string          sql = "select * from ExamSet where ID=1";
            OleDbCommand    com = new OleDbCommand(sql, con);
            OleDbDataReader re  = com.ExecuteReader();

            re.Read();
            coXR.Text = re[1].ToString();
            coX.Text  = re[2].ToString();
            coPR.Text = re[3].ToString();
            coP.Text  = re[4].ToString();
            texT.Text = re[5].ToString();
            con.Close();
        }
Ejemplo n.º 8
0
 public static Exam ex  = new Exam();  //声明静态全局变量 考试窗口实例
 private void LogButt_Click(object sender, EventArgs e)
 {
     //判断是否选择登陆身份
     if (useIdeTextBox.Text == "")
     {
         MessageBox.Show("请选择登陆身份!");
     }
     else
     {
         //判断是否输入用户名和密码
         if (accTextBox.Text == "" || pwdTxtBox.Text == "")
         {
             MessageBox.Show("请输入用户名和密码!");
         }
         else
         {
             //如果是考生
             if (useIdeTextBox.Text == "考生")
             {
                 //判断用户名密码是否符合
                 OleDbConnection con = DataClass.DBCon();
                 con.Open();
                 OleDbCommand com = new OleDbCommand(
                     "select * from UserInfo where userAcc='" + accTextBox.Text + "' and userPwd='" + pwdTxtBox.Text + "' and userIde=0", con);
                 OleDbDataReader red = com.ExecuteReader();
                 red.Read();
                 if (red.HasRows)
                 {
                     ComVal.userPwd = pwdTxtBox.Text;
                     ComVal.userAcc = accTextBox.Text;
                     Exam._Useracc  = ComVal.userAcc; //传递用户名
                     ex.Show();                       //显示考试窗口
                     this.Hide();
                 }
                 else
                 {
                     MessageBox.Show("用户名或密码错误!");
                 }
                 con.Close();
             }
             else
             {
                 //如果不是学生,则判断管理员的身份是否符合
                 OleDbConnection con = DataClass.DBCon();
                 con.Open();
                 OleDbCommand com = new OleDbCommand(
                     "select * from UserInfo where userIde=1 and userAcc='" + accTextBox.Text + "' and userPwd='" + pwdTxtBox.Text + "'", con);
                 OleDbDataReader red = com.ExecuteReader();
                 red.Read();
                 if (red.HasRows)
                 {
                     //上传用户名密码
                     ComVal.userPwd  = pwdTxtBox.Text;
                     ComVal.userAcc  = accTextBox.Text;
                     ComVal.userName = red[2].ToString();
                     ad.Show();//显示管理员窗口
                     this.Hide();
                 }
                 else
                 {
                     MessageBox.Show("用户名或密码错误!");
                 }
                 con.Close();
             }
         }
     }
 }