Esempio n. 1
0
//--------------------------------------------------------------教师功能---------------------------------------------
//一、成绩查询
//1.查询所有成绩
        //查询所有成绩
        private void 查询所有成绩ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //控制显示学生成绩的控件的初始位置
            dataGridView1.Top    = 25;
            dataGridView1.Left   = 30;
            dataGridView1.Height = 350;
            dataGridView1.Rows.Clear();                         //初始化dataGridView
            dataGridView1.Visible   = true;                     //显示控件
            GeRenChengji_op.Visible = false;
            DBlink db = new DBlink();                           //创建数据库连接实例

            if (db.DBconn())                                    //连接数据库
            {
                db.GetScoreData("select * from student_score"); //执行sql
            }
            db.DBclose();                                       //关闭数据库连接

            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];      //填充姓名
            }
        }
Esempio n. 2
0
//--------------------------------------------------------------学生功能---------------------------------------------
//一、成绩查询
//1.查询个人成绩
        private void 个人成绩查询ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            dataGridView1.Top    = 25;
            dataGridView1.Left   = 30;
            dataGridView1.Height = 350;
            dataGridView1.Rows.Clear();   //初始化dataGridView
            dataGridView1.Visible = true; //显示控件
            DBlink db = new DBlink();

            if (db.DBconn())
            {
                db.GetScoreData("select * from student_score where number='" + LoginInfo.number + "'"); //执行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();
        }
Esempio n. 3
0
//2.删除用户
        private void  除用户ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DBlink db = new DBlink();       //创建数据库连接实例

            if (db.DBconn())
            {              //打开数据库连接
                db.GetUserInfoData("select * from login_info");
            }
            db.DBclose();                                    //关闭数据库连接
            dataGridView2.Rows.Clear();                      //初始化dataGridView
            for (int i = 0; i < LoginInfo.idList.Count; i++) //循环将数据实体类的数据存放到dataGridView中
            {
                int index = this.dataGridView2.Rows.Add();
                //实现隔行换色
                if (i % 2 == 0)
                {
                    this.dataGridView2.Rows[index].DefaultCellStyle.BackColor = Color.Gainsboro;//双数行
                }
                else
                {
                    this.dataGridView2.Rows[index].DefaultCellStyle.BackColor = Color.GhostWhite; //单数行
                }
                this.dataGridView2.Rows[index].Cells[0].Value = LoginInfo.idList[i];              //填充序号
                this.dataGridView2.Rows[index].Cells[1].Value = LoginInfo.usernameList[i];        //填充用户名
                this.dataGridView2.Rows[index].Cells[2].Value = LoginInfo.passwordList[i];        //填充密码
                if (LoginInfo.SfList[i].Equals("s"))                                              //根据SF的值填充用户身份
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "学生";
                }
                else if (LoginInfo.SfList[i].Equals("t"))
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "教师";
                }
                else
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "管理员";
                }

                this.dataGridView2.Rows[index].Cells[4].Value = LoginInfo.numberList[i]; //填充用户编号
                this.dataGridView2.Rows[index].Cells[5].Value = LoginInfo.banjiList[i];  //填充用户所属班级
            }
            //控制显示用户信息数据的dataGridView出现的位置
            dataGridView2.Top     = 25;
            dataGridView2.Left    = 30;
            dataGridView2.Height  = 350;
            dataGridView2.Visible = true;//显示数据集
            //控制操作的出现位置,给控件赋值
            panel1.Top         = 400;
            panel1.Left        = 30;
            panel1.Visible     = true;  //显示删除操作面板
            daishenghe.Visible = false; //隐藏审核操作面板
            RG.Visible         = false; //隐藏注册窗体
        }
Esempio n. 4
0
        //删除用户的按钮事件
        private void button2_Click(object sender, EventArgs e)
        {
            string str = "delete from login_info where username='******' and SF!= 'a'";
            DBlink db  = new DBlink();

            if (db.DBconn())
            {
                if (db.UpdataDeletAdd(str))//修改当前用户的tag标志
                {
                    DialogResult dr = MessageBox.Show("用户" + textBox1.Text + "删除成功!", "标题", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    除用户ToolStripMenuItem_Click(null, null); //重新加载数据
                    //将用户输入的内容和提示信息文本置空
                    textBox2.Text = "";
                    label5.Text   = "";
                }
            }
        }
Esempio n. 5
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;
                }
            }
        }
Esempio n. 6
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;
                }
            }
        }
Esempio n. 7
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();
            }
        }