?? frmoperman.frm
字號:
Text1(3).Text = ""
Text1(0).SetFocus
Else
With tUserInfo
.UserCode = Trim(Me.Text1(0))
.UserName = Trim(Me.Text1(1))
.Pwd = Trim(Me.Text1(2))
If Me.Option1(0).Value = True Then
.QX = 0
ElseIf Me.Option1(1).Value = True Then
.QX = 1
End If
.BeiZhu = Trim(Me.Text1(3))
End With
If AddOperData Then
Me.cmdAdd.Caption = "&A.添 加"
Me.cmdDelete.Enabled = True
Me.cmdEdit.Enabled = True
For i = 0 To 3
Me.Text1(i).Enabled = False
Next i
Me.Option1(0).Enabled = False
Me.Option1(1).Enabled = False
Me.Text1(2) = "**********"
End If
End If
End Sub
Private Function AddOperData() As Boolean
Dim re As String
AddOperData = True
re = MsgBox("確認添加新的操作員嗎?", vbYesNo + vbQuestion, "系統提示")
If re = vbNo Then
AddOperData = False
End If
If Not Validate_Data Then
AddOperData = False
Exit Function
End If
Me.MousePointer = 11
On Error GoTo ErrorHander
sSQL = "select * from t_user where usercode='" & Trim(tUserInfo.UserCode) & "'"
Set RS = ConnWZ.Execute(sSQL)
If RS.EOF Then
With tUserInfo
sSQL = "insert t_user(usercode,username,password,qx,beizhu) values('" & .UserCode & "','" & .UserName & "','" & .Pwd & "'," & .QX & ",'" & .BeiZhu & "')"
Set RS = ConnWZ.Execute(sSQL)
Call ShowOperator
End With
Else
MsgBox "代碼為" & Trim(Me.Text1(0)) & "的操作員信息已存在,無法添加!", 48, "系統提示"
RS.Close
AddOperData = False
Me.MousePointer = 0
Exit Function
End If
RS.Close
Me.MousePointer = 0
On Error GoTo 0
Exit Function
ErrorHander:
MsgBox "添加操作員失敗,請重試!", 48, "系統提示"
AddOperData = False
Me.MousePointer = 0
End Function
Private Sub cmdclear_Click()
For i = 0 To 3
Me.Text1(i).Text = ""
Me.Text1(i).Enabled = True
Next i
Me.Text1(0).SetFocus
Me.cmdAdd.Enabled = True
Me.cmdDelete.Enabled = True
Me.cmdEdit.Enabled = True
Me.cmdAdd.Caption = "&A.添 加"
Me.cmdEdit.Caption = "&M 修 改"
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmddelete_Click()
Dim re As String
If UserInfo.QX = 1 Then
MsgBox "對不起,普通用戶無權操作!", 48, "系統提示"
Exit Sub
End If
re = MsgBox("確認刪除" & Trim(Me.Text1(0)) & "用戶嗎?", vbYesNo + vbQuestion, "系統提示")
If re = vbNo Then Exit Sub
Me.MousePointer = 11
If Len(Me.Text1(0)) = 0 Then
MsgBox "請選擇操作員后再刪除!", 48, "系統提示"
Me.MousePointer = 0
Exit Sub
End If
If Trim(UserInfo.UserCode) = Trim(Me.Text1(0)) Then
MsgBox "此為當前操作員,無法刪除!", 48, "系統提示"
Me.MousePointer = 0
Exit Sub
End If
sSQL = "select * from t_user where usercode='" & Trim(Me.Text1(0)) & "'"
Set RS = ConnWZ.Execute(sSQL)
If RS.EOF Then
RS.Close
MsgBox "找不到代碼為" & Trim(Me.Text1(0)) & "的操作員信息,刪除失敗!", 48, "系統提示"
Me.MousePointer = 0
Exit Sub
End If
RS.Close
sSQL = "delete t_user where usercode='" & Trim(Me.Text1(0)) & "'"
ConnWZ.Execute (sSQL)
Call ShowOperator
Me.MousePointer = 0
End Sub
Private Sub cmdedit_Click()
If UserInfo.QX = 1 Then
MsgBox "對不起,普通用戶無權操作!", 48, "系統提示"
Exit Sub
End If
If Len(Me.Text1(0)) = 0 Then
MsgBox "請選擇操作員信息后再操作!", 48, "系統提示"
Exit Sub
End If
Me.Text1(0).Enabled = False
Me.Text1(2).Enabled = False
Me.Option1(0).Enabled = True
Me.Option1(1).Enabled = True
If Me.cmdEdit.Caption = "&M 修 改" Then
For i = 0 To 3
Me.Text1(i).Enabled = True
Me.Text1(i).Locked = False
Next i
Me.cmdEdit.Caption = "&M 確 定"
Me.Text1(0).Enabled = False
Me.Text1(2).Enabled = False
Me.cmdAdd.Enabled = False
Me.cmdDelete.Enabled = False
With Me.Text1(1)
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Else
With tUserInfo
.UserCode = Trim(Me.Text1(0))
.UserName = Trim(Me.Text1(1))
.BeiZhu = Trim(Me.Text1(3))
If Me.Option1(0).Value = True Then
.QX = 0
ElseIf Me.Option1(1).Value = True Then
.QX = 1
End If
End With
If ModiOperData Then
Me.cmdEdit.Caption = "&M 修 改"
For i = 0 To 3
Me.Text1(i).Enabled = False
Next i
Me.Option1(0).Enabled = False
Me.Option1(1).Enabled = False
Me.cmdAdd.Enabled = True
Me.cmdDelete.Enabled = True
End If
End If
End Sub
Private Function ModiOperData() As Boolean
Dim re As String
ModiOperData = True
re = MsgBox("確認要修改代碼為" & Trim(Me.Text1(0)) & "的操作員信息嗎?", vbYesNo + vbQuestion, "系統提示")
If re = vbNo Then
ModiOperData = False
Exit Function
End If
If Not Validate_Data Then
ModiOperData = False
Exit Function
End If
Me.MousePointer = 11
sSQL = "select * from t_user where usercode='" & Trim(tUserInfo.UserCode) & "' "
Set RS = ConnWZ.Execute(sSQL)
If RS.EOF Then
MsgBox "找不到代碼為" & Trim(tUserInfo.UserCode) & "的操作員信息!", 48, "系統提示"
ModiOperData = False
RS.Close
Me.MousePointer = 0
Exit Function
Else
With tUserInfo
sSQL = "update t_user set username='" & Trim(.UserName) & "',beizhu='" & .BeiZhu & "',qx=" & .QX & " where usercode='" & Trim(.UserCode) & "'"
ConnWZ.Execute (sSQL)
MsgBox "修改記錄成功,信息已入庫!", 64, "系統提示"
Call ShowOperator
End With
End If
RS.Close
Me.MousePointer = 0
End Function
Private Sub Form_Activate()
Call ShowOperator
AddFlag = False
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
Unload Me
End If
End Sub
Private Sub MSFGOperator_Click()
With Me.MSFGOperator
Me.Text1(0) = Trim(.TextMatrix(.RowSel, 0))
Me.Text1(1) = Trim(.TextMatrix(.RowSel, 1))
Me.Text1(3) = Trim(.TextMatrix(.RowSel, 3))
Me.Text1(2) = "**********"
If Trim(.TextMatrix(.RowSel, 2)) = "超級用戶" Then
Me.Option1(0).Value = True
ElseIf Trim(.TextMatrix(.RowSel, 2)) = "普通用戶" Then
Me.Option1(1).Value = True
End If
End With
Me.cmdDelete.Enabled = True
Me.cmdEdit.Enabled = True
Me.cmdAdd.Caption = " 添 加(&A)"
End Sub
Private Sub MSFGOperator_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then cmdAdd.SetFocus
End Sub
Private Sub Option1_Click(Index As Integer)
QX = Index
End Sub
Private Sub Option1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then SendKeys "{TAB}"
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index).Text)
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then SendKeys "{TAB}"
End Sub
Private Sub HideButtons()
Text1(0).Locked = False
Text1(1).Locked = False
Text1(2).Locked = False
Text1(3).Locked = False
Text1(0).Enabled = True
Text1(1).Enabled = True
Text1(2).Enabled = True
Text1(3).Enabled = True
Option1(0).Enabled = True
Option1(1).Enabled = True
cmdAdd.Caption = " 確 定(&A)"
cmdEdit.Enabled = False
cmdDelete.Enabled = False
End Sub
Private Sub ShowButtons()
Text1(1).Locked = True
Text1(2).Locked = True
Text1(3).Locked = True
Text1(1).Enabled = False
Text1(2).Enabled = False
Text1(3).Enabled = False
Option1(0).Enabled = False
Option1(1).Enabled = False
cmdAdd.Visible = True
cmdEdit.Visible = True
cmdDelete.Visible = True
cmdClose.Visible = True
cmdAdd.Enabled = True
cmdEdit.Enabled = True
cmdDelete.Enabled = True
cmdClose.Enabled = True
End Sub
Private Sub ShowOperator()
sSQL = "select * from t_user order by usercode"
Set RS = ConnWZ.Execute(sSQL)
If Not RS.EOF Then
RS.MoveLast
RS.MoveFirst
With MSFGOperator
.Clear
.Rows = RS.RecordCount + 1
.Cols = 4
.FormatString = "^ 操作員代碼 |^ 操作員名 |^ 操作權限 |^ 備 注 "
End With
For i = 0 To RS.RecordCount - 1
With Me.MSFGOperator
.TextMatrix(i + 1, 0) = Trim(RS!UserCode)
.TextMatrix(i + 1, 1) = Trim(RS!UserName & "")
If RS!QX = 0 Then
.TextMatrix(i + 1, 2) = "超級用戶"
ElseIf RS!QX = 1 Then
.TextMatrix(i + 1, 2) = "普通用戶"
End If
.TextMatrix(i + 1, 3) = Trim(RS!BeiZhu & "")
End With
RS.MoveNext
Next i
Else
With MSFGOperator
.Clear
.Rows = 2
.Cols = 4
.FormatString = "^ 操作員代碼 |^ 操作員名 |^ 操作權限 |^ 備 注 "
End With
End If
End Sub
Private Function Validate_Data() As Boolean
Validate_Data = True
If LenB(StrConv(Trim$(Me.Text1(0)), vbFromUnicode)) > 10 Or Len(Me.Text1(0)) = 0 Then
MsgBox "代碼信息錄入非法!", 48, "系統提示"
With Me.Text1(0)
.SelStart = 0
.SelLength = Len(.Text)
End With
Validate_Data = False
Exit Function
End If
If LenB(StrConv(Trim$(Me.Text1(1)), vbFromUnicode)) > 20 Or Len(Me.Text1(1)) = 0 Then
MsgBox "姓名信息錄入非法!", 48, "系統提示"
With Me.Text1(1)
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Validate_Data = False
Exit Function
End If
If LenB(StrConv(Trim$(Me.Text1(2)), vbFromUnicode)) > 20 Or Len(Me.Text1(2)) = 0 Then
MsgBox "口令信息錄入非法!", 48, "系統提示"
With Me.Text1(2)
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Validate_Data = False
Exit Function
End If
If LenB(StrConv(Trim$(Me.Text1(3)), vbFromUnicode)) > 50 Then
MsgBox "備注信息錄入非法!", 48, "系統提示"
With Me.Text1(3)
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Validate_Data = False
Exit Function
End If
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -