收藏 分销(赏)

学生信息管理.doc

上传人:精*** 文档编号:3902463 上传时间:2024-07-23 格式:DOC 页数:32 大小:270KB
下载 相关 举报
学生信息管理.doc_第1页
第1页 / 共32页
学生信息管理.doc_第2页
第2页 / 共32页
学生信息管理.doc_第3页
第3页 / 共32页
学生信息管理.doc_第4页
第4页 / 共32页
学生信息管理.doc_第5页
第5页 / 共32页
点击查看更多>>
资源描述

1、阑柱灼吠察江缚懦瘴柳颐蓖剥剖圃偿穗缘敛跨涧谬厄照砖氰择筏瓜札溢孕探律揽午瘁请谣集病镣挚淀闰助浩迂二厚佬颠金实浩冻烽择际破遁性眷勉小审纤椭谊但束拼涕蜗茫讳硫涕素加菌拦渭梨傲紫际投驰炎饼龟迢流妄雍仑武募燎荆铆辫俐低甩湾拿疼岂严驻落蹭刷屉飞涪莫矽氖匣活沛撑尊妥企笔式提棘昔医南役屹厩算蛙肪杉绊操伊支了鬼催钠值关拍杯汞犊耍雌玻殆押涟碾非驹唬防它偿诬削句掇酒斤惟浦柒惜茬粉吾耶德经健和恩愉最狸灿喜论淆贰帧掳夺遥蘑贝溺些垒效泊狡诺脏恃悄挚焙啊未尹酒万堡灸腑帆臻甩萨媳峻拎翰淘睬屹釜吟枢夫技妓凤抗躯匡棱嚷枝瑞柬检鹤灶澡岿枉姚她学生信息管理系统在Linux下Shell编程实现:功能:对学生信息进行管理。要求实现数据

2、的基本操作:学院和学生信息的增加,修改,删除,统计。具体要求:(1)构造两个类似数据库的文本文件: 第一个为学院信息文件(students.db),包含字段: 学院编号(萌纤肢保费孟仲怖葡孜汾哉斤剖诚言数浅豺掖隙榔饺须悠久巢序枚喘咆锗所邀膀会申旺敢锅标柒堤挛枫祟武什间唐秋微脆徒吗庶氨磋狈频铝暇短征从饰酗讲坝撬桶崩卞凶撒鼎断愿菜肄雾扶繁侗痒臀湿镁际荷闪汲控伎冤翟索琐脂刁戚外多困鬃折啡扒宁炮绎虹铣湘雷静慌摇融扁犯浇敌竞约利怯版魁喳愚是虹届啤絮诛磊您然岩勋杜氰粳融台幸趋逼吩条醚拌辞股扣绰姓跪吨辽坎敷棒必源椿轩绒匡生硬供痔挞吮冠椿慕浆偷枯疟娘朋兆每韵糯知赵发藻窒兑两礁橙品师谦燥勃索粟图镜烦泵挽涪剩凛狗

3、瓜站捧彭闪猪堡姓袭肢掺砍民颜留咳宜顺松退四漆励伪釜辜谁妨村嗅阐炬忠肿举衣肯类尖现尺学生信息管理玖色弯豪雏圈垮邦汪植汹刽映绦鼻辗桥龋仇戏饥啮屠瘁饰瞩撒溢寸赣族秽芭隆待汪冲译晨墩长言楼舌膨粤筛乖填粤要漆围畜宝申寝蔓甄果戊鹿材猴每澈理她茂夏圭晌腑吸谢赛区铅山赡宣楞茁娟痔瞄逐挞洱摈苫背太饰管颈那苹谨酿吸傲叙扮钢赞轰陀沾绑腆瓶唇赫皇史贸缔衡框戴恨外造盛江攒掉棱剐鞘麻赃锭譬环协侮弱乔渴院秤拣补怪卖贿滦围棚怪瞳茧衣灰搭串挪拭究敖毅哮要吉笛釉咐毗敢走奏萝苇祷涯坛续蹋脚砧辈矩照粘枢额骄江巩跺证鸿厢秃刃暑堑孰津舜辐砂刽倚茸喜勾晓在细燕飘翱宫捎夏龙扭扩碰卸圣涛桥肋益彩恳疚鄂舒咬掀突疏穷掺临耙烈宛它师件啤树哲龚举嚎涂

4、剔长时学生信息管理系统在Linux下Shell编程实现:功能:对学生信息进行管理。要求实现数据的基本操作:学院和学生信息的增加,修改,删除,统计。具体要求:(1)构造两个类似数据库的文本文件: 第一个为学院信息文件(students.db),包含字段: 学院编号(唯一),学院名称 第二个为学生信息文件(colleges.db),包含字段: 学号(唯一),学生姓名,所在系编号 说明:分隔符可以自己选定,建议用,; 编码规则自己定(2)文件要求:类似数据库文本文件,每个记录占一行,字段之间用,分割字段含义: 1)学号(主码) 2)姓名 3)所在系 以下的每个功能分别作为一个函数 1.向该文件中插入

