SqlConnection con = data.DBConnection();
            con.Open();
            if (tbxid.Text == "" && tbxPassw.Text == "")
            {
                MessageBox.Show("用户名和密码为空!");
                tbxid.Focus();
            }            else
            {
                string s = "select * from userinfo where userid='" + tbxid.Text.Trim()
                      + "' and userpassw='" + tbxPassw.Text.Trim() + "'";
                SqlCommand cmd = new SqlCommand(s, con);
                //int count = Convert.ToInt32(cmd.ExecuteScalar());
                 //if (count > 0)
                 //{
                     //Main M = new Main();
                     //M.Show();
                     //this.Hide();
                 //}
                 SqlDataReader result = cmd.ExecuteReader();
                 if (result.Read() == true)
               {
               }
                 
                    else
                 {
                     MessageBox.Show("用户名和密码错误!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     tbxid.Text = "";
                     tbxPassw.Text = "";
                     tbxid.Focus();
                 }
            }
            con.Close();我的意思是以上代码中,屏蔽的那部分是没有判断的,只是有数据就可以登录!但我要的是红色字体里面如何实现判断用户的权限,从而进不同权限的页面,即席在不同的页面传递不知道如何代码实现,请指教,谢谢
        

解决方案 »

  1.   

                SqlConnection con = data.DBConnection();
                con.Open();
                if (tbxid.Text == "" && tbxPassw.Text == "")
                {
                    MessageBox.Show("用户名和密码为空!");
                    tbxid.Focus();
                }            else
                {
                    string s = "select * from userinfo where userid='" + tbxid.Text.Trim()
                          + "' and userpassw='" + tbxPassw.Text.Trim() + "'";
                    SqlCommand cmd = new SqlCommand(s, con);
                    //int count = Convert.ToInt32(cmd.ExecuteScalar());
                     //if (count > 0)
                     //{
                         //Main M = new Main();
                         //M.Show();
                         //this.Hide();
                     //}
                     SqlDataReader result = cmd.ExecuteReader();
                     if (result.Read() == true)
                   {
                   }
                     
                        else
                     {
                         MessageBox.Show("用户名和密码错误!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         tbxid.Text = "";
                         tbxPassw.Text = "";
                         tbxid.Focus();
                     }
                }
                con.Close();我的意思是以上代码中,屏蔽的那部分是没有判断的,只是有数据就可以登录!但我要的是红色字体里面如何实现判断用户的权限,从而进不同权限的页面,即席在不同的页面传递不知道如何代码实现,请指教,谢谢