Compare commits
2 Commits
9532657455
...
87840349db
Author | SHA1 | Date | |
---|---|---|---|
87840349db | |||
314e3c7ae3 |
@ -15,7 +15,7 @@ void inv_control(){
|
|||||||
"List(allow all operation include add)",
|
"List(allow all operation include add)",
|
||||||
"Add item(shortcut to add item)"
|
"Add item(shortcut to add item)"
|
||||||
};
|
};
|
||||||
choice = choices_selecter(items,2,NULL);
|
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\nInventory control\n");
|
||||||
switch (choice){
|
switch (choice){
|
||||||
case 1:;//list
|
case 1:;//list
|
||||||
//add a new element with product name new item
|
//add a new element with product name new item
|
||||||
|
@ -31,7 +31,7 @@ void normal_menu(){
|
|||||||
"Search item",
|
"Search item",
|
||||||
"Self help sale system"
|
"Self help sale system"
|
||||||
};
|
};
|
||||||
choice = choices_selecter(items,3,"><Welcome to the Student Union POS system><\nNormal User Menu");
|
choice = choices_selecter(items,3,"><Welcome to the Student Union POS system><\nNormal User Menu\n");
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case 1://List items
|
case 1://List items
|
||||||
@ -86,7 +86,7 @@ void search_item(){
|
|||||||
char * items[] = {
|
char * items[] = {
|
||||||
"search"
|
"search"
|
||||||
};
|
};
|
||||||
breakout = choices_selecter(items,1,"><Welcome to the Student Union POS system><");
|
breakout = choices_selecter(items,1,"><Welcome to the Student Union POS system><\n");
|
||||||
if(breakout == 2){
|
if(breakout == 2){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ void self_help_sale_system(){
|
|||||||
"scan barcode",
|
"scan barcode",
|
||||||
"cart/checkout"
|
"cart/checkout"
|
||||||
};
|
};
|
||||||
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><");
|
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\n");
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
//role control
|
//role control
|
||||||
void add_role();
|
void add_role();
|
||||||
void list_role();
|
|
||||||
void print_role(struct linkedlist* list,int cur,int end,struct Map* map);
|
void print_role(struct linkedlist* list,int cur,int end,struct Map* map);
|
||||||
void showRole(struct linkedlist* list,int index);
|
void showRole(struct linkedlist* list,int index);
|
||||||
struct Map* sortRole(struct linkedlist* list,int choice);
|
struct Map* sortRole(struct linkedlist* list,int choice);
|
||||||
@ -14,9 +13,9 @@ void role_control(){
|
|||||||
"add admin role",
|
"add admin role",
|
||||||
"list role"
|
"list role"
|
||||||
};
|
};
|
||||||
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\nRole control");
|
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\nRole control\n");
|
||||||
switch (choice){
|
switch (choice){
|
||||||
case 0:
|
case 3:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
add_role();
|
add_role();
|
||||||
@ -27,13 +26,13 @@ void role_control(){
|
|||||||
"role",
|
"role",
|
||||||
};
|
};
|
||||||
void * list = getLinkedList(role_list_db(),0);
|
void * list = getLinkedList(role_list_db(),0);
|
||||||
// lister(list,NULL,sizeofLinkedlist(list),"Role",SortItems,2,print_role,sortRole,showRole);
|
lister(list,NULL,sizeofLinkedlist(list),"Role",SortItems,2,print_role,sortRole,showRole);
|
||||||
list_role(db);
|
//warning appears but can be ignore due to the fact that they are just pointer, no difference
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(choice != 0);
|
}while(choice != 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,85 +56,6 @@ void add_role(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void list_role(){
|
|
||||||
struct linkedlist* list = getLinkedList(role_list_db(),0);
|
|
||||||
int list_size = sizeofLinkedlist(list);
|
|
||||||
int choice = -1;
|
|
||||||
int page = 0;
|
|
||||||
int page_size = PAGE_SIZE;
|
|
||||||
int total_pages = ceil( (double)list_size / page_size);
|
|
||||||
struct Map* map = NULL;
|
|
||||||
//list role
|
|
||||||
do{
|
|
||||||
Cls();
|
|
||||||
welcome_message();
|
|
||||||
printf("Role list\n");
|
|
||||||
printf("0 exit\n");
|
|
||||||
printf("1 sort admin ascending\n");
|
|
||||||
printf("2 sort admin descending\n");
|
|
||||||
printf("3 sort role ascending\n");
|
|
||||||
printf("4 sort role descending\n");
|
|
||||||
if(page+1 == total_pages){
|
|
||||||
print_role(list,page*page_size,list_size,map);
|
|
||||||
}else{
|
|
||||||
print_role(list,page*page_size,(page+1)*page_size,map);
|
|
||||||
}
|
|
||||||
//page control
|
|
||||||
int current_page_size = page_size+2;
|
|
||||||
if(page+1 == total_pages){
|
|
||||||
current_page_size = list_size - page*page_size + 4;
|
|
||||||
}
|
|
||||||
printf("%d next page\n",current_page_size+1);
|
|
||||||
printf("%d previous page\n",current_page_size+2);
|
|
||||||
printf("%d set page size\n",current_page_size+3);
|
|
||||||
printf("%d/%d/%d(page size/page number/total)\n",page_size,page+1,total_pages);
|
|
||||||
|
|
||||||
bool valid = true;
|
|
||||||
do{
|
|
||||||
valid = true;
|
|
||||||
printf("Please input your choice\n>");
|
|
||||||
fflush_stdin();
|
|
||||||
scanf("%d", &choice);
|
|
||||||
if(choice <=4 && choice > 0){
|
|
||||||
printf("sorting...\n");
|
|
||||||
map = sortRole(list,choice);
|
|
||||||
}else if(choice == current_page_size+1){
|
|
||||||
if(page + 1 < total_pages){
|
|
||||||
page++;
|
|
||||||
}else{
|
|
||||||
printf("Already at last page\n");
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}else if(choice == current_page_size+2){
|
|
||||||
if(page > 0){
|
|
||||||
page--;
|
|
||||||
}else{
|
|
||||||
printf("Already at first page\n");
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}else if(choice == current_page_size+3){
|
|
||||||
printf("Enter page size: ");
|
|
||||||
fflush_stdin();
|
|
||||||
scanf("%d", &page_size);
|
|
||||||
total_pages = ceil( (double)list_size / page_size);
|
|
||||||
page = 0;
|
|
||||||
|
|
||||||
}else if(choice >= 5 && choice <= current_page_size){
|
|
||||||
if(map == NULL){
|
|
||||||
showRole(list,choice - 5 + page_size*page);
|
|
||||||
}else{
|
|
||||||
showRole(list,map[choice - 5 + page_size*page].key);
|
|
||||||
}
|
|
||||||
}else if(choice != 0){
|
|
||||||
printf("Invalid choice\n");
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}while(!valid);
|
|
||||||
}while(choice != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_role(struct linkedlist* list,int cur,int end,struct Map* map){
|
void print_role(struct linkedlist* list,int cur,int end,struct Map* map){
|
||||||
printf("%-10s%-10s%-10s\n","No.","Role","Admin?");
|
printf("%-10s%-10s%-10s\n","No.","Role","Admin?");
|
||||||
if(map == NULL){
|
if(map == NULL){
|
||||||
|
@ -12,7 +12,7 @@ void tran_control(){
|
|||||||
"List transaction",
|
"List transaction",
|
||||||
"new transaction"
|
"new transaction"
|
||||||
};
|
};
|
||||||
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\nTransaction control");
|
choice = choices_selecter(items,2,"><Welcome to the Student Union POS system><\nTransaction control\n");
|
||||||
switch(choice){
|
switch(choice){
|
||||||
case 1:
|
case 1:
|
||||||
char * SortItems[] = {
|
char * SortItems[] = {
|
||||||
|
@ -10,13 +10,10 @@ void user_control(){
|
|||||||
int choice = 0;
|
int choice = 0;
|
||||||
while(choice != 3){
|
while(choice != 3){
|
||||||
Cls();
|
Cls();
|
||||||
printf("User Control\n");
|
choice = choices_selecter((char*[]){
|
||||||
printf("1. Add User(shortcut)\n");
|
"Add user",
|
||||||
printf("2. List User\n");
|
"List user",
|
||||||
printf("3. Exit\n");
|
},3,"><Welcome to the Student Union POS system><\nUser control\n");
|
||||||
printf("Please input your choice\n>");
|
|
||||||
fflush_stdin();
|
|
||||||
scanf("%d",&choice);
|
|
||||||
switch(choice){
|
switch(choice){
|
||||||
case 1:
|
case 1:
|
||||||
db = add_user(db);
|
db = add_user(db);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user