Example #1
0
        //管理员输入审核用户名时验证该用户是否存在,并提示
        private void textBox2_KeyUp(object sender, KeyEventArgs e)
        {
            DBlink db = new DBlink();

            if (db.DBconn())
            {
                string str = "select * from login_info where username='******'";
                if (db.search(str))
                {
                    label5.Text     = "*删除用户!" + textBox2.Text + "?请点击删除按钮";
                    button2.Enabled = true;
                }
                else
                {
                    label5.Text     = "*用户不存在!";
                    button2.Enabled = false;
                }
            }
        }
Example #2
0
        //管理员输入审核用户名时验证该用户是否存在,并提示
        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            DBlink db = new DBlink();

            if (db.DBconn())
            {
                string str = "select * from login_info where tag=0 and username='******'";
                if (db.search(str))
                {
                    label3.Text     = "*该用户未审核!";
                    button1.Enabled = true;
                }
                else
                {
                    label3.Text     = "*用户不存在!";
                    button1.Enabled = false;
                }
            }
        }
Example #3
0
        //教师输入要查询的学号时验证该学号的成绩信息是否已经存在
        private void StuNum_in_KeyUp(object sender, KeyEventArgs e)
        {
            dataGridView1.Rows.Clear(); //初始化dataGridView
            DBlink  db  = new DBlink();
            Boolean tag = false;        //辅助标记,先查询该学号是否存在,若存在再进行数据查询的操作
            string  str = "select * from login_info where number='" + StuNum_in.Text + "'";

            if (db.DBconn())  //连接数据库成功
            {
                if (db.search(str))
                {
                    Search_TS.Text = "查询到" + StuNum_in.Text + "同学的成绩信息如上!";
                    tag            = true;
                }
                else
                {
                    Search_TS.Text = "该用户不存在";
                }
            }
            db.DBclose(); //避免多线程操作数据库,影响系统报错,先关闭数据连接

            if (tag)      //输入的学号在用户名中存在
            {
                if (db.DBconn())
                {
                    db.GetScoreData("select * from student_score where number='" + StuNum_in.Text + "'"); //执行sql
                    for (int i = 0; i < ScoreInfo.id.Count; i++)                                          //循环将数据实体类的数据存放到dataGridView中
                    {
                        int index = this.dataGridView1.Rows.Add();
                        this.dataGridView1.Rows[index].Cells[0].Value = ScoreInfo.id[i];        //填充编号
                        this.dataGridView1.Rows[index].Cells[1].Value = ScoreInfo.number[i];    //填充学号
                        this.dataGridView1.Rows[index].Cells[2].Value = ScoreInfo.xueqi[i];     //填充课程归属
                        this.dataGridView1.Rows[index].Cells[3].Value = ScoreInfo.kecheng[i];   //填充课程名
                        this.dataGridView1.Rows[index].Cells[4].Value = ScoreInfo.chengji[i];   //填充成绩
                        this.dataGridView1.Rows[index].Cells[5].Value = ScoreInfo.name[i];      //填充姓名
                    }
                }
                db.DBclose();
            }
        }