Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.Con nection Name = "User"
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Sel ect * From {Users} Wh ere [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.DataRows.Count = 0 Then
Messagebox.show("此用户不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
dr = dt.DataRows(0)
If e.Form.Controls("PassWord").Value = dr("Password") Then
_UserName = UserName
_UserGroup = dr("Group")
Dim fdr As DataRow =DataTables("项目名称").find("项目名称 = '" & e.Form.Controls("账套").Value & "'")
If fdr IsNot Nothing
Dim dts As new List(Of String)
For Each dt1 As DataTable In DataTables
If dt1.C Then
dts.Add(dt1.name)
End If
Next
Dim glfs As new List(Of String)
For Each re As Relation In Relations
If not glfs.Contains(Re.ParentTable.Name) Then glfs.Add(Re.ParentTable.Name)
If not glfs.Contains(Re.ChildTable.Name) Then glfs.Add(Re.ChildTable.Name)
Next
Dim n As Integer
For Each dt1 As String In dts
If not glfs.Contains(dt1) Then
DataTables.unLoad(dt1)
End If
Next
DataTables.unLoad(String.Join("|",glfs.ToArray()))
Connections.Delete("项目数据")
Connections.Add("项目数据", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectPath & fdr("数据源") & ";Persist Security Info=False")
For Each dt1 As String In dts
DataTables.Load(dt1)
Next
End If
e.Form.Close
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If