update, not fin not runnable
This commit is contained in:
parent
a19fec0548
commit
ae074c42e6
22
admin_user.h
22
admin_user.h
@ -38,15 +38,13 @@ void admin_menu(){
|
|||||||
if(user == NULL){//invalid user
|
if(user == NULL){//invalid user
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Welcome %s(%s)\n", user->name,user->role);
|
char * Items[] = {
|
||||||
char * Items = {
|
|
||||||
"Inventory control",
|
"Inventory control",
|
||||||
"Transaction control",
|
"Transaction control",
|
||||||
"User control",
|
"User control",
|
||||||
"Role control",
|
"Role control",
|
||||||
};
|
};
|
||||||
choice = choices_selecter(Items,4)
|
switch (choices_selecter(Items,4,strcat("Welcome ")"""%s(%s)\n", user->name,user->role))
|
||||||
switch (choice)
|
|
||||||
{
|
{
|
||||||
case 1://action with inventory
|
case 1://action with inventory
|
||||||
inv_control();
|
inv_control();
|
||||||
@ -137,7 +135,7 @@ void inv_control(){
|
|||||||
do{
|
do{
|
||||||
choice = prompt_inv_control();
|
choice = prompt_inv_control();
|
||||||
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
|
||||||
//for item control
|
//for item control
|
||||||
struct inventory db = read_db_invt();
|
struct inventory db = read_db_invt();
|
||||||
@ -736,7 +734,7 @@ struct Map* sortTrans(struct transaction db,int choice){
|
|||||||
|
|
||||||
switch(choice){
|
switch(choice){
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:;
|
||||||
long long temp = (long long)db.row[i].time.second+ db.row[i].time.minute*60 + db.row[i].time.hour*3600 + db.row[i].date.day*86400 + db.row[i].date.month*2592000 + db.row[i].date.year*31104000;
|
long long temp = (long long)db.row[i].time.second+ db.row[i].time.minute*60 + db.row[i].time.hour*3600 + db.row[i].date.day*86400 + db.row[i].date.month*2592000 + db.row[i].date.year*31104000;
|
||||||
long long* tempstar = malloc(sizeof(long long));
|
long long* tempstar = malloc(sizeof(long long));
|
||||||
*tempstar = temp;
|
*tempstar = temp;
|
||||||
@ -744,19 +742,19 @@ struct Map* sortTrans(struct transaction db,int choice){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:;
|
||||||
long* tempstar2 = malloc(sizeof(long));
|
long* tempstar2 = malloc(sizeof(long));
|
||||||
*tempstar2 = db.row[i].barcode;
|
*tempstar2 = db.row[i].barcode;
|
||||||
map[i].value = (void*)tempstar2;
|
map[i].value = (void*)tempstar2;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:;
|
||||||
int* tempstar3 = malloc(sizeof(int));
|
int* tempstar3 = malloc(sizeof(int));
|
||||||
*tempstar3 = db.row[i].quantity;
|
*tempstar3 = db.row[i].quantity;
|
||||||
map[i].value = (void*)tempstar3;
|
map[i].value = (void*)tempstar3;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:;
|
||||||
long temp4 = lround(db.row[i].price * db.row[i].quantity * 10000);//clear all decimal places
|
long temp4 = lround(db.row[i].price * db.row[i].quantity * 10000);//clear all decimal places
|
||||||
long* tempstar4 = malloc(sizeof(long));
|
long* tempstar4 = malloc(sizeof(long));
|
||||||
*tempstar4 = temp4;
|
*tempstar4 = temp4;
|
||||||
@ -982,20 +980,20 @@ struct Map* sortUser(struct user db,int choice){
|
|||||||
map[i].key = i;
|
map[i].key = i;
|
||||||
switch(choice){
|
switch(choice){
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:;
|
||||||
char* temp = malloc(sizeof(char) * 100);
|
char* temp = malloc(sizeof(char) * 100);
|
||||||
strcpy(temp,db.row[i].name);
|
strcpy(temp,db.row[i].name);
|
||||||
map[i].value = (void*)temp;
|
map[i].value = (void*)temp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:;
|
||||||
char* temp2 = malloc(sizeof(char) * 100);
|
char* temp2 = malloc(sizeof(char) * 100);
|
||||||
strcpy(temp2,db.row[i].role);
|
strcpy(temp2,db.row[i].role);
|
||||||
map[i].value = (void*)temp2;
|
map[i].value = (void*)temp2;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:;
|
||||||
long* tempstar3 = malloc(sizeof(long));
|
long* tempstar3 = malloc(sizeof(long));
|
||||||
*tempstar3 = db.row[i].id;
|
*tempstar3 = db.row[i].id;
|
||||||
map[i].value = (void*)tempstar3;
|
map[i].value = (void*)tempstar3;
|
||||||
|
3
main.c
3
main.c
@ -8,6 +8,7 @@
|
|||||||
#include<math.h>
|
#include<math.h>
|
||||||
#include<time.h>
|
#include<time.h>
|
||||||
#include<ctype.h>
|
#include<ctype.h>
|
||||||
|
#include <stddef.h>
|
||||||
#endif
|
#endif
|
||||||
#ifndef CUSTOM_H
|
#ifndef CUSTOM_H
|
||||||
#define CUSTOM_H
|
#define CUSTOM_H
|
||||||
@ -60,4 +61,4 @@ int main(){
|
|||||||
} while (check);
|
} while (check);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -208,9 +208,9 @@ struct Map* sortItems(struct inventory db, int sort){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:;
|
||||||
long price = db.row[i].price * 100;
|
double price = db.row[i].price * 100;
|
||||||
long * price_star = malloc(sizeof(long));
|
double * price_star = malloc(sizeof(long));
|
||||||
*price_star = price;
|
*price_star = price;
|
||||||
map[i].value = (void*)price_star;//presume there is no price contain 0.001
|
map[i].value = (void*)price_star;//presume there is no price contain 0.001
|
||||||
break;
|
break;
|
||||||
|
14
utils.h
14
utils.h
@ -1,10 +1,14 @@
|
|||||||
int choices_selecter(char * Items,int items) {
|
int choices_selecter(char * Items[],int items,char * welcome_message ){
|
||||||
int choice =0
|
int choice = 0;
|
||||||
do{
|
do{
|
||||||
printf("Select An Option:");
|
system("cls");
|
||||||
|
if ((*welcome_message) !=NULL){
|
||||||
|
printf("%s",welcome_message)
|
||||||
|
}
|
||||||
|
printf("Select An Option:\n");
|
||||||
int i;
|
int i;
|
||||||
for (i=0, i<items;i++){
|
for (i=0; i<items;i++){
|
||||||
print("%d. %s\n",i+1,Items[i]);
|
printf("%d. %s\n",i+1,Items[i]);
|
||||||
}
|
}
|
||||||
printf("%d. Exit\n",i+1);
|
printf("%d. Exit\n",i+1);
|
||||||
printf(">");
|
printf(">");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user