VB学生信息管理系统及源代码
Option Explicit
'标识是否能关闭
Dim mbClose As Boolean
'标识当前要显示的照片的文件 Dim mstrFileName As String Private Sub Form_Load()
On Error Resume Next
If frmMain.mnUserType = 1 Then
'学生用户
fraSeek.Enabled = False
fraBrowse.Enabled = False
cmdAdd.Enabled = False
cmdDelete.Enabled = False
txtSerial.Enabled = False
dcbClass.Enabled = False
grdScan.Enabled = False
If Not(DataEnv.rsStudent.EOF And DataEnv.rsStudent.BOF)Then
Dim Temp As String
Temp = “name = ” & “'” & frmMain.msUserName & “'”
DataEnv.rsStudent.MoveFirst
DataEnv.rsStudent.Find Temp
'刷新所绑定的控件
Call RefreshBinding
End If
Exit Sub
Else
fraSeek.Enabled = True
fraBrowse.Enabled = True
cmdAdd.Enabled = True
cmdDelete.Enabled = True
txtSerial.Enabled = True
dcbClass.Enabled = True
grdScan.Enabled = True
End If
Dim rsDep As New ADODB.Recordset, rsClass As New ADODB.Recordset
Set rsDep = DataEnv.rsDepartment
Set rsClass = DataEnv.rsClass
rsDep.Open
'从Department表中读取数据,填充cboDep组合框到中
cboDep.Clear
cboDep.AddItem “全部”
'将各个系的id号作为ItemData附加到组合框中
cboDep.ItemData(0)= 0
While Not rsDep.EOF
cboDep.AddItem rsDep(“Name”)
cboDep.ItemData(cboDep.ListCount1)
ChunkAry = blobColumn.GetChunk(Fragment)
Put FileNumber, , ChunkAry
'写入文件
End If
ReDim ChunkAry(ChunkSize-1)
'为数据块重新开辟空间
For lngI = 1 To Chunks
'循环读出所有块
ChunkAry = blobColumn.GetChunk(ChunkSize)
'在数据库中连续读数据块
Put FileNumber, , ChunkAry()
'将数据块写入文件中
Next lngI
Close FileNumber
ReadImage = strFileName
Exit Function
errHander:
ReadImage = “" End Function
Private Sub imgPhoto_Click()End
'关闭文件 Sub
Option Explicit '表示当前的用户类型:0---管理员类型的用户;1---学生类型的用户 Public mnUserType As Integer '表示当前登录的用户名 Public msUserName As String
Private Sub MDIForm_Load()
'根据不同的用户类型,使相应的菜单项可见
Select Case mnUserType
Case 0:
'以管理员身份登录
mnuFind.Visible = True
tlbMain.Buttons.Item(3).Visible = True
tlbMain.Buttons.Item(4).Visible = True
Exit Sub
Case 1:
'以学生身份登录,只能查询自己的信息
mnuFind.Visible = False
'“信息查询”菜单不可见
tlbMain.Buttons.Item(3).Visible = False
'“信息查询”按钮不可见
tlbMain.Buttons.Item(4).Visible = False
'第二个分隔条不可见
Exit Sub
End Select End Sub
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox(”真的要对出本系统吗?“, vbQuestion + vbYesNo + vbDefaultButton2, ”退出“)= vbNo Then
Cancel = 1
End If End Sub Private Sub mnuAbout_Click()
Load frmSplash
frmSplash.mbAbout = True
frmSplash.Show vbModal End Sub
Private Sub mnuArr_Click()
frmMain.Arrange(3)
'设置主窗体中所有最小化MDI子窗体图标重排 End Sub
Private Sub mnuCas_Click()
frmMain.Arrange(0)
'设置主窗体中所有非最小化MDI子窗体层叠显示 End Sub
Private Sub mnuExit_Click()
Unload Me End Sub
Private Sub mnuFind_Click()
frmFind.Show End Sub
Private Sub mnuHori_Click()
frmMain.Arrange(1)
'设置主窗体中所有非最小化MDI子窗体水平平铺 End Sub
Private Sub mnuLog_Click()
If MsgBox(”若重新登录,所有窗体都将关闭!“ & vbCrLf & ”
是否重新登录?“, _
vbQuestion + vbYesNo + vbDefaultButton2, ”重新登录“)= vbYes Then
Unload Me
frmLogin.Show
End If End Sub
Private Sub mnuStudent_Click()
Load frmStudent
frmStudent.Show End Sub Private Sub mnuVer_Click()
frmMain.Arrange(2)
'设置主窗体中所有非最小化MDI子窗体垂直平铺 End Sub
Private Sub tlbMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case ”Student“
mnuStudent_Click
Exit Sub
Case ”Find“
mnuFind_Click
Exit Sub
Case ”Login“
mnuLog_Click
Exit Sub
Case ”Exit“
mnuExit_Click
Exit Sub
End Select End SubOption Explicit
'表示当前用户登录所选择的身份,即用户类型, 0-表示教务管理人员;1-表示学生 Dim mnUserType As Integer Private Sub cmdCancel_Click()
Unload Me End Sub
Private Sub cmdOK_Click()
'取得用户输入的用户名和密码
Dim user As String, pwd As String
user = Trim(txtUser)
pwd = Trim(txtPwd)
'根据不同的身份,选择不同的表用以查询
Dim r As New ADODB.Recordset
Set r = DataEnv.rssqlSeek
Dim strSQL As String
Select Case mnUserType
Case 0: '若身份为管理员
strSQL = ”select * from 系统人员表 where name='“ & user & ”' and pwd='“ & pwd & ”'“
Case 1: '若身份为学生
strSQL = ”select * from 学生信息表 where name='“ & user & ”' and serial='“ & pwd & ”'“
End Select
On Error Resume Next
'查询DataEnv.rssqlSeek的状态,如果已经打开,则先关闭
If r.State = adStateOpen Then r.Close
r.Open strSQL
'根据strSQL的内容刷新DataEnv.rssqlSeek
'用户密码错误的次数,如果错误次数超过3次,则退出系统
Static nTryCount As Integer
If r.EOF Then
'登录失败
MsgBox ”对不起,无此用户或者密码不正确!请重新输入!“, vbCritical, ”错误“
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser)
nTryCount = nTryCount + 1
If nTryCount >= 3 Then
MsgBox ”您无权操作本系统!“, vbCritical, ”错误“
Unload Me
End If
Else
'登陆成功
'显示MDI窗体, 并将用户类型和用户名传到MDI窗体中的mnUserType, msUserName中
With frmMain
.mnUserType = mnUserType
.msUserName = user
End With
Load frmMain
frmMain.Show
Unload Me
End If End Sub Private Sub Form_Load()
optUserType(0).Value = True End Sub
Private Sub optUserType_Click(Index As Integer)
mnUserType = Index End Sub Explicit
Private Sub Command1_Click()
Dim strCon1 As String
Dim strCon2 As String
On Error GoTo myerr
If Trim(Text1.Text)= ”“ Or Trim(Text2.Text)= ”“ Then
If MsgBox(”请输入查询条件!“, vbInformation, ”提示“)Then GoTo myerr
End If
Select Case Trim(Combo1.Text)
Case ”学号“
strCon1 = ”Serial“
Case ”姓名“
strCon1 = ”Name“
Case ”班级“
strCon1 = ”Class“
Option
Case ”生日“
strCon1 = ”Birthday“
Case ”性别“
strCon1 = ”Sex“
Case ”家庭地址“
strCon1 = ”Address“
Case ”电话“
strCon1 = ”Tel“
End Select
Select Case Trim(Combo4.Text)
Case ”学号“
strCon2 = ”Serial“
Case ”姓名“
strCon2 = ”Name“
Case ”班级“
strCon2 = ”Class“
Case ”生日“
strCon2 = ”Birthday“
Case ”性别“
strCon2 = ”Sex“
Case ”家庭地址“
strCon1 = ”Address“
Case ”电话“
strCon2 = ”Tel“
End Select
DataEnv.rsStudent.Close
DataEnv.rsStudent.Open ”select * from 学生信息表
where “ & _
strCon1 & Trim(Combo2.Text)& ” '“ & Trim(Text1.Text)_
& ”'“ & ” “ & Trim(Combo3.Text)& ” “ & strCon2 & _
Trim(Combo5.Text)& ”'“ & Trim(Text2.Text)& ”'“
dgdCX.DataMember = ”“
dgdCX.Refresh
DataEnv.rsStudent.Requery
dgdCX.DataMember = ”Student“
dgdCX.Refresh myerr: End Sub
Private Sub Command3_Click()
Unload Me End Sub
Private Sub dgdCX_Click()
End Sub
Private Sub Form_Load()
'添加Combo1的子项作为查询标准
Combo1.AddItem(”学号“)
Combo1.AddItem(”姓名“)
Combo1.AddItem(”班级“)
Combo1.AddItem(”生日“)
Combo1.AddItem(”性别“)
Combo1.AddItem(”家庭地址“)
Combo1.AddItem(”电话“)
Combo1.ListIndex = 0
'添加Combo2的子项作为关系符
Combo2.AddItem(”=“)
Combo2.AddItem(”>“)
Combo2.AddItem(”>=“)
Combo2.AddItem(”<“)
Combo2.AddItem(”<=“)
Combo2.AddItem(”<>“)
Combo2.ListIndex = 0
'添加Combo3的子项作为逻辑连接符
Combo3.AddItem(”And“)
Combo3.AddItem(”Or“)
Combo3.ListIndex = 0
'添加Combo4的子项作为第二种查询标准
Combo4.AddItem(”学号“)
Combo4.AddItem(”姓名“)
Combo4.AddItem(”班级“)
Combo4.AddItem(”生日“)
Combo4.AddItem(”性别“)
Combo4.AddItem(”家庭地址“)
Combo4.AddItem(”电话“)
Combo4.ListIndex = 0
'添加Combo5的子项作为第二种关系符
Combo5.AddItem(”=“)
Combo5.AddItem(”>“)
Combo5.AddItem(”>=“)
Combo5.AddItem(”<“)
Combo5.AddItem(”<=“)
Combo5.AddItem(”<>")
Combo5.ListIndex = 0 End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Enabled = True
frmMain.Show End Sub
学生信息管理系统源代码
import java.io.*;
class StuInfo {
public String name;
public int number;
public String sex;
public String age;
public String bir;
public String email;
public String addr;
public String tel;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public int getNumber(){
return number;
}
public void setNumber(int number){
this.number = number;
}
public String getSex(){
return sex;
}
public void setSex(String sex){
this.sex = sex;
}
public String getAge(){
return age;
}
public void setAge(String age){
this.age = age;
}
public String getBir(){
return bir;
}
public void setBir(String bir){
this.bir = bir;
}
public String getEmail(){
return email;
} public void setEmail(String email){
this.email = email;} public String getAddr(){
return addr;} public void setAddr(String addr){
this.addr = addr;} public String getTel(){
return tel;} public void setTel(String tel){
this.tel = tel;} } public class Student { private static PrintStream out = System.out;private static String filename = “Stu.txt”;private static int total = 0;private static int rt = 0;//recyle length private StuInfo[] stuInfos;private StuInfo[] recycle;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));//创建缓冲流
public Student(){
stuInfos = new StuInfo[11];
}
public void 信息录入(){
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.print(“n请输入学生信息(以0结束)n”);
System.out.print(“学号:n”);
StuInfo stu = new StuInfo();
stu.setNumber(Integer.parseInt(buf.readLine()));
while(stu.getNumber()!=0){
System.out.print(“姓名:nn”);
stu.setName(buf.readLine());
System.out.print(“性别:nn”);
stu.setSex(buf.readLine());
System.out.print(“年龄:nn”);
stu.setAge(buf.readLine());
System.out.print(“生日:nn”);
stu.setBir(buf.readLine());
System.out.print(“邮箱:nn”);
stu.setEmail(buf.readLine());
System.out.print(“地址:nn”);
stu.setAddr(buf.readLine());
System.out.print(“电话:nn”);
stu.setTel(buf.readLine());
//添加其他输入信息
stuInfos[total]=stu;
total++;
stu = new StuInfo();
System.out.print(“n请输入下一个学生信息(以0结束)n”);
System.out.print(“姓名:n”);
stu.setName(buf.readLine());
}
}catch(Exception e){
out.print(e);
}
} public void 保存数据(){ try{
FileWriter fwr=new FileWriter(filename);
BufferedWriter fw = new BufferedWriter(fwr);
fw.write(total+“rn”);
for(int k=0;kfw.write(stuInfos[k].getNumber()+“rn”);
fw.write(stuInfos[k].getName()+“rn”);
fw.write(stuInfos[k].getSex()+“rn”);
fw.write(stuInfos[k].getAge()+“rn”);
fw.write(stuInfos[k].getBir()+“rn”);
fw.write(stuInfos[k].getEmail()+“rn”);
fw.write(stuInfos[k].getAddr()+“rn”);
fw.write(stuInfos[k].getTel()+“rn”);
}
fw.write(rt+“rn”);
for(int k=0;k