📄 frmsysini.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form FrmSysIni
BorderStyle = 1 'Fixed Single
Caption = "系统初始化设置"
ClientHeight = 9465
ClientLeft = 45
ClientTop = 495
ClientWidth = 15270
Icon = "FrmSysIni.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 9465
ScaleWidth = 15270
Begin VB.TextBox Text1
Height = 375
Left = 5280
TabIndex = 9
Top = 720
Visible = 0 'False
Width = 2415
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 5280
Top = 240
Visible = 0 'False
Width = 2415
_ExtentX = 4260
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox TxtServer
Height = 375
Left = 7080
TabIndex = 2
ToolTipText = "SQL Server服务器名"
Top = 2760
Width = 2775
End
Begin VB.TextBox TxtUser
Height = 405
Left = 7080
TabIndex = 1
ToolTipText = "服务器用户名"
Top = 3360
Width = 2775
End
Begin VB.TextBox TxtPassword
Height = 405
IMEMode = 3 'DISABLE
Left = 7080
PasswordChar = "*"
TabIndex = 0
ToolTipText = "服务器密码"
Top = 3960
Width = 2775
End
Begin VB.Image Image1
Height = 300
Left = 8520
Picture = "FrmSysIni.frx":0CCA
Top = 6600
Width = 300
End
Begin VB.Label LblBack
BackStyle = 0 'Transparent
Caption = "返 回"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 9120
MouseIcon = "FrmSysIni.frx":10E6
MousePointer = 99 'Custom
TabIndex = 8
Top = 6600
Width = 855
End
Begin VB.Label LblRead
BackStyle = 0 'Transparent
Caption = "读 取"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 6000
MouseIcon = "FrmSysIni.frx":13F0
MousePointer = 99 'Custom
TabIndex = 7
Top = 6600
Width = 735
End
Begin VB.Image Image3
Height = 300
Left = 5400
Picture = "FrmSysIni.frx":16FA
Top = 6600
Width = 300
End
Begin VB.Label LblSet
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "设 定"
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 7320
MouseIcon = "FrmSysIni.frx":1B16
MousePointer = 99 'Custom
TabIndex = 6
Top = 6600
Width = 645
End
Begin VB.Image Image4
Height = 300
Left = 6840
Picture = "FrmSysIni.frx":1E20
Top = 6600
Width = 300
End
Begin VB.Label Label1
Caption = "服务器名"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5400
TabIndex = 5
Top = 2760
Width = 1455
End
Begin VB.Label Label2
Caption = "用 户 名"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5400
TabIndex = 4
Top = 3360
Width = 1335
End
Begin VB.Label Label3
Caption = "密 码"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5400
TabIndex = 3
Top = 3960
Width = 1335
End
End
Attribute VB_Name = "FrmSysIni"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'判断文件是否存在
Function FileExist(Fname As String) As Boolean
On Local Error Resume Next
FileExist = (Dir(Fname) <> "")
End Function
Public Function GetKey(Tmp_File As String, Tmp_Key As String) As String
Dim File As Long
'分配文件句柄
File = FreeFile
'如果文件不存在则创建一个默认的Setup.ini文件
If FileExist(Tmp_File) = False Then
GetKey = ""
Call WritePrivateProfileString("Setup Information", "Server Name ", "", App.Path + "\Setup.ini")
Call WritePrivateProfileString("Setup Information", "UserName ", " ", App.Path + "\Setup.ini")
Call WritePrivateProfileString("Setup Information", "PasswordName ", " ", App.Path + "\Setup.ini")
Exit Function
End If
'读取数据项值
Open Tmp_File For Input As File
Do While Not EOF(1)
Line Input #File, buffer
If Left(buffer, Len(Tmp_Key)) = Tmp_Key Then
pos = InStr(buffer, "=")
GetKey = Trim(Mid(buffer, pos + 1))
End If
Loop
Close File
End Function
Private Sub LblBack_Click()
Unload Me
End Sub
Private Sub LblRead_Click()
'从Setup.ini中读取服务器的名字
ServerName = GetKey(App.Path + "\Setup.ini", "Server Name")
UserName = GetKey(App.Path + "\Setup.ini", "User")
PasswordName = GetKey(App.Path + "\Setup.ini", "Password")
If ServerName = "" Then
MsgBox "初始信息没有设置,请填入初始信息"
LblRead.Enabled = False
LblSet.Enabled = True
Else
TxtServer.Text = ServerName
TxtUser.Text = UserName
TxtPassword.Text = PasswordName
LblSet.Caption = "修改设定"
LblSet.Enabled = True
LblRead.Enabled = False
End If
End Sub
Private Sub Test()
Adodc1.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
Adodc1.RecordSource = "select * from Users"
Set Text1.DataSource = Adodc1
Text1.DataField = "Name"
End Sub
Private Sub LblSet_Click()
If TxtServer.Text = "" Then
MsgBox "请填入服务器名称"
TxtServer.SetFocus
Exit Sub
End If
Call WritePrivateProfileString("Setup Information", "Server Name ", TxtServer.Text, App.Path + "\Setup.ini")
Call WritePrivateProfileString("Setup Information", "UserName ", TxtUser.Text, App.Path + "\Setup.ini")
Call WritePrivateProfileString("Setup Information", "PasswordName ", TxtPassword.Text, App.Path + "\Setup.ini")
Server = TxtServer.Text
User = TxtUser.Text
Password = TxtUser.Text
DataEnvironmentItem.Item.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
DataEnvironmentPurchase.Purchase.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
DataEnvironmentSales.Sales.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
DataEnvironmentStore.Store.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
DataEnvironmentManpower.Manpower.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
DataEnvironmentClient.Client.ConnectionString = "driver={SQL Server};server=" + Trim(Server) + ";uid=" + Trim(User) + ";pwd=" + Trim(Password) + ";database=ERP"
Test
If Text1.Text <> "" Then
MsgBox "设置成功"
FrmManManage.LblDatabaseManage.Enabled = True
FrmManManage.LblDatabaseSet.Enabled = True
FrmManManage.LblUserManage.Enabled = True
Else
MsgBox "设置失败,设置参数与SQL服务器参数不符,请重新设置"
TxtServer.Text = ""
TxtUser.Text = ""
TxtPassword.Text = ""
TxtServer.SetFocus
Exit Sub
End If
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -