⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 关于工业设备型号数量库存价格等信息的管理系统的课程设计
💻 FRM
📖 第 1 页 / 共 3 页
字号:
                        fillDeviceGrid grdDevice
                    End If
                    Set device = Nothing
                End If
            End If
        End If
    End With

End Sub









Private Sub cmdReset_Click()

    If MsgBox("你是否真的要重置数据库吗?这个操作将会删除所有记录!", vbOKCancel + vbDefaultButton2) = vbOK Then
        gConn.Execute "delete from tbldevice"
        gConn.Execute "delete from tbluser"
        gConn.Execute "delete from tbllend"
        gConn.Execute "insert into tbluser (login,pwd,level) values ('admin','888',-1)"
        
        gConn.Close
        
        MsgBox "重置数据库成功!管理系统将退出!!!"
        
        Unload Me
        
    End If
    

End Sub





Private Sub Command1_Click()
 Dim oldPass As String
    Dim newPass1 As String
    Dim newPass2 As String
    
    
    oldPass = InputBox("请输入旧密码:", "密码修改")
    If Len(oldPass) > 0 Then
        If oldPass <> gUser.Password Then
            MsgBox "输入密码不正确!"
            Exit Sub
        End If
        
        newPass1 = InputBox("请输入新密码:", "密码修改")
        If Len(newPass1) = 0 Then
            MsgBox "密码修改不成功!"
            Exit Sub
        Else
            newPass2 = InputBox("请再次输入新密码确认:", "密码修改")
            If Len(newPass2) = 0 Then
                MsgBox "密码修改不成功!"
                Exit Sub
            ElseIf newPass1 = newPass2 Then
                If gUser.resetPassword(newPass1) = False Then
                    MsgBox "数据操作错误,密码修改不成功!"
                Else
                    MsgBox "密码成功修改!请保存好你的密码!"
                End If
                Exit Sub
            Else
                MsgBox "两次输入的新密码不一样,修改失败!"
                Exit Sub
            End If
        End If
    Else
        MsgBox "密码修改不成功!"
        Exit Sub
    End If

End Sub

Private Sub Command2_Click()

    If MsgBox("是否真的要退出系统吗?", vbYesNo) = vbYes Then
        Unload Me
    End If
End Sub

Private Sub Command3_Click()

End Sub

Private Sub Form_Load()
    Dim rs As ADODB.Recordset
    
    Dim strSQL As String
    
    strSQL = "SELECT * FROM tblTypeInfo ORDER BY TypeNO"
    Set rs = gConn.Execute(strSQL)
    
    cboQTypeNO.AddItem ""
    
    With rs
        Do Until .EOF
            cboQTypeNO.AddItem .Fields("TypeNO").value & "-" & .Fields("TypeName").value
            .MoveNext
        Loop
    End With

    cboQTypeNO.ListIndex = 0
    
    strSQL = "SELECT * FROM tblDepartment ORDER BY DeptNO"
    Set rs = gConn.Execute(strSQL)
    
    cboQDept.AddItem ""
    With rs
        Do Until .EOF
            cboQDept.AddItem .Fields("DeptNO").value & "-" & .Fields("Department").value
            .MoveNext
        Loop
    End With
    
    cboQDept.ListIndex = 0
    
    rs.Close
    Set rs = Nothing
    
    With tabMain
        Select Case gUser.Level
            Case 1  '数据操作员
                '.TabVisible(3) = False
                fillDeviceGrid grdDevice
               ' frameSystem.Visible = False
            
            Case -1 '系统管理员
                fillDeviceGrid grdDevice
                .TabVisible(0) = False
                .TabVisible(1) = False
                .TabVisible(2) = False
                frameSystem.Visible = True
                
            Case Else   '普通人员
                .Tab = 1
                .TabVisible(0) = False
                .TabVisible(3) = False
                frameSystem.Visible = False
                
        End Select
    End With
    
End Sub

Private Sub Form_Unload(Cancel As Integer)


    gConn.Close
    Set gConn = Nothing
    Set gUser = Nothing
    
End Sub

Private Sub grdDevice_DblClick()
    
    Dim iid As String
    
    With grdDevice
        If .Row > 0 Then
            .Col = 1
            iid = .Text
            Call doDevice(iid)
        End If
    End With

End Sub

Private Sub grdUser_DblClick()

    Dim uid As String
    
    With grdUser
        If .Row > 0 Then
            .Col = 1
            uid = .Text
            Call doUser(uid)
        End If
    End With

End Sub

Private Sub tabMain_Click(PreviousTab As Integer)

    Dim strSQL As String
    
    Select Case tabMain.Tab
        Case 0
            strSQL = "SELECT a.*,b.department,c.TypeName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO=b.DeptNO) INNER JOIN tblTypeInfo C ON a.TypeNO=c.TypeNO ORDER BY A.IID DESC"
            Call fillDeviceGrid(grdDevice, strSQL)
        
        Case 3
            'Call fillUserGrid
    End Select
    
