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