以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  项目BeforeOpenProject事件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=38218)

--  作者:mamuaiqing
--  发布时间:2013/7/23 10:00:00
--  项目BeforeOpenProject事件

项目BeforeOpenProject事件中写入下面的代码,打开项目前出现图中提示

If UKey.Start() Then
    Dim jm As String
    Dim pd As Boolean = False
    Dim cmd As New SQLCommand
    Dim dt As DataTable
    cmd.C
    cmd.CommandText = "SELECT * From {加密狗用户表} "
    dt = cmd.ExecuteReader
    If dt.DataRows.Count > 0 Then
        jm = dt.DataRows(0)("加密字符")
        For Each dr As DataRow In dt.DataRows
            If UKey.Encrypt2(jm) <> dr("用户结果") Then
                pd = True
                Exit For
            End If
        Next
        If pd = True Then
            MessageBox.Show("请插上XX公司提供的UKey!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            e.Cancel = True
        End If
    End If
Else
    MessageBox.Show("启动UKey失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel = True
End If


图片点击可在新窗口打开查看此主题相关图片如下:图1.png
图片点击可在新窗口打开查看

--  作者:mamuaiqing
--  发布时间:2013/7/23 10:03:00
--  
BeforeOpenProject事件是不是不能用读取数据代码?
--  作者:Bin
--  发布时间:2013/7/23 10:07:00
--  
这个时候还不能使用  SQLCommand吧 这个messagebox.show 分析调试一下即可知道.
--  作者:mamuaiqing
--  发布时间:2013/7/23 10:21:00
--  

感谢Bin老师,因为项目中要用到多个Ukey,每个的加密结果都不一样,难道只能用帮助文件那样,也要写多个加密结果?

If UKey.Start() Then
    If UKey.Encrypt2("abc") <> "483DBF9FDD0574C0" Then
       
MessageBox.Show("请插上XX公司提供的UKey!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = True
    End
If

Else

    MessageBox.Show("启动UKey失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel =
True

End
If


--  作者:Bin
--  发布时间:2013/7/23 10:27:00
--  
要不你写到AlterOpenProject事件里面去吧,判断不符合要求执行退出程序代码
--  作者:mamuaiqing
--  发布时间:2013/7/23 10:33:00
--  
OK