End Sub

Private Sub fillDeviceGrid(grid As MSFlexGrid, Optional strSQL As String)

    Dim rs As ADODB.Recordset
    Dim strRowData As String
    Dim rowindex As Integer
    
    If Len(strSQL) = 0 Then
        strSQL = "SELECT a.*,b.department,c.TypeName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO=b.DeptNO) INNER JOIN tblTypeInfo C ON a.TypeNO=c.TypeNO ORDER BY A.IID DESC"
    End If
    
    rowindex = 1
    
With grid
    If .Tag = "" Then

        Set rs = gConn.Execute(strSQL)
        .Rows = 1
        .Cols = 13
        
        .Row = 0
        .Col = 0
        .Text = "序号"
        .Col = 1
        .Text = "ID"
        .ColWidth(1) = 0
        .Col = 2
        .Text = "设备编号"
        .Col = 3
        .Text = "设备名称"
        .Col = 4
        .Text = "设备型号"
        .Col = 5
        .Text = "设备分类"
        .Col = 6
        .Text = "所属部门"
        .Col = 7
        .Text = "购买价格"
        .Col = 8
        .Text = "折旧成本"
        .Col = 9
        .Text = "购买日期"
        .Col = 10
        .Text = "状态"
        .Col = 11
        .Text = "报废日期"
        .Col = 12
        .Text = "注销日期"
        
        Do Until rs.EOF
            strRowData = rowindex & vbTab
            strRowData = strRowData & rs("IID").value & vbTab
            strRowData = strRowData & rs("DeviceNO").value & vbTab
            strRowData = strRowData & rs("DeviceName").value & vbTab
            strRowData = strRowData & rs("DeviceModel").value & vbTab
            strRowData = strRowData & rs("TypeName").value & vbTab
            strRowData = strRowData & rs("Department").value & vbTab
            strRowData = strRowData & rs("ProductPrice").value & vbTab
            strRowData = strRowData & rs("Productcost").value & vbTab
            strRowData = strRowData & FormatDateTime(rs("PurchaseDate").value, vbLongDate) & vbTab
            If rs("Status").value = 0 Then
                strRowData = strRowData & "在库" & vbTab
            Else
                strRowData = strRowData & "借出" & vbTab
            End If
            strRowData = strRowData & rs("RejectDate").value & vbTab
            strRowData = strRowData & rs("DisCardDate").value & vbTab
            .AddItem strRowData
            
            rs.MoveNext
            rowindex = rowindex + 1
        Loop
        rs.Close
        Set rs = Nothing
        
        .Tag = 1

    End If
End With

End Sub

Private Sub fillUserGrid()

    Dim rs As ADODB.Recordset
    Dim strRowData As String
    Dim rowindex As Integer
    
    rowindex = 1
    
With grdUser
    If .Tag = "" Then

        Set rs = gConn.Execute("SELECT * FROM tblUser ORDER BY UID DESC")
        .Rows = 1
        .Cols = 4
        
        .Row = 0
        .Col = 0
        .Text = "序号"
        .ColWidth(0) = 500
        .Col = 1
        .ColWidth(1) = 0
        .Col = 2
        .Text = "用户名"
        .ColWidth(2) = 1500
        .Col = 3
        .Text = "用户级别"
        .ColWidth(3) = 3000
        
        Do Until rs.EOF
            strRowData = rowindex & vbTab
            strRowData = strRowData & rs("UID").value & vbTab
            strRowData = strRowData & rs("login").value & vbTab
           ' Select Case rs("userlevel").value
              '  Case -1
                 '   strRowData = strRowData & "系统管理员" & vbTab
               ' Case 0
               '     strRowData = strRowData & "普通用户" & vbTab
                'Case 1
               '     strRowData = strRowData & "数据操作员" & vbTab
            'End Select
            .AddItem strRowData
            
            rs.MoveNext
            rowindex = rowindex + 1
        Loop
        rs.Close
        Set rs = Nothing
        
        .Tag = 1
        
    End If
End With

End Sub

Private Function getDeptNo() As String

    Dim str As String
    Dim pos As Integer
    
    With cboQDept
        str = .List(.ListIndex)
    End With
    
    pos = InStr(str, "-")
    
    getDeptNo = Left(str, pos - 1)

End Function

Private Function getTypeNO() As String

    Dim str As String
    Dim pos As Integer
    
    With cboQTypeNO
        str = .List(.ListIndex)
    End With
    
    pos = InStr(str, "-")
    
    getTypeNO = Left(str, pos - 1)

End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -