📄 form6.frm
字号:
VERSION 5.00
Begin VB.Form Form6
Caption = "图书信息"
ClientHeight = 5340
ClientLeft = 60
ClientTop = 345
ClientWidth = 9090
LinkTopic = "Form6"
MaxButton = 0 'False
ScaleHeight = 5340
ScaleWidth = 9090
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "修改"
Height = 375
Left = 1680
TabIndex = 22
Top = 4320
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 7800
TabIndex = 21
Top = 4320
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 240
TabIndex = 20
Top = 4320
Width = 1215
End
Begin VB.Frame Frame1
Height = 3615
Left = 120
TabIndex = 0
Top = 120
Width = 8895
Begin VB.TextBox Text6
Height = 375
Left = 5040
TabIndex = 19
Text = "1"
Top = 2880
Width = 975
End
Begin VB.TextBox Text5
Height = 375
Left = 840
TabIndex = 17
Text = "1"
Top = 2880
Width = 975
End
Begin VB.ComboBox Combo1
Height = 300
Left = 840
TabIndex = 14
Text = "Combo1"
Top = 2160
Width = 3735
End
Begin VB.TextBox Text4
Height = 390
Left = 6720
TabIndex = 11
Top = 1440
Width = 1575
End
Begin VB.TextBox Text3
Height = 375
Left = 840
TabIndex = 8
Top = 1440
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
Left = 840
TabIndex = 5
Top = 840
Width = 3135
End
Begin VB.TextBox Text1
Height = 375
Left = 840
TabIndex = 2
Top = 240
Width = 3135
End
Begin VB.Label Label12
Caption = "库存量:"
Height = 255
Left = 4080
TabIndex = 18
Top = 3000
Width = 735
End
Begin VB.Label Label11
Caption = "复本量:"
Height = 255
Left = 120
TabIndex = 16
Top = 3000
Width = 735
End
Begin VB.Label Label9
Caption = "*(字符数不得超过20个)"
ForeColor = &H000000FF&
Height = 255
Left = 4800
TabIndex = 15
Top = 2280
Width = 2535
End
Begin VB.Label Label8
Caption = "出版社:"
Height = 255
Left = 120
TabIndex = 13
Top = 2160
Width = 735
End
Begin VB.Label Label7
Caption = "元"
Height = 255
Left = 8400
TabIndex = 12
Top = 1560
Width = 255
End
Begin VB.Label Label6
Caption = "价格:"
Height = 255
Left = 5880
TabIndex = 10
Top = 1560
Width = 615
End
Begin VB.Label Label10
Caption = "*(填入的字符数不得超过20个)"
ForeColor = &H000000FF&
Height = 255
Left = 2400
TabIndex = 9
Top = 1560
Width = 2535
End
Begin VB.Label Label5
Caption = "作者:"
Height = 255
Left = 120
TabIndex = 7
Top = 1560
Width = 615
End
Begin VB.Label Label4
Caption = "*(填入的数据大小必须是1-50个字符)"
ForeColor = &H000000FF&
Height = 255
Left = 4080
TabIndex = 6
Top = 960
Width = 3255
End
Begin VB.Label Label3
Caption = "书名:"
Height = 255
Left = 120
TabIndex = 4
Top = 960
Width = 615
End
Begin VB.Label Label2
Caption = "*(填入的数据大小必须是1-16个字符)"
ForeColor = &H000000FF&
Height = 255
Left = 4080
TabIndex = 3
Top = 360
Width = 3255
End
Begin VB.Label Label1
Caption = "ISBN:"
Height = 255
Left = 120
TabIndex = 1
Top = 360
Width = 615
End
End
End
Attribute VB_Name = "Form6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim response
Private Sub Command1_Click()
Dim mycnn As New ADODB.Connection
Dim mycmd As New ADODB.Command
Dim myrs As New ADODB.Recordset
If Len(Trim(Text1.Text)) > 16 Or Trim(Text1.Text) = "" Or Len(Trim(Text2.Text)) > 50 Or _
Trim(Text2.Text) = "" Or Len(Trim(Text3.Text)) > 20 Or Trim(Text3.Text) = "" Or _
Trim(Combo1.Text) = "" Or Len(Trim(Combo1.Text)) > 20 Or Trim(Text4.Text) = "" Or _
Trim(Text5.Text) = "" Then
response = MsgBox("请按照要求输入完整的信息", vbOKOnly + vbExclamation, "注意")
Else
Set mycnn = cnn
Set mycmd.ActiveConnection = mycnn
mycmd.CommandText = "select * from BOOK where ISBN=" & "'" & Trim(Text1.Text) & "'"
Set myrs = mycmd.Execute
If myrs.EOF = True Then
Set cmd.ActiveConnection = cnn
cmd.CommandText = "exec book_insert " & "'" & Trim(Text1.Text) & "'" & "," & "'" & _
Trim(Text2.Text) & "'" & "," & "'" & Trim(Text3.Text) & "'" & "," & "'" & _
Combo1.Text & "'" & "," & Trim(Text4.Text) & "," & _
Trim(Text5.Text) & "," & Trim(Text6.Text)
cmd.Execute
response = MsgBox("添加成功", vbOKOnly + vbExclamation, "恭喜您")
Else
response = MsgBox("添加失败,该ISBN已经存在", vbOKOnly + vbExclamation, "注意")
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Len(Trim(Text1.Text)) > 16 Or Trim(Text1.Text) = "" Or Len(Trim(Text2.Text)) > 50 Or _
Trim(Text2.Text) = "" Or Len(Trim(Text3.Text)) > 20 Or Trim(Text3.Text) = "" Or _
Trim(Combo1.Text) = "" Or Len(Trim(Combo1.Text)) > 20 Or Trim(Text4.Text) = "" Or _
Trim(Text5.Text) = "" Then
response = MsgBox("请按照要求输入完整的信息", vbOKOnly + vbExclamation, "注意")
Else
Set cmd.ActiveConnection = cnn
cmd.CommandText = "select ISBN from BOOK where ISBN=" & "'" & Trim(Text1.Text) & "'"
Set rs = cmd.Execute
If rs.EOF = False Then
cmd.CommandText = "exec book_update " & "'" & Trim(Text1.Text) & "'" & "," & "'" & _
Trim(Text2.Text) & "'" & "," & "'" & Trim(Text3.Text) & "'" & "," & "'" & _
Combo1.Text & "'" & "," & Trim(Text4.Text) & "," & _
Trim(Text5.Text) & "," & Trim(Text6.Text)
cmd.Execute
response = MsgBox("修改成功", vbOKOnly + vbExclamation, "恭喜您")
Else
response = MsgBox("修改失败,ISBN不存在", vbOKOnly + vbExclamation, "注意")
End If
End If
End Sub
Private Sub Form_Load()
Me.Combo1.Text = "电子工业出版社"
With Me.Combo1
.AddItem "电子工业出版社"
.AddItem "清华大学出版社"
.AddItem "机械工业出版社"
.AddItem "人民邮电出版社"
.AddItem "北京大学出版社"
.AddItem "中国水利水电"
.AddItem "人民出版社"
.AddItem "华中科技大学出版社"
.AddItem "武汉大学出版社"
.AddItem "长大出版社"
End With
End Sub
Private Sub Text1_Change()
Set cmd.ActiveConnection = cnn
cmd.CommandText = "select * from BOOK where ISBN=" & "'" & Trim(Text1.Text) & "'"
Set rs = cmd.Execute
If rs.EOF = False Then
Text2.Text = rs.Fields("书名")
Text3.Text = rs.Fields("作者")
Combo1.Text = rs.Fields("出版社")
Text4.Text = rs.Fields("价格")
Text5.Text = rs.Fields("复本量")
Text6.Text = rs.Fields("库存量")
Else
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -