#! /bin/sh
insert_s()
{
file_name="/root/aillo/students.db"
dialog --title "Student: Insert a record " --inputbox "Please input the student's information in the sort:(id,name,college):" 20 50 2>tmp.txt
content=$(cat tmp.txt)
IFS=","
read sid sname sin
unset IFS
grep -c "$sid" $file_name>menu.txt
sid=$(cat menu.txt)
if [ "$sid" != "0" ];then
dialog --title "ERROR" --msgbox "Record has existed!" 20 30
else
echo "$content">>$file_name
dialog --title "Reply Info" --msgbox "Add successfully!" 10 30
fi
}
insert_c()
{
file_name="/root/aillo/colleges.db"
dialog --title "College: Insert a record " --inputbox "Please input the college's information in the sort(cid,cname):" 20 50 2>tmp.txt
content=$(cat tmp.txt)
IFS=","
read cid cname
unset IFS
grep -c "$cid" $file_name>tmp.txt
cid=$(cat tmp.txt)
if [ "$cid" != "0" ];then
dialog --title "ERROR" --msgbox "Record has existed!" 30 50
else
echo "$content">>$file_name
dialog --title "Reply Info" --msgbox "Add successfully!" 10 30</