📄 frmaddtitle.frm
字号:
VERSION 5.00
Begin VB.Form FrmAddTitle
Caption = "增加新书种界面"
ClientHeight = 2175
ClientLeft = 60
ClientTop = 450
ClientWidth = 9900
LinkTopic = "Form1"
ScaleHeight = 2175
ScaleWidth = 9900
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdExit
Caption = "返回"
Height = 375
Left = 8640
TabIndex = 16
Top = 1200
Width = 975
End
Begin VB.CommandButton cmdSubmit
Caption = "提交"
Height = 375
Left = 8640
TabIndex = 15
Top = 480
Width = 975
End
Begin VB.Frame Frame1
Caption = "书种信息"
ForeColor = &H000000FF&
Height = 1695
Left = 360
TabIndex = 0
Top = 120
Width = 8055
Begin VB.ComboBox Combo1
Height = 315
Left = 4920
TabIndex = 17
Top = 960
Width = 1435
End
Begin VB.TextBox txtNum
Height = 315
Left = 6480
TabIndex = 14
Top = 960
Width = 1435
End
Begin VB.TextBox txtIsbsn
Height = 315
Left = 3360
TabIndex = 13
Top = 960
Width = 1435
End
Begin VB.TextBox txtAuthor
Height = 315
Left = 1800
TabIndex = 12
Top = 960
Width = 1435
End
Begin VB.TextBox txtName
Height = 315
Left = 240
TabIndex = 11
Top = 960
Width = 1435
End
Begin VB.Frame Frame6
Height = 375
Left = 6480
TabIndex = 9
Top = 360
Width = 1455
Begin VB.Label Label5
Caption = "数量"
Height = 200
Left = 120
TabIndex = 10
Top = 120
Width = 975
End
End
Begin VB.Frame Frame5
Height = 375
Left = 4920
TabIndex = 7
Top = 360
Width = 1455
Begin VB.Label Label4
Caption = "种类"
Height = 200
Left = 120
TabIndex = 8
Top = 120
Width = 975
End
End
Begin VB.Frame Frame4
Height = 375
Left = 3360
TabIndex = 5
Top = 360
Width = 1455
Begin VB.Label Label3
Caption = "ISBSN"
Height = 200
Left = 120
TabIndex = 6
Top = 120
Width = 975
End
End
Begin VB.Frame Frame3
Height = 375
Left = 1800
TabIndex = 3
Top = 360
Width = 1455
Begin VB.Label Label2
Caption = "作者"
Height = 200
Left = 120
TabIndex = 4
Top = 120
Width = 975
End
End
Begin VB.Frame Frame2
Height = 375
Left = 240
TabIndex = 1
Top = 360
Width = 1455
Begin VB.Label Label1
Caption = "书名"
Height = 200
Left = 120
TabIndex = 2
Top = 120
Width = 975
End
End
End
End
Attribute VB_Name = "FrmAddTitle"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdExit_Click()
Me.Hide
End Sub
Private Sub cmdSubmit_Click()
'检验数据的有效性
If Trim(txtName) = "" Then
MsgBox "请输入书名"
Exit Sub
End If
If Trim(txtAuthor) = "" Then
MsgBox "请输入作者"
Exit Sub
End If
If Trim(txtIsbsn) = "" Then
MsgBox "请输入ISBSN"
Exit Sub
End If
If Trim(txtNum) = "" Then
MsgBox "请输入数量"
Exit Sub
End If
If CDec(txtNum) <= 0 Then
MsgBox "数量必须为正值"
Exit Sub
End If
Dim myDbOper As New DbOperation
Dim rst As ADODB.Recordset
Dim sql As String
'建立连接
myDbOper.DB_Connect
'定义查询语句
sql = "SELECT * FROM Title WHERE Name='" + Trim(txtName) + "'"
Set rst = myDbOper.querySQL(sql)
If rst.EOF = True Then
'向Title添加新记录
With rst
.AddNew
!Name = Me.txtName
!author = Me.txtAuthor
!isbsn = Me.txtIsbsn
!Type = Me.Combo1.Text
!Num = Me.txtNum
.Update
End With
'向Book表中添加新记录
Dim insert_sql As String
insert_sql = "INSERT INTO Book(name,loan,borrowerId,BorrowDate) VALUES('" _
+ Trim(txtName) + "','在库',Null,Null)"
For I = 1 To CDec(txtNum)
myDbOper.executeSQL (insert_sql)
Next
MsgBox "信息添加成功."
Else
MsgBox "该书名已经存在,请重新输入."
End If
rst.Close
'关闭连接
myDbOper.DB_DisConnect
End Sub
Private Sub Form_Load()
'初始化类型列表框
Dim buildCombo As New BuildComboList
Dim type_sql As String
'定义查询书种的SQL语句
type_sql = "SELECT DISTINCT type FROM Title"
Combo1 = buildCombo.getList(type_sql, Combo1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -