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

📄 frmmodify.frm

📁 本源代码为学生图书管管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmModify 
   Caption         =   "图书信息修改"
   ClientHeight    =   2715
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6285
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   ScaleHeight     =   2715
   ScaleWidth      =   6285
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame2 
      Height          =   735
      Left            =   240
      TabIndex        =   5
      Top             =   0
      Width           =   5775
      Begin VB.CommandButton cmdNext 
         Caption         =   "后一条 >"
         Height          =   375
         Left            =   2880
         TabIndex        =   9
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdLast 
         Caption         =   "末记录>>|"
         Height          =   375
         Left            =   4320
         TabIndex        =   8
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdForward 
         Caption         =   "< 前一条"
         Height          =   375
         Left            =   1440
         TabIndex        =   7
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdFirst 
         Caption         =   "|<<首记录"
         Height          =   375
         Left            =   120
         TabIndex        =   6
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1815
      Left            =   240
      TabIndex        =   0
      Top             =   720
      Width           =   6015
      Begin VB.CommandButton cmdOK 
         Caption         =   "确定"
         Height          =   375
         Left            =   4800
         TabIndex        =   14
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdSearch 
         Caption         =   "按编号查询"
         Height          =   375
         Left            =   3480
         TabIndex        =   13
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton cmdSave 
         Caption         =   "保存修改"
         Height          =   375
         Left            =   4800
         TabIndex        =   12
         Top             =   1200
         Width           =   1095
      End
      Begin VB.TextBox txtBName2 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1080
         TabIndex        =   10
         Top             =   1200
         Width           =   3615
      End
      Begin VB.TextBox txtBName 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1080
         TabIndex        =   4
         Top             =   720
         Width           =   3615
      End
      Begin VB.TextBox txtBID 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1080
         TabIndex        =   3
         Top             =   240
         Width           =   2295
      End
      Begin VB.Label Label3 
         Caption         =   "改为:"
         Height          =   255
         Left            =   480
         TabIndex        =   11
         Top             =   1320
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "图书名称:"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   840
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "图书编号:"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmModify"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rsBook As New ADODB.Recordset

Private Sub cmdFirst_Click()
    If Not rsBook.BOF Then
        rsBook.MoveFirst
        ShowInfo
    End If
    txtBName2.Text = ""
End Sub

Private Sub cmdForward_Click()
    rsBook.MovePrevious
    If rsBook.BOF Then
        rsBook.MoveFirst
    Else
    '    rsBook.MovePrevious
    End If
    ShowInfo
    txtBName2.Text = ""
End Sub

Private Sub cmdLast_Click()
    If Not rsBook.EOF Then
       rsBook.MoveLast
       ShowInfo
    End If
    txtBName2.Text = ""
End Sub

Private Sub cmdNext_Click()
    rsBook.MoveNext
    If rsBook.EOF Then
       
        rsBook.MoveLast
    End If
    ShowInfo
    txtBName2.Text = ""
End Sub

Private Sub cmdOK_Click()
    Dim strsql As String
    Dim rsinfo As New ADODB.Recordset
    strsql = "select * from tblbooks where bookid='" & txtBID.Text & "'"
    rsinfo.Open strsql, conLIB, adOpenDynamic, adLockOptimistic
    If rsinfo.EOF And rsinfo.BOF Then
        MsgBox "没有此书号的图书信息", vbOKOnly, "提示"
        txtBID.SelStart = 0
        txtBID.SelLength = Len(txtBID.Text)
        rsinfo.Close
        Set rsinfo = Nothing
        Exit Sub
    Else
        txtBName.Text = rsinfo!bookname
        
    End If
    txtBName2.Text = ""
    cmdSave.Enabled = False
    rsinfo.Close
    Set rsinfo = Nothing
End Sub

Private Sub cmdSave_Click()
    Dim strsql As String
    If txtBName2.Text = "" Then
        Exit Sub
    Else
        strsql = "update tblbooks set bookname='" & txtBName2.Text & "' where bookid='" & txtBID.Text & "'"
        conLIB.Execute strsql
    End If
End Sub

Private Sub cmdSearch_Click()
    txtBID.Enabled = True
    txtBID.SelStart = 0
    txtBID.SelLength = Len(txtBID.Text)
    
    txtBName.Text = ""
    txtBID.SetFocus
    cmdOK.Enabled = True
    txtBName2.Text = ""
    cmdSave.Enabled = False
End Sub

Private Sub Form_Load()
    Dim strsql As String
    strsql = "select * from tblbooks"
    txtBID.Enabled = False
    txtBName.Enabled = False
    
    If rsBook.State = adStateOpen Then rsBook.Close
    rsBook.Open strsql, conLIB, adOpenDynamic, adLockOptimistic
    If rsBook.EOF And rsBook.BOF Then
        MsgBox "数据库中没有任何书籍信息,请先添加后再做修改", vbOKOnly, "提示"
        rsBook.Close
        Set rsBook = Nothing
        Exit Sub
    Else
       ShowInfo
    End If
    cmdOK.Enabled = False
    cmdSave.Enabled = False
End Sub
Private Sub ShowInfo()
    txtBID.Text = rsBook!bookid
    txtBName.Text = rsBook!bookname
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If rsBook.State = adStateOpen Then
        rsBook.Close
        Set rsBook = Nothing
    End If
End Sub

Private Sub txtBName2_Change()
    If txtBName2.Text <> "" Then
        cmdSave.Enabled = True
    End If
End Sub

⌨️ 快捷键说明

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