📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form Form3
AutoRedraw = -1 'True
Caption = "读者信息"
ClientHeight = 4635
ClientLeft = 60
ClientTop = 345
ClientWidth = 9705
LinkTopic = "Form3"
MaxButton = 0 'False
ScaleHeight = 4635
ScaleWidth = 9705
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "修改"
Height = 375
Left = 2280
TabIndex = 23
Top = 4080
Width = 975
End
Begin VB.Frame Frame1
Height = 3855
Left = 0
TabIndex = 2
Top = 0
Width = 9615
Begin VB.TextBox Text3
Height = 390
Left = 1080
TabIndex = 11
Text = "0"
Top = 2520
Width = 1095
End
Begin VB.ComboBox Combo4
Height = 300
Left = 3480
TabIndex = 10
Text = "12"
Top = 3360
Width = 735
End
Begin VB.ComboBox Combo3
Height = 300
Left = 2400
TabIndex = 9
Text = "5"
Top = 3360
Width = 735
End
Begin VB.ComboBox Combo2
Height = 300
Left = 1080
TabIndex = 8
Text = "1987"
Top = 3360
Width = 975
End
Begin VB.ComboBox Combo1
Height = 300
Left = 4680
TabIndex = 7
Text = "地理信息系统"
Top = 1680
Width = 2415
End
Begin VB.OptionButton Option2
Caption = "女"
Height = 375
Left = 2160
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.OptionButton Option1
Caption = "男"
Height = 375
Left = 1080
TabIndex = 5
Top = 1680
Width = 615
End
Begin VB.TextBox Text2
Height = 375
Left = 1080
TabIndex = 4
Top = 960
Width = 2535
End
Begin VB.TextBox Text1
Height = 375
Left = 1080
TabIndex = 3
Top = 360
Width = 2535
End
Begin VB.Label Label12
Caption = "*(填入的字符数不得超过20个)"
ForeColor = &H000000FF&
Height = 255
Left = 7080
TabIndex = 24
Top = 1680
Width = 2535
End
Begin VB.Label Label11
Caption = "借书量:"
Height = 255
Left = 120
TabIndex = 22
Top = 2640
Width = 855
End
Begin VB.Label Label10
Caption = "*(填入的字符数不得超过20个)"
ForeColor = &H000000FF&
Height = 255
Left = 3720
TabIndex = 21
Top = 960
Width = 2535
End
Begin VB.Label Label9
Caption = "*(请填入八位数字)"
ForeColor = &H000000FF&
Height = 255
Left = 3720
TabIndex = 20
Top = 360
Width = 1695
End
Begin VB.Label Label8
Caption = "日"
Height = 255
Left = 4320
TabIndex = 19
Top = 3360
Width = 495
End
Begin VB.Label Label7
Caption = "月"
Height = 255
Left = 3240
TabIndex = 18
Top = 3360
Width = 255
End
Begin VB.Label Label6
Caption = "年"
Height = 255
Left = 2160
TabIndex = 17
Top = 3360
Width = 255
End
Begin VB.Label Label5
Caption = "出生时间:"
Height = 255
Left = 120
TabIndex = 16
Top = 3480
Width = 975
End
Begin VB.Label Label4
Caption = "专业名:"
Height = 375
Left = 3720
TabIndex = 15
Top = 1680
Width = 855
End
Begin VB.Label Label3
Caption = "性别:"
Height = 375
Left = 120
TabIndex = 14
Top = 1800
Width = 615
End
Begin VB.Label Label2
Caption = "姓名:"
Height = 255
Left = 120
TabIndex = 13
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "借书证号:"
Height = 255
Left = 120
TabIndex = 12
Top = 480
Width = 975
End
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 8400
TabIndex = 1
Top = 4080
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 360
TabIndex = 0
Top = 4080
Width = 1095
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sex As String
Dim response
Private Sub Command1_Click()
Dim mycnn As New ADODB.Connection
Dim mycmd As New ADODB.Command
Dim myrs As New ADODB.Recordset
If Me.Option1.Value = True Then
sex = "男"
Else
sex = "女"
End If
If Len(Trim(Text1.Text)) <> 8 Or Len(Trim(Text2.Text)) > 20 Or Trim(Text2.Text) = "" Or Trim(Text3.Text) = "" Or _
Len(Trim(Combo2.Text)) <> 4 Or Len(Trim(Combo3.Text)) > 2 Or Len(Trim(Combo4.Text)) > 2 _
Or Trim(Combo3.Text) = "" Or Trim(Combo4.Text) = "" Or Trim(Combo1.Text) = "" Or _
Len(Trim(Combo1.Text)) > 20 Then
response = MsgBox("请按照要求输入完整的信息", vbOKOnly + vbExclamation, "注意")
Else
Set mycnn = cnn
Set mycmd.ActiveConnection = mycnn
mycmd.CommandText = "select * from XS where 借书证号=" & "'" & Trim(Text1.Text) & "'"
Set myrs = mycmd.Execute
If myrs.EOF = True Then
Set cmd.ActiveConnection = cnn
cmd.CommandText = "EXEC xs_insert " & "'" & Trim(Text1.Text) & "'" & "," & "'" & _
Trim(Text2.Text) & "'" & "," & "'" & Combo1.Text & "'" & "," & "'" & sex & "'" & "," & "'" & _
Combo2.Text & "-" & Combo3.Text & "-" & Combo4.Text & "'" & "," & "'" & Trim(Me.Text3.Text) & "'"
cmd.Execute
' Call SaveToDB("d:\1.jpg", Trim(Text1.Text))
response = MsgBox("添加成功", vbOKOnly + vbExclamation, "恭喜您")
Else
response = MsgBox("添加失败,该借书证号已经存在", vbOKOnly + vbExclamation, "注意")
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Me.Option1.Value = True Then
sex = "男"
Else
sex = "女"
End If
If Len(Trim(Text1.Text)) <> 8 Or Len(Trim(Text2.Text)) > 20 Or Trim(Text2.Text) = "" Or Trim(Text3.Text) = "" Or _
Len(Trim(Combo2.Text)) <> 4 Or Len(Trim(Combo3.Text)) > 2 Or Len(Trim(Combo4.Text)) > 2 _
Or Trim(Combo3.Text) = "" Or Trim(Combo4.Text) = "" Then
response = MsgBox("请按照要求输入完整的信息", vbOKOnly + vbExclamation, "注意")
Else
Set cmd.ActiveConnection = cnn
cmd.CommandText = "select 借书证号 from XS where 借书证号=" & "'" & Text1.Text & "'"
Set rs = cmd.Execute
If rs.EOF = False Then
cmd.CommandText = "EXEC xs_update " & "'" & Trim(Text1.Text) & "'" & "," & "'" & _
Trim(Text2.Text) & "'" & "," & "'" & Combo1.Text & "'" & "," & "'" & sex & "'" & "," & "'" & _
Combo2.Text & "-" & Combo3.Text & "-" & Combo4.Text & "'" & "," & "'" & Trim(Me.Text3.Text) & "'"
cmd.Execute
response = MsgBox("修改成功", vbOKOnly + vbExclamation, "恭喜您")
Else
response = MsgBox("修改失败,借书证号不存在", vbOKOnly + vbExclamation, "注意")
End If
End If
End Sub
Private Sub Form_Load()
Dim i
For i = 1920 To 2006
Me.Combo2.AddItem i
Next
For i = 1 To 12
Me.Combo3.AddItem i
Next
For i = 1 To 31
Me.Combo4.AddItem i
Next
With Me.Combo1
.AddItem "地理信息系统"
.AddItem "资源勘察工程"
.AddItem "地质"
.AddItem "计算机"
.AddItem "英语"
.AddItem "数学"
.AddItem "会计"
.AddItem "机械设计"
.AddItem "经济"
.AddItem "生物工程"
.AddItem "石油工程"
.AddItem "车辆工程"
.AddItem "化学工程"
.AddItem "体育"
.AddItem "电子信息工程"
End With
Me.Option1.Value = True
End Sub
Private Sub Text1_Change()
Set cmd.ActiveConnection = cnn
cmd.CommandText = "select * from XS where 借书证号=" & "'" & Trim(Text1.Text) & "'"
Set rs = cmd.Execute
If rs.EOF = False Then
Text2.Text = rs.Fields("姓名")
Text3.Text = rs.Fields("借书量")
Combo1.Text = rs.Fields("专业名")
Combo2.Text = Left(rs.Fields("出生时间"), 4) '将年份输出
i = InStr(rs.Fields("出生时间"), "-")
s = Mid(rs.Fields("出生时间"), i + 1, Len(rs.Fields("出生时间")) - i)
i = InStr(s, "-")
Combo3.Text = Left(s, i - 1) '将月份输出
s = Mid(s, i + 1, Len(s) - i)
Combo4.Text = s '将日子输出
Select Case rs.Fields("性别")
Case "男"
Option1.Value = True
Case "女"
Option2.Value = True
End Select
Else
Text2.Text = ""
Option1.Value = True
Option2.Value = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -