📄 frmseach.frm
字号:
OrigRight = 2865
OrigBottom = 4365
Max = 3000
Min = 1900
SyncBuddy = -1 'True
BuddyProperty = 0
Enabled = -1 'True
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "学生学号"
Height = 180
Index = 8
Left = 1275
TabIndex = 19
Top = 390
Width = 720
End
Begin VB.Label Label4
Caption = "姓名(支持模糊查询):"
Height = 165
Left = 285
TabIndex = 18
Top = 1005
Width = 1800
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "级别:"
Height = 165
Index = 11
Left = 285
TabIndex = 17
Top = 1965
Width = 540
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "班别:"
Height = 165
Index = 12
Left = 255
TabIndex = 16
Top = 2670
Width = 540
End
Begin VB.Label Label5
Caption = "性别:"
Height = 240
Left = 285
TabIndex = 15
Top = 3375
Width = 540
End
Begin VB.Shape Shape2
BackColor = &H00E8F4F8&
FillColor = &H00FFFFFF&
FillStyle = 0 'Solid
Height = 315
Left = 855
Top = 3285
Width = 1815
End
End
Begin MSDataGridLib.DataGrid DGKS
Height = 7275
Left = 90
TabIndex = 1
Top = 270
Width = 7740
_ExtentX = 13653
_ExtentY = 12832
_Version = 393216
AllowUpdate = 0 'False
BackColor = 15267064
HeadLines = 1
RowHeight = 18
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 12
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
MarqueeStyle = 3
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "FrmSeach"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim sql As String
If MsgBox("执行这个动作将会产生很严重的后果!你是否真的执行?", vbYesNo, "警告!") = vbYes Then
If MsgBox("这将会删除你所查询的考生的信息!而已还会删除他们的所有成绩!是否真的执行?", vbYesNo, "警告!") = vbYes Then
Dim adoRs As Recordset
Set adoRs = New Recordset
Dim IdStr As String
adoRs.Open "select score.id from score,kaosheng where kaosheng.id=score.studentid" + GetTJStr(), adoCn, adOpenStatic, adLockOptimistic
Do While Not adoRs.EOF
IdStr = IdStr & adoRs.Fields(0).Value & ","
adoRs.MoveNext
Loop
If IdStr = "" Then IdStr = ","
IdStr = Left(IdStr, Len(IdStr) - 1)
If IdStr <> "" Then
sql = "delete from score where id in(" + IdStr + ")"
adoCn.Execute sql
sql = "delete from scoretk where id in(" + IdStr + ")"
adoCn.Execute sql
sql = "delete from scorewd where id in(" + IdStr + ")"
adoCn.Execute sql
sql = "delete from scorezw where id in(" + IdStr + ")"
adoCn.Execute sql
sql = "delete from scorepd where id in(" + IdStr + ")"
adoCn.Execute sql
End If
sql = "delete from kaosheng" + " where name like '%%'" + GetTJStr()
adoCn.Execute sql
'刷新
Command3_Click
End If
End If
End Sub
Private Sub CmdPrint_Click()
' ' Dim KSStr As String
' '' Dim i As Integer
' ' For i = 0 To DGKS.ApproxCount - 1
' ' DGKS.Row = i
' ' KSStr = KSStr + DGKS.Columns(0).Text + ","
'
' 'Next i
' 'KSStr = Left(KSStr, Len(KSStr) - 1)
' CRp.ReportFileName = App.Path + "\rpt\zkz.rpt"
' CRp.SelectionFormula = "{kaosheng.code}='" + DGKS.Columns(0).Text + "'"
' 'CRp.SelectionFormula = "{kaosheng.code} in (" + KSStr + ")"
' CRp.WindowState = crptMaximized
' CRp.WindowTitle = "准考证打印预览"
' CRp.PrintReport
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
'得到条件字符串
Function GetTJStr() As String
'定义查询条件,保存各个查询条件
Dim SqlXueHao As String
Dim SqlName As String
Dim SqlNianJi As String
Dim SqlClass As String
Dim SqlSex As String
Dim SqlYear As String
Dim TempRs As Recordset
Set TempRs = New Recordset
'设置编号查询条件
If TXTCode.Text <> "" Then
SqlXueHao = " and code" + CmbCZF.Text + "'" + TXTCode.Text + "'"
Else
SqlXueHao = ""
End If
'设置姓名关键字
If TXTName.Text <> "" Then
SqlName = " and name like '%" + TXTName.Text + "%'"
Else
SqlName = ""
End If
'设置姓别
If OptAllMan.Value = True Then
SqlSex = ""
ElseIf OptNan.Value = True Then
SqlSex = " and sex='男'"
Else
SqlSex = " and sex='女'"
End If
'设置年份
If CmbNianJi.ListIndex = 0 Then
SqlNianJi = ""
Else
Dim YearNum As Integer
TempRs.Open "select xuhao from nianji where name='" + CmbNianJi.Text + "'", adoCn, adOpenStatic, adLockOptimistic
YearNum = Num2Year(TempRs.Fields(0).Value)
TempRs.Close
SqlNianJi = " and ryear=" + Int2Str(YearNum)
End If
'设置车间号
SqlClass = " and class=" + Int2Str(CmbClass.ListIndex)
If CmbClass.ListIndex = 0 Then
SqlClass = ""
End If
'设置入学年条件
If CheYear.Value = 1 Then
SqlYear = " and ryear" + CmbCZY.Text + TXTYear.Text
Else
SqlYear = ""
End If
GetTJStr = SqlXueHao + SqlName + SqlSex + SqlNianJi + SqlClass + SqlYear
End Function
Private Sub Command3_Click()
Dim adoRs As Recordset
Dim sql As String
Set adoRs = New Recordset
'==========================================
sql = "select code as 编号,name as 姓名,sex as 性别,ryear as 入职年份,class as 所在部门 from kaosheng"
sql = sql + " where name like '%%'" + GetTJStr()
adoRs.Open sql, adoCn, adOpenStatic, adLockOptimistic
Set DGKS.DataSource = adoRs
End Sub
Private Sub Form_Load()
Dim adoRs As Recordset
Set adoRs = New Recordset
Dim i As Integer
'添加分局到下拉框
adoRs.Open "nianji", adoCn, adOpenStatic, adLockOptimistic
CmbNianJi.Clear
CmbNianJi.AddItem "所有部门"
Do While Not adoRs.EOF
CmbNianJi.AddItem adoRs.Fields("name").Value
adoRs.MoveNext
Loop
adoRs.Close
'添加车间号到下拉框
CmbClass.Clear
CmbClass.AddItem "所有车间"
For i = 1 To 25
CmbClass.AddItem Int2Str(i) + "车间"
Next i
'设置初始值
CmbNianJi.ListIndex = 0
CmbClass.ListIndex = 0
CmbCZF.ListIndex = 0
CmbCZY.ListIndex = 0
'显示所有考生信息
Dim adoKsRS As Recordset
Set adoKsRS = New Recordset
adoKsRS.Open "select code as 考号,name as 姓名,sex as 性别,ryear as 入职年份,class as 所在车间 from kaosheng", adoCn, adOpenStatic, adLockOptimistic
Set DGKS.DataSource = adoKsRS
End Sub
Private Sub TXTCode_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = -24145
End Sub
Private Sub TXTName_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = -24145
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -