学生学籍管理信息系统的设计与实现分析 下载本文

登录窗体

代码实现:

Private Sub Command1_Click() Dim mrc As ADODB.Recordset

txtsql = \用户名,标识 from 用户 where 用户名='\& Trim(Text1.Text) & \ Set mrc = ExecuteSQL(txtsql) If mrc.EOF = True Then

MsgBox \用户名错误!\警告\ Text1.SetFocus 'Text1.SelStart = 0

'Text1.SelLength = Len(Text1.Text) Exit Sub End If

username = mrc.Fields(0) qxstra = mrc.Fields(1) mrc.Close

txtsql = \密码 from 用户 where 密码='\ Set mrc = ExecuteSQL(txtsql) If mrc.EOF = True Then

MsgBox \密码错误!\ Text2.SetFocus 'Text2.SelStart = 0

'Text2.SelLength = Len(Text2.Text) Exit Sub End If 主窗体.Show Unload Me End Sub

26

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Text1.Text = \Text2.Text = \End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single) End Sub

Private Sub Label3_Click() End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Text2.SetFocus End If End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Command1.SetFocus End If End Sub

27

代码实现:

Dim mrc As ADODB.Recordset Private Sub Command1_Click() If Text14.Text = \

MsgBox \输入查找学号!\警告\Text14.SetFocus Exit Sub End If

If Text15.Text = \

MsgBox \输入查找姓名!\警告\Text15.SetFocus Exit Sub End If

txtsql = \a.学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 and a.学号='\姓名='\Trim(Text15.Text) & \Set mrc = ExecuteSQL(txtsql) If Not mrc.EOF Then Me.fz Me.sz Else

MsgBox \不存在该档案!\警告\Text14.SetFocus Exit Sub End If

Text14.Text = \Text15.Text = \

28

mrc.Close

'使用一组按钮,不是按某一个值来查找

txtsql = \a.学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 \Set mrc = ExecuteSQL(txtsql) Command3.Enabled = True Command4.Enabled = True Command5.Enabled = True Command6.Enabled = True End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Command3_Click()

'txtsql = \学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 \'Set mrc = ExecuteSQL(txtsql) mrc.MoveFirst Me.fz 'mrc.Close End Sub

Private Sub Command4_Click()

'txtsql = \学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 \'Set mrc = ExecuteSQL(txtsql)

29

mrc.MovePrevious If mrc.BOF Then mrc.MoveFirst

MsgBox \到第一条记录!\提示\End If Me.fz 'mrc.Close End Sub

Private Sub Command5_Click()

'txtsql = \学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 \'Set mrc = ExecuteSQL(txtsql) mrc.MoveNext If mrc.EOF Then mrc.MoveLast

MsgBox \到最后一条记录!\提示\End If Me.fz 'mrc.Close End Sub

Private Sub Command6_Click()

'txtsql = \学号,a.姓名,a.性别,a.民族,a.血型,a.出生年月,b.院系名称,c.专业名称,d.班级名称,a.联系电话,a.邮编,a.籍贯,a.家庭住址,a.备注 from 学生基本信息 a,院系 b,专业 c,班级 d where a.院系代码=b.院系代码 and a.专业代码=c.专业代码 and a.班级代码=d.班级代码 \'Set mrc = ExecuteSQL(txtsql) mrc.MoveLast Me.fz 'mrc.Close

30