📄 frmbookinfoedit.frm
字号:
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 360
TabIndex = 13
Top = 3960
Width = 720
End
Begin VB.Label Label3
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 = 360
TabIndex = 12
Top = 3360
Width = 720
End
Begin VB.Label Label8
AutoSize = -1 'True
BackColor = &H00FFC0C0&
BackStyle = 0 'Transparent
Caption = "图书名称"
Height = 180
Left = 360
TabIndex = 10
Top = 960
Width = 720
End
Begin VB.Label Label4
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 = 360
TabIndex = 9
Top = 2160
Width = 720
End
Begin VB.Label Label6
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 = 360
TabIndex = 8
Top = 2760
Width = 720
End
Begin VB.Label Label1
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 = 360
TabIndex = 7
Top = 360
Width = 720
End
End
Begin VB.Image Image1
Height = 4215
Left = 120
Stretch = -1 'True
Top = 240
Width = 2775
End
End
Attribute VB_Name = "FrmBookInfoEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean '插入=false,修改=true
Public OriNo As String
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_GetImg_Click()
'AdoBookInfo的数据源是当前选择工作区的图书信息
AdoBookInfo.RecordSource = "Select * from BookInfo where BookNo='" + Trim(MakeStr(txtBookNo)) + "'"
AdoBookInfo.Refresh
'保存图片到数据库
Dim DiskFile As String
'如果没有选择图书,则返回
If Len(Trim(txtBookNo)) = 0 Then
MsgBox "请先保存图书信息"
Exit Sub
End If
'使用CommonDialog控件读取图像文件
CommonDialog1.Filter = "BMP文件(*.bmp)|*.bmp|JPEG文件(*.jpg)|*.jpg|GIF文件(*.gif)|*.gif"
CommonDialog1.ShowOpen
DiskFile = CommonDialog1.FileName
'如果没有选择图像文件,则提供选择
If DiskFile = "" Then
MsgBox "请选择图书的图片文件"
Exit Sub
End If
'存储并显示照片
Call SaveImage(DiskFile, AdoBookInfo)
Call ShowImage(Image1, AdoBookInfo)
Cmd_OK.Enabled = False
End Sub
Private Sub Cmd_OK_Click()
'检查用户录入数据的有效性
If Len(Trim(txtBookNo)) = 0 Then
MsgBox "请输入图书编号!"
txtBookNo.SetFocus
txtBookNo.SelStart = 0
txtBookNo.SelLength = Len(txtBookNo)
Exit Sub
End If
If Len(Trim(txtBookName)) = 0 Then
MsgBox "请输入图书名称"
txtBookName.SetFocus
txtBookName.SelStart = 0
txtBookName.SelLength = Len(txtBookName)
Exit Sub
End If
If Len(Trim(ComboBookType)) = 0 Then
MsgBox "请输入图书分类"
ComboBookType.SetFocus
ComboBookType.SelStart = 0
ComboBookType.SelLength = Len(ComboBookType)
Exit Sub
End If
If Len(Trim(txtPublisher)) = 0 Then
MsgBox "请输入出版社"
txtPublisher.SetFocus
txtPublisher.SelStart = 0
txtPublisher.SelLength = Len(txtPublisher)
Exit Sub
End If
If Len(Trim(txtBPrice)) = 0 Then
MsgBox "请输入图书价格"
txtBPrice.SetFocus
txtBPrice.SelStart = 0
txtBPrice.SelLength = Len(txtBPrice)
Exit Sub
End If
'把用户录入的数据赋值到数据库对象变量中
With MyBookInfo
.BookNo = MakeStr(txtBookNo)
.BookName = MakeStr(txtBookName)
.Publisher = MakeStr(txtPublisher)
.Author = MakeStr(txtAuthor)
.Ptimes = MakeStr(txtPtimes)
.Bprice = Val(txtBPrice)
.Btype = MyBookType.GetId(MakeStr(ComboBookType.Text))
'根据变量Modify的值,决定是插入新数据,还是修改已有的数据
If Modify = False Then
.Insert
Cmd_OK.Enabled = False
Else
Call .Update(OriNo)
End If
End With
'显示载入图片按钮
Cmd_GetImg.Enabled = True
txtBookNo.Enabled = False
End Sub
Private Sub ComboBookType_GotFocus()
'把焦点设置在其他控件,否则会循环调用此过程
txtAuthor.SetFocus
'设置FrmBookTypeSel窗体的位置
FrmBookTypeSel.Left = Me.Left + ComboBookType.Left + 450
FrmBookTypeSel.Top = Me.Top
FrmBookTypeSel.Show 1
'将选择的图书分类显示到ComboUpper控件中
ComboBookType.Text = CurBookType.TypeName
End Sub
Private Sub Form_Load()
'只有编辑状态的图书才需要装入图像
If Modify = True Then
'根据当前的图书编号,设置数据源
AdoBookInfo.RecordSource = "Select * from BookInfo where BookNo='" + Trim(OriNo) + "'"
AdoBookInfo.Refresh
'载入图片
Call ShowImage(Image1, AdoBookInfo)
End If
End Sub
Private Sub txtAuthor_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
Private Sub txtBookName_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
Private Sub txtBookNo_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
Private Sub txtBPrice_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
If In_Single(KeyAscii) = False Then
KeyAscii = 0
End If
End Sub
Private Sub txtPtimes_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
Private Sub txtPublisher_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -