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

📄 frmlend.frm

📁 关于工业设备型号数量库存价格等信息的管理系统的课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
Begin VB.Form frmLend 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "设备借出借入记录"
   ClientHeight    =   4068
   ClientLeft      =   1320
   ClientTop       =   1548
   ClientWidth     =   7572
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4068
   ScaleWidth      =   7572
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frameLend 
      Caption         =   "选择借出单位"
      Height          =   672
      Left            =   132
      TabIndex        =   4
      Top             =   3156
      Width           =   3672
      Begin VB.ComboBox cboDept 
         Height          =   276
         Left            =   1116
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   252
         Width           =   1932
      End
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   552
      Left            =   5868
      TabIndex        =   2
      Top             =   3252
      Width           =   1476
   End
   Begin VB.CommandButton cmdLend 
      Caption         =   "借出/归还"
      Height          =   564
      Left            =   4116
      TabIndex        =   1
      Top             =   3252
      Width           =   1404
   End
   Begin MSFlexGridLib.MSFlexGrid grdLend 
      Height          =   2424
      Left            =   120
      TabIndex        =   0
      Top             =   564
      Width           =   7260
      _ExtentX        =   12806
      _ExtentY        =   4276
      _Version        =   393216
      FocusRect       =   0
      HighLight       =   2
      SelectionMode   =   1
   End
   Begin VB.Label Label1 
      Caption         =   "借出借入记录:"
      Height          =   324
      Left            =   156
      TabIndex        =   3
      Top             =   216
      Width           =   2388
   End
End
Attribute VB_Name = "frmLend"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim theDevice As New classDevice

Public isUpdate As Boolean

Private Sub cmdExit_Click()

    Me.Hide

End Sub

Private Sub cmdLend_Click()

    Dim lendDept As String
    Dim strSQL As String
    
    If theDevice.Status = 0 Then
        '借出设备
        If cboDept.ListIndex = 0 Then
            MsgBox "请选择借出设备的部门!"
        Else
            lendDept = cboDept.List(cboDept.ListIndex)
            strSQL = "INSERT INTO tblLend (DeviceID, Operation, Lenddept, LendMan, LendDate) VALUES( "
            strSQL = strSQL & theDevice.iid & ",'借出','" & lendDept & "','" & gUser.UserName & "',now())"
            gConn.Execute strSQL
            gConn.Execute "UPDATE tblDevice SET Status=1 WHERE Status=0 AND IID=" & theDevice.iid
            
            isUpdate = True
            
            Me.Hide
        End If
    Else
        '归还设备
        strSQL = "INSERT INTO tblLend (DeviceID, Operation, Lenddept, LendMan, LendDate) VALUES( "
        strSQL = strSQL & theDevice.iid & ",'归还','','" & gUser.UserName & "',now())"
        gConn.Execute strSQL

        gConn.Execute "UPDATE tblDevice SET Status=0 WHERE Status=1 AND IID=" & theDevice.iid
        
        isUpdate = True
        
        Me.Hide
    End If
    

End Sub

Private Sub Form_Load()

    Dim rs As ADODB.Recordset
    
    Dim strSQL As String
    
    strSQL = "SELECT * FROM tblDepartment ORDER BY DeptNO"
    Set rs = gConn.Execute(strSQL)
    
    cboDept.AddItem ""
    With rs
        Do Until .EOF
            cboDept.AddItem .Fields("DeptNO").value & "-" & .Fields("Department").value
            .MoveNext
        Loop
    End With
    
    cboDept.ListIndex = 0
    
    rs.Close
    Set rs = Nothing
    
    isUpdate = False

End Sub

Private Function getDeptNo() As String

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

End Function


Public Function loadLendData(DeviceID As String) As Boolean

    Dim rs As ADODB.Recordset
    
    
    If theDevice.loadDataByID(DeviceID) = False Then
        MsgBox "设备装载不正确!"
        loadLendData = False
        Exit Function
    End If
    
    Me.Caption = "设备[" & theDevice.DeviceName & "]借出借入记录"
    
    If theDevice.Status = 0 Then
        frameLend.Visible = True
        cmdLend.Caption = "借出设备"
    Else
        frameLend.Visible = False
        cmdLend.Caption = "归还设备"
    End If

    loadLendData = fillLend()
    
End Function


Private Function fillLend() As Boolean

    Dim rs As ADODB.Recordset
    Dim strRowData As String
    Dim rowindex As Integer
    
    rowindex = 1
    
    With grdLend
        Set rs = gConn.Execute("SELECT * FROM tblLend WHERE DeviceID=" & theDevice.iid & " ORDER BY LID DESC")
        .Rows = 1
        .Cols = 5
        
        .Row = 0
        .Col = 0
        .Text = "序号"
        .ColWidth(0) = 500
        .Col = 1
        .ColWidth(1) = 500
        .Text = "操作"
        .Col = 2
        .Text = "使用部门"
        .ColWidth(2) = 1500
        .Col = 3
        .Text = "操作人"
        .ColWidth(3) = 1500
        .Col = 4
        .Text = "操作时间"
        .ColWidth(4) = 1500
        
        Do Until rs.EOF
            strRowData = rowindex & vbTab
            strRowData = strRowData & rs("Operation").value & vbTab
            strRowData = strRowData & rs("lenddept").value & vbTab
            strRowData = strRowData & rs("LendMan").value & vbTab
            strRowData = strRowData & FormatDateTime(rs("LendDate").value, vbShortDate)
            .AddItem strRowData
            
            rs.MoveNext
            rowindex = rowindex + 1
        Loop
        rs.Close
        Set rs = Nothing
    End With
    
    fillLend = True

End Function

⌨️ 快捷键说明

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