📄 frmoperborrower.frm
字号:
VERSION 5.00
Begin VB.Form FrmOperBorrower
BorderStyle = 1 'Fixed Single
Caption = "增加借阅者界面"
ClientHeight = 5400
ClientLeft = 45
ClientTop = 435
ClientWidth = 5985
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5400
ScaleWidth = 5985
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdExit
Caption = "关闭"
Height = 375
Left = 3240
TabIndex = 12
Top = 4680
Width = 975
End
Begin VB.CommandButton cmdSubmit
Caption = "提交"
Height = 375
Left = 1440
TabIndex = 11
Top = 4680
Width = 975
End
Begin VB.Frame Frame1
Caption = "借阅卡信息"
Height = 4215
Left = 240
TabIndex = 0
Top = 240
Width = 5535
Begin VB.ComboBox Combo2
Height = 315
Left = 2040
TabIndex = 14
Top = 2280
Width = 2415
End
Begin VB.ComboBox Combo1
Height = 315
Left = 2040
TabIndex = 13
Top = 1680
Width = 2415
End
Begin VB.TextBox txtPhone
Height = 375
Left = 2040
TabIndex = 8
Top = 3480
Width = 2415
End
Begin VB.TextBox txtName
Height = 375
Left = 2040
TabIndex = 6
Top = 2880
Width = 2415
End
Begin VB.TextBox txtStuNum
Height = 375
Left = 2040
TabIndex = 4
Top = 1080
Width = 2415
End
Begin VB.TextBox txtBorrId
Height = 375
Left = 2040
TabIndex = 2
Top = 480
Width = 2415
End
Begin VB.Label Label6
Caption = "电话号码:"
Height = 375
Left = 720
TabIndex = 10
Top = 3480
Width = 1335
End
Begin VB.Label Label5
Caption = "姓名:"
Height = 375
Left = 720
TabIndex = 9
Top = 2880
Width = 1335
End
Begin VB.Label Label4
Caption = "学院:"
Height = 375
Left = 720
TabIndex = 7
Top = 2280
Width = 1335
End
Begin VB.Label Label3
Caption = "年级:"
Height = 375
Left = 720
TabIndex = 5
Top = 1680
Width = 1335
End
Begin VB.Label Label2
Caption = "学号:"
Height = 375
Left = 720
TabIndex = 3
Top = 1080
Width = 1335
End
Begin VB.Label Label1
Caption = "借书卡号:"
Height = 375
Left = 720
TabIndex = 1
Top = 480
Width = 1335
End
End
End
Attribute VB_Name = "FrmOperBorrower"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'标识界面的操作类型(添加或修改)
Public IsModify As Boolean
Private Sub cmdExit_Click()
Me.Hide
End Sub
Private Sub cmdSubmit_Click()
'检验数据的有效性
If Trim(txtBorrId) = "" Then
MsgBox "请输入借书卡号"
Exit Sub
End If
If Trim(txtStuNum) = "" Then
MsgBox "请输入学号"
Exit Sub
End If
If Trim(txtName) = "" Then
MsgBox "请输入姓名"
Exit Sub
End If
'获取年级和学院的ID
Dim buildCombo As New BuildComboList
Dim grade_sql As String
Dim institute_sql As String
Dim gradeId As String
Dim instituteId As String
'定义查询年级名称对应Id的语句
grade_sql = "SELECT GradeId FROM Grade WHERE Grade='" + Trim(Combo1.Text) + "'"
'定义查询学院名称对应Id的语句
institute_sql = "SELECT InstituteId FROM Institute WHERE Institute='" + Trim(Combo2.Text) + "'"
'获取Id
gradeId = buildCombo.getIdByName(grade_sql)
instituteId = buildCombo.getIdByName(institute_sql)
Dim myDbOper As New DbOperation
Dim rst As ADODB.Recordset
Dim sql As String
'建立连接
myDbOper.DB_Connect
'定义查询语句
sql = "SELECT * FROM Borrower WHERE BorrowerId='" + Trim(txtBorrId) + "'"
Set rst = myDbOper.querySQL(sql)
If rst.EOF = True Then
'插入新记录
With rst
.AddNew
!BorrowerID = Me.txtBorrId
!instituteId = instituteId
!gradeId = gradeId
!Name = Me.txtName
!StudentNum = Me.txtStuNum
!teleNumber = Me.txtPhone
!borrowBookNum = "0"
.Update
End With
MsgBox "信息添加成功."
Else
If IsModify = False Then
MsgBox "该编号已经存在,请重新输入."
Else
With rst
!instituteId = instituteId
!gradeId = gradeId
!Name = Me.txtName
!StudentNum = Me.txtStuNum
!teleNumber = Me.txtPhone
.Update
End With
MsgBox "信息修改成功."
End If
End If
rst.Close
'关闭连接
myDbOper.DB_DisConnect
End Sub
Private Sub Form_Load()
'初始化年级、学院列表框
Dim buildCombo As New BuildComboList
Dim grade_sql As String
Dim institute_sql As String
'定义查询年级的SQL语句
grade_sql = "SELECT Grade FROM Grade"
'定义查询学院的SQL语句
institute_sql = "SELECT Institute FROM Institute"
Combo1 = buildCombo.getList(grade_sql, Combo1)
Combo2 = buildCombo.getList(institute_sql, Combo2)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -