?? 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 = "關(guān)閉"
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 = "學(xué)院:"
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 = "學(xué)號:"
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()
'檢驗數(shù)據(jù)的有效性
If Trim(txtBorrId) = "" Then
MsgBox "請輸入借書卡號"
Exit Sub
End If
If Trim(txtStuNum) = "" Then
MsgBox "請輸入學(xué)號"
Exit Sub
End If
If Trim(txtName) = "" Then
MsgBox "請輸入姓名"
Exit Sub
End If
'獲取年級和學(xué)院的ID
Dim buildCombo As New BuildComboList
Dim grade_sql As String
Dim institute_sql As String
Dim gradeId As String
Dim instituteId As String
'定義查詢年級名稱對應(yīng)Id的語句
grade_sql = "SELECT GradeId FROM Grade WHERE Grade='" + Trim(Combo1.Text) + "'"
'定義查詢學(xué)院名稱對應(yīng)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 "該編號已經(jīng)存在,請重新輸入."
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
'關(guān)閉連接
myDbOper.DB_DisConnect
End Sub
Private Sub Form_Load()
'初始化年級、學(xué)院列表框
Dim buildCombo As New BuildComboList
Dim grade_sql As String
Dim institute_sql As String
'定義查詢年級的SQL語句
grade_sql = "SELECT Grade FROM Grade"
'定義查詢學(xué)院的SQL語句
institute_sql = "SELECT Institute FROM Institute"
Combo1 = buildCombo.getList(grade_sql, Combo1)
Combo2 = buildCombo.getList(institute_sql, Combo2)
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -