//加载页面,通过用户名得到用户名的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();   //关闭数据库连接
        }
Esempio n. 2
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();//关闭数据连接
        }