📄 frmclerk.frm
字号:
End With
rstClerk.Close
Set rstClerk = Nothing
End Sub
Private Sub Initialize()
On Error GoTo Fail
With lsvClerk
.ColumnHeaders.Add , , "UserCode", 1000
.ColumnHeaders.Add , , "UserName", .Width - 1100
.LabelEdit = lvwManual
.FullRowSelect = True
.HideSelection = False
.View = lvwReport
End With
Me.KeyPreview = True
Exit Sub
Fail:
err.Raise err.Number, , err.Description
End Sub
Private Sub lsvClerk_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim ClerkCode As String
ClerkCode = Right(lsvClerk.SelectedItem.Key, Len(lsvClerk.SelectedItem.Key) - 1)
Call ScanClerk(ClerkCode)
End Sub
Private Sub ScanClerk(ByVal ClerkCode As String)
Dim sSQL As String
Dim rstClerk As Recordset
sSQL = "select * from sysusr where usrcode='" & ClerkCode & "'"
Set rstClerk = Acs_cnt.Execute(sSQL)
With rstClerk
Do While Not .EOF
txtCode = rstClerk!UsrCode
txtName = rstClerk!UrsName
txtContack.Text = rstClerk!Contack
txtPass = rstClerk!Password
txtRemarks = rstClerk!remarks
Call SetCmbRole(rstClerk!RolCode)
.MoveNext
Loop
End With
rstClerk.Close
Set rstClerk = Nothing
Exit Sub
Fail:
End Sub
Private Sub SetCmbRole(ByVal RolCode As String)
Dim i As Long
For i = 1 To cmbRole.ListCount
If cmbRole.ItemData(i - 1) = RolCode Then
cmbRole.Text = cmbRole.List(i - 1)
End If
Next i
End Sub
Private Sub IniClerkDetail()
txtCode.Text = ""
txtPass.Text = ""
txtName.Text = ""
txtRemarks.Text = ""
txtContack.Text = ""
txtPass.Text = ""
End Sub
Private Sub SetToolBar(ByVal mkey As String)
Select Case mkey
Case "new"
With UserControl1
.DisplayButton "New", "New", False, , "New"
' .DisplayButton "Find", "Find", False, , "Find"
.DisplayButton "Delete", "Delete", False, , "Delete"
' .DisplayButton "Print", "Print", True, , "Print"
.DisplayButton "Modify", "Modify", False, , "Modify"
.DisplayButton "Save", "Save", True, , "Save"
.DisplayButton "Undo", "Undo", True, , "Undo"
' .DisplayButton "Redo", "Redo", True, , "Redo"
.DisplayButton "Close", "Close", False, , "Close"
End With
frmClerk.Enabled = False
frmClerkDetail.Enabled = True
txtCode.SetFocus
Case "modify"
With UserControl1
.DisplayButton "New", "New", False, , "New"
' .DisplayButton "Find", "Find", False, , "Find"
.DisplayButton "Delete", "Delete", False, , "Delete"
' .DisplayButton "Print", "Print", False, , "Print"
.DisplayButton "Modify", "Modify", False, , "Modify"
.DisplayButton "Save", "Save", True, , "Save"
.DisplayButton "Undo", "Undo", True, , "Undo"
' .DisplayButton "Redo", "Redo", True, , "Redo"
.DisplayButton "Close", "Close", False, , "Close"
End With
frmClerk.Enabled = False
frmClerkDetail.Enabled = True
Case "undo"
With UserControl1
.DisplayButton "New", "New", True, , "New"
' .DisplayButton "Find", "Find", True, , "Find"
.DisplayButton "Delete", "Delete", True, , "Delete"
' .DisplayButton "Print", "Print", True, , "Print"
.DisplayButton "Modify", "Modify", True, , "Modify"
.DisplayButton "Save", "Save", False, , "Save"
.DisplayButton "Undo", "Undo", False, , "Undo"
' .DisplayButton "Redo", "Redo", False, , "Redo"
.DisplayButton "Close", "Close", True, , "Close"
End With
frmClerk.Enabled = True
frmClerkDetail.Enabled = False
Case "delete"
With UserControl1
.DisplayButton "New", "New", True, , "New"
' .DisplayButton "Find", "Find", True, , "Find"
.DisplayButton "Delete", "Delete", True, , "Delete"
' .DisplayButton "Print", "Print", True, , "Print"
.DisplayButton "Save", "Save", False, , "Save"
.DisplayButton "Modify", "Modify", True, , "Modify"
.DisplayButton "Undo", "Undo", False, , "Undo"
' .DisplayButton "Redo", "Redo", False, , "Redo"
.DisplayButton "Close", "Close", True, , "Close"
End With
frmClerk.Enabled = True
frmClerkDetail.Enabled = False
Case "save"
With UserControl1
.DisplayButton "New", "New", True, , "New"
' .DisplayButton "Find", "Find", True, , "Find"
.DisplayButton "Delete", "Delete", True, , "Delete"
' .DisplayButton "Print", "Print", True, , "Print"
.DisplayButton "Save", "Save", False, , "Save"
.DisplayButton "Modify", "Modify", True, , "Modify"
.DisplayButton "Undo", "Undo", False, , "Undo"
' .DisplayButton "Redo", "Redo", False, , "Redo"
.DisplayButton "Close", "Close", True, , "Close"
End With
frmClerk.Enabled = True
frmClerkDetail.Enabled = False
Case Else
With UserControl1
.DisplayButton "New", "New", True, , "New"
' .DisplayButton "Find", "Find", True, , "Find"
.DisplayButton "Delete", "Delete", True, , "Delete"
' .DisplayButton "Print", "Print", True, , "Print"
.DisplayButton "Save", "Save", False, , "Save"
.DisplayButton "Modify", "Modify", True, , "Modify"
.DisplayButton "Undo", "Undo", False, , "Undo"
' .DisplayButton "Redo", "Redo", False, , "Redo"
.DisplayButton "Close", "Close", True, , "Close"
End With
frmClerk.Enabled = True
frmClerkDetail.Enabled = False
End Select
End Sub
Private Sub txtCode_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{tab}"
End If
End Sub
Private Sub txtContack_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{tab}"
End If
End Sub
Private Sub txtname_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{tab}"
End If
End Sub
Private Sub txtPass_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{tab}"
End If
End Sub
Private Sub txtRemarks_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{tab}"
End If
End Sub
Private Sub UserControl1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next
mkey = LCase(Button.Key)
Select Case LCase(Button.Key)
Case "new"
lblStatus.Caption = mkey
Call IniClerkDetail
Case "edit"
Case "save"
If lblStatus.Caption = "new" Then
Call SaveClerkInfo
Call RefershClerk
ElseIf lblStatus.Caption = "modify" Then
Call ModifyClerkInfo
End If
Case "delete"
If MsgBox("Are you want delete this usercode?", vbYesNo, "Message") = vbYes Then
Call DeleteClerkInfo
Call RefershClerk
Else
Exit Sub
End If
Case "modify"
lblStatus.Caption = mkey
txtCode.Locked = True
Case "close"
Unload Me
Case Else
End Select
Call SetToolBar(mkey)
End Sub
Private Sub ModifyClerkInfo()
Dim sSQL As String
Dim sCode As String
Dim sRemark As String, sname As String, sContack As String, sRoleCode As String
sRemark = txtRemarks.Text
sCode = txtCode.Text
sname = txtName.Text
sContack = txtContack.Text
sRoleCode = cmbRole.ItemData(cmbRole.ListIndex)
sSQL = "update sysusr set remarks='" & sRemark & "' ,rolcode='" & sRoleCode & "',contack='" & sContack & "' ,ursname='" & sname & "' where usrcode='" & sCode & "'"
Acs_cnt.BeginTrans
Acs_cnt.Execute (sSQL)
Acs_cnt.CommitTrans
End Sub
Private Sub DeleteClerkInfo()
Dim sSQL As String
Dim sCode As String
sCode = Right(lsvClerk.SelectedItem.Key, Len(lsvClerk.SelectedItem.Key) - 1)
sSQL = "delete from sysusr where usrcode='" & sCode & "'"
Acs_cnt.BeginTrans
Acs_cnt.Execute (sSQL)
Acs_cnt.CommitTrans
End Sub
Private Sub SaveClerkInfo()
Dim sCode As String, sname As String, sPass As String, sRemark As String, sContack As String
Dim rstClerk As Recordset
Dim sSQL As String, sRole As String
sCode = Trim(txtCode.Text)
sname = Trim(txtName.Text)
sPass = Trim(txtPass.Text)
sRole = Trim(cmbRole.ItemData(cmbRole.ListIndex))
sRemark = Trim(txtRemarks.Text)
sContack = Trim(txtContack.Text)
sSQL = "select * from sysusr where usrcode='" & sCode & "'"
Set rstClerk = Acs_cnt.Execute(sSQL)
With rstClerk
If Not .EOF Then
MsgBox "This UserCode is exist,please change your usercode!", vbInformation, "Error"
Exit Sub
End If
End With
sSQL = "insert into sysusr(usrcode,ursname,password,rolcode,remarks,contack)" & _
" values('" & sCode & "','" & sname & "','" & sPass & "','" & sRole & "','" & sRemark & "','" & sContack & "') "
Acs_cnt.BeginTrans
Acs_cnt.Execute (sSQL)
Acs_cnt.CommitTrans
End Sub
Private Sub RefershClerk()
lsvClerk.ListItems.Clear
Call ShowClerks
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -