?? 購書.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 = "數(shù)量"
Height = 615
Left = 240
TabIndex = 4
Top = 2040
Width = 975
End
Begin VB.Label Label3
Caption = "定價(jià)"
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("定價(jià)").Value '自動(dòng)顯示定價(jià)和剩余的數(shù)量
Text1.Text = note.Fields("數(shù)量").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("數(shù)量").Value = 0 Then
note.Delete
note.Update
note.Close '數(shù)量為0的時(shí)候,警告無此書了
Exit Sub
MsgBox "此類書籍已經(jīng)沒有了!"
ElseIf note.Fields("數(shù)量").Value >= Val(Text4.Text) Then
note.Fields("數(shù)量").Value = note.Fields("數(shù)量").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("定價(jià)").Value = Text3.Text
note.Fields("數(shù)量").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 "數(shù)量不足,請重新輸入數(shù)量!"
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) '總額=定價(jià)*數(shù)量
End Sub
Private Sub Timer1_Timer()
Label7.Caption = Date '當(dāng)前的日期
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -