Skip to content

Commit dcfb2a3

Browse files
author
Biswajit Behera
committed
Added sales_order_system by Biswajit-Behera
1 parent 2717a2c commit dcfb2a3

File tree

9 files changed

+179
-0
lines changed

9 files changed

+179
-0
lines changed

sales_order_system/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# School-projects

sales_order_system/mainmenu.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
clear
2+
i="y"
3+
while [ $i = "y" ]; do
4+
clear
5+
tput setaf 3
6+
tput cup 2 20; echo "--------------------------------"
7+
tput cup 3 20; echo "-------- Main Menu -----------"
8+
tput cup 4 20; echo "--------------------------------"
9+
tput cup 5 20; echo "------- 1. TRANSACTION ------"
10+
tput cup 6 20; echo "------- 2. SEARCH ------"
11+
tput cup 7 20; echo "------- 3. REPORT ------"
12+
tput cup 8 20; echo "------- 4. QUIT ------"
13+
tput cup 9 20; echo "--------------------------------"
14+
tput cup 10 20; echo -n " SELECT AN OPTION : "
15+
read option
16+
tput cup 11 20; echo "--------------------------------"
17+
case $option in
18+
1) sh transaction.sh ;;
19+
2) sh search_order.sh ;;
20+
3) sh report.sh ;;
21+
4) exit ;;
22+
*) tput cup 12 20; echo "Invalid option....Quitting"
23+
sleep 1
24+
exit ;;
25+
esac
26+
tput cup 13 20; echo -n "Do you want to continue(y/n)? "
27+
read i
28+
if [ $i != "y" ]; then
29+
tput cup 14 20; echo "Quitting the program..."
30+
sleep 1
31+
exit
32+
fi
33+
done

sales_order_system/new_order.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
clear
2+
i="y"
3+
while [ $i = "y" ]; do
4+
clear
5+
line_no=`wc -l orders.txt | cut -d" " -f1`
6+
if [ $line_no = 0 ]
7+
then
8+
order_no=10001
9+
else
10+
order_no=`tail -1 orders.txt | cut -d":" -f1`
11+
order_no=`expr $order_no + 1`
12+
fi
13+
order_date=`date +%D`
14+
echo "Date de commande: $order_date"
15+
echo "New commande number: $order_no"
16+
echo -n "Enter First Name: "
17+
read first_name
18+
echo -n "Enter Last Name: "
19+
read last_name
20+
echo -n "Enter Article: "
21+
read article
22+
echo -n "Enter Quantity: "
23+
read quantity
24+
echo -n "Enter Price: "
25+
read price
26+
echo "$order_no : $first_name $last_name : $article : $quantity : $price : $order_date" >> orders.txt
27+
echo -n "Do you want to add new order(y/n)? "
28+
read i
29+
if [ $i != "y" ]; then
30+
exit
31+
fi
32+
done

sales_order_system/orders.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
10001 : Ousseynou Diop : Savon : 2 : 800 : 01/01/20
2+
10002 : Modou Diop : Livre Python : 1 : 15000 : 01/01/20
3+
10003 : Absa Yam :Savon feminin:4: 178999 : 01/01/20

sales_order_system/report.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
clear
2+
echo "| ---------------------------------------------------------------------------- |"
3+
echo "| SALES ORDER SYSTEM |"
4+
echo "| ---------------------------------------------------------------------------- |"
5+
echo "| ORDER_NO | CLIENT | ARTICLE | QUANTITE | PRIX | DATE DE COMMANDE |"
6+
n=6
7+
while read line;
8+
do
9+
sleep 1
10+
tput cup $n; echo "| `echo $line | cut -d":" -f1` "
11+
tput cup $n 11; echo "| `echo $line | cut -d":" -f2` "
12+
tput cup $n 30; echo "| `echo $line | cut -d":" -f3` "
13+
tput cup $n 47; echo "| `echo $line | cut -d":" -f4` "
14+
tput cup $n 55; echo "| `echo $line | cut -d":" -f5` "
15+
tput cup $n 67; echo "| `echo $line | cut -d":" -f6` "
16+
tput cup $n 78; echo " | "
17+
n=`expr $n + 1`
18+
done < orders.txt
19+
# `sort -t ":" -k3 orders.txt`
20+
echo "| ---------------------------------------------------------------------------- |"

