-
Notifications
You must be signed in to change notification settings - Fork 0
/
sale.h
210 lines (198 loc) · 4.57 KB
/
sale.h
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include<stdio.h>
#include<conio.h>
#include<time.h>
void rsale()
{
char nam[20],cnf,exp[14],senam[20];
float price,tprice;
int quan,option=1,unit,bno,bn,coun=0,i,response,fd,fm,fy;
FILE *fh,*fs;
//time start
int d,m,y;
time_t k;
time(&k);
struct tm *local=localtime(&k);
d=local->tm_mday;
m=local->tm_mon +1;
y=local->tm_year +1900;
//time end
system("cls");
gotoxy(50,0);
printf("Welcome to Medical Store");
gotoxy(20,2);
printf("Medicine sale prompt");
gotoxy(19,3);
for(i=0;i<36;i++)
{
printf("-");
}
gotoxy(20,4);
printf("Please select the option [1/2] ");
gotoxy(20,5);
for(i=0;i<30;i++)
printf("-");
gotoxy(20,6);
printf("1.Sale Medicine by name");
gotoxy(20,7);
printf("2.Sale Medicine by batch no");
gotoxy(20,8);
printf("0.Main menu");
response=(int)getch();
system("cls");
while(option)
{
price=0,tprice=0;
fh=fopen("medlist.txt","r");
system("cls");
gotoxy(50,0);
printf("Welcome to Medical Store");
gotoxy(20,2);
printf("Medicine sale prompt");
gotoxy(19,3);
for(i=0;i<36;i++)
{
printf("-");
}
gotoxy(20,5);
printf("Enter Batch no. : ");
gotoxy(20,7);
printf("Name of Medicine : ");
gotoxy(20,9);
printf("Price per tab: ");
gotoxy(20,11);
printf("Enter Quantity : ");
gotoxy(20,13);
printf("Enter expiry date: ");
gotoxy(20,15);
printf("Total price : ");
if(response==49)
{
gotoxy(45,7);
scanf("%s",&senam);
while(fscanf(fh,"%i %s %f %i %i %i %i",&bn,&nam,&price,&fd,&fm,&fy,&unit)!=EOF)
{
if(strcmp(strupr(senam),strupr(nam)))
{
}
else
{
gotoxy(45,5);
printf("%i",bn);
gotoxy(45,9);
printf("%.2f",price);
gotoxy(45,13);
printf("%i-%i-%i",fd,fm,fy);
coun++;
break;
}
}
if(coun==0)
{
gotoxy(45,5);
scanf("%i",&bno);
price=0;
gotoxy(45,9);
scanf("%f",&price);
gotoxy(45,11);
scanf("%i",&quan);
tprice=price*quan;
gotoxy(45,15);
printf("%.2f",tprice);
gotoxy(45,13);
scanf("%s",&exp);
}
else{
gotoxy(45,11);
scanf("%i",&quan);
tprice=price*quan;
gotoxy(45,15);
printf("%.2f",tprice);
getch();
coun=0;
fclose(fh);
}
}
else if(response==50)
{
gotoxy(45,5);
scanf("%i",&bno);
while(fscanf(fh,"%i %s %f %i %i %i %i",&bn,&nam,&price,&fd,&fm,&fy,&unit)!=EOF)
{
if(bn==bno)
{
//printf("%i %s %f %s %i",bn,nam,price,exp,unit);
gotoxy(45,7);
printf("%s",nam);
gotoxy(45,9);
printf("%.2f",price);
gotoxy(45,13);
printf("%i-%i-%i",fd,fm,fy);
coun++;
break;
}
}
if(coun==0)
{
gotoxy(45,7);
scanf("%s",&nam);
price=0;
gotoxy(45,9);
scanf("%f",&price);
gotoxy(45,11);
scanf("%i",&quan);
tprice=price*quan;
gotoxy(45,15);
printf("%.2f",tprice);
gotoxy(45,13);
scanf("%s",&exp);
}
else
{
gotoxy(45,11);
scanf("%i",&quan);
tprice=quan*price;
gotoxy(45,15);
printf("%.2f",tprice);
getch();
gotoxy(20,14);
coun=0;
fclose(fh);
}
}
else if(response==48)
{
main();
}
else
{
system("cls");
gotoxy(20,7);
printf("Oops that was an invalid option (Try[1/2/0])");
getch();
rsale();
}
gotoxy(20,18);
fflush(stdin);
printf("Do you want to record this sale[Y/N] : ");
scanf("%c",&cnf);
if(cnf=='y'||cnf=='Y')
{
//do here coding stuff
fs=fopen("medsale.txt","a");
fprintf(fs,"%i %s %.2f %i %i %i %i %.2f %i %i %i\n",bn,nam,price,fd,fm,fy,quan,tprice,d,m,y);
fclose(fs);
gotoxy(20,20);
printf("Sale recorded sucessfully ");
getch();
main();
}
else
{
gotoxy(20,20);
printf("Sale recording aborted ");
getch();
main();
}
getch();
}
}