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

📄 frmbinfoman.frm

📁 在VB中开发的连接SQL的图书管理系统。
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmBInfoMan 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "图书基本信息管理"
   ClientHeight    =   5175
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9450
   Icon            =   "frmBInfoMan.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5175
   ScaleWidth      =   9450
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdBack 
      Caption         =   "返 回"
      Height          =   495
      Left            =   7200
      TabIndex        =   6
      Top             =   4440
      Width           =   1215
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删 除"
      Height          =   495
      Left            =   5040
      TabIndex        =   5
      Top             =   4440
      Width           =   1215
   End
   Begin VB.CommandButton cmdModi 
      Caption         =   "修 改"
      Height          =   495
      Left            =   3000
      TabIndex        =   4
      Top             =   4440
      Width           =   1215
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添 加"
      Height          =   495
      Left            =   840
      TabIndex        =   3
      Top             =   4440
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc adoBInfo 
      Height          =   375
      Left            =   0
      Top             =   0
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "连接dtgBInfo"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid dtgBInfo 
      Bindings        =   "frmBInfoMan.frx":044A
      Height          =   3735
      Left            =   2520
      TabIndex        =   2
      Top             =   360
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   6588
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TreeView tvwBType 
      Height          =   3375
      Left            =   120
      TabIndex        =   0
      Top             =   720
      Width           =   2175
      _ExtentX        =   3836
      _ExtentY        =   5953
      _Version        =   393217
      HideSelection   =   0   'False
      LabelEdit       =   1
      LineStyle       =   1
      Style           =   7
      SingleSel       =   -1  'True
      Appearance      =   1
   End
   Begin VB.Label lblBType 
      AutoSize        =   -1  'True
      Caption         =   "图书分类"
      Height          =   180
      Left            =   120
      TabIndex        =   1
      Top             =   360
      Width           =   720
   End
End
Attribute VB_Name = "frmBInfoMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义condition变量
Dim condition As String
  
'网格控件加载函数
Private Sub adoBInfoRefresh()
  '设置ADO控件adoBInfoRefresh的连接字符串
  adoBInfo.ConnectionString = CONSTR
  '设置数据源
  Dim tmpRecordSource As String
  tmpRecordSource = "SELECT i.BookNo AS 图书编号, i.BookName AS 图书名称," _
                  + " t.TypeName AS 图书类型名称, i.Author AS 作者, i.Publisher AS 出版社," _
                  + " i.Price AS 图书价格, i.Memo AS 图书说明" _
                  + " FROM BookInfo i, BookType t" _
                  + " WHERE i.TypeID = t.TypeID" _
                  + condition + " ORDER BY i.BookNo"
  adoBInfo.RecordSource = tmpRecordSource
  adoBInfo.Refresh
  '设置列宽
  With dtgBInfo
  .Columns(0).Width = 1000
  .Columns(1).Width = 1500
  .Columns(2).Width = 1500
  .Columns(3).Width = 1200
  .Columns(4).Width = 1500
  .Columns(5).Width = 1000
  .Columns(6).Width = 2000
  End With
End Sub

'窗体装载事件
Private Sub Form_Load()
  '为TreeView控件tvwBType对象装载图书分类名称
  tvwBType.Nodes.Clear
  Set tvwNode = tvwBType.Nodes.Add(, , "tvwAll", "全部分类")
  Call Add_BTypeToTree(tvwBType, "tvwAll")
  
  '给objBookType初始化
  objBookType.Init
  
  '给condition初始化
  condition = ""
  
  '调用adoBInfoRefresh过程
  Call adoBInfoRefresh
End Sub

'单击tvwBType结点
Private Sub tvwBType_NodeClick(ByVal Node As MSComctlLib.Node)
  '如果是根结点
  If Node.Text = Node.Root.Text Then
    objBookType.Init
    condition = ""
  Else
    '得到书籍分类信息
    objBookType.GetInfo Trim(Node.Text)
    If objBookType.UID = 0 Then
      '如果所选的为一级分类
      condition = " AND t.UID = " + Trim(Str(objBookType.TypeID))
    Else
      '如果所选的为二级分类
      condition = " AND t.TypeID = " + Trim(objBookType.TypeID)
    End If
  End If
    
  '调用adoBInfoRefresh过程
  Call adoBInfoRefresh
