前端之家收集整理的这篇文章主要介绍了
[VB.NET]登陆窗口登陆成功后的ID值如何取出来....,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
登陆窗口登陆成功后的ID值如何取出来.... Public UserName As String = Public UserId As String = Public Shared Sub Main()
显示登陆对话框 Dim loginFrm As frmLogin = New frmLogin loginFrm.ShowDialog() 合法
用户进入系统 If loginFrm.bResult = True Then Dim frm As frmMain = New frmMain frm.UserName = loginFrm.UserName frm.UserId = loginFrm.UserId Application.Run(frm) End If Application.Run(New frmMain) End Sub Private Sub SetRight(ByVal sUserId As String) If sUserId = 1 Then MenuItemGoodsInfo.Enabled = True MenuItemSupplyInfo.Enabled = True MenuItemClientInfo.Enabled = True MenuItemOrderList.Enabled = True MenuItemSellList.Enabled = True MenuItemDepotSearch.Enabled = True MenuItemManageRight.Enabled = True End If Dim db As DataBase = New DataBase 根据当前登陆
用户从
数据库查询他的权限 Dim str
sql As String = SELECT
用户编号,权限
名称 str
sql += FROM 权限清单 where
用户编号= + sUserId + Dim dvRight As DataView = db.RunSelect
sql(str
sql) Dim i As Integer Dim sRight As String 根据当前登陆
用户权限设置
菜单项是否可用 For i = 0 To dvRight.Count - 1 sRight = dvRight(i)( 权限
名称 ) sRight = sRight.Trim() If sRight = MenuItemGoodsInfo.Text.Trim() Then MenuItemGoodsInfo.Enabled = True ElseIf sRight = MenuItemSupplyInfo.Text.Trim() Then MenuItemSupplyInfo.Enabled = True ElseIf sRight = MenuItemClientInfo.Text.Trim() Then MenuItemClientInfo.Enabled = True ElseIf sRight = MenuItemOrderList.Text.Trim() Then MenuItemOrderList.Enabled = True ElseIf sRight = MenuItemSellList.Text.Trim() Then MenuItemSellList.Enabled = True ElseIf sRight = MenuItemDepotSearch.Text.Trim() Then MenuItemDepotSearch.Enabled = True ElseIf sRight = MenuItemManageRight.Text.Trim() Then MenuItemManageRight.Enabled = True End If Next db.Dispose() End Sub Private Sub frmMain_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load 根据登陆
用户的ID设置
菜单 Me.SetRight(Me.UserId) End Sub __________________________________________________________________________ 好象没取出来,因为除了 1 以外的ID都是灰色
菜单.... __________________________________________________________________________ 我也觉得奇怪,登陆时设个
全局变量很困难一样。 __________________________________________________________________________ 你也这个问题? __________________________________________________________________________ 我顶~~~ __________________________________________________________________________ 我也在弄权限设定,不会写
代码,帮楼上的顶,楼上的
解决了话发我一份参考下 __________________________________________________________________________ 取个值咋就这么难..... __________________________________________________________________________ 我继续顶 __________________________________________________________________________ 还顶,帮忙啊~~~~~ __________________________________________________________________________ 帮你顶 __________________________________________________________________________ 你试一下在frmMain中写个窗体重载,然后通过这个重载过程来传递ID值等参数。 __________________________________________________________________________ 调整下思路,新增个模块
文件,在里面申明个
全局变量UserId,里面创建过程 Public Sub Main() 在过程里写
登录代码,在
登录窗口中记录
登录的
用户ID,并用变量记录客户是选择确定,还是取消操作。 判断客户选择的操作,如果是取消操作,则
退出系统,如果是确定操作,则根据
用户ID设置权限。 最后
修改工程的启动对象为Sub Main __________________________________________________________________________
原文链接:/vb/263432.html