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

📄 frmmain.frm

📁 固定资产管理系统VB开发 已经测试
💻 FRM
📖 第 1 页 / 共 3 页
字号:
    End If
    
    grdQuery.Tag = ""
    
    fillDeviceGrid grdQuery, strSQL
    
End Sub

Private Sub cmdReject_Click()

    Dim iid As String
    Dim strDate As String
    
    With grdDevice
        If .Row = 0 Then
            MsgBox "请选择要报废的设备!"
        Else
            If MsgBox("你是否真的要报废当前选择的设备吗?报废后将不能恢复!", vbOKCancel) = vbOK Then
                .Col = 1
                iid = .Text
                                
                strDate = getDate("")
                If Len(strDate) > 0 Then
                    Dim device As New classDevice
                    If device.DisCard(iid, strDate) = True Then
                        .Tag = ""
                    
                        fillDeviceGrid grdDevice
                    End If
                    Set device = Nothing
                End If
            End If
        End If
    End With

End Sub

Private Sub cmdReport1_Click()

    Dim report As New drDevice
    Dim rs As ADODB.Recordset
    
    Set rs = gConn.Execute("SELECT * FROM tbldevice")
    With report
        Set .DataSource = rs
        .DataMember = ""
               
        .Show vbModal
        
    End With
    
    Set report = Nothing

End Sub

Private Sub cmdReport2_Click()

    Dim report As New drDepartment
    Dim rs As ADODB.Recordset
    
    Set rs = gConn.Execute("SELECT department,count(*) as countofDevice, sum(productprice) as sumofDevice FROM tbldevice a inner join tbldepartment b on a.deptno=b.deptno group by b.department")
    With report
        Set .DataSource = rs
        .DataMember = ""
               
        .Show vbModal
        
    End With
    
    Set report = Nothing


End Sub

Private Sub cmdReport3_Click()

    Dim report As New drReject
    Dim rs As ADODB.Recordset
    
    Set rs = gConn.Execute("SELECT devicename, department,rejectdate FROM tbldevice a inner join tbldepartment b on a.deptno=b.deptno where rejectdate is not null")
    With report
        Set .DataSource = rs
        .DataMember = ""
               
        .Show vbModal
        
    End With
    
    Set report = Nothing
End Sub

Private Sub cmdReport4_Click()


    Dim report As New drCost
    Dim rs As ADODB.Recordset
    
    Set rs = gConn.Execute("SELECT devicename, department,productprice, productcost FROM tbldevice a inner join tbldepartment b on a.deptno=b.deptno")
    With report
        Set .DataSource = rs
        .DataMember = ""
               
        .Show vbModal
        
    End With
    
    Set report = Nothing

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 cmdUserAdd_Click()

    Call doUser("")
    
End Sub

Private Sub cmdUserDelete_Click()

    Dim uid As String
    
    With grdUser
        If .Row = 0 Then
            MsgBox "请选择要删除的用户!"
        Else
            If MsgBox("你是否真的要删除当前选择的用户吗?删除后将不能恢复!", vbOKCancel) = vbOK Then
                .Col = 1
                uid = .Text
                
                Dim user As New ClassUser
                
                user.deleteData uid
                grdUser.Tag = ""
                Call fillUserGrid
                
            End If
        End If
    End With
    
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 + -