Example #1
0
        private void textBox3_Leave(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1  = "select count(*) from course_information where Id = " + textBox3.Text;
                string count = db3.Getstringsearch(Str1);
                if (count.Equals("0"))
                {
                    MessageBox.Show("该老师不存在,请重新输入");
                }
                else
                {
                    bool2 = true;
                }
            }
            db3.DBclose();//关闭数据连接
        }
Example #2
0
        private void textBox1_Leave(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1  = "select count(*) from course_information where Course_Id = " + textBox1.Text;
                string count = db3.Getstringsearch(Str1);
                if (count.Equals("1"))
                {
                    MessageBox.Show("该课程信息已经录入,请移步信息维护界面");
                    this.Close();
                }
                else
                {
                    bool1 = true;
                }
            }
            db3.DBclose();//关闭数据连接
        }
        //加载页面,通过用户名得到用户名的Id
        private void User_info_display_Load(object sender, EventArgs e)
        {
            panel1.Visible = false;//默认不可以看其他用户信息
            // 设置日历控件选择时间范围,生日不得超过今天
            dateTimePicker1.MinDate = new DateTime(1990, 1, 1);
            dateTimePicker1.MaxDate = DateTime.Today;
            if (Globel.id_tag.Equals("ts"))
            {
                panel1.Visible = true;//如果是教学秘书可以查看其他人的信息
            }
            else
            {
            }
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())
            {          //创建数据库连接
                string Str1 = "select Id from login_info WHERE username = '******'";
                Globel.Id = db.Getstringsearch(Str1);
                string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'";
                if (db.Getstringsearch(Str2).Equals(""))
                {
                    MessageBox.Show("您的个人信息还未录入,请先录入");
                    this.Close();
                }
                else
                {
                    string Str3 = "Select Count(*) from user_information";
                    MaxValue = db.GetIntsearch(Str3);
                    string Str4   = "select number from user_information WHERE Id = " + Globel.Id;
                    int    number = db.GetIntsearch(Str4);
                    string Str5   = "SELECT count(*) FROM user_information WHERE number <=" + number;
                    sta = db.GetIntsearch(Str5);
                    showInfo(sta - 1);
                }
            }
            db.DBclose();   //关闭数据库连接
        }
        private void button3_Click(object sender, EventArgs e)
        {
            ScoreInfo.id        = textBox1.Text;
            ScoreInfo.course_id = textBox2.Text;
            string delsql = "delete from score_info where Id= '" + ScoreInfo.id + "'and Course_Id = '" + ScoreInfo.course_id + "'";
            //delete from user_information where Id= 266;
            DBlink db4 = new DBlink();   //创建数据库连接对象

            if (db4.DBconn())
            { //连接数据库
                if (db4.UpdataDeletAdd(delsql))
                {
                    MessageBox.Show("删除记录成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("删除失败!");
                    this.Close();
                }
            }
            db4.DBclose();//关闭数据连接
        }
Example #5
0
        //确定
        private void button3_Click(object sender, EventArgs e)
        {
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())
            { //连接数据库
                string str1 = "insert into course_information(Course_Id,course_name,course_type,Obligatory,credit,Theoretical_hours,Experimental_hours,id) " +
                              "values('" + course_info.course_id + "','" + course_info.course_name + "','" + course_info.course_type + "','" + course_info.Obligatory + "','"
                              + course_info.credit + "','" + course_info.Theoretical_hours + "','"
                              + course_info.Experimental_hours + "','" + course_info.id + "');";
                string info = "提交成功!";
                if (db.UpdataDeletAdd(str1))
                {
                    DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    if (dr == DialogResult.OK)
                    {
                        this.Visible = false;//隐藏当前窗口
                    }
                }
            }

            db.DBclose();//关闭数据连接
        }
Example #6
0
        //验证用户登录
        private void DoLogin_Click(object sender, EventArgs e)
        {
            DBlink db = new DBlink();                              //创建数据库连接对象

            Identification.identification(identity.SelectedIndex); //根据用户选择的值判断用户身份
            if (db.DBconn())
            {
                //数据库连接成功
                if (db.GetLoginData("select * from login_info where id_tag='" + Globel.id_tag + "'and username='******'"))
                {
                    //用户存在
                    if (int.Parse(LoginInfo.tag) == 1)             //账号已被审核允许登录
                    {
                        if (Tpass.Text.Equals(LoginInfo.password)) //登录成功
                        {
                            Globel.username = Tusername.Text;
                            new MainMenu().ShowDialog();//显示主菜单界面
                            this.Hide();
                            this.Visible = false;
                        }
                        else    //密码错误
                        {
                            label6.Text = "密码错误!";
                        }
                    }
                    else    //账号未审核
                    {
                        label6.Text = "该账号未审核,请联系管理员";
                    }
                }
                else
                {
                    label6.Text = "登录失败,用户名不存在!";
                }
            }
            db.DBclose();//关闭数据库连接
        }
