📄 frmcinfoman.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmCInfoMan
BorderStyle = 1 'Fixed Single
Caption = "借阅证件信息管理"
ClientHeight = 5205
ClientLeft = 45
ClientTop = 330
ClientWidth = 9270
Icon = "frmCInfoMan.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5205
ScaleWidth = 9270
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cboStatus
Height = 300
ItemData = "frmCInfoMan.frx":044A
Left = 120
List = "frmCInfoMan.frx":045A
Style = 2 'Dropdown List
TabIndex = 7
Top = 600
Width = 2175
End
Begin VB.CommandButton cmdAdd
Caption = "添 加"
Height = 495
Left = 840
TabIndex = 3
Top = 4440
Width = 1215
End
Begin VB.CommandButton cmdModi
Caption = "修 改"
Height = 495
Left = 3000
TabIndex = 2
Top = 4440
Width = 1215
End
Begin VB.CommandButton cmdDel
Caption = "删 除"
Height = 495
Left = 5040
TabIndex = 1
Top = 4440
Width = 1215
End
Begin VB.CommandButton cmdBack
Caption = "返 回"
Height = 495
Left = 7200
TabIndex = 0
Top = 4440
Width = 1215
End
Begin MSAdodcLib.Adodc adoCInfo
Height = 375
Left = 0
Top = 0
Visible = 0 'False
Width = 2535
_ExtentX = 4471
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "连接dtgCInfo"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid dtgCInfo
Bindings = "frmCInfoMan.frx":0476
Height = 3735
Left = 2520
TabIndex = 4
Top = 360
Width = 6495
_ExtentX = 11456
_ExtentY = 6588
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView tvwCType
Height = 2775
Left = 120
TabIndex = 8
Top = 1320
Width = 2175
_ExtentX = 3836
_ExtentY = 4895
_Version = 393217
HideSelection = 0 'False
LabelEdit = 1
LineStyle = 1
Style = 7
FullRowSelect = -1 'True
SingleSel = -1 'True
Appearance = 1
End
Begin VB.Label lblState
AutoSize = -1 'True
Caption = "证件状态"
Height = 180
Left = 120
TabIndex = 6
Top = 360
Width = 720
End
Begin VB.Label lblBType
AutoSize = -1 'True
Caption = "证件类型"
Height = 180
Left = 120
TabIndex = 5
Top = 960
Width = 720
End
End
Attribute VB_Name = "frmCInfoMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义condition变量
Dim conditionTree As String
Dim conditionCombo As String
'网格控件加载函数
Private Sub adoCInfoRefresh()
'设置ADO控件adoCInfoRefresh的连接字符串
adoCInfo.ConnectionString = CONSTR
'设置数据源
Dim tmpRecordSource As String
tmpRecordSource = "SELECT i.CardNo AS 借阅证号, i.Reader AS 读者姓名, i.WorkPlace AS 工作单位," _
+ " i.IDCard AS 身份证号, i.CTypeID AS 借阅证类型, t.TypeName AS 类型名称," _
+ " t.MaxCount AS 借书数目, t.MaxDays AS 借书时间, t.RenewDays AS 续借时间," _
+ " i.CreateDate AS 办证时间 FROM CardInfo i, CardType t" _
+ " WHERE i.CTypeID = t.CTypeID" _
+ conditionTree + conditionCombo + " ORDER BY i.CardNo"
adoCInfo.RecordSource = tmpRecordSource
adoCInfo.Refresh
'设置列宽
With dtgCInfo
.Columns(0).Width = 1000
.Columns(1).Width = 1200
.Columns(2).Width = 1800
.Columns(3).Width = 1000
.Columns(4).Width = 800
.Columns(5).Width = 1200
.Columns(6).Width = 1000
.Columns(7).Width = 1000
.Columns(8).Width = 1000
.Columns(9).Width = 1500
End With
End Sub
'窗体装载事件
Private Sub Form_Load()
'设置证件状态
cboStatus.ListIndex = 0
'为TreeView控件tvwCType对象装载图书分类名称
tvwCType.Nodes.Clear
Set tvwNode = tvwCType.Nodes.Add(, , "tvwAll", "所有证件类型")
Call Add_CTypeToTree(tvwCType, "tvwAll")
'给objCardType初始化
objCardType.Init
'给两个condition初始化
conditionTree = ""
conditionCombo = ""
'调用adoCInfoRefresh过程
Call adoCInfoRefresh
End Sub
'单击cboStatus
Private Sub cboStatus_Click()
If cboStatus.ListIndex = 0 Then
'如果选择全部
conditionCombo = ""
Else
'如果选择其他
conditionCombo = " AND i.CardState = " + Trim(Str(cboStatus.ListIndex - 1))
End If
'调用adoCInfoRefresh过程
Call adoCInfoRefresh
End Sub
'单击tvwCType结点
Private Sub tvwCType_NodeClick(ByVal Node As MSComctlLib.Node)
'如果是根结点
If Node.Text = Node.Root.Text Then
objCardType.Init
conditionTree = ""
Else
'得到借阅证分类信息
objCardType.GetInfo Trim(Node.Text)
conditionTree = " AND t.CTypeID = '" + Trim(objCardType.CTypeID) + "'"
End If
'调用adoCInfoRefresh过程
Call adoCInfoRefresh
End Sub
'插入按钮
Private Sub cmdAdd_Click()
'给借阅证件信息编辑窗口赋值
frmCInfoEdit.txtCNo = ""
frmCInfoEdit.txtCNo.Locked = False
frmCInfoEdit.txtReader = ""
frmCInfoEdit.txtWorkPlace = ""
frmCInfoEdit.txtIDCard = ""
frmCInfoEdit.dtpCreateDate = Now
frmCInfoEdit.txtState = "有效"
IsAdd = True
'启动编辑窗体
frmCInfoEdit.Show 1
'刷新adoCInfo控件
adoCInfo.Refresh
End Sub
'修改按钮
Private Sub cmdModi_Click()
'如果没记录的话,不能进行修改
If adoCInfo.Recordset.BOF Or adoCInfo.Recordset.EOF Then
MsgBox "请选择一条记录", vbInformation, "信息提示"
Exit Sub
End If
'给借阅证件信息编辑窗口赋值
frmCInfoEdit.txtCNo = Trim(adoCInfo.Recordset.Fields(0))
frmCInfoEdit.txtCNo.Locked = True
frmCInfoEdit.txtReader = Trim(adoCInfo.Recordset.Fields(1))
frmCInfoEdit.txtWorkPlace = Trim(adoCInfo.Recordset.Fields(2))
frmCInfoEdit.txtIDCard = Trim(adoCInfo.Recordset.Fields(3))
frmCInfoEdit.dtpCreateDate = adoCInfo.Recordset.Fields(9)
'根据办证时间判断此证件是否过期
If Now - adoCInfo.Recordset.Fields(9) > 365 Then
objCardInfo.UpdateState Trim(adoCInfo.Recordset.Fields(0)), 1
MsgBox "此证件已过期", vbInformation, "信息提示"
End If
objCardInfo.GetInfo Trim(adoCInfo.Recordset.Fields(0))
Dim CardStateName As String
Select Case objCardInfo.CardState
Case 0
CardStateName = "有效"
Case 1
CardStateName = "过期"
Case 2
CardStateName = "挂失"
frmCInfoEdit.cmdLoss.Caption = "取消挂失"
End Select
frmCInfoEdit.txtState = CardStateName
IsAdd = False
'启动编辑窗体
frmCInfoEdit.Show 1
'刷新adoCInfo控件
adoCInfo.Refresh
End Sub
'删除按钮
Private Sub cmdDel_Click()
Dim isDel As Integer
If adoCInfo.Recordset.BOF Or adoCInfo.Recordset.EOF Then
MsgBox "请选择一条记录", vbInformation, "信息提示"
Else
isDel = MsgBox("是否删除所选择的记录", vbYesNo + vbQuestion + vbDefaultButton2, "是否删除")
If isDel = vbYes Then
objCardInfo.Delete dtgCInfo.Columns(0)
MsgBox "删除成功!", vbInformation, "信息提示"
End If
End If
'刷新
adoCInfo.Refresh
End Sub
'返回按钮
Private Sub cmdBack_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -