Exemple #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            //int i = 0;
            SqlConnection conn = new SqlConnection(StrConn);

            conn.Open();
            //MessageBox.Show("数据库连接成功", "好");
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "Select * FROM [User]";
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                usersys u = new usersys();
                u.UserName  = reader["UserName"].ToString();
                u.Date      = reader["Date"].ToString();
                u.Rank      = reader["Rank"].ToString();
                u.UserState = reader["State"].ToString();
                listUser.Add(u);

                /*  TextBox1.Text = reader["UserName"].ToString();*/
            }
            //length=listUser.Count;
            /*TextBox1.Text = UserName[1];*/
            reader.Close();
            conn.Close();
        }
Exemple #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            string susername = Session["susername"].ToString();

            SuperUserName = susername;
            //int i = 0;
            //   string superUserName=Session["UserName"]==null?"":Session["UserName"].ToString();
            // SuperUserName = Session["UserName"] == null ? "" : Session["susername"].ToString();
            SqlConnection conn = new SqlConnection(StrConn);

            conn.Open();
            //MessageBox.Show("数据库连接成功", "好");
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "Select * FROM [User] Where Rank=3";
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                usersys u = new usersys();
                u.UserName = reader["UserName"].ToString();
                u.Date     = reader["Date"].ToString();
                if (reader["Rank"].ToString() == "3")
                {
                    u.Rank = "管理员";
                }
                u.UserState = reader["State"].ToString();
                listUser.Add(u);

                /*  TextBox1.Text = reader["UserName"].ToString();*/
            }
            //length=listUser.Count;
            /*TextBox1.Text = UserName[1];*/
            reader.Close();
            conn.Close();
        }