-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
138 lines (135 loc) · 3.15 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <stdio.h>
#include<stdlib.h>
#include "structures.h"
#include "1.h"
#include "2.h"
#include "3.h"
#include "4.h"
#include "5.h"
#include "6.h"
//DO NOT FORGET TO UPDATE MASTER RECORD FOR FUNCTIONS 2 AND 3 <-------------------- IMPORTANT-----------------------------------
int main()
{
login();
int to_continue = 1;
while(to_continue != 0)
{
to_continue = display_menu();
if(to_continue == 1)
{
struct bill temp_bill;
system("clear");
FILE* fp2;
fp2 = fopen("store.txt","rb");
int m=0;
while(fread(&arr[m],sizeof(product),1,fp2))
{
m++;
}
fclose(fp2);
temp_bill = create_new_bill();
if(temp_bill.total_qty == 0)
{
delete_bill(temp_bill.bill_no);
}
else
{
display_bill(temp_bill);
update_master_record();
}
}
else if(to_continue == 2)
{
system("clear");
FILE* fp2;
fp2 = fopen("store.txt","rb");
int m=0;
while(fread(&arr[m],sizeof(product),1,fp2))
{
m++;
}
fclose(fp2);
int bill_to_delete;
printf("Enter bill number to delete : ");
scanf("%d",&bill_to_delete);
delete_bill(bill_to_delete);
update_master_record();
}
else if(to_continue == 3)
{
system("clear");
int bill_to_find;
printf("Please enter bill number to search for : ");
scanf("%d",&bill_to_find);
int is_found = find_bill(bill_to_find);
if(is_found == -2)
{
continue;
}
if(is_found == -1)
{
printf("\nBill with bill number %d does not exist !\n",bill_to_find);
}
else
{
display_bill(read_bill(is_found));
}
}
else if(to_continue == 4)
{
system("clear");
char cust_name[50];
printf("\nPlease enter customer name to search for : ");
scanf("%s",cust_name);
search_bill_by_name(cust_name);
}
else if(to_continue == 5)
{
system("clear");
find_max_sales();
}
else if(to_continue == 6)
{
system("clear");
find_min_sales();
}
else if(to_continue == 7)
{
system("clear");
display_sales_before();
}
else if(to_continue == 8)
{
system("clear");
display_sales_after();
}
else if(to_continue == 9)
{
system("clear");
display_sales_today();
}
else if(to_continue == 10)
{
system("clear");
display_master_record();
}
else if(to_continue == 11)
{
system("clear");
view_inventory();
}
else if(to_continue==0)
{
break;
}
else
{
system("clear");
printf("\nInvalid Option!! \nRe-enter your Option\n\n");
continue;
}
}
system("clear");
printf("\n\nThanks for using this Program !\n\n");
return 0;
}