Ejemplo n.º 1
0
        //--------------------------------------------------------------用户功能---------------------------------------------
        //一、成绩管理
        private void 成绩管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            panel3.Visible = false;
            panel4.Visible = true;    //隐藏成绩与课程信息

            DBlink db = new DBlink(); //创建数据库连接对象

            if (db.DBconn())
            {          //创建数据库连接
                string Str1 = "select Id from login_info WHERE username = '******'";
                Globel.Id = db.Getstringsearch(Str1);
            }
            db.DBclose();   //关闭数据库连接
            string sql = "SELECT score_info.Id as 学号, score_info.name as 姓名,score_info.course_name as 课程,score_info.score as 成绩 FROM score_info";

            if (LoginInfo.id_tag.Equals("s"))
            {
                BindsocreData("select score_info.Id as 学号, score_info.name as 姓名,score_info.course_name as 课程,score_info.score as 成绩 from score_info where Id = '" + Globel.Id + "'");
            }
            else if (LoginInfo.id_tag.Equals("t"))
            {
                BindsocreData(sql);
                panel5.Visible = true; //教师可以管理成绩
                panel6.Visible = true; //教师可以查询成绩
            }
            else if (LoginInfo.id_tag.Equals("ts"))
            {
                BindsocreData(sql);
                panel6.Visible = true;//教学秘书可以查询成绩
            }
        }
Ejemplo n.º 2
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.id_tagList[i].Equals("s"))                                          //根据SF的值填充用户身份
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "学生";
                }
                else if (LoginInfo.id_tagList[i].Equals("t"))
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "教师";
                }
                else if (LoginInfo.id_tagList[i].Equals("ts"))
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "教学秘书";
                }
                else
                {
                    this.dataGridView2.Rows[index].Cells[3].Value = "管理员";
                }
            }
            //控制显示用户信息数据的dataGridView出现的位置
            dataGridView2.Top     = 25;
            dataGridView2.Left    = 30;
            dataGridView2.Height  = 350;
            dataGridView2.Visible = true;//显示数据集
            //控制操作的出现位置,给控件赋值
            panel1.Top     = 400;
            panel1.Left    = 30;
            panel1.Visible = true;  //显示删除操作面板
            panel2.Visible = false; //隐藏审核操作面板
            RG.Visible     = false; //隐藏注册窗体
        }
Ejemplo n.º 3
0
        //更新成绩
        private void button6_Click(object sender, EventArgs e)
        {
            ScoreInfo.id        = textBox6.Text;
            ScoreInfo.course_id = textBox7.Text;
            ScoreInfo.score     = numericUpDown1.Value.ToString();
            string Str3 = "select count(*) from score_info where Id = '" + ScoreInfo.id + "'and Course_Id = '" + ScoreInfo.course_id + "'";
            string str5 = "update score_info set score = '" + ScoreInfo.score + "'where Course_Id = '" + ScoreInfo.course_id + "'and Id = '" + ScoreInfo.id + "'";
            DBlink db   = new DBlink(); //创建数据库连接对象
            DBlink db4  = new DBlink(); //创建数据库连接对象

            if (db4.DBconn())
            { //连接数据库
                string Str1 = "select Course_name from course_information where Course_Id = " + ScoreInfo.course_id;
                string Str2 = "select name from user_information where Id = " + ScoreInfo.id;
                ScoreInfo.course_name = db4.Getstringsearch(Str1);
                ScoreInfo.name        = db4.Getstringsearch(Str2);
                //MessageBox.Show(ScoreInfo.course_id + ScoreInfo.course_name);
                int count = db4.GetIntsearch(Str3);
                if (count == 0)
                {
                    string str4 = "insert into score_info(name,Id,Course_name,Course_Id,score) " +
                                  "values('" + ScoreInfo.name + "','" + ScoreInfo.id + "','" + ScoreInfo.course_name + "','" + ScoreInfo.course_id + "','"
                                  + ScoreInfo.score + "');";
                    bool bool6 = db4.UpdataDeletAdd(str4);// 执行查询
                    if (bool6)
                    {
                        MessageBox.Show("更新记录成功!");
                    }
                    else
                    {
                        MessageBox.Show("更新记录失败!");
                    }
                }
                else
                {
                    bool bool7 = db4.UpdataDeletAdd(str5);// 执行查询
                    if (bool7)
                    {
                        MessageBox.Show("更新记录成功!");
                    }
                    else
                    {
                        MessageBox.Show("更新记录失败!");
                    }
                }
            }
            db4.DBclose();//关闭数据连接
            string sql = "SELECT score_info.Id as 学号, score_info.name as 姓名,score_info.course_name as 课程,score_info.score as 成绩 FROM score_info";

            BindsocreData(sql);
        }
Ejemplo 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   = "";
                }
            }
        }
Ejemplo 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;
                }
            }
        }
Ejemplo 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;
                }
            }
        }
Ejemplo n.º 7
0
        //退出
        //删除成绩
        private void button7_Click(object sender, EventArgs e)
        {
            ScoreInfo.id        = textBox6.Text;
            ScoreInfo.course_id = textBox7.Text;
            string delsql = "delete from score_info where Id= '" + ScoreInfo.id + "'and Course_Id = '" + ScoreInfo.course_id + "'";
            DBlink db4    = new DBlink(); //创建数据库连接对象

            if (db4.DBconn())
            { //连接数据库
                if (db4.UpdataDeletAdd(delsql))
                {
                    MessageBox.Show("删除记录成功!");
                }
                else
                {
                    MessageBox.Show("删除失败!");
                }
            }
            db4.DBclose();//关闭数据连接
            string sql = "SELECT score_info.Id as 学号, score_info.name as 姓名,score_info.course_name as 课程,score_info.score as 成绩 FROM score_info";

            BindsocreData(sql);
        }