📄 frmbinfoedit.frm
字号:
VERSION 5.00
Begin VB.Form frmBInfoEdit
BackColor = &H00E0E0E0&
Caption = "图书基本信息窗体"
ClientHeight = 6825
ClientLeft = 4800
ClientTop = 3240
ClientWidth = 8130
LinkTopic = "Form1"
ScaleHeight = 6825
ScaleWidth = 8130
Begin VB.PictureBox Picture1
Height = 6495
Left = 4680
Picture = "frmBInfoEdit.frx":0000
ScaleHeight = 6435
ScaleWidth = 3315
TabIndex = 18
Top = 120
Width = 3375
End
Begin VB.CommandButton cmdCancel
Caption = "取消(&C)"
Height = 615
Left = 3000
TabIndex = 17
Top = 6120
Width = 1575
End
Begin VB.CommandButton cmdOk
Caption = "确定(&O)"
Height = 615
Left = 600
TabIndex = 16
Top = 6120
Width = 1695
End
Begin VB.TextBox txtMemo
Height = 1335
Left = 1680
TabIndex = 15
Top = 4680
Width = 2415
End
Begin VB.TextBox txtPrice
Height = 495
Left = 1680
TabIndex = 14
Top = 3960
Width = 2415
End
Begin VB.TextBox txtPublisher
Height = 495
Left = 1680
TabIndex = 13
Top = 3360
Width = 2415
End
Begin VB.TextBox txtAuthor
Height = 495
Left = 1680
TabIndex = 12
Top = 2760
Width = 2415
End
Begin VB.TextBox txtSubBType
BackColor = &H00FFFFFF&
Height = 495
Left = 1680
TabIndex = 11
Top = 2160
Width = 2415
End
Begin VB.TextBox txtBType
BackColor = &H00FFFFFF&
Height = 495
Left = 1680
TabIndex = 10
Top = 1560
Width = 2415
End
Begin VB.TextBox txtBName
Height = 495
Left = 1680
TabIndex = 9
Top = 840
Width = 2415
End
Begin VB.TextBox txtBNo
Height = 495
Left = 1680
TabIndex = 8
Top = 240
Width = 2415
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "备注信息"
Height = 495
Left = 240
TabIndex = 7
Top = 4680
Width = 975
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "价格"
Height = 375
Left = 240
TabIndex = 6
Top = 4080
Width = 975
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "出版社"
Height = 375
Left = 240
TabIndex = 5
Top = 3480
Width = 975
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "作者"
Height = 375
Left = 240
TabIndex = 4
Top = 2880
Width = 975
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "二级分类"
Height = 495
Left = 240
TabIndex = 3
Top = 2160
Width = 975
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "图书分类"
Height = 375
Left = 240
TabIndex = 2
Top = 1560
Width = 975
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "图书名称"
Height = 375
Left = 240
TabIndex = 1
Top = 960
Width = 975
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "图书编号"
Height = 375
Left = 240
TabIndex = 0
Top = 360
Width = 975
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 '定义图片路径变量
Dim tmpSQLStmt As String '定义tmpSQLStmt变量
'取消按钮
Private Sub cmdCancel_Click()
Unload Me
End Sub
'取消选择图书封面
'Private Sub cmdDel_Click()
'如果没有选择图片,则不用取消图片
'If ImgBCover.Picture = 0 Then
'Exit Sub
'End If
'取消显示图片
'ImgBCover.Picture = LoadPicture("")
'End Sub
'单击"确定"按钮,将录入的图书信息插入或更新到数据表BookInfo中
Private Sub cmdOk_Click()
Dim rs As ADODB.Recordset
Dim vTypeID As Integer
Dim SQLStr As String
'是否输入图书名称
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 'frmBInfoM单击"添加"按钮
'是否输入图书编码
If Trim(txtBNo.Text) = "" Then
MsgBox "请输入图书编号", vbInformation, "信息提示"
Exit Sub
End If
'判断图书编号是否重复
Dim rst As ADODB.Recordset
SQLStr = "select * from BookInfo where BookNo='" & Trim(txtBNo.Text) & "'"
Set rst = SQLQuery(SQLStr)
If Not rst.EOF Then
MsgBox "些图书编号号已经存在" + vbCrLf + "请输入其他图书编号", vbInformation, "信息提示"
Exit Sub
End If
'确定分类名称TypeName对应的分类号TypeID
SQLStr = "select * from BookType where TypeName='" + Trim(txtSubBType.Text) + "'"
Set rs = SQLQuery(SQLStr)
vTypeID = rs.Fields(0)
'设置insert语句
SQLStr = "insert into BookInfo(BookNo,BookName,Author,Publisher,Price,TypeID,Memo) values('" + Trim(txtBNo.Text) + "','" + Trim(txtBName.Text) + "','" + Trim(txtAuthor.Text) + "','" + Trim(txtPublisher.Text) + "'," + txtPrice.Text + "," + Str(vTypeID) + ",'" + Trim(txtMemo.Text) + "')"
SQLExt SQLStr '执行insert 语句
'If ImgBCover.Picture <> 0 Then
'tmpSQLStmt = "select * from BookInfo where BookNo='" + Trim(txtBNo.Text) + "'" '设置SQL语句
'Call SaveImage(DiskFile, tmpSQLStmt) '存储图片
'End If
MsgBox "插入成功!", vbInformation, "添加提示"
Unload Me '关闭窗口
Else 'frmBInfoM单击"修改"按钮
SQLStr = "select * from BookType where TypeName='" + Trim(txtSubBType.Text) + "'"
Set rs = SQLQuery(SQLStr)
vTypeID = rs.Fields(0)
SQLStr = "update BookInfo set BookName='" + Trim(txtBName.Text) + "',Author='" + Trim(txtAuthor.Text) + "',Publisher='" + Trim(txtPublisher.Text) + "',Price=" + Trim(txtPrice.Text) + ",TypeID=" + Str(vTypeID) + ",Memo='" + Trim(txtMemo.Text) + "'" + "where BookNo='" + Trim(txtBNo.Text) + "'"
SQLExt SQLStr '执行update语句
'tmpSQLStmt = "select * from BookInfo where BookNo='" + Trim(txtBNo.Text) + "'" '设置SQL 语句
'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 cmdSel_Click()
'使用CmnDlgImage控件读取图像文件
'CmnDlgImage.Filter = "BMP 文件(*.bmp)|*.bmp|JPEG文件(*.jpg)|*.jpg|" + "GIF文件(*.gif)|*.gip|全部文件(*.*)|*.*"
'CmnDlgImage.ShowOpen
'DiskFile = CmnDlgImage.FileName
'如果没有选择图片,则不用显示照片
'If DiskFile = "" Then
'Exit Sub
'End If
'ImgBCover.Picture = LoadPicture(DiskFile) '显示图片
'End Sub
'窗体激活事件
'Private Sub Form_Activate()
'If Trim(txtBNo.Text) <> "" Then
'tmpSQLStmt = "select * from BookInfo where BookNo='" + Trim(txtBNo) + "'"
'Call ShowImage(ImgBCover, tmpSQLStmt)
'End If
'End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -