【正文】
With cboDepartment For pos = 0 To .ListCount 1 If Left(.List(pos), Len(DeptNo)) = DeptNo Then .ListIndex = pos Exit For End If Next End WithEnd SubPrivate Function getTypeNO() As String Dim str As String Dim pos As Integer With cboTypeNO str = .List(.ListIndex) End With pos = InStr(str, ) getTypeNO = Left(str, pos 1)End FunctionPrivate Function getDeptNo() As String Dim str As String Dim pos As Integer With cboDepartment str = .List(.ListIndex) End With pos = InStr(str, ) getDeptNo = Left(str, pos 1)End FunctionPublic Sub setStatus() If = 0 Then = False = False = False End If End SubPrivate Function saveData() As Boolean Dim DeviceNo As String Dim DeviceModel As String Dim DeviceName As String Dim TypeNo As String Dim DeptNo As String Dim Price As String Dim Cost As String Dim PurchaseDate As String saveData = False DeviceNo = Trim() DeviceModel = Trim() DeviceName = Trim() Price = Trim() Cost = Trim() PurchaseDate = FormatDateTime(, vbShortDate) If Len(DeviceNo) = 0 Then MsgBox 請(qǐng)輸入設(shè)備編號(hào) Exit Function End If If 0 Then MsgBox 請(qǐng)選擇設(shè)備類型! Exit Function End If If 0 Then MsgBox 請(qǐng)選擇設(shè)備所屬部門(mén)! Exit Function End If If IsNumeric(Price) = False Then MsgBox 請(qǐng)輸入正確的價(jià)格! Exit Function End If If IsNumeric(Cost) = False Then MsgBox 請(qǐng)輸入正確的成本! Exit Function End If If IsDate(PurchaseDate) = False Then MsgBox 請(qǐng)輸入正確的購(gòu)買(mǎi)日期! Exit Function End If With theDevice .DeviceNo = DeviceNo .DeviceModel = DeviceModel .DeviceName = DeviceName .TypeNo = getTypeNO() 。顯示用戶數(shù)據(jù) With theDevice .loadDataByID iid = .DeviceNo = .DeviceModel = .DeviceName setTypeIndex .TypeNo setDeptIndex .DeptNo = .ProductPrice = .ProductCost dtPurchaseDate = .PurchaseDate If .Status = 0 Then = 在庫(kù) Else = 借出 End If If Len(.RejectDate) = 0 Then = False Else = .RejectDate End If If Len(.DisCardDate) = 0 Then = False Else = .DisCardDate End If End With End SubPrivate Sub setTypeIndex(TypeNo As String) Dim pos As Integer TypeNo = TypeNo amp。 amp。 amp。控制輸入 = True 39。系統(tǒng)管理員 = 2 Case Else 39。顯示用戶數(shù)據(jù) With theUser .loadDataByID uid = .UserName = .Password Select Case .Level Case 1 39。 數(shù)據(jù)操作員 amp。 普通用戶 amp。 系統(tǒng)管理員 amp。 rs(login).value amp。 rs(UID).value amp。 vbTab .AddItem strRowData rowindex = rowindex + 1 Loop Set rs = Nothing .Tag = 1 End IfEnd WithEnd SubPrivate Sub fillUserGrid() Dim rs As Dim strRowData As String Dim rowindex As Integer rowindex = 1 With grdUser If .Tag = Then Set rs = (SELECT * FROM tblUser ORDER BY UID DESC) .Rows = 1 .Cols = 4 .Row = 0 .Col = 0 .Text = 序號(hào) .ColWidth(0) = 500 .Col = 1 .ColWidth(1) = 0 .Col = 2 .Text = 用戶名 .ColWidth(2) = 1500 .Col = 3 .Text = 用戶級(jí)別 .ColWidth(3) = 3000 Do Until strRowData = rowindex amp。 vbTab strRowData = strRowData amp。 vbTab End If strRowData = strRowData amp。 vbTab Else strRowData = strRowData amp。 vbTab If rs(Status).value = 0 Then strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。 vbTab strRowData = strRowData amp。系統(tǒng)管理員 fillDeviceGrid grdDevice .TabVisible(0) = False .TabVisible(1) = False .TabVisible(2) = False = True Case Else 39。 .Fields(Department).value .MoveNext Loop End With = 0 Set rs = Nothing With tabMain Select Case Case 1 39。 .Fields(TypeName).value .MoveNext Loop End With = 0 strSQL = SELECT * FROM tblDepartment ORDER BY DeptNO Set rs = (strSQL) With rs Do Until .EOF .Fields(DeptNO).value amp。,1) MsgBox 重置數(shù)據(jù)庫(kù)成功!管理系統(tǒng)將退出!!! Unload Me End If End SubPrivate Sub cmdUserAdd_Click() Call doUser() End SubPrivate Sub cmdUserDelete_Click() Dim uid As String With grdUser If .Row = 0 Then MsgBox 請(qǐng)選擇要?jiǎng)h除的用戶! Else If MsgBox(你是否真的要?jiǎng)h除當(dāng)前選擇的用戶嗎?刪除后將不能恢復(fù)!, vbOKCancel) = vbOK Then .Col = 1 uid = .Text