📄 frmcinfoedit.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmCInfoEdit
BackColor = &H00FFC0C0&
Caption = "借阅证件信息编辑"
ClientHeight = 6960
ClientLeft = 5025
ClientTop = 3015
ClientWidth = 8190
LinkTopic = "Form1"
ScaleHeight = 6960
ScaleWidth = 8190
Begin MSComCtl2.DTPicker dtpCreateDate
Height = 495
Left = 1680
TabIndex = 17
Top = 3360
Width = 3015
_ExtentX = 5318
_ExtentY = 873
_Version = 393216
Format = 25493505
CurrentDate = 39592
End
Begin VB.CommandButton cmdCancel
Caption = "取消(&C)"
Height = 615
Left = 5640
TabIndex = 16
Top = 5520
Width = 1335
End
Begin VB.CommandButton cmdDate
Caption = "取消过期(&V)"
Height = 615
Left = 3960
TabIndex = 15
Top = 5520
Width = 1215
End
Begin VB.CommandButton cmdLoss
Caption = "挂失(&L)"
Height = 615
Left = 2280
TabIndex = 14
Top = 5520
Width = 1215
End
Begin VB.CommandButton cmdOk
Caption = "确定(&O)"
Height = 615
Left = 600
TabIndex = 13
Top = 5520
Width = 1215
End
Begin VB.ComboBox cboState
Height = 300
ItemData = "frmCInfoEdit.frx":0000
Left = 1680
List = "frmCInfoEdit.frx":000D
TabIndex = 12
Top = 4200
Width = 3015
End
Begin VB.ComboBox cboCType
Height = 300
ItemData = "frmCInfoEdit.frx":0023
Left = 5520
List = "frmCInfoEdit.frx":0025
TabIndex = 11
Top = 240
Width = 1935
End
Begin VB.TextBox txtIDCard
Height = 495
Left = 1680
TabIndex = 10
Top = 2400
Width = 2775
End
Begin VB.TextBox txtWorkPlace
Height = 495
Left = 1680
TabIndex = 9
Top = 1680
Width = 3615
End
Begin VB.TextBox txtReader
Height = 495
Left = 1680
TabIndex = 8
Top = 960
Width = 2415
End
Begin VB.TextBox txtCNo
Height = 495
Left = 1680
TabIndex = 7
Top = 240
Width = 1695
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "状态"
Height = 495
Left = 360
TabIndex = 6
Top = 4200
Width = 1095
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "发证日期"
Height = 615
Left = 240
TabIndex = 5
Top = 3360
Width = 1095
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "身份证号码"
Height = 615
Left = 240
TabIndex = 4
Top = 2520
Width = 1215
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "工作单位"
Height = 495
Left = 240
TabIndex = 3
Top = 1800
Width = 1215
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "读者姓名"
Height = 495
Left = 240
TabIndex = 2
Top = 1080
Width = 1215
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "借阅证件类型"
Height = 495
Left = 4080
TabIndex = 1
Top = 240
Width = 1215
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "借阅证编号"
Height = 495
Left = 240
TabIndex = 0
Top = 360
Width = 1095
End
End
Attribute VB_Name = "frmCInfoEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim SQLStr As String
Dim oldCTypeName As String
Dim vCTypeID As String
Dim vCardNo As String
'单击证件类型控件cboCType, 获取该类型名称所对应的类型编号
Private Sub cboCType_Click()
SQLStr = "select * from CardType where TypeName='" + Trim(cboCType.Text) + "'"
Set rs = SQLQuery(SQLStr)
vCTypeID = rs.Fields(0)
End Sub
'单击"取消"按钮
Private Sub cmdCancel_Click()
Unload Me
End Sub
'单击"取消过期"按钮
Private Sub cmdDate_Click()
'不是过期状态的借阅证件不能"取消过期"
If Trim(cboState.Text) <> "过期" Then
Exit Sub
End If
'定义是否取消过期变量
Dim IsCancelOverdue As Integer
IsCancelOverdue = MsgBox("此证件是否取消过期?", vbYesNo + vbQuestion + vbDefaultButton1, "询问")
If IsCancelOverdue = vbYes Then
SQLStr = "select * from CardInfo where CardNo='" + Trim(txtCNo) + "'"
Set rs = SQLQuery(SQLStr)
rs.Fields(5) = Format(Now, "yyyy-mm-dd") '设为当前日期
rs.Fields(6) = 0 '取消过期状态
rs.Update
MsgBox "借阅证号为" + Trim(txtCNo) + "的证件已经可以使用", vbInformation, "取消过期成功"
End If
Unload Me '关闭窗口
End Sub
'单击"挂失"按钮,设置已存在的证件状态为挂失
Private Sub cmdLoss_Click()
If IsAdd Then '如果为添加状态不能使用挂失按钮
Exit Sub
End If
'定义是否挂失(或取消挂失)变量
Dim lsLoss As Integer
If Left(cmdLoss.Caption, 2) = "挂失" Then
IsLoss = MsgBox("是否将此证件挂失" + vbCrLf + "如果挂失,此证将不能正常借书", vbYesNo + vbQuestion + vbDefaultButton2, "询问")
If IsLoss = vbYes Then
SQLStr = "update CardInfo set CardState=2" + "where CardNo='" + Trim(txtCNo) + "'"
SQLExt SQLStr
MsgBox "借阅证号为" + Trim(txtCNo) + "的证件挂失成功", vbInformation, "信息提示"
End If
Else
IsLoss = MsgBox("是否取消挂失此证件?", vbYesNo + vbQuestion + vbDefaultButton1, "询问")
If IsLoss = vbYes Then
SQLStr = "update CardInfo set CardState=0" + "where CardNo='" + Trim(txtCNo) + "'"
SQLExt SQLStr
MsgBox "借阅证号为" + Trim(txtCNo) + "的证件已经可以使用", vbInformation, "取消挂失成功"
End If
End If
Unload Me '关闭窗口
End Sub
'单击"确定"按钮,将窗体输入的证件信息插入或更新到表CardInfo中
Private Sub cmdOk_Click()
'是否选择借阅证类型
If Trim(cboCType.Text) = "" Then
MsgBox "请选择借阅证件类型", vbInformation, "添加信息"
cboCType.SetFocus
Exit Sub
End If
'是否输入读者姓名
If Trim(txtReader.Text) = "" Then
MsgBox "请输入读者姓名", vbInformation, "添加信息"
txtReader.SetFocus
Exit Sub
End If
'是否输入出版社
If Trim(txtWorkPlace.Text) = "" Then
MsgBox "请输入工作单位", vbInformation, "添加信息"
txtWorkPlace.SetFocus
Exit Sub
End If
'是否输入身份证号码
If Trim(txtIDCard.Text) = "" Then
MsgBox "请输入身份证号码", vbInformation, "添加信息"
txtIDCard.SetFocus
Exit Sub
End If
'输入身份证号码是否合法
If Not IsNumeric(txtIDCard.Text) Then
MsgBox "身份证号码为数字" + vbCrLf + "请输入正确的身份证号码", vbInformation, "添加信息"
txtIDCard.SetFocus
txtIDCard.SelStart = 0
txtIDCard.SelLength = Len(txtIDCard.Text)
Exit Sub
End If
If IsAdd Then '如果是单击frmCInfoM窗体的"添加"按钮
'是否输入借阅证编号
If Trim(txtCNo.Text) = "" Then
MsgBox "请输入借阅证编号", vbInformation, "添加信息"
Exit Sub
End If
'判断是否存在此借阅证编号
SQLStr = "select * from CardInfo where CardNo='" + Trim(txtCNo) + "'"
Set rs = SQLQuery(SQLStr)
If Not rs.EOF Then
MsgBox "此借阅证编号已存在" + vbCrLf + "请输入其他借阅证编号", vbInformation, "添加信息"
Exit Sub
End If
End If
If IsAdd Then
'cboState 的属性值为0,1,2,对应表CardInfo的CardState字段的值
'分别为胡效,过期,挂失
'设置insert语句
SQLStr = "insert into CardInfo values('" + Trim(txtCNo) + "','" + Trim(txtReader) + "','" + Trim(txtWorkPlace) + "','" + Trim(txtIDCard) + "','" + Trim(vCTypeID) + "'," + Format(dtpCreateDate.Value, "yyyy-mm-dd") + "," + Str(cboState.ListIndex) + ")"
SQLExt SQLStr '执行insert语句
MsgBox "插入成功!", vbInformation, "添加信息"
Else
SQLStr = "update CardInfo set Reader='" + Trim(txtReader) + "',WorkPlace='" + Trim(txtWorkPlace) + "',IDCard='" + Trim(txtIDCard) + "',CTypeID='" + Trim(vCTypeID) + "',CreateDate='" + Format(dtpCreateDate.Value, "yyyy-mm-dd") + "',CardState=" + Str(cboState.ListIndex) + "where CardNo='" + Trim(txtCNo) + "'"
SQLExt SQLStr '执行update语句
MsgBox "修改成功", vbInformation, "修改信息"
End If
Unload Me '关闭窗口
End Sub
'窗体frmCInfoEdit激活事件
Private Sub Form_Activate()
If Not IsAdd Then '如果是修改 frmCInfoM窗体的证件信息
cboCType.Text = frmCInfoM.adoCInfo.Recordset.Fields(5).Value
SQLStr = "select * from CardType where TypeName='" + Trim(cboCType.Text) + "'"
Set rs = SQLQuery(SQLStr)
vCTypeID = rs.Fields(0)
End If
End Sub
'窗体frmCInfoEdit 加载事件
Private Sub Form_Load()
SQLStr = "select * from CardType" '获取CardType表中的证件类型名称
Addcbo cboCType, SQLStr, 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -