?? frmoperator.frm
字號:
End
Begin VB.Menu mnuModify
Caption = "&M 修改帳號"
Shortcut = {F12}
End
Begin VB.Menu Line01
Caption = "-"
End
Begin VB.Menu MnuDelete
Caption = "&D 刪除帳號 ..."
Shortcut = {DEL}
End
End
Begin VB.Menu MnuReturn
Caption = "返回首頁(&R)"
End
End
Attribute VB_Name = "frmOperator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DelNO As Integer, UserStr As String
Private Sub cmbEmploy_Change()
On Error Resume Next
Text1.Text = cmbEmploy.Text
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End Sub
Private Sub cmbEmploy_Click()
On Error Resume Next
Text1.Text = cmbEmploy.Text
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End Sub
Private Sub cmdModify_Click()
If Grid1.Text = "" Then
MsgBox "請選擇用戶名后再修改? ", vbInformation
Exit Sub
End If
If cmdModify.Caption = "保存(&S)" Then
cmdModify.Caption = "修改(&M)"
If Trim(Text2.Text) = Trim(Text3.Text) Then
Dim shiftStr As String, shiftStrR As Variant, shiftNum As Integer, ili As Integer, SureStr As String
shiftStr = Trim(Text2.Text)
shiftNum = Len(shiftStr)
ili = 1
SureStr = ""
For ili = 1 To shiftNum
shiftStrR = Mid(shiftStr, ili, 1)
shiftStrR = Asc(shiftStrR)
shiftStrR = shiftStrR - 3
shiftStrR = Chr(shiftStrR)
SureStr = SureStr & shiftStrR
Next
'=========================================================
Dim DB As Connection, RecStr As String
Set DB = CreateObject("ADODB.Connection")
DB.Open Constr
RecStr = "Update Main Set 口令='" & SureStr & "' Where 操作員='" & Trim(Text1.Text) & "'"
DB.Execute RecStr
DB.Close
Set DB = Nothing
Command1.Enabled = True
Command2.Enabled = True
mnuModify.Enabled = True
MnuDelete.Enabled = True
Grid1.Enabled = True
Text1.Enabled = True
ConfigGrid
Text1.Text = "": Text2.Text = "": Text3.Text = ""
Text1.SetFocus
Exit Sub
Else
MsgBox "對不起,兩次口令不一致,請重新輸入? ", vbInformation
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
Exit Sub
End If
Else
cmdModify.Caption = "保存(&S)"
Text1.Text = Grid1.Text
Text1.Enabled = False
Text2.SetFocus
Command1.Enabled = False
Command2.Enabled = False
mnuModify.Enabled = False
MnuDelete.Enabled = False
Grid1.Enabled = False
End If
End Sub
Private Sub Command1_Click()
On Error GoTo AddERR
'校對數(shù)據(jù)庫是否已經(jīng)存在該操作員
Dim DB As Connection, EF As Recordset, RecStr As String
Set DB = CreateObject("ADODB.Connection")
Set EF = CreateObject("ADODB.Recordset")
DB.Open Constr
EF.Open "Main", DB, adOpenStatic, adLockOptimistic, adCmdTable
RecStr = "操作員='" & Trim(Text1.Text) & "'"
EF.Find RecStr
'已經(jīng)有該操作員時提示
If Not EF.EOF Then
EF.Close
Set EF = Nothing
DB.Close
Set DB = Nothing
MsgBox "操作員< " & Trim(Text1.Text) & " >已經(jīng)存在,不能繼續(xù)! ", vbInformation
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
EF.Close
Set EF = Nothing
'保存
'如果要加密的話,請將 Text2.text 的文本加密!
'別忘記在登錄時,要進行解密!
Dim shiftStr As String, shiftStrR As Variant, shiftNum As Integer, ili As Integer, SureStr As String
shiftStr = Trim(Text2.Text)
shiftNum = Len(shiftStr)
ili = 1
SureStr = ""
For ili = 1 To shiftNum
shiftStrR = Mid(shiftStr, ili, 1)
shiftStrR = Asc(shiftStrR)
shiftStrR = shiftStrR - 3
shiftStrR = Chr(shiftStrR)
SureStr = SureStr & shiftStrR
Next
'添加該記錄
RecStr = "Insert into Main (操作員,口令) values('" & Trim(Text1.Text) & "','" & Trim(SureStr) & "')"
DB.Execute RecStr
DB.Close
Set DB = Nothing
ConfigGrid
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Exit Sub
AddERR:
MsgBox "對不起,啟動操作員錯誤:" & Err.Description, vbCritical
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
frmMain.lbControl.Caption = "操作員管理"
End Sub
Private Sub Form_Load()
On Error GoTo LoadERR
frmOperator.HelpContextID = 5
GetFormSet Me, frmMain
OperatorFocus = True
'給出員工內(nèi)容
GetEmployList cmbEmploy
'配置網(wǎng)格
Grid1.Visible = False
Grid1.Cols = 2
Grid1.FormatString = "^ 操作員 |^ 口令 "
Grid1.ColWidth(0) = 800
Grid1.ColWidth(1) = 1210
Dim DB As Connection, EF As Recordset, HH As Integer
Dim shiftStr As String, shiftStrL As String, shiftStrR As String, shiftNum As Integer, ili As Integer, tempStr As String, SureStr As String, Qy As Integer
Set DB = CreateObject("ADODB.Connection")
Set EF = CreateObject("ADODB.Recordset")
DB.Open Constr
EF.ActiveConnection = DB
EF.Open "MAIN", , adOpenStatic, adLockReadOnly, adCmdTable
DelNO = EF.RecordCount
Grid1.Rows = EF.RecordCount + 1
EF.Close
EF.Open "Select * From MAIN", , adOpenStatic, adLockReadOnly, adCmdText
HH = 1
Do While Not EF.EOF()
Grid1.Row = HH
Grid1.Col = 0
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(0).Value) Then
Grid1.Text = EF.Fields(0).Value
UserStr = Grid1.Text
End If
Grid1.Row = HH
Grid1.Col = 1
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(1).Value) Then
'解口令為可視
shiftStr = Trim(EF.Fields(1).Value)
shiftNum = Len(shiftStr)
ili = 1
SureStr = ""
Qy = 0
For ili = 1 To shiftNum
shiftStrR = Mid(shiftStr, ili, 1)
shiftStrR = Asc(shiftStrR)
shiftStrR = shiftStrR + 3
shiftStrR = Chr(shiftStrR)
SureStr = SureStr & shiftStrR
Next
'因為是超級用戶,所以可以看見所有的帳號密碼
Grid1.Text = SureStr
End If
EF.MoveNext
HH = HH + 1
Loop
EF.Close
Set EF = Nothing
DB.Close
Set DB = Nothing
Grid1.Col = 0
Grid1.Row = 1
Grid1.ColSel = 1
Grid1.Visible = True
Exit Sub
LoadERR:
MsgBox "啟動操作員管理錯誤:" & Err.Description, vbCritical
Exit Sub
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveFormSet Me
frmMain.lbControl.Caption = "收銀控制中心"
OperatorFocus = False
End Sub
Private Sub Grid1_DblClick()
If Grid1.Text = "" Then
MnuDelete.Enabled = False
MnuAuthority.Enabled = False
cmdModify.Enabled = False
mnuModify.Enabled = False
Else
MnuDelete.Enabled = True
MnuAuthority.Enabled = True
mnuModify.Enabled = True
cmdModify.Enabled = True
End If
PopupMenu MnuOperate
End Sub
Private Sub Grid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Grid1.Text = "" Then
MnuDelete.Enabled = False
MnuAuthority.Enabled = False
mnuModify.Enabled = False
cmdModify.Enabled = False
Else
MnuDelete.Enabled = True
mnuModify.Enabled = True
cmdModify.Enabled = True
End If
If Button = 2 Then
PopupMenu MnuOperate
End If
End Sub
Private Sub MnuAuthority_Click()
Me.MousePointer = 11
If Grid1.Rows = 1 Then Exit Sub
If Grid1.Text = "" Then Exit Sub
If Grid1.Text = "超級用戶" Then
Me.MousePointer = 0
MsgBox "超級用戶不用設置權(quán)限,其已經(jīng)擁有所有權(quán)限。 ", vbInformation
Exit Sub
End If
frmAuthor.suserID = Grid1.Text
frmAuthor.Show 1
Me.MousePointer = 0
End Sub
Private Sub MnuDelete_Click()
DeleteRecord
End Sub
Private Sub mnuModify_Click()
cmdModify_Click
End Sub
Private Sub MnuReturn_Click()
Unload Me
End Sub
Private Sub Text1_Change()
If cmdModify.Caption = "修改(&M)" Then
If Trim(Text1.Text) <> "" Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Trim(Text1.Text) <> "" Then
SendKeys "{tab}"
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub Text3_LostFocus()
If Trim(Text3.Text) <> Trim(Text2.Text) Then
MsgBox "兩次口令不符,請重新再來 ", vbOKOnly + 64, "口令不符"
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
End If
End Sub
Private Sub DeleteRecord()
On Error GoTo DelERR
If Grid1.Text = "" Or Grid1.MouseRow = 0 Then Exit Sub
'超級用戶時
If Grid1.Text = "超級用戶" Then
MsgBox "超級用戶不能刪除,只能修改其密碼! ", vbOKOnly + 32, "不能刪除"
Exit Sub
End If
If DelNO = 1 Then
MsgBox "僅剩下當前用戶了,不能繼續(xù),請注意! ", vbOKOnly + 32, "不能刪除"
Exit Sub
End If
Dim Qp As Integer
Qp = MsgBox("真的要刪除[" & Grid1.Text & "]操作員嗎(Y/N)?", vbYesNo + 16, "確認刪除")
If Qp = 7 Then
Exit Sub
End If
Dim DB As Connection, RecStr As String
Set DB = CreateObject("ADODB.Connection")
DB.Open Constr
RecStr = "Delete * From Main Where 操作員='" & Grid1.Text & "'"
DB.Execute RecStr
DB.Close
Set DB = Nothing
ConfigGrid
Exit Sub
DelERR:
MsgBox "刪除操作員錯誤:" & Err.Description, vbCritical
Exit Sub
End Sub
Private Sub ConfigGrid()
'配置網(wǎng)格
Grid1.Visible = False
Grid1.Clear
Grid1.Cols = 2
Grid1.FormatString = "^ 操作員 |^ 口令 "
Grid1.ColWidth(0) = 800
Grid1.ColWidth(1) = 1210
Grid1.Rows = 1
Dim DB As Connection
Dim HH As Integer
Dim EF As Recordset
SureStr = ""
shiftStr = ""
shiftStrL = ""
shiftStrR = ""
shiftNum = 0
ili = 0
tempStr = ""
Qy = 0
Set DB = CreateObject("ADODB.connection")
Set EF = CreateObject("ADODB.Recordset")
DB.Open Constr
EF.Open "MAIN", DB, adOpenStatic, adLockReadOnly, adCmdTable
DelNO = EF.RecordCount
Grid1.Rows = EF.RecordCount + 1
EF.Close
EF.Open "Select * From MAIN", DB, adOpenDynamic, adLockReadOnly, adCmdText
HH = 1
Do While Not EF.EOF()
Grid1.Row = HH
Grid1.Col = 0
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(0).Value) Then
Grid1.Text = EF.Fields(0).Value
UserStr = Grid1.Text
End If
Grid1.Row = HH
Grid1.Col = 1
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(1).Value) Then
'解口令為可視
shiftStr = Trim(EF.Fields(1).Value)
shiftNum = Len(shiftStr)
ili = 1
SureStr = ""
Qy = 0
For ili = 1 To shiftNum
shiftStrR = Mid(shiftStr, ili, 1)
shiftStrR = Asc(shiftStrR)
shiftStrR = shiftStrR + 3
shiftStrR = Chr(shiftStrR)
SureStr = SureStr & shiftStrR
Next
'因為是超級用戶,所以可以看見所有的帳號密碼
End If
EF.MoveNext
HH = HH + 1
Loop
EF.Close
Set EF = Nothing
DB.Close
Set DB = Nothing
Grid1.Col = 0
Grid1.Row = 1
Grid1.ColSel = 1
Grid1.Visible = True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -