b
PrivateSubCommand1_Click()
DimdbAsConnection
Setdb=NewConnection
db.CursorLocation=adUseClient
db.Open"PROVIDER=Microsoft.Jet.OLEDB.3.51;DataSource=xjgl.mdb;"
SetadoPrimaryRS=NewRecordset
a=Combo1.Text
b=Text1.Text
adoPrimaryRS.Open"select学籍号,姓名,性别,出生年月,班级,家庭住址,父母姓名,联系电话,毕业级别,奖惩记载,学生简历fromxsdawhere"&a&"like'%"&b&"%'",db,adOpenStatic,adLockOptimistic
SetDataGrid1.DataSource=adoPrimaryRS
EndSub
PrivateSubCommand2_Click()
DimiAsInteger,jAsInteger
DimxlappAsExcel.Application
DimxlbookAsExcel.Workbook
DimxlsheetAsExcel.Worksheet
Setxlapp=CreateObject("excel.application")
xlapp.Visible=True
Setxlbook=xlapp.Workbooks.Add
Setxlsheet=xlbook.Worksheets(1)
xlsheet.Cells(1,1)="学籍号"
xlsheet.Cells(1,2)="姓名"
xlsheet.Cells(1,3)="性别"
xlsheet.Cells(1,4)="出生年月"
xlsheet.Cells(1,5)="班级"
xlsheet.Cells(1,6)="家庭住址"
xlsheet.Cells(1,7)="父母姓名"
xlsheet.Cells(1,8)="联系电话"
xlsheet.Cells(1,9)="毕业级别"
xlsheet.Cells(1,10)="奖惩记载"
xlsheet.Cells(1,11)="学生简历"
adoPrimaryRS.MoveFirst
i=0
DoWhile(adoPrimaryRS.EOF=False)
Forj=0ToadoPrimaryRS.Fields.Count-1
DataGrid1.Col=j
xlsheet.Cells(i+2,j+1)=DataGrid1.Text
Nextj
adoPrimaryRS.MoveNext
i=i+1
Loop
Setxlapp=Nothing
Setxlbook=Nothing
EndSub
PrivateSubCommand3_Click()
UnloadMe
EndSub
PrivateSubForm_Load()
Left=(Screen.Width-Width)\2
Top=(Screen.Height-Height)\2
DimdbAsConnection
Setdb=NewConnection
db.CursorLocation=adUseClient
db.Open"PROVIDER=Microsoft.Jet.OLEDB.3.51;DataSource=xjgl.mdb;"
SetadoPrimaryRS=NewRecordset
adoPrimaryRS.Open"select学籍号,姓名,性别,出生年月,班级,家庭住址,父母姓名,联系电话,毕业级别,奖惩记载,学生简历fromxsda",db,adOpenStatic,adLockOptimistic
SetDataGrid1.DataSource=adoPrimaryRS
mbDataChanged=False
EndSub
3:学生成绩的录入窗体的源代码:
DimWithEventsadoPrimaryRSAsRecordset
DimWithEventsadoPrimaryRS1AsRecordset
DimWithEventsadoPrimaryRS2AsRecordset
DimWithEventsadoPrimaryRS3AsRecordset
DimWithEventsadoPrimaryRS4AsRecordset
PrivateSubCommand1_Click()
DimdbAsConnection
Setdb=NewConnection
db.CursorLocation=adUseClient
db.Open"PROVIDER=Microsoft.Jet.OLEDB.3.51;DataSource=xjgl.mdb;"
SetadoPrimaryRS1=NewRecordset
a="学籍号"
b=Text3.Text
adoPrimaryRS1.Open"select学籍号,姓名fromxsdawhere"&a&"like'%"&b&"%'",db,adOpenStatic,adLockOptimistic
IfadoPrimaryRS1.EOF=TrueThen
MsgBox("该生还未注册")
Else
SetadoPrimaryRS2=NewRecordset
a="学籍号"
b=Text3.Text
c="科目"
d=Text1.Text
e="学期"
f=Text2.Text
adoPrimaryRS2.Open"select学籍号,姓名,科目,学期fromxscjwhere"&a&"like'%"&b&"%'and"&c&"like'%"&d&"%'and"&e&"like'%"&f&"%'",db,adOpenStatic,adLockOptimistic
IfadoPrimaryRS2.EOF=TrueThen
adoPrimaryRS.AddNew
adoPrimaryRS.Fields("学籍号")=Text3.Text
adoPrimaryRS.Fields("姓名")=adoPrimaryRS1.Fields("姓名")
adoPrimaryRS.Fields("科目")=Text1.Text
adoPrimaryRS.Fields("成绩")=Text4.Text
adoPrimaryRS.Fields("学期")=Text2.Text
adoPrimaryRS.Update
IfText4.Text>=60Then
SetadoPrimaryRS3=NewRecordset
adoPrimaryRS3.Open"select*fromjxjhwhere课程名='"&d&"'",db,adOpenStatic,adLockOptimistic
SetadoPrimaryRS4=NewRecordset
adoPrimaryRS4.Open"select*fromxfwhere学籍号='"&b&"'",db,adOpenStatic,adLockOptimistic
IfadoPrimaryRS4.EOF=TrueThen
adoPrimaryRS4.AddNew
adoPrimaryRS4.Fields("学籍号")=Text3.Text
adoPrimaryRS4.Fields("学分")=adoPrimaryRS3.Fields("学分")
adoPrimaryRS4.Update
Else
adoPrimaryRS4.Fields("学分")=adoPrimaryRS4.Fields("学分")+adoPrimaryRS3.Fields("学分")
adoPrimaryRS4.Update
EndIf
EndIf
Else
MsgBox("该生该科成绩已经录入")
EndIf
EndIf
Text3.Text=""
Text4.Text=""
EndSub
PrivateSubCommand3_Click()
UnloadMe
EndSub
PrivateSubCommand4_Click()
IfCommand4.Caption="成绩修改"Then
Command4.Caption="保存"
DataGrid1.Enabled=True
Else
Command4.Caption="成绩修改"
DataGrid1.Enabled=False
EndIf
EndSub
PrivateSubCommand5_Click()
adoPrimaryRS.Delete
adoPrimaryRS.MovePrevious
IfadoPrimaryRS.BOFThen
adoPrimaryRS.MoveFirst
EndIf
EndSub
PrivateSubForm_Load()
Left=(Screen.Width-Width)\2
Top=(Screen.Height-Height)\2
DimdbAsConnection
Setdb=NewConnection
db.CursorLocation=adUseClient
db.Open"PROVIDER=Microsoft.Jet.OLEDB.3.51;DataSource=xjgl.mdb;"
SetadoPrimaryRS=NewRecordset
adoPrimaryRS.Open"select学籍号,姓名,科目,成绩,学期fromxscj",db,adOpenStatic,adLockOptimistic
SetDataGrid1.DataSource=adoPrimaryRS
mbDataChanged=False
EndSub
4:学生成绩查询窗体的源代码:
DimWithEventsadoPrimaryRSAsRecordset
PrivateSubCombo1_Click()
Text1.Text=""
EndSub
PrivateSubCommand1_Click()
DimdbAsConnection
Setdb=NewConnection
db.CursorLocation=adUseClient
db.Open"PROVIDER=Microsoft.Jet.OLEDB.3.51;DataSource=xjgl.mdb;"
SetadoPrimaryRS=NewRecordset
a=Combo1.Text
b=Text1.Text
c="学期"
d=Text2.Text
IfCombo1.Text="班级"Then
adoPrimaryRS.Open"selectdistinct学籍号,姓名,科目,成绩,学期fromxscjwhere"&c&"like'%"&d&"%'and学籍号in(select学籍号fromxsdawhere"&a&"like'%"&b&"%')",db,adOpenStatic,adLockOptimistic
Else
adoPrimaryRS.Open"selectdistinct学籍号,姓名,科目,成绩,学期fromxscjwhere"&a&"like'%"&b&"%'and"&c&"like'%"&d&"%'",db,adOpenStatic,adLockOptimistic
EndIf
SetDataGrid1.DataSource=adoPrimaryRS
EndSub
PrivateSubCommand2_Click()
DimiAsInteger,jAsInteger
DimxlappAsExcel.Application
DimxlbookAsExcel.Workbook
DimxlsheetAsExcel.Worksheet
Setxlapp=CreateObject("excel.application")
xlapp.Visible=True
Setxlbook=xlapp.Workbooks.Add
Setxlsheet=xlbook.Worksheets(1)
xlsheet.Cells(1,1)="学籍号"
xlsheet.Cells(1,2)="姓名"
xlsheet.Cells(1,3)="科目"
xlsheet.Cells(1,4)="成绩"
xlsheet.Cells(1,5)="学期"
adoPrimaryRS.MoveFirst
i=0
DoWhile(adoPrimaryRS.EOF=False)
Forj=0ToadoPrimaryRS.Fields.Count-1
DataGrid1.Col=j
xlsheet.Cells(i+2,j+1)=DataGrid1.Text
Nextj
adoPrimaryRS.MoveNext
i=i+1
Loop
Setxlapp=Nothing
Setxlbook=Nothing
EndSub
上一篇:
vb学生评语生成系统论文(论文和程序)
下一篇:
英语论文网([网学网]):英语专业本科生毕业论文写作