sales_order_system/sales_order.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
clear
2+
tput cup setaf 3
3+
tput cup 5 20; echo "--------------------------------"
4+
tput cup 6 20; echo "-- Sales order system --"
5+
tput cup 7 20; echo "--------------------------------"
6+
tput cup 8 20; echo "--------------------------------"
7+
tput cup 9 20; echo -n "Username : "
8+
read usrnm
9+
tput cup 10 20; echo -n "Password : "
10+
read psswd
11+
if test $usrnm = "admin" -a $psswd = "diopdiop"; then
12+
tput cup 11 20; echo "REGISTRATION SUCCESSFUL..."
13+
sleep 1
14+
sh mainmenu.sh
15+
else
16+
tput cup 12 20; echo "REGISTRATION FAILED, Try again..."
17+
sleep 1
18+
sh sales_order.sh
19+
fi

sales_order_system/search_order.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
clear
2+
echo "SEARCH AN ORDER"
3+
echo -n "Enter order number: "
4+
read order_no
5+
line=`grep -n $order_no orders.txt | wc -l`
6+
if [ $line -gt 0 ]
7+
then
8+
line=`grep -n $order_no orders.txt`
9+
echo "--------------------------------"
10+
echo "Order No : `echo $line | cut -d":" -f2` "
11+
echo "Client : `echo $line | cut -d":" -f3` "
12+
echo "Article : `echo $line | cut -d":" -f4` "
13+
echo "Quantity : `echo $line | cut -d":" -f5` "
14+
echo "Price : `echo $line | cut -d":" -f6` "
15+
echo "Order Date : `echo $line | cut -d":" -f7` "
16+
echo "--------------------------------"
17+
else
18+
echo "Invalid option...."
19+
fi

sales_order_system/transaction.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
clear
2+
i="y"
3+
while [ $i = "y" ]; do
4+
clear
5+
tput setaf 3
6+
tput cup 2 20; echo "--------------------------------"
7+
tput cup 3 20; echo "------ TRANSACTION Menu -------"
8+
tput cup 4 20; echo "--------------------------------"
9+
tput cup 5 20; echo "------- 1. NEW ORDER ------"
10+
tput cup 6 20; echo "------- 2. UPDATE ORDER ------"
11+
tput cup 7 20; echo "------- 3. QUIT ------"
12+
tput cup 8 20; echo "--------------------------------"
13+
tput cup 9 20; echo -n "---- SELECT AN OPTION : "
14+
read option
15+
tput cup 10 20; echo "-------------------------------"
16+
case $option in
17+
1) sh new_order.sh ;;
18+
2) sh update_order.sh ;;
19+
3) exit ;;
20+
*) tput cup 11 20; echo "Invalid option....Quitting"
21+
sleep 1
22+
exit ;;
23+
esac
24+
tput cup 12 20; echo -n "Return to transaction menu(y/n)? "
25+
read i
26+
if [ $i != "y" ]; then
27+
echo "Quitting the program..."
28+
sleep 1
29+
exit
30+
fi
31+
done

sales_order_system/update_order.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
clear
2+
echo "UPDATE AN ORDER"
3+
echo -n "Enter order number: "
4+
read order_no
5+
chk=`grep -c $order_no orders.txt`
6+
if [ $chk -gt 0 ]
7+
then
8+
line=`grep -n $order_no orders.txt`
9+
line_no=`echo $line | cut -d":" -f1`
10+
old_quantity=`echo $line | cut -d":" -f5`
11+
echo "The order is: "
12+
echo $line
13+
else
14+
echo "Invalide order number"
15+
exit
16+
fi
17+
echo "Update forms"
18+
echo -n "Enter new quantity : "
19+
read new_quantity
20+
sed "$line_no s/$old_quantity/$new_quantity/" "orders.txt" > file.tmp && mv file.tmp "orders.txt"
21+
echo "Order quantity updated successfully!"

0 commit comments

Comments
 (0)