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

📄 frmbinfoedit.frm

📁 在VB中开发的连接SQL的图书管理系统。
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   18
         Top             =   2640
         Width           =   720
      End
      Begin VB.Label lblAuthor 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "作    者"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   17
         Top             =   2160
         Width           =   720
      End
      Begin VB.Label lblPrice 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "价    格"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   16
         Top             =   3120
         Width           =   720
      End
      Begin VB.Label lblBType 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "图书分类"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   180
         Left            =   240
         TabIndex        =   15
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label lblMemo 
         Caption         =   "备注信息"
         Height          =   180
         Left            =   240
         TabIndex        =   14
         Top             =   3600
         Width           =   720
      End
      Begin VB.Label lblSubBType 
         Caption         =   "二级分类"
         Height          =   180
         Left            =   240
         TabIndex        =   13
         Top             =   1800
         Width           =   720
      End
   End
End
Attribute VB_Name = "frmBInfoEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义图片路径变量
Dim DiskFile As String
'定义tmpSQLStmt变量
Dim tmpSQLStmt As String

'窗体激活事件
Private Sub Form_Activate()
  If Trim(txtBNo.Text) <> "" Then
    tmpSQLStmt = "SELECT * FROM BookInfo WHERE BookNo = '" _
               + Trim(StrReplace(txtBNo)) + "'"
    Call ShowImage(imgBCover, tmpSQLStmt)
  End If
End Sub

'选择图书封面
Private Sub cmdSel_Click()
  '使用CmnDlgImage控件读取图像文件
  CmnDlgImage.Filter = "BMP文件(*.bmp)|*.bmp|JPEG文件(*.jpg)|*.jpg|" _
                       + "GIF文件(*.gif)|*.gif|全部文件(*.*)|*.*"
  CmnDlgImage.ShowOpen
  DiskFile = CmnDlgImage.FileName
  '如果没有选择图片,则不用显示照片
  If DiskFile = "" Then
    Exit Sub
  End If
  '显示图片
  imgBCover.Picture = LoadPicture(DiskFile)
End Sub

'取消选择图书封面
Private Sub cmdDel_Click()
  '如果没有选择图片,则不用取消图片
  If imgBCover.Picture = 0 Then
    Exit Sub
  End If
  '取消显示图片
  imgBCover.Picture = LoadPicture("")
End Sub

'确定按钮
Private Sub cmdOK_Click()
  '================判断文本框的有效性==================
  '是否输入图书名称
  If Trim(txtBName.Text) = "" Then
    MsgBox "请输入图书名称", vbInformation, "信息提示"
    txtBName.SetFocus
    Exit Sub
  End If
  '是否输入作者
  If Trim(txtAuthor.Text) = "" Then
    MsgBox "请输入作者姓名", vbInformation, "信息提示"
    txtAuthor.SetFocus
    Exit Sub
  End If
  '是否输入出版社
  If Trim(txtPublisher.Text) = "" Then
    MsgBox "请输入出版社名称", vbInformation, "信息提示"
    txtPublisher.SetFocus
    Exit Sub
  End If
  '是否输入图书价格
  If Trim(txtPrice.Text) = "0" Or Trim(txtPrice) = "" Then
    MsgBox "请输入图书价格", vbInformation, "信息提示"
    txtPrice.SetFocus
    Exit Sub
  End If
  '输入图书价格是否合法
  If Not IsNumeric(txtPrice.Text) Then
    MsgBox "图书价格为数字" + vbCrLf + "请输入正确的图书价格", vbInformation, "信息提示"
    txtPrice.SetFocus
    txtPrice.SelStart = 0
    txtPrice.SelLength = Len(txtPrice.Text)
    Exit Sub
  End If
  '===============判断文本框有效性结束=================
  '========增加========
  If IsAdd Then
    '是否输入图书编码
    If Trim(txtBNo.Text) = "" Then
      MsgBox "请输入图书编号", vbInformation, "信息提示"
      Exit Sub
    End If
    '判断图书编号是否重复
    If objBookInfo.IsExistBNo(Trim(txtBNo.Text)) Then
      MsgBox "此图书编号已经存在" + vbCrLf _
           + "请输入其他图书编号", vbInformation, "信息提示"
      Exit Sub
    End If
    '给objBookInfo赋值
    objBookInfo.BookNo = Trim(txtBNo.Text)
    objBookInfo.BookName = Trim(txtBName.Text)
    objBookInfo.Author = Trim(txtAuthor.Text)
    objBookInfo.Publisher = Trim(txtPublisher.Text)
    objBookInfo.Price = Val(txtPrice.Text)
    objCurBType.GetInfo txtSubBType.Text
    objBookInfo.TypeID = objCurBType.TypeID
    objBookInfo.Memo = Trim(txtMemo.Text)
    objBookInfo.Insert
    If imgBCover.Picture <> 0 Then
      '设置SQL语句
      tmpSQLStmt = "SELECT * FROM BookInfo WHERE BookNo = '" _
                 + Trim(StrReplace(txtBNo.Text)) + "'"
      '存储图片
      Call SaveImage(DiskFile, tmpSQLStmt)
    End If
    MsgBox "插入成功", vbInformation, "信息提示"
    '关闭窗口
    Unload Me
  '========修改========
  Else
    '给objBookInfo赋值
    objBookInfo.BookNo = Trim(txtBNo.Text)
    objBookInfo.BookName = Trim(txtBName.Text)
    objBookInfo.Author = Trim(txtAuthor.Text)
    objBookInfo.Publisher = Trim(txtPublisher.Text)
    objBookInfo.Price = Val(txtPrice.Text)
    objCurBType.GetInfo txtSubBType.Text
    objBookInfo.TypeID = objCurBType.TypeID
    objBookInfo.Memo = Trim(txtMemo.Text)
    objBookInfo.Update objBookInfo.BookNo
    '设置SQL语句
    tmpSQLStmt = "SELECT * FROM BookInfo WHERE BookNo = '" _
               + Trim(StrReplace(txtBNo.Text)) + "'"
    If imgBCover.Picture = 0 Then
      '删除图片
      Call DelImage(imgBCover, tmpSQLStmt)
    Else
      '存储图片
      Call SaveImage(DiskFile, tmpSQLStmt)
    End If
    MsgBox "修改成功", vbInformation, "信息提示"
    '关闭窗口
    Unload Me
  End If
End Sub

'取消按钮
Private Sub cmdCancel_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

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