AfterOpenProject
'''
'数据源连接
msgbox("OpenFileargs.Count = " & OpenFileargs.Count)
msgbox("OrganizationName = " & OrganizationName )
If OpenFileargs.Count = 0 Then
Dim cmd22 As New SQLCommand
Dim dt22 As DataTable
cmd22.ConnectionName = "数据源名称"
cmd22.CommandText = "SELECT * From {用户授权} where 单位名称 = '" & OrganizationName & "'"
dt22 = cmd22.ExecuteReader
msgbox("dt22.DataRows.Count = " & dt22.DataRows.Count )
If dt22.DataRows.Count > 0 Then
Dim dr22 As DataRow = dt22.DataRows(0)
Dim s1 As String = dr22("数据源_密码")
Dim s2 As String = dr22("数据源_用户名")
Dim s3 As String = dr22("数据源_数据库名称")
Dim s4 As String = dr22("数据源_IP")
Dim cs As String = "Provider=SQLOLEDB.1;Password=" & s1 & ";Persist Security Info=True;User ID=" & s2 & ";Initial Catalog=" & s3 & ";Data Source=" & s4
Syscmd.Project.Open(ProjectFile,cs)
Return
End If
End If
'用户验证
msgbox("C数据源名称") )
Dim cmd1 As New SQLCommand
Dim dt1 As DataTable
cmd1.ConnectionName = "数据源名称"
cmd1.CommandText = "SELECT * From {机器码}"
dt1 = cmd1.ExecuteReader
msgbox("ComputerId = " & ComputerId )
Dim dr1 As DataRow = dt1.SQLFind("机器码 = '" & ComputerId & "'")
msgbox("dr1 = " & (dr1 IsNot Nothing) )
If dr1 IsNot Nothing Then
Dim dr2 As DataRow = dt1.SQLFind("机器码 = '" & ComputerId & "' AND 授权 = 1")
msgbox("dr2 = " & (dr2 IsNot Nothing) )
If dr2 IsNot Nothing Then
Dim cmd2 As New SQLCommand
Dim dt2 As DataTable
cmd2.ConnectionName = "数据源名称"
cmd2.CommandText = "SELECT 单位名称,产品有效期 From {用户授权}"
dt2 = cmd2.ExecuteReader
msgbox("dr2单位名称 = " & dr2("单位名称"))
Dim dr3 As DataRow = dt2.SQLFind("单位名称 = '" & dr2("单位名称") & "'")
msgbox("dr3 = " & (dr3 IsNot Nothing) )
If dr3 IsNot Nothing Then
Dim d1 As Date = Date.Today
Dim d2 As Date = dr3("产品有效期")
If d2 < d1 Then
MessageBox.Show("产品已过期!")
Syscmd.Project.Exit()
Return
End If
If Syscmd.Project.Update(False,False) = True '自动升级
Return
End If
Forms("用户登录").Open()
If UserName = "" Then
Syscmd.Project.Exit()
Return '这个要加上,因为既然要退出,就不应该再执行后面的初始化代码了,否则会出错
End If
……