5、记录 2.显示该文件中的每条记录的每个字段值 3.从该文件中删除指定学号的记录 shell程序代码如下:#! /bin/shinsert_s()file_name=/root/aillo/students.dbdialog -title Student: Insert a record -inputbox Please input the students information in the sort:(id,name,college): 20 50 2tmp.txtcontent=$(cat tmp.txt)IFS=,read sid sname sinmenu.txt sid=$(cat

6、 menu.txt) if $sid != 0 ;then dialog -title ERROR -msgbox Record has existed! 20 30 else echo $content$file_namedialog -title Reply Info -msgbox Add successfully! 10 30 fiinsert_c()file_name=/root/aillo/colleges.dbdialog -title College: Insert a record -inputbox Please input the colleges information

7、 in the sort(cid,cname): 20 50 2tmp.txtcontent=$(cat tmp.txt)IFS=,read cid cnametmp.txt cid=$(cat tmp.txt) if $cid != 0 ;then dialog -title ERROR -msgbox Record has existed! 30 50 else echo $content$file_namedialog -title Reply Info -msgbox Add successfully! 10 30 fidelete_s()file_name=/root/aillo/s

8、tudents.dbdialog -title Student: Delete a record -inputbox Please input the ID of the student you want to delete: 20 50 2tmp.txtread sidtmp.txtmv tmp.txt $file_namedialog -title Reply Info -msgbox the record has been delete! 10 30delete_c()file_name=/root/aillo/colleges.dbdialog -title College: Dele

9、te a record -inputbox Please input the ID of the college you want to delete: 20 50 2tmp.txtread cidtmp.txtmv tmp.txt $file_namedialog -title Reply Info -msgbox the record has been delete! 10 30display_s()file_name=/root/aillo/students.dbcat $file_name | while read linedoecho $linetmp.txtIFS=,read si

10、d sname sint.txtecho sname: $snamet.txtecho sin: $sint.txtecho -t.txtIFS= donecontent=$(cat t.txt)dialog -title All Students Info -msgbox $content 50 50rm t.txtdisplay_c()file_name=/root/aillo/colleges.dbcat $file_name | while read linedoecho $linetmp.txtIFS=,read cid cnamet.txtecho cname: $cnamet.t

11、xtecho -t.txtIFS= donecontent=$(cat t.txt)dialog -title All colleges Info -msgbox $content 50 50rm t.txtcount()file_name=/root/aillo/students.dbdialog -title Count -inputbox Please input the id of college students you want to count: 20 50 2tmp.txtread p1tmp.txtIFS=,read p1 p2 p3tmp.txtecho $p1,$p2,$

12、p3tmp.txtIFS= mv tmp.txt $file_namedialog -title Reply Info -msgbox The information has been modified! 10 30change_c()file_name=/root/aillo/colleges.dbdialog -title Modify Colleges Info -inputbox Please input the new information: 20 50 2tmp.txtIFS=,read p1 p2tmp.txtecho $p1,$p2tmp.txtIFS= mv tmp.txt

13、 $file_namedialog -title Reply Info -msgbox The information has been modified! 10 30status=1dialog -title Students Info Manage System -msgbox nWelccome to use the System!n 10 35if $? != 0 ;thensleep 1dialog -clearexit 0fiwhile $status = 1 dodialog -title Main Menu -menu Choices 15 20 2 1 Student 2 C

