📄 购书.frm
字号:
VERSION 5.00
Begin VB.Form Form2
Caption = "购书"
ClientHeight = 5805
ClientLeft = 60
ClientTop = 390
ClientWidth = 5070
LinkTopic = "Form2"
ScaleHeight = 5805
ScaleWidth = 5070
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 375
Left = 3120
TabIndex = 15
Top = 1560
Width = 975
End
Begin VB.Timer Timer1
Interval = 1000
Left = 3840
Top = 3120
End
Begin VB.ComboBox Combo2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1080
TabIndex = 12
Top = 240
Width = 1815
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1080
TabIndex = 11
Top = 840
Width = 1815
End
Begin VB.TextBox Text5
Height = 495
Left = 1080
TabIndex = 9
Top = 2640
Width = 1815
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 3720
TabIndex = 7
Top = 4320
Width = 855
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 2640
TabIndex = 6
Top = 4320
Width = 855
End
Begin VB.TextBox Text4
Height = 495
Left = 1080
TabIndex = 5
Top = 2040
Width = 1815
End
Begin VB.TextBox Text3
Height = 495
Left = 1080
TabIndex = 2
Top = 1440
Width = 1815
End
Begin VB.Label Label9
Caption = "本"
Height = 375
Left = 4320
TabIndex = 16
Top = 1560
Width = 615
End
Begin VB.Label Label8
Caption = "此书还剩"
Height = 375
Left = 3240
TabIndex = 14
Top = 1080
Width = 855
End
Begin VB.Label Label7
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 13
Top = 3240
Width = 1935
End
Begin VB.Label Label6
Caption = "日期"
Height = 495
Left = 240
TabIndex = 10
Top = 3240
Width = 975
End
Begin VB.Label Label5
Caption = "总额"
Height = 495
Left = 240
TabIndex = 8
Top = 2640
Width = 975
End
Begin VB.Label Label4
Caption = "数量"
Height = 615
Left = 240
TabIndex = 4
Top = 2040
Width = 975
End
Begin VB.Label Label3
Caption = "定价"
Height = 495
Left = 240
TabIndex = 3
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "书号"
Height = 495
Left = 360
TabIndex = 1
Top = 840
Width = 975
End
Begin VB.Label Label1
Caption = "会员号"
Height = 495
Left = 240
TabIndex = 0
Top = 360
Width = 975
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim note As New ADODB.Recordset
Private Sub Combo1_Click()
Dim sql As String
sql = "select * from 书库表 where 书号='" & Trim(Combo1.Text) & "'"
note.Open sql, cnn, 3, 2
Text3.Text = note.Fields("定价").Value '自动显示定价和剩余的数量
Text1.Text = note.Fields("数量").Value
note.Close
End Sub
Private Sub Command1_Click()
Dim sql As String
Dim sql2 As String
sql = "select * from 书库表 where 书号='" & Trim(Combo1.Text) & "'"
note.Open sql, cnn, 3, 2
If note.Fields("数量").Value = 0 Then
note.Delete
note.Update
note.Close '数量为0的时候,警告无此书了
Exit Sub
MsgBox "此类书籍已经没有了!"
ElseIf note.Fields("数量").Value >= Val(Text4.Text) Then
note.Fields("数量").Value = note.Fields("数量").Value - Val(Text4.Text)
note.Update
note.Close
sql2 = "select * from 购书表" '更新购书表
note.Open sql2, cnn, 3, 2
note.AddNew
note.Fields("会员号").Value = Combo2.Text
note.Fields("书号").Value = Combo1.Text
note.Fields("定价").Value = Text3.Text
note.Fields("数量").Value = Text4.Text
note.Fields("总额").Value = Text5.Text
note.Fields("日期").Value = Label7.Caption
note.Update
MsgBox "提交成功!"
Text1.Text = ""
Combo2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
note.Close
Else
MsgBox "数量不足,请重新输入数量!"
note.Close
Text4.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
Dim sql2 As String
sql = "select * from 书库表" '书号和会员分别从书库表和会员表提取
note.Open sql, cnn, 3, 2
Combo1.Clear
note.MoveFirst
Do While Not note.EOF
Combo1.AddItem note.Fields("书号").Value
note.MoveNext
Loop
note.Close
sql2 = "select * from 会员表"
note.Open sql2, cnn, 3, 2
Combo2.Clear
note.MoveFirst
Do While Not note.EOF
Combo2.AddItem note.Fields("会员号").Value
note.MoveNext
Loop
note.Close
End Sub
Private Sub Text4_Change()
Text5.Text = Val(Text3.Text) * Val(Text4.Text) '总额=定价*数量
End Sub
Private Sub Timer1_Timer()
Label7.Caption = Date '当前的日期
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -