frmchecksinfo.frm
来自「数据库管理系统的实习内容」· FRM 代码 · 共 385 行
FRM
385 行
VERSION 5.00
Begin VB.Form frmChecksinfo
BorderStyle = 1 'Fixed Single
Caption = "一卡通帐户信息查询"
ClientHeight = 3630
ClientLeft = 45
ClientTop = 435
ClientWidth = 4965
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3630
ScaleWidth = 4965
Begin VB.TextBox txtSID
Height = 285
Left = 1440
TabIndex = 23
Top = 1170
Width = 2895
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Left = 120
TabIndex = 21
Top = 1200
Width = 135
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1440
TabIndex = 17
Top = 240
Width = 2895
End
Begin VB.CommandButton cmdExit
Caption = "取消 (&X)"
Height = 375
Left = 3120
TabIndex = 16
Top = 2880
Width = 1215
End
Begin VB.CommandButton cmdOk
Caption = "确定 (&O)"
Default = -1 'True
Height = 375
Left = 480
TabIndex = 15
Top = 2880
Width = 1215
End
Begin VB.CheckBox chkItem
Caption = "Check1"
Height = 180
Index = 0
Left = 120
TabIndex = 14
TabStop = 0 'False
Top = 240
Value = 1 'Checked
Width = 132
End
Begin VB.CheckBox chkItem
Caption = "Check1"
Height = 180
Index = 1
Left = 120
TabIndex = 13
TabStop = 0 'False
Top = 720
Width = 132
End
Begin VB.Frame Frame1
Height = 1095
Left = 1440
TabIndex = 2
Top = 1560
Width = 2895
Begin VB.ComboBox cboYear
Height = 315
Index = 1
Left = 675
Style = 2 'Dropdown List
TabIndex = 6
Top = 690
Width = 765
End
Begin VB.ComboBox cboYear
Height = 315
Index = 0
Left = 675
Style = 2 'Dropdown List
TabIndex = 5
Top = 240
Width = 765
End
Begin VB.ComboBox cboMonth
Height = 315
Index = 1
Left = 1845
Style = 2 'Dropdown List
TabIndex = 4
Top = 690
Width = 645
End
Begin VB.ComboBox cboMonth
Height = 315
Index = 0
Left = 1845
Style = 2 'Dropdown List
TabIndex = 3
Top = 240
Width = 645
End
Begin VB.Label Label1
Caption = "年"
Height = 210
Index = 4
Left = 1560
TabIndex = 12
Top = 720
Width = 225
End
Begin VB.Label Label1
Caption = "到:"
Height = 210
Index = 3
Left = 255
TabIndex = 11
Top = 735
Width = 375
End
Begin VB.Label Label1
Caption = "月"
Height = 210
Index = 2
Left = 2520
TabIndex = 10
Top = 240
Width = 240
End
Begin VB.Label Label1
Caption = "年"
Height = 210
Index = 1
Left = 1515
TabIndex = 9
Top = 240
Width = 240
End
Begin VB.Label Label1
Caption = "从:"
Height = 210
Index = 6
Left = 240
TabIndex = 8
Top = 240
Width = 375
End
Begin VB.Label Label1
Caption = "月"
Height = 210
Index = 7
Left = 2520
TabIndex = 7
Top = 720
Width = 240
End
End
Begin VB.CheckBox chkItem
Caption = "Check1"
Height = 180
Index = 2
Left = 120
TabIndex = 1
TabStop = 0 'False
Top = 1920
Width = 132
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1440
TabIndex = 0
Top = 720
Width = 2895
End
Begin VB.Label Label2
Caption = "学 号:"
Height = 255
Left = 480
TabIndex = 22
Top = 1200
Width = 735
End
Begin VB.Label lblitem
Caption = "姓 名:"
Height = 255
Index = 0
Left = 480
TabIndex = 20
Top = 720
Width = 1095
End
Begin VB.Label lblitem
Caption = "入学时间:"
Height = 375
Index = 1
Left = 480
TabIndex = 19
Top = 1920
Width = 735
End
Begin VB.Label lblitem
Caption = "卡 号:"
Height = 255
Index = 2
Left = 480
TabIndex = 18
Top = 240
Width = 1215
End
End
Attribute VB_Name = "frmChecksinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'用于传递查询块
Public sQSql As String
Private Sub cboMonth_Click(Index As Integer)
If cboMonth(0) <> "" And cboMonth(1) <> "" Then
If CInt(cboYear(0)) = CInt(cboYear(1)) Then
Select Case Index
Case 0
If CInt(cboMonth(Index)) > CInt(cboMonth(1)) Then
cboMonth(Index) = cboMonth(1)
End If
Case 1
If CInt(cboMonth(Index)) < CInt(cboMonth(0)) Then
cboMonth(Index) = cboMonth(0)
End If
End Select
End If
End If
End Sub
Private Sub cboYear_Click(Index As Integer)
If cboYear(0) <> "" And cboYear(1) <> "" Then
Select Case Index
Case 0
If CInt(cboYear(Index)) > CInt(cboYear(1)) Then
cboYear(Index) = cboYear(1)
End If
Case 1
If CInt(cboYear(Index)) < CInt(cboYear(1)) Then
cboYear(Index) = cboYear(0)
End If
End Select
Call cboMonth_Click(Index)
End If
End Sub
Private Sub chkItem_Click(Index As Integer)
If Index = 2 Then
cboYear(0).SetFocus
Else
txtItem(Index).SetFocus
End If
End Sub
Private Sub cmdExit_Click()
Me.Hide
End Sub
Private Sub cmdOK_Click()
Dim dBeginDate As String
Dim dEndDateTemp As Date
Dim dEndDate As String
If Check1.value = vbChecked Then
sQSql = " student_ID= '" & Trim(txtSID & " ") & "'"
End If
If chkItem(0).value = vbChecked Then
If Trim(sQSql & " ") = "" Then
sQSql = " card_ID= '" & Trim(txtItem(0) & " ") & "'"
Else
sQSql = sQSql & " and card_ID= '" & Trim(txtItem(0) & " ") & "'"
End If
End If
If chkItem(1).value = vbChecked Then
If Trim(sQSql & " ") = "" Then
sQSql = "student_Name = '" & Trim(txtItem(1) & " ") & "'"
Else
sQSql = sQSql & " and student_Name= '" & Trim(txtItem(1) & " ") & "'"
End If
End If
If chkItem(2).value = vbChecked Then
dBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-1"), "yyyy-mm-dd")
dEndDateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear(1)), CInt(cboMonth(1)), 1)))
dEndDate = Format(dEndDateTemp, "yyyy-mm-dd")
If Trim(sQSql & " ") = "" Then
sQSql = " ru_Date >= '" & dBeginDate & "' and ru_Date <= '" & dEndDate & "'"
Else
sQSql = sQSql & " and (ru_Date >= '" & dBeginDate & "' and ru_Date <= '" & dEndDate & "')"
End If
End If
If Trim(sQSql) = "" Then
frmModifysinfo.txtSQL = "select * from student_Info"
flagEdit = True
frmModifysinfo.ShowTitle
frmModifysinfo.ShowData
Else
frmModifysinfo.txtSQL = "select * from student_Info where " & sQSql
flagEdit = True
frmModifysinfo.ShowTitle
frmModifysinfo.ShowData
End If
sQSql = ""
Me.Hide
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
txtSQL = "select distinct datepart(yy,ru_Date) from student_Info"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
Do While Not .EOF
If Not IsNull(.Fields(0)) Then
cboYear(0).AddItem .Fields(0)
cboYear(1).AddItem .Fields(0)
End If
.MoveNext
Loop
End With
mrc.Close
For i = 0 To 1
cboYear(i).ListIndex = 0
Next i
For i = 0 To 1
For j = 1 To 12
cboMonth(i).AddItem j
Next j
Next i
For i = 0 To 1
cboMonth(i).Text = Month(Now())
Next i
Else
cmdOk.Enabled = False
End If
End Sub
Private Sub lblitem_Click(Index As Integer)
chkItem(Index).value = vbChecked
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?