AddNewBook.frm
上传用户:zhuahui520
上传日期:2007-05-21
资源大小:347k
文件大小:12k
- VERSION 5.00
- Begin VB.Form AddNewBook
- BorderStyle = 3 'Fixed Dialog
- Caption = "添加新图书"
- ClientHeight = 4905
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6645
- Icon = "AddNewBook.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4905
- ScaleWidth = 6645
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 '屏幕中心
- Begin VB.CommandButton cmdOkCancel
- Cancel = -1 'True
- Caption = "取消(&C)"
- BeginProperty Font
- Name = "楷体_GB2312"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Index = 1
- Left = 3960
- Style = 1 'Graphical
- TabIndex = 14
- ToolTipText = "关闭此对话框"
- Top = 4320
- Width = 1335
- End
- Begin VB.CommandButton cmdOkCancel
- Caption = "添加(&E)"
- Default = -1 'True
- BeginProperty Font
- Name = "楷体_GB2312"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Index = 0
- Left = 1560
- Style = 1 'Graphical
- TabIndex = 13
- ToolTipText = "将图书加入数据库"
- Top = 4320
- Width = 1335
- End
- Begin VB.Frame Frame1
- Caption = "新书基本信息"
- Height = 3975
- Left = 120
- TabIndex = 1
- Top = 120
- Width = 6375
- Begin VB.Frame Frame2
- Height = 855
- Left = 360
- TabIndex = 11
- Top = 3120
- Width = 5775
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "** 请将以上信息填写完整,以便日后查询"
- ForeColor = &H00C000C0&
- Height = 180
- Left = 1080
- TabIndex = 12
- Top = 360
- Width = 3420
- End
- End
- Begin VB.ComboBox Combo1
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 330
- ItemData = "AddNewBook.frx":0442
- Left = 4800
- List = "AddNewBook.frx":0444
- TabIndex = 10
- Text = "Combo1"
- Top = 1320
- Width = 1335
- End
- Begin VB.TextBox txtCost
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 315
- Left = 4800
- TabIndex = 9
- Text = "Text1"
- Top = 2280
- Width = 1335
- End
- Begin VB.TextBox txtBookChu
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 315
- Left = 1200
- TabIndex = 8
- Text = "Text1"
- Top = 2280
- Width = 2535
- End
- Begin VB.TextBox txtBookName
- BeginProperty Font
- Name = "宋体"
- Size = 10.5
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 315
- Left = 1200
- TabIndex = 7
- Text = "Text1"
- Top = 1290
- Width = 2535
- End
- Begin VB.TextBox txtBookNum
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 330
- Left = 1920
- TabIndex = 0
- Top = 600
- Width = 1815
- End
- Begin VB.Image Image1
- Height = 480
- Left = 4800
- Picture = "AddNewBook.frx":0446
- Top = 480
- Width = 480
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "出版社"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 240
- Index = 4
- Left = 360
- TabIndex = 6
- Top = 2280
- Width = 780
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "类 别"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 240
- Index = 3
- Left = 3960
- TabIndex = 5
- Top = 1320
- Width = 795
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "价 格"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 240
- Index = 2
- Left = 3960
- TabIndex = 4
- Top = 2280
- Width = 795
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "书 名"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FF0000&
- Height = 240
- Index = 1
- Left = 360
- TabIndex = 3
- Top = 1320
- Width = 795
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "输入图书编号"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H000000C0&
- Height = 240
- Index = 0
- Left = 360
- TabIndex = 2
- Top = 600
- Width = 1545
- End
- End
- End
- Attribute VB_Name = "AddNewBook"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim db As Database
- Dim rst As Recordset
- Dim db1 As Database
- Dim rst1 As Recordset
- Private Sub cmdOkCancel_Click(Index As Integer)
- Select Case Index
- Case 0
- If txtBookNum = "" Or txtBookName = "" Or Combo1.Text = "" _
- Or txtCost = "" Or txtBookChu = "" Then
- MsgBox "请将所有信息填写完整!", 0 + 48, "提示"
- Exit Sub
- End If
- rst.Seek "=", Trim(txtBookNum.Text)
- If rst.NoMatch = False Then
- MsgBox "此编号已经存在,请填写其它编号!", 0 + 48, "提示"
- 'txtBookNum.SelText = txtBookNum.Text
- txtBookNum.SetFocus
- Exit Sub
- End If
- rst.AddNew
- rst.Fields("图书编号") = Trim(txtBookNum.Text)
- rst.Fields("书名") = txtBookName.Text
- rst.Fields("类别") = Combo1.Text
- rst.Fields("价格") = txtCost.Text
- rst.Fields("出版社") = txtBookChu.Text
- rst.Update
- MsgBox "添加成功!按回车继续", 0 + 48, "成功"
- txtBookNum.Text = ""
- txtBookName = ""
- txtCost = ""
- Combo1.Text = ""
- txtBookChu = ""
- txtBookNum.SetFocus
- Case 1
- Unload Me
- End Select
- End Sub
- Private Sub Form_Load()
- Set db = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
- Set rst = db.OpenRecordset("Book", dbOpenTable)
- rst.Index = "图书编号"
- Set db1 = Workspaces(0).OpenDatabase("DataBaseData.mdb", False)
- Set rst1 = db1.OpenRecordset("Type", dbOpenTable)
- TypeAdd
- txtBookNum.Text = ""
- txtBookName = ""
- txtCost = ""
- Combo1.Text = ""
- txtBookChu = ""
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- rst.Close
- rst1.Close
- db1.Close
- db.Close
- End Sub
- Private Sub TypeAdd()
- rst1.MoveLast
- rst1.MoveFirst
- For i = 1 To rst1.RecordCount
- Combo1.AddItem rst1.Fields("类别")
- rst1.MoveNext
- If rst1.EOF Then Exit Sub
- Next
- End Sub