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

📄 frmreturn1.frm

📁 图书管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            End If
            mrcc.Close
        End If
    End If
End Sub

Private Sub cmdSave_Click()
    Dim intCount As Integer
    Dim sMeg As String
    Dim MsgText As String
    Dim returnDate As String
    Dim mrcd As ADODB.Recordset
    Dim bYear As Integer
    Dim eYear As Integer
    Dim bDays As Integer
    Dim eDays As Integer
    Dim aDays As Integer
    Dim uDays As Integer
    
    
    If Trim(txtNo) = "" Then
        MsgBox "请选择借书信息!", vbOKOnly + vbExclamation, "警告"
        cboItem(1).SetFocus
        Exit Sub
    End If
    
    returnDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")
    If Trim(returnDate) = "" Then
        MsgBox "请选择还书日期!", vbOKOnly + vbExclamation, "警告"
        cboYear(1).SetFocus
        Exit Sub
    End If
    
    If gintBBmode = 2 Then
        txtSQL = "select * from books where bookid = '" & Trim(BookID) & "'"
        Set mrcd = ExecuteSQL(txtSQL, MsgText)
        If Not mrcd.EOF Then
            mrcd!putup = "y"
        End If
        mrcd.Update
        mrcd.Close
    End If
    
    txtSQL = "select * from borrowinfo where  borrowno = '" & Trim(txtNo) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If Not mrc.EOF Then
        mrc.Fields(6) = Trim(returnDate)
        txtSQL = "select * from books where bookid = '" & Trim(BookID) & "'"
        Set mrcd = ExecuteSQL(txtSQL, MsgText)
        
        If Not mrcd.EOF Then
            mrcd!putup = " "
        End If
        mrcd.Update
        mrcd.Close
        
    End If
    mrc.Update
    mrc.Close
    
    
    bYear = DatePart("yyyy", cboItem(3))
    eYear = DatePart("yyyy", returnDate)
    bDays = DatePart("y", cboItem(3))
    eDays = DatePart("y", returnDate)
    If bYear = eYear Then
        aDays = eDays - bDays
    Else
        aDays = (eYear - bYear - 1) * 365 + (365 - bDays) + eDays
    End If
    
    txtSQL = "select readertype from readers where readerno = '" & Trim(cboItem(0)) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    
    If Not mrc.EOF Then
        sMeg = mrc.Fields(0)
    End If
    mrc.Close
    
    txtSQL = "select bookdays from readertype where typename = '" & Trim(sMeg) & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If Not mrc.EOF Then
        uDays = mrc.Fields(0)
    End If
    mrc.Close
    
    If uDays < aDays Then
        MsgBox "过期" & (aDays - uDays) & "天,罚款" & (0.1 * (aDays - uDays)) & "元!", vbOKOnly + vbExclamation, "警告"
    End If
    
    
    
    If gintBBmode = 1 Then
        MsgBox "添加还书信息成功!", vbOKOnly + vbExclamation, "添加借书消息"
        Unload Me
        If flagBBedit Then
            Unload frmReturn
        End If
        frmReturn.txtSQL = "select * from borrowinfo"
        frmReturn.Show
    Else
        MsgBox "修改还书信息成功!", vbOKOnly + vbExclamation, "修改借书消息"
        Unload Me
        If flagBBedit Then
            Unload frmReturn
        End If
        frmReturn.txtSQL = "select * from borrowinfo"
        frmReturn.Show
    End If
    
End Sub

Private Sub Form_Load()
    
    Dim sSql As String
    Dim intCount As Integer
    Dim MsgText As String
    Dim i As Integer
    Dim j As Integer
    
    
    
    If gintBBmode = 1 Then
        Me.Caption = Me.Caption & "添加"
        
        '初始化客房信息
        txtSQL = "select DISTINCT readername from borrowinfo where returndate is null "
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        
        If Not mrc.EOF Then
                
            Do While Not mrc.EOF
                cboItem(1).AddItem Trim(mrc.Fields(0))
                mrc.MoveNext
            Loop
        Else
            MsgBox "没人借书!", vbOKOnly + vbExclamation, "警告"
            cmdSave.Enabled = False
            Exit Sub
        End If
        mrc.Close
        
        txtSQL = "select distinct datepart(yy,borrowdate) from borrowinfo where returndate is null "
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        If mrc.EOF = False Then
            With mrc
            Do While Not .EOF
                cboYear(0).AddItem .Fields(0)
                .MoveNext
            Loop
            End With
            
            cboYear(0).ListIndex = 0
            
            For j = 1 To 12
                cboMonth(0).AddItem j
            Next j
            cboMonth(0).Text = Month(Now())
            
            For j = 1 To 31
                cboDay.AddItem j
            Next j
            cboDay.Text = Day(Now())
            
        Else
            cmdSave.Enabled = False
        End If
        mrc.Close
            
        
            
        
            
    ElseIf gintBBmode = 2 Then
        Me.Caption = Me.Caption & "修改"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        
        If Not mrc.EOF Then
            txtNo = mrc!borrowno
            
            For intCount = 0 To 1
                cboItem(intCount).Clear
                cboItem(intCount).AddItem mrc.Fields(intCount + 1)
                cboItem(intCount).ListIndex = 0
            Next intCount
            
            BookID = mrc.Fields(3)
            
            For intCount = 2 To 3
                cboItem(intCount).Clear
                cboItem(intCount).AddItem mrc.Fields(intCount + 2)
                cboItem(intCount).ListIndex = 0
            Next intCount
            
            txtItem(0) = mrc.Fields(7)
        End If
        
        mrc.Close
        
        txtSQL = "select distinct datepart(yy,borrowdate) from borrowinfo where returndate is not null "
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        If mrc.EOF = False Then
            With mrc
            Do While Not .EOF
                cboYear(0).AddItem .Fields(0)
                .MoveNext
            Loop
            End With
            
            cboYear(0).ListIndex = 0
            
            For j = 1 To 12
                cboMonth(0).AddItem j
            Next j
            cboMonth(0).Text = Month(Now())
            
            For j = 1 To 31
                cboDay.AddItem j
            Next j
            cboDay.Text = Day(Now())
            
        Else
            cmdSave.Enabled = False
        End If
        mrc.Close
            
        
            
            
    End If
    
    
    
    mblChange = False
        
    
    

    
End Sub

Private Sub Form_Unload(Cancel As Integer)
    gintBBmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
    '有变化设置gblchange
    mblChange = True
    
End Sub

Private Sub txtItem_GotFocus(Index As Integer)
    txtItem(Index).SelStart = 0
    txtItem(Index).SelLength = Len(txtItem(Index))
    
End Sub

Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
        EnterToTab KeyCode

End Sub
Private Sub cmdExit_Click()
    If mblChange And cmdSave.Enabled Then
        If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
            '保存
            Call cmdSave_Click
        End If
    End If
    Unload Me
End Sub

⌨️ 快捷键说明

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