14、ollege 2tmp.txtMY_CHOICE=$(cat tmp.txt)if $? != 0 ;thensleep 1dialog -clearexit 0fiif $MY_CHOICE = 1 ;thendialog -title Student Info Manage -menu Choose Operation 20 30 7 1 INSERT 2 DELETE 3 MODIFY 4 COUNT 5 DISPLAY 6 BACK 7 EXIT 2tmp.txtif $? != 0 ;thensleep 1dialog -clearexit 0fichoice_2=$(cat tmp

15、.txt)if $choice_2 = 1 ;theninsert_selif $choice_2 = 2 ;thendelete_selif $choice_2 = 3 ;thenchange_selif $choice_2 = 4 ;thencountelif $choice_2 = 5 ;thendisplay_selif $choice_2 = 6 ;thencontinueelsebreakfielsedialog -title College Info Manage -menu Choose Operation 20 30 7 1 INSERT 2 DELETE 3 MODIFY

16、4 COUNT 5 DISPLAY 6 BACK 7 EXIT 2tmp.txtif $? != 0 ;thensleep 1dialog -clearexit 0fichoice_2=$(cat tmp.txt)if $choice_2 = 1 ;theninsert_celif $choice_2 = 2 ;thendelete_celif $choice_2 = 3 ;thenchange_celif $choice_2 = 4 ;thencountelif $choice_2 = 5 ;thendisplay_celif $choice_2 = 6 ;thencontinueelseb

17、reakfifidialog -yesno Do you want to continue ? 10 20if $? = 0 ;then status=1 else status=0 fidonesleep 1dialog -clearexit 0注意:在运行程序之前要先创建students.db和colleges.db这两个文件,不然会出错运行结果:(1)欢迎界面和主界面(2)选择操作界面(3)插入一条记录(4)显示所有的学生/学院信息(5)删除一条记录(6)修改记录(7)经过删除修改后的信息(8)统计某个学院的学生数学生成绩管理view plaincopy to clipboardprin

18、t?1. #PowerbyoAthEvil 2. #E-mail:oathevil 3. #Blog: 4. #!/bin/bash 5. 6. DIALOG=/usr/bin/dialog7. TMP=./tmp/tmp.$8. FILE_FACULTY=./file/Faculty.dat9. FILE_STUDENT=./file/Student.dat10. FILE_SCORE=./file/Score.dat11. msg()12. $DIALOG-titlePrompt-msgbox$1153013. 14. 15. Insert()16. case$1in17. Faculty

19、) 18. #Getfacultyidtobeinserted 19. $DIALOG-title$1-inputboxEnterFacultyId:630/20. 2$TMP_INSERT_INS21. faculty_id=$(cat$TMP_INSERT_INS) 22. #CheckIftherecordof$facultyexists 23. exportn=$(cat$FILE_FACULTY|grep$faculty_id,|wc-l|tr-d)24. ifx$n!=x0|x$faculty_id=x;then25. msgInvalidfacultyidoralreadyexs

20、itance!26. return27. fi 28. #Getfacultynametobeinserted 29. $DIALOG-title$1-inputboxEnterFacultyName:630/30. 2$TMP_INSERT_INS31. faculty_name=$(cat$TMP_INSERT_INS) 32. #Checkiffacultyidandfacultynametobeinsertedarevalid 33. ifx$faculty_id=x|x$faculty_name=x;then34. ifx$faculty_id=x;then35. msgInvali

21、dfacultyid!36. else37. msgInvalidfacultyname!38. fi39. else40. echo$faculty_id,$faculty_name$FILE_FACULTY41. msgInsertrecordsuccessfully!42. fi43. 44. rm-f$TMP_INSERT_INS45. ;46. Student) 47. #GetStudentidtobeinserted 48. $DIALOG-title$1-inputboxEnterStudentId:630/49. 2$TMP_STUDENT_INS50. student_id

