Linux趣事 -- (2.3)学生信息管理系统

这篇是在前面两篇的基础上继续完善学生信息管理系统的功能。

(1)http://blog.csdn.net/wjf_1997/article/details/78474118
(2)http://blog.csdn.net/wjf_1997/article/details/78502039

实现的功能:删除

一、功能描述

删除功能从三个方面进行数据的删除,涉及到的函数有三个:

(1)delete_college_info():根据比较学院的编号进行删除

(2)delete_stu_info():根据比较学生的编号进行删除

(3)delete_stugrade_info():根据比较学生的编号进行删除

二、代码

2.1 delete_college_info()

delete_college_info(){
    show_college_info;
    echo "请输入要删除的学院的编号(若不存在,删除失败!):"
    read collegeNo
    export nowLine=0;
    while read line
    do 
        export  nowLine=$(($nowLine+1))
        nowCollegeNo=${line/,*/}
        if [ "$nowCollegeNo" = "$collegeNo" ]; then
        {
            sed "$nowLine"d $DBCollegeInfoPath > $DBCollegeInfoPath"_back"
            mv $DBCollegeInfoPath"_back" $DBCollegeInfoPath
            echo "删除成功!"
        }
        else
        {
            echo "删除失败!"
        }
        fi
    done<$DBCollegeInfoPath
    show_college_info;
}

2.2 delete_stu_info()

delete_stu_info(){
    show_stu_info;
    echo "请输出要删除学生的编号(若不存在,删除失败!):"
    read studentNo
    export nowLine=0;
    while read line
    do
        export nowLine=$(($nowLine+1))
        echo $line":"$nowLine
        lineStudentNo=${line/,*/}
        if [ "$lineStudentNo" = "$studentNo" ]; then
        {
            #echo $nowLine "是当前行"
            sed "$nowLine"d $DBStudentInfoPath > $DBStudentInfoPath"_back"
            export delCount=$(($delCount+1))
            mv $DBStudentInfoPath"_back" $DBStudentInfoPath
            echo "删除成功!"
        }
        else
        {
            echo "删除失败!"
        }
        fi

        done<$DBStudentInfoPath
        show_stu_info;
    }

2.3 delete_stugrade_info()

delete_stugrade_info(){
        show_stugrade_info;
        echo "请输出要删除学生的编号(若不存在,删除失败!):"
        read studentNo
        #export existFlag=false
        export nowLine=0;
        while read line
        do 
            export nowLine=$(($nowLine+1))
            lineStudentNo=${line/,*/}
            if [ "$lineStudentNo" = "$studentNo" ]; then
            {
                sed "$nowLine"d $DBStudentGradeInfoPath > $DBStudentGradeInfoPath"_back"
                mv $DBStudentGradeInfoPath"_back" $DBStudentGradeInfoPath
                echo "删除成功!"
            }
            else
            {
                echo "删除失败!"
            }
            fi
        done<$DBStudentGradeInfoPath

        #while read line
        #do 
        #   lineStudentNo=${line/,*/}
        #if [ "$lineStudentNo" = "$studentNo" ]; then 
        #{
        #   export existFlag=true
        #   break
        #}
        #fi
        #   done<$DBStudentInfoPath
        #if [ "$existFlag" = "true" ]; then
        #{
        #   export existFlag=false
        #   sed -i '/$studentNo/d' $DBStudentGradeInfoPath > $DBStudentGradeInfoPath"_back"
        #   mv $DBStudentGradeInfoPath"_back" $DBStudentGradeInfoPath
        #   echo "删除成功!"
        #   show_stugrade_info;
        #}
        #else {
        #   echo "删除失败!"
        #}
        show_stugrade_info;
    }

分析:
通过运行情况可以分析出,在成绩删除中会出现问题。删除的时候,同一个人的不同学科成绩没有办法正确的删除。(以后找到解决办法再处理)

参考资料:
(1)vim环境配置脚本,让你的心情愉快:
http://blog.csdn.net/mengyafei43/article/details/46559911
https://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html
https://www.cnblogs.com/oxspirt/p/6206787.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值