End Sub

'插入按钮
Private Sub cmdAdd_Click()
  '只能在根节点下面添加书籍,判断是否为根节点
  If tvwBType.SelectedItem.Text = "全部分类" Then
    MsgBox "只能在最下级添加图书", vbInformation, "信息提示"
    Exit Sub
  End If
  '不能在一级分类下添加书籍
  If objBookType.UID = 0 Then
    MsgBox "不能在一级图书分类下添加图书" + vbCrLf + "只能在最下级添加图书", _
           vbInformation, "信息提示"
    Exit Sub
  End If
  '给图书编辑窗口赋值
  frmBInfoEdit.txtBNo = ""
  frmBInfoEdit.txtBNo.Locked = False
  frmBInfoEdit.txtBName = ""
  frmBInfoEdit.txtBType = Trim(objBookType.GetTypeName(objBookType.UID))
  frmBInfoEdit.txtSubBType = Trim(objBookType.TypeName)
  frmBInfoEdit.txtAuthor = ""
  frmBInfoEdit.txtPublisher = ""
  frmBInfoEdit.txtPrice = "0"
  frmBInfoEdit.txtMemo = ""
  IsAdd = True
  '启动编辑窗体
  frmBInfoEdit.Show 1
  '刷新adoBInfo控件
  adoBInfo.Refresh
End Sub

'修改按钮
Private Sub cmdModi_Click()
  '如果没记录的话,不能进行修改
  If adoBInfo.Recordset.BOF Or adoBInfo.Recordset.EOF Then
    MsgBox "请选择一条图书记录", vbInformation, "信息提示"
    Exit Sub
  End If
  '给图书编辑窗口赋值
  frmBInfoEdit.txtBNo = Trim(adoBInfo.Recordset.Fields(0))
  frmBInfoEdit.txtBNo.Locked = True
  frmBInfoEdit.txtBName = Trim(adoBInfo.Recordset.Fields(1))
  objCurBType.GetInfo Trim(adoBInfo.Recordset.Fields(2))
  frmBInfoEdit.txtBType = Trim(objCurBType.GetTypeName(objCurBType.UID))
  frmBInfoEdit.txtSubBType = Trim(objCurBType.TypeName)
  frmBInfoEdit.txtAuthor = Trim(adoBInfo.Recordset.Fields(3))
  frmBInfoEdit.txtPublisher = Trim(adoBInfo.Recordset.Fields(4))
  frmBInfoEdit.txtPrice = Trim(Str(adoBInfo.Recordset.Fields(5)))
  If IsNull(Trim(adoBInfo.Recordset.Fields(6))) Then
    frmBInfoEdit.txtMemo = ""
  Else
    frmBInfoEdit.txtMemo = Trim(adoBInfo.Recordset.Fields(6))
  End If
  IsAdd = False
  '启动编辑窗体
  frmBInfoEdit.Show 1
  '刷新adoBInfo控件
  adoBInfo.Refresh
End Sub

'删除按钮
Private Sub cmdDel_Click()
  Dim isDel As Integer
  If adoBInfo.Recordset.BOF Or adoBInfo.Recordset.EOF Then
    MsgBox "请选择一条图书记录", vbInformation, "信息提示"
  Else
    isDel = MsgBox("是否删除所选择的记录", vbYesNo + vbQuestion + vbDefaultButton2, "是否删除")
    If isDel = vbYes Then
      objBookInfo.Delete dtgBInfo.Columns(0)
      MsgBox "删除成功!", vbInformation, "信息提示"
    End If
  End If
  '刷新
  adoBInfo.Refresh
End Sub

'返回按钮
Private Sub cmdBack_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

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