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

📄 frmdelete.frm

📁 本源代码为学生图书管管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmDelete 
   Caption         =   "图书删除"
   ClientHeight    =   2205
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6150
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   ScaleHeight     =   2205
   ScaleWidth      =   6150
   StartUpPosition =   1  '所有者中心
   Begin VB.Frame Frame1 
      Height          =   1215
      Left            =   120
      TabIndex        =   5
      Top             =   840
      Width           =   5895
      Begin VB.CommandButton cmdSearch 
         Caption         =   "按编号查询"
         Height          =   375
         Left            =   3480
         TabIndex        =   13
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton cmdOK 
         Caption         =   "确定"
         Height          =   375
         Left            =   4800
         TabIndex        =   12
         Top             =   240
         Width           =   855
      End
      Begin VB.CommandButton cmdSave 
         Caption         =   "保存修改"
         Height          =   375
         Left            =   4800
         TabIndex        =   11
         Top             =   1200
         Width           =   1095
      End
      Begin VB.TextBox txtBID 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1080
         TabIndex        =   8
         Top             =   240
         Width           =   2295
      End
      Begin VB.TextBox txtBName 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1080
         TabIndex        =   7
         Top             =   720
         Width           =   3375
      End
      Begin VB.CommandButton cmdDelete 
         Caption         =   "删除"
         Height          =   375
         Left            =   4800
         TabIndex        =   6
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "图书编号:"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "图书名称:"
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   840
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Height          =   735
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5895
      Begin VB.CommandButton cmdFirst 
         Caption         =   "|<<首记录"
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton cmdForward 
         Caption         =   "< 前一条"
         Height          =   375
         Left            =   1440
         TabIndex        =   3
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdLast 
         Caption         =   "末记录>>|"
         Height          =   375
         Left            =   4320
         TabIndex        =   2
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdNext 
         Caption         =   "后一条 >"
         Height          =   375
         Left            =   2880
         TabIndex        =   1
         Top             =   240
         Width           =   1335
      End
   End
End
Attribute VB_Name = "frmDelete"
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 cmdDelete_Click()
    Dim strsql As String
    
    strsql = "delete  from tblbooks where bookid='" & txtBID.Text & "'"
    conLIB.Execute strsql
    initinfo
    
End Sub

Private Sub cmdFirst_Click()
    If Not rsBook.BOF Then
        rsBook.MoveFirst
        ShowInfo
    End If
   
End Sub

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

Private Sub cmdLast_Click()
    If Not rsBook.EOF Then
       rsBook.MoveLast
       ShowInfo
    End If
   
End Sub

Private Sub cmdNext_Click()
    
        rsBook.MoveNext
        If rsBook.EOF Then
            rsBook.MoveLast
        End If
        
   
    ShowInfo
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
   
    rsinfo.Close
    Set rsinfo = Nothing
End Sub

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

End Sub

Private Sub Form_Load()
    initinfo
    
End Sub
Private Sub initinfo()
    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

⌨️ 快捷键说明

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