主题:[原创]一个星期贴完自己写的药品进销存管理软件(四)
'文件名
'frmlogin.frm
'用于用户登录
Option Explicit
Private Sub cmdCancel_Click()
End
End Sub
Private Sub CmdOk_Click()
'检查正确的密码 DigestStrToHexStr("111")
On Error Resume Next
SaveR = 0
If Trim(OperatorName) = "admin" Then
'登录成功
Unload Me
frmMain.ShowMainFrm = True
'MainFrm.Show
SysSetFrm.Show 1
Exit Sub
End If
DataRedSet.CursorLocation = adUseClient
DataRedSet.Open "select * from UserTable where UserName='" & txtUserName & "'", DataCon.ConnectionString
If DataRedSet.RecordCount = 0 Then
DataRedSet.Close
Exit Sub
End If
If DataRedSet.Fields(1) = DigestStrToHexStr(LCase(txtPassword.Text)) Then
'成功
OperatorName = txtUserName
OperatorPower = Trim(DataRedSet.Fields(2))
frmMain.Show
'MainFrm.Show
DataRedSet.Close
Unload Me
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
DataRedSet.Close
End If
End Sub
Private Sub Form_Load()
txtUserName.Clear
SqlConStr = "driver={SQL Server};server=192.168.3.85;uid=sa;pwd=sa;database=test2"
DataCon.Open SqlConStr
DataRedSet.CursorLocation = adUseClient
DataRedSet.Open "select * from UserTable ", DataCon
If DataRedSet.RecordCount = 0 Then
Label1.Caption = "初始用户名为:admin 初始密码为:admin"
OperatorName = "admin"
Exit Sub
End If
Do While Not DataRedSet.EOF
txtUserName.AddItem DataRedSet.Fields(0)
DataRedSet.MoveNext
Loop
DataRedSet.Close
Dim FileP, pat As String
Dim a As Long
If Len(App.Path) = 3 Then
FileP = App.Path
Else
FileP = App.Path & "\"
End If
pat = Space$(1)
a = GetPrivateProfileString("系统设置", "系统自动打开统合计划", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "系统自动生成入库单号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "系统自动生成出库单号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品质量情况", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆备注内容", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品验收结论", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品批号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品批准文号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "允许自动添加药品资料", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
End Sub
'frmlogin.frm
'用于用户登录
Option Explicit
Private Sub cmdCancel_Click()
End
End Sub
Private Sub CmdOk_Click()
'检查正确的密码 DigestStrToHexStr("111")
On Error Resume Next
SaveR = 0
If Trim(OperatorName) = "admin" Then
'登录成功
Unload Me
frmMain.ShowMainFrm = True
'MainFrm.Show
SysSetFrm.Show 1
Exit Sub
End If
DataRedSet.CursorLocation = adUseClient
DataRedSet.Open "select * from UserTable where UserName='" & txtUserName & "'", DataCon.ConnectionString
If DataRedSet.RecordCount = 0 Then
DataRedSet.Close
Exit Sub
End If
If DataRedSet.Fields(1) = DigestStrToHexStr(LCase(txtPassword.Text)) Then
'成功
OperatorName = txtUserName
OperatorPower = Trim(DataRedSet.Fields(2))
frmMain.Show
'MainFrm.Show
DataRedSet.Close
Unload Me
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
DataRedSet.Close
End If
End Sub
Private Sub Form_Load()
txtUserName.Clear
SqlConStr = "driver={SQL Server};server=192.168.3.85;uid=sa;pwd=sa;database=test2"
DataCon.Open SqlConStr
DataRedSet.CursorLocation = adUseClient
DataRedSet.Open "select * from UserTable ", DataCon
If DataRedSet.RecordCount = 0 Then
Label1.Caption = "初始用户名为:admin 初始密码为:admin"
OperatorName = "admin"
Exit Sub
End If
Do While Not DataRedSet.EOF
txtUserName.AddItem DataRedSet.Fields(0)
DataRedSet.MoveNext
Loop
DataRedSet.Close
Dim FileP, pat As String
Dim a As Long
If Len(App.Path) = 3 Then
FileP = App.Path
Else
FileP = App.Path & "\"
End If
pat = Space$(1)
a = GetPrivateProfileString("系统设置", "系统自动打开统合计划", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "系统自动生成入库单号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "系统自动生成出库单号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品质量情况", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆备注内容", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品验收结论", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品批号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "自动记忆药品批准文号", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
a = GetPrivateProfileString("系统设置", "允许自动添加药品资料", "", pat, 1000, FileP & "sysini.ini")
SysSetLog = SysSetLog & Val(pat)
End Sub