我用的数据库的SQL SERVER 2000,我在数据库里用户资料里定义了1.2.3等权限,希望用户根据权限打开相应的界面,没有
权利打开的界面显示灰色.请问各位高手哥哥姐姐,相应的界面上应该写什么样的代码,请将您认为该写的代码展示给小弟看,感激不尽
高手大哥,下面是我的登陆代码:
'Public UserStatus As String
'Public Maxlogintimes As String = 3
Public User As String
Public password As String
Dim conn As New SqlConnection("Server=.;" & _
"Database=yysjk; " & _
"Integrated Security=SSPI ")
Dim comm As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
User = TextBox1.Text
password = TextBox2.Text
Dim str As String
str = "select * from 员工信息 where 姓名='" & User & "' and 密码='" & password & "'"
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = str
da.SelectCommand = comm
Try
conn.Open()
da.Fill(ds)
If ds.Tables(0).Rows.Count <> 0 Then
Dim frm2 As New 主界面
frm2.Show()
Me.Hide()
Else
MessageBox.Show("密码或用户名错误,请重新输入", "提示信息")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
Catch ex As Exception
MessageBox.Show("登陆失败", "提示信息")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
Application.Exit()
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) _
And TextBox2.Text <> "" Then
Me.Button1_Click(Nothing, Nothing)
End If
End Sub
End Class
当用户名和密码检查完后,他们都将进入一个主界面,这个主界面含有许多mainmenu控件.我想,是不是要在这些mainmenu控件的下拉菜单上加上一些权限判断代码,如果用户权限符合菜单权限,则显示能用,如果不符合,则显示灰色.
小弟初学,不知道对不对,还请您多多指教.感激不尽!