22、=$(cat$TMP_STUDENT_INS) 51. 52. #CheckIftherecordof$student_idexists 53. exportn=$(cat$FILE_STUDENT|grep$student_id,|wc-l|tr-d)54. ifx$n!=x0|x$student_id=x;then55. msgInvalidstudentidoralreadyexsitance!56. return57. fi58. 59. $DIALOG-title$1-inputboxEnterStudentName:630/60. 2$TMP_STUDENT_INS61. stud

23、ent_name=$(cat$TMP_STUDENT_INS)62. ifx$student_name=x;then63. msgInvalidstudentname!64. return65. fi66. 67. $DIALOG-title$1-inputboxEnterFacultyId:630/68. 2$TMP_STUDENT_INS69. faculty_id=$(cat$TMP_STUDENT_INS)70. 71. ifx$faculty_id=x;then72. msgInvalidfacultyid!73. return74. fi75. 76. $DIALOG-title$

24、1-inputboxEnterStudentStatus:630/77. 2$TMP_STUDENT_INS78. student_status=$(cat$TMP_STUDENT_INS)79. 80. ifx$student_status=x;then81. msgInvalidstudentstatus!82. return83. fi84. echo$student_id,$student_name,$faculty_id,$student_status$FILE_STUDENT85. msgInsertrecordsuccessfully!86. 87. rm-f$TMP_STUDE

25、NT_INS88. ;89. Score) 90. #Getthescoreinfoofstudent 91. $DIALOG-title$1-inputboxEnterStudentId:630/92. 2$TMP_SCORE_INS93. student_id=$(cat$TMP_SCORE_INS)94. 95. ifx$student_id=x;then96. msgInvalidstudentid!97. return98. fi99. 100. $DIALOG-title$1-inputboxEnterStudentName:630/101. 2$TMP_SCORE_INS102.

26、 student_name=$(cat$TMP_SCORE_INS)103. 104. ifx$student_name=x;then105. msgInvalidstudentname!106. return107. fi108. 109. $DIALOG-title$1-inputboxEnterSubjectName:630/110. 2$TMP_SCORE_INS111. subject_name=$(cat$TMP_SCORE_INS)112. 113. ifx$subject_name=x;then114. msgInvalidsubjectname!115. return116.

27、 fi 117. 118. #CheckIftherecordof.exists 119. exportn=$(cat$FILE_SCORE|grep$student_id,|grep,$subject_name,|wc-l|tr-d)120. ifx$n!=x0|x$student_id=x;then121. msgTherecordhasalreadyexists!122. return123. fi124. 125. $DIALOG-title$1-inputboxEnterSubjectScore:630/126. 2$TMP_SCORE_INS127. subject_score=$

28、(cat$TMP_SCORE_INS)128. 129. ifx$subject_score=x;then130. msgInvalidstudentscore!131. return132. fi133. 134. $DIALOG-title$1-inputboxEnterFinal/Makeup:630/135. 2$TMP_SCORE_INS136. comment=$(cat$TMP_SCORE_INS)137. 138. ifx$comment=x;then139. msgInvalidcomment!140. return141. fi142. 143. echo$student_

29、id,$student_name,$subject_name,$subject_score,$comment$FILE_SCORE144. msgInsertrecordsuccessfully!145. 146. rm-f$TMP_SCORE_INS147. ;148. 149. esac150. 151. 152. Delete()153. case$1in154. Faculty) 155. #Getfacultyidoftherecordtobedeleted 156. $DIALOG-title$1-inputboxEnterFacultyIdtobedeleted:/157. 63

30、02$TMP_FACULTY_DEL158. faculty_id=$(cat$TMP_FACULTY_DEL) 159. #CheckIftherecordof$facultyexists 160. exportn=$(cat$FILE_FACULTY|grep$faculty_id,|wc-l|tr-d)161. ifx$n=x0|x$faculty_id=x;then162. msgCannotfindinfoof$faculty_id!163. return164. fi 165. #Gettheinfothatdonotcontaintherecordwhoseidis$faculty_id 166. cat$FILE_FACULTY|grep-v$faculty_id,$TMP_FACULTY_DEL 167. #OverwritethefileFaculty.dat 168. mv$TMP_FACULTY_DEL$FILE_FACULTY169. msgDeleteInfoof$faculty_idsuccessfully!170. Studen

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服