📄 add_reader_info1.frm
字号:
VERSION 5.00
Begin VB.Form add_reader_info1
Caption = "添加读者信息"
ClientHeight = 6405
ClientLeft = 60
ClientTop = 465
ClientWidth = 9135
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6405
ScaleWidth = 9135
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Height = 855
Left = 2040
TabIndex = 17
Top = 4320
Width = 5175
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 2640
TabIndex = 19
Top = 240
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 960
TabIndex = 18
Top = 240
Width = 1215
End
End
Begin VB.Frame Frame1
Height = 3735
Left = 600
TabIndex = 0
Top = 240
Width = 7575
Begin VB.TextBox Text6
Height = 375
Left = 1560
TabIndex = 16
Top = 2880
Width = 5295
End
Begin VB.TextBox Text5
Height = 375
Left = 1560
TabIndex = 14
Top = 2160
Width = 5295
End
Begin VB.TextBox Text4
Height = 375
Left = 5280
TabIndex = 12
Top = 1560
Width = 1575
End
Begin VB.TextBox Text3
Height = 375
Left = 1560
TabIndex = 10
Top = 1560
Width = 1455
End
Begin VB.ComboBox Combo2
Height = 300
Left = 5280
TabIndex = 8
Top = 960
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
Left = 1560
TabIndex = 6
Top = 840
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 5280
TabIndex = 4
Top = 240
Width = 1575
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1560
TabIndex = 2
Top = 240
Width = 1455
End
Begin VB.Label Label8
Caption = "家庭住址:"
Height = 375
Left = 480
TabIndex = 15
Top = 2880
Width = 1095
End
Begin VB.Label Label7
Caption = "工作单位:"
Height = 375
Left = 480
TabIndex = 13
Top = 2280
Width = 1095
End
Begin VB.Label Label6
Caption = "电话号码:"
Height = 375
Left = 4200
TabIndex = 11
Top = 1560
Width = 1095
End
Begin VB.Label Label5
Caption = "读者编号:"
Height = 375
Left = 480
TabIndex = 9
Top = 1560
Width = 1095
End
Begin VB.Label Label4
Caption = "性别:"
Height = 375
Left = 4560
TabIndex = 7
Top = 960
Width = 735
End
Begin VB.Label Label3
Caption = "读者姓名:"
Height = 375
Left = 480
TabIndex = 5
Top = 960
Width = 975
End
Begin VB.Label Label2
Caption = "登记日期:"
Height = 375
Left = 4320
TabIndex = 3
Top = 360
Width = 1095
End
Begin VB.Label Label1
Caption = "读者类别:"
Height = 255
Left = 600
TabIndex = 1
Top = 360
Width = 975
End
End
End
Attribute VB_Name = "add_reader_info1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs_readerinfo As New ADODB.Recordset
Private Sub Command1_Click()
Dim sql As String
If Trim(Combo1.Text) = "" Then
MsgBox "请选择读者类别", vbOKOnly, ""
Combo1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "读者姓名不能为空", vbOKOnly, ""
Text2.SetFocus
Exit Sub
End If
If Trim(Text3.Text) = "" Then
MsgBox "读者编号不能为空", vbOKOnly, ""
Text3.SetFocus
Exit Sub
End If
sql = "select * from 读者信息 where 读者编号='" & Text3.Text & "'"
rs_readerinfo.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_readerinfo.EOF = True Then
rs_readerinfo.AddNew
rs_readerinfo.Fields(0) = Trim(Text2.Text)
rs_readerinfo.Fields(1) = Trim(Text3.Text)
rs_readerinfo.Fields(2) = Trim(Combo2.Text)
rs_readerinfo.Fields(3) = Trim(Combo1.Text)
rs_readerinfo.Fields(4) = Trim(Text5.Text)
rs_readerinfo.Fields(5) = Trim(Text6.Text)
rs_readerinfo.Fields(6) = Trim(Text4.Text)
rs_readerinfo.Fields(7) = CDate(Text1.Text)
rs_readerinfo.Fields(8) = "0"
rs_readerinfo.Update
MsgBox "读者信息添加成功", vbOKOnly, ""
rs_readerinfo.Close
Unload Me
Else
MsgBox "读者编号已经存在", vbOKOnly, ""
Text3.SetFocus
Text3.Text = ""
Exit Sub
rs_readerinfo.Close
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Combo2.AddItem "男"
Combo2.AddItem "女"
Dim rs_leibie As New ADODB.Recordset
Dim sql As String
sql = "select * from 读者类别"
rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_leibie.MoveFirst
Do While Not rs_leibie.EOF
Combo1.AddItem rs_leibie.Fields(0)
rs_leibie.MoveNext
Loop
rs_leibie.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -