教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 实用文档 >

学生信息管理系统VB课程设计(2)

来源:网络收集 时间:2026-08-26
导读: wherestr = wherestr + gender like '% 女 %' End If bwhere = True End If If chkFAcceptanceTime.Value = 1 And txtFYear.Text Then If txtFMon.Text = Then txtFMon.Text = 00 If bwhere Then wherestr = wheres

wherestr = wherestr + " gender like '%" & "女" & "%'" End If

bwhere = True End If

If chkFAcceptanceTime.Value = 1 And txtFYear.Text <> "" Then If txtFMon.Text = "" Then txtFMon.Text = "00" If bwhere Then wherestr = wherestr + " and " If optnFore.Value Then

wherestr = wherestr + " acceptancetime<'" & txtFYear + "-" + txtFMon & "'" Else

wherestr = wherestr + " acceptancetime>'" & txtFYear + "-" + txtFMon & "'" End If

bwhere = True End If

If chkFHometown.Value = 1 And txtFHometown.Text <> "" Then If bwhere Then wherestr = wherestr + " and "

wherestr = wherestr + " hometown like '%" & txtFHometown & "%'" bwhere = True End If

If bwhere Then sqlstr = sqlstr + " where " + wherestr

sqlstr = sqlstr + " order by Studentid asc"

mands("cmdFindStudent").CommandText = sqlstr '刷新Grid,这两句不可省 DataE.conLibrary.Close

DataE.conLibrary.Open DataE.cmdfindstudent dgrdStudent.ClearFields

dgrdStudent.DataMember = mands("cmdFindStudent").Name dgrdStudent.ReBind

If DataE.rscmdFindStudent.RecordCount = 0 Then

MsgBox "在数据库中没找到要查询的对象", vbOKOnly + vbInformation, "查询失败" End If End Sub

4.3 用户查询界面设计

如图4-3。

图4-3 用户查询界面

查询控件编码:

Private Sub cmdSearch_Click() Dim sqlstr As String Dim wherestr As String Dim i As Integer

sqlstr = "select StudentID,StudentName,Class,Gender from StudentTable " wherestr = ""

If cmbItem.ListIndex <> 0 And txtKey.Text <> "" Then Select Case cmbItem.ListIndex

Case 1 '学号

wherestr = wherestr + "StudentID='" & txtKey & "'" Case 2 '姓名

wherestr = wherestr + "StudentName='" & txtKey & "'" Case 3 '班级

wherestr = wherestr + "Class='" & txtKey & "'" Case 4 '备注

wherestr = wherestr + "Gender='" & txtKey & "'" Case 5 '关键字

wherestr = wherestr + "(studentid like '%" & txtKey & "%' or studentname like '%" & txtKey & "%' or class like '%" & txtKey & "%' )" End Select End If

'学号关键字

If frameStudentID.Visible And chkIDKey.Value = 1 And txtIDKey.Text <> "" Then If wherestr <> "" Then

If optnIDand.Value Then

wherestr = wherestr + " and " Else

wherestr = wherestr + " or " End If End If

wherestr = wherestr + "StudentID like '%" & txtIDKey & "%'" End If

'姓名关键字

If frameStudentName.Visible And chkNameKey.Value = 1 And txtNameKey.Text <> "" Then If wherestr <> "" Then

If optnNameand.Value Then

wherestr = wherestr + " and " Else

wherestr = wherestr + " or " End If End If

wherestr = wherestr + "StudentName like '%" & txtNameKey & "%'" End If

'班级关键字

If frameClass.Visible And chkClassKey.Value = 1 And txtClassKey.Text <> "" Then If wherestr <> "" Then

If optnClassand.Value Then

wherestr = wherestr + " and " Else

wherestr = wherestr + " or " End If End If

wherestr = wherestr + "Class like '%" & txtClassKey & "%'" End If

'性别关键字

If frameGender1.Visible And chkGenderKey.Value = 1 Then If wherestr <> "" Then

If optnGenderand.Value Then wherestr = wherestr + " and " Else

wherestr = wherestr + " or " End If End If

If OptnMale.Value Then

wherestr = wherestr + "Gender like '%" & "男" & "%'" ElseIf OptnFemale.Value Then

wherestr = wherestr + "Gender like '%" & "女" & "%'" End If End If '入学时间

If frameTime.Visible And chkTimeKey.Value = 1 Then If optnKeyFore.Value Or optnKeyBack.Value Then

If txtYearKeyFore.Text = "" Or txtMonKeyFore.Text = "" Then

MsgBox "请完整填写查询时间!", vbOKOnly + vbInformation, "查询" Exit Sub End If

If wherestr <> "" Then

If optnTimeand.Value Then

wherestr = wherestr + " and " Else

wherestr = wherestr + " or " End If End If

If optnKeyFore Then

wherestr = wherestr + "publishtime <'" & txtYearKeyFore.Text + "-" + txtMonKeyFore.Text & "'" Else

wherestr = wherestr + "publishtime >'" & txtYearKeyFore.Text + "-" + txtMonKeyFore.Text & "'" End If

ElseIf optnKeyBetween.Value Then

If txtYearKeyFore.Text = "" Or txtMonKeyFore.Text = "" Or txtYearKeyBack.Text = "" Or txtMonKeyBack.Text = "" Then

MsgBox "请完整填写查询时间!", vbOKOnly + vbInformation, "查询" Exit Sub End If

If wherestr < …… 此处隐藏:3187字,全部文档内容请下载后查看。喜欢就下载吧 ……

学生信息管理系统VB课程设计(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/135089.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)