Example #7
0
        private void button7_Click_1(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            {                                               //连接数据库
                string Str1    = "select COUNT(*) from course_information WHERE Course_Id = " + textBox4.Text;
                string count   = db3.Getstringsearch(Str1); // 执行查询
                string Str2    = "select number from course_information WHERE Course_Id = " + textBox4.Text;
                int    counter = db3.GetIntsearch(Str2);
                if (count.Equals("0"))
                {
                    MessageBox.Show("抱歉未查询到该课程信息");
                    this.Close();
                }
                else if (count.Equals("1"))
                {
                    string Str4 = "SELECT count(*) FROM course_information WHERE number <= " + counter;
                    sta = db3.GetIntsearch(Str4);
                    showInfo(sta - 1);
                }
            }
            db3.DBclose();//关闭数据连接
        }
        //提交用户信息
        private void button1_Click(object sender, EventArgs e)
        {
            //格式化用户所提交之信息
            User_info.id   = textBox1.Text;
            Globel.Id      = User_info.id;
            User_info.name = Textname.Text;
            if (radioButton1.Checked)
            {
                User_info.sex = radioButton1.Text;
            }
            else
            {
                User_info.sex = radioButton2.Text;
            }
            User_info.birth = dateTimePicker1.Value.Date.ToLongDateString();
            //MessageBox.Show(DateTime.Now.ToShortDateString().ToString());
            User_info.College_Id = chooseCollege.SelectedItem.ToString();
            User_info.Speciality = textBox2.Text;
            User_info.Hobby      = "";
            if (checkBox1.Checked)
            {
                User_info.Hobby += checkBox1.Text;
            }
            if (checkBox2.Checked)
            {
                User_info.Hobby += "、" + checkBox2.Text;
            }
            if (checkBox3.Checked)
            {
                User_info.Hobby += "、" + checkBox3.Text;
            }
            if (checkBox4.Checked)
            {
                User_info.Hobby += "、" + checkBox4.Text;
            }
            if (checkBox5.Checked)
            {
                User_info.Hobby += "、" + checkBox5.Text;
            }
            if (checkBox6.Checked)
            {
                User_info.Hobby += "、" + checkBox6.Text;
            }
            User_info.Political_Outlook = comboBox2.SelectedItem.ToString();
            User_info.qualifications    = comboBox3.SelectedItem.ToString();
            User_info.id_tag            = Globel.id_tag;
            //满足条件才能提交信息
            if (bool1 == true)
            {
                DBlink db = new DBlink(); //创建数据库连接对象
                if (db.DBconn())
                {                         //连接数据库
                    string str1 = "insert into user_information(Id,name,sex,birth,College_Id,Speciality,Hobby,Political_Outlook,qualifications,id_tag) " +
                                  "values('" + User_info.id + "','" + User_info.name + "','" + User_info.sex + "','" + User_info.birth + "','" + User_info.College_Id + "','" + User_info.Speciality + "','"
                                  + User_info.Hobby + "','" + User_info.Political_Outlook + "','" + User_info.qualifications + "','" + User_info.id_tag + "');";
                    string info = "提交成功!";

                    if (db.UpdataDeletAdd(str1))
                    {
                        DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        if (dr == DialogResult.OK)
                        {
                            this.Visible = false;//隐藏当前窗口
                        }
                    }
                }

                db.DBclose();//关闭数据连接
            }
            else
            {
                MessageBox.Show("您的学号输入错误,请核对");
            }
        }
        //更新按钮
        private void button1_Click(object sender, EventArgs e)
        {
            User_info.name = textBox2.Text;
            if (radioButton1.Checked)
            {
                User_info.sex = radioButton1.Text;
            }
            else
            {
                User_info.sex = radioButton2.Text;
            }
            User_info.birth      = dateTimePicker1.Value.Date.ToLongDateString();
            User_info.College_Id = comboBox1.SelectedItem.ToString();
            User_info.Speciality = textBox3.Text;
            User_info.Hobby      = "";
            if (checkBox1.Checked)
            {
                User_info.Hobby += checkBox1.Text;
            }
            if (checkBox2.Checked)
            {
                User_info.Hobby += "、" + checkBox2.Text;
            }
            if (checkBox3.Checked)
            {
                User_info.Hobby += "、" + checkBox3.Text;
            }
            if (checkBox4.Checked)
            {
                User_info.Hobby += "、" + checkBox4.Text;
            }
            if (checkBox5.Checked)
            {
                User_info.Hobby += "、" + checkBox5.Text;
            }
            if (checkBox6.Checked)
            {
                User_info.Hobby += "、" + checkBox6.Text;
            }
            User_info.Political_Outlook = comboBox2.SelectedItem.ToString();
            User_info.qualifications    = comboBox3.SelectedItem.ToString();
            User_info.id_tag            = Globel.id_tag;

            string uptsql;

            uptsql = "update user_information set name='" + User_info.name + "', sex='" + User_info.sex + "', birth='" + User_info.birth + "', College_Id='" + User_info.College_Id +
                     "', Speciality='" + User_info.Speciality + "', Hobby='" + User_info.Hobby + "', Political_Outlook ='" + User_info.Political_Outlook +
                     "', qualifications='" + User_info.qualifications + "'where Id=" + Globel.Id;
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1 = "select Id from login_info WHERE username = '******'";
                Globel.Id = db3.Getstringsearch(Str1);
                string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'";
                if (!db3.Getstringsearch(Str2).Equals(textBox2.Text))
                {
                    MessageBox.Show("您不能修改其他用户信息");
                    this.Close();
                }
                else
                {
                    if (db3.UpdataDeletAdd(uptsql))
                    {
                        MessageBox.Show("用户信息更新成功", "更新成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("未更新,请检查!", "无更新", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            db3.DBclose();//关闭数据连接
            //showInfo(state);
        }