-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
2917 lines (2521 loc) · 81.2 KB
/
main.c
File metadata and controls
2917 lines (2521 loc) · 81.2 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Windows.h>
int survey(char type[],char name[]);
int submit();
int login();
void seller(char nameseller[]);
void customer(char namecustomer[]);
int sell(int price);
void admin(void);
void ssort(char thing[],char nameseller[]);
//void search (file,char c[]);
void basket(char namecu[]);
void Purchasedgoods(char namecu[]);
void specification(char name[],char familyname[]);//send file of customer or name
//void showbuy(char c[]);
void newgood();//send file the seller
void soldgood(char type[],char name[]);//send file of customer or boss
void boss(char nameboss[]);
void bossmangerin(char c[],char nameboss);
void usres(char c[]);//send file of boss
void comment(char sellername[],char type[]);
void defineidcard(void);
void transfer (char nameseller[]);
int karmozd;
typedef struct opinions
{
char opinion[100];
int year;
int mounth;
int day;
int hour;
char name[100];
char nameseller[100];
} opinions;
typedef struct goodprofile//seller
{
char name[100];
int price;
char explanation[100];
int num;
char type[100];
int score;
char nameseller[100];
int id;
char status[50];
} good;
typedef struct member//submit
{
char name[100];
char username[100];
char password[100];
char phonenumber[15];
char type[100];
char homeaddrese[100];
char workaddrese[100];
char status[50];
} memb;
typedef struct basket
{
char status[100];
char name[100];
char namecustomer[100];
char nameseller[100];
int numbergood;
int price;
int year;
int mounth;
int day;
int hour;
int minute;
} baskets;
typedef struct card
{
char id[100];
char netpass[100];
char user[100];
int mojody;
char type[50];
} card;
typedef struct discount
{
char idcard[50];
int year;
int mounth;
int day;
int hour;
int percent;
} dis;
int price=100;
int timerecived=1;
int main()
{
FILE *ptr=fopen("good.bin","a+b");
FILE *ptt=fopen("memberspe.bin","a+b");
FILE *Ptc=fopen("comment.bin","a+b");
FILE *boosdis=fopen("dicount.bin","a+b");
FILE *idcard=fopen("idcard.txt","a+");
FILE *pmk=fopen ("basknotpay.bin", "a+b");
loop:
system("color b0");
system("cls");
printf("Welcome to the main page of shop \n");
printf("please inter the number of section you want:))\n");
puts("1-for surving number 1\n2-for register number 2\n3-for login number 3\n4-for define card num 4");
int a;
scanf("%d",&a);
switch(a)
{
case 1:
survey("guest","");
break;
case 2:
submit();
break;
case 3:
login();
break;
case 4:
defineidcard();
break;
}
return 0;
}
int submit(void)
{
memb mem;
FILE *ptr=fopen("memberspe.bin","a+b");
system("color e1");
system("cls");
char v[50];
gets(v);
//in thi50s place i think we must use file in the past copmplete
printf("welcome to the submit section\nplease inter your name and family name");
gets(mem.name);
puts("user name ");
gets(mem.username);
puts("password");
gets(mem.password);
puts("phone numer");
gets(mem.phonenumber);
printf("are you customer or seller .if you are customer inter 0,if seller 1 for boss num 2;");
int d;
scanf("%d",&d);
char c[20];
gets(c);
if(d==0)
{
strcpy(mem.type,"customer");
printf("plese inter your home address ");
gets(mem.homeaddrese);
}
else if(d==1)
{
strcpy(mem.type,"seller");
printf("plese inter work address");
gets(mem.workaddrese);
}
else if(d==2)
{
strcpy(mem.type,"boss");
printf("plese inter work address");
gets(mem.workaddrese);
}
int x=fwrite(&mem,sizeof(struct member),1,ptr);
if(x==NULL)
{
printf("sorry your spefication dont save please inter again");
submit();
}
fclose(ptr);
printf("if you want back to main menu inter 1");
int back;
scanf("%d",&back);
if(back)
{
return main();
}
}
int login()
{
//openn file declare in submit
FILE *ptr=fopen("memberspe.bin","a+b");
char username[1000];
printf("plese inter your username");
char c[50];
gets(c);
gets(username);
printf("plese inter your password");
char password[1000];
gets(password);
memb members;
printf("please inter your type");
char type[50];
gets(type);
///customer(file or name of the file)||seller(file or name of file)
fseek (ptr,-sizeof (struct member), SEEK_SET);
if (ptr)
{
while(fread(&members, sizeof (struct member), 1, ptr)!=0) ///ok shod
{
if(strcmp(password,members.password)==0&&strcmp(username,members.username)==0&&strcmp(type,members.type)==0)
{
if(strcmp(members.type,"customer")==0)
{
customer(members.name);
}
else if(strcmp(members.type,"seller")==0)
{
seller(members.name);
}
else if(strcmp(members.type,"boss")==0)
{
boss(members.name);
}
}
}
fclose (ptr);
}
else
{
printf("sorry your username or password isnt true please inter again");
}
}
void customer(char namecustomer[])
//must send stucture that have Specifications seller
{
system("color a1");
system("cls");
printf("welcome to the customer section\n for surving number1\nfor see what you buyed and Non-delivered purchases number2\n for changing Specifications number3\nand for see shop list numer4\n back to the main page num 5\n");
printf("for exist number -1");
int a;
scanf("%d",&a);
switch(a)
{
case 1:
survey("customer",namecustomer);///see good /addcomment /search good /buygood just add
break;
case 2:
Purchasedgoods(namecustomer);///see recived and unrecived good
break;
case 3:
specification(namecustomer,"");///change spefication
//send the file or name of customer to open the file
//change address ,username and...with structure send to function
break;
case 4:
basket(namecustomer);///complete buy or remove good
break;
case 5:
main();
}
}
void seller(char nameseller[])
{
system("color a1");
system("cls");
printf("welcome to the seller page");
puts("for add goods and sorting num1\nsee what you sold num2\n see opnions num6\nchange Specifications num 3\n surving num4\nTransfer to account num5 ");
//open file seller have link list for selles
//open comment file
int a;
scanf("%d",&a);
switch(a)
{
case 1:
newgood(nameseller);///add new good for sell(seller) add sort
break;
case 2:
soldgood("seller",nameseller);///kalahay frokhte shode
break;
case 3:
specification(nameseller,"");//send file of seller
break;
case 4:
survey("guest",nameseller);///see good
break;
case 5:
transfer(nameseller);///esafe kardan kard
break;
case 6:
comment(nameseller,"seller");///sort by history
break;
}
}
void comment(char sellername[],char type[])///sort comments based history
{
if(strcmp(type,"seller")==0)
{
opinions opin;
FILE *fptr=fopen("comment.bin","a+b");
int p[5][1000];
int i=0;
int temp;
int j=0;
int n=0;
while(fread(&opin, sizeof (struct opinions), 1, fptr)!=NULL) ///ok shod
{
if(strcmp(sellername,opin.nameseller)==0)///sort by history
{
p[0][n]=i;
p[1][n]=opin.day;
p[2][n]=opin.hour;
p[3][n]=opin.mounth;
p[4][n]=opin.year;
n++;
}
i++;
}
for(i=0; i<n; i++)
{
for(j=i; j<=n; j++)
{
if((p[4][i]<p[4][j])||(p[4][i]==p[4][j]&&p[3][i]<p[3][j])||(p[4][i]==p[4][j]&&p[3][i]==p[3][j]&&p[2][i]<p[2][j])||(p[4][i]==p[4][j]&&p[3][i]==p[3][j]&&p[2][i]<p[2][j]&&p[1][i]<p[1][j]))
{
temp=p[0][j];
p[0][j]=p[0][i];
p[0][i]=temp;
}
}
}
fclose(fptr);
for(j=0; j<=n; j++)
{
FILE *pte=fopen("comment.bin","a+b");
fseek (pte,-sizeof (struct opinions), SEEK_SET);
i=0;
while(fread(&opin, sizeof (struct opinions), 1, pte)!=NULL) ///ok shod
{
if(p[0][j]==i)
{
printf(" %d %d %d %d \n",opin.hour,opin.day,opin.mounth,opin.year);
}
i++;
}
fclose(pte);
}
}
if(strcmp(type,"boss")==0)///sort comment by history
{
opinions opin;
FILE *fptrbo=fopen("comment.bin","a+b");
int p[5][1000];
int i=0;
int temp;
int j=0;
int n=0;
while(fread(&opin, sizeof (struct opinions), 1, fptrbo)!=NULL) ///ok shod
{
p[0][i]=i;
p[1][i]=opin.day;
p[2][i]=opin.hour;
p[3][i]=opin.mounth;
p[4][i]=opin.year;
n++;
i++;
}
for(i=0; i<n; i++)
{
for(j=i; j<=n; j++)
{
if((p[4][i]<p[4][j])||(p[4][i]==p[4][j]&&p[3][i]<p[3][j])||(p[4][i]==p[4][j]&&p[3][i]==p[3][j]&&p[2][i]<p[2][j])||(p[4][i]==p[4][j]&&p[3][i]==p[3][j]&&p[2][i]<p[2][j]&&p[1][i]<p[1][j]))
{
temp=p[0][j];
p[0][j]=p[0][i];
p[0][i]=temp;
}
}
}
fseek(fptrbo,-sizeof(struct opinions),1);
fclose(fptrbo);
for(j=0; j<=n; j++)
{
FILE *pteboos=fopen("comment.bin","a+b");
fseek (pteboos,-sizeof (struct opinions), SEEK_SET);
i=0;
while(fread(&opin, sizeof (struct opinions), 1, pteboos)!=NULL) ///ok shod
{
if(p[0][j]==i)
{
printf(" %s %d %d %d %d \n",opin.opinion,opin.hour,opin.day,opin.mounth,opin.year);
}
i++;
}
fclose(pteboos);
}
}
printf("if you want to add comment num 1 ");
int c;
scanf("%d",&c);
if(c==1)///add comment
{
opinions opin;
good goods;
FILE *ptc=fopen("comment.bin","a+b");
printf("please inter comment");
gets(opin.opinion);
printf("please inter name of good you want to add");
getc(opin.name);///or
int idgoods;
int o=0;
puts("please inter id good you want to comment ");
scanf("%d",&idgoods);
FILE *ppp=fopen ("good.bin", "a+b");
fseek (ppp,-sizeof (struct goodprofile), SEEK_SET);
if (ppp)
{
while(fread(&goods, sizeof (struct goodprofile), 1, ppp)!=NULL) ///ok shod
{
if(o==idgoods)
{
break;
}
o++;
}
strcpy(opin.name,goods.name);
}
SYSTEMTIME time;
GetSystemTime(&time);
opin.day=time.wDay;
opin.hour=time.wHour;
opin.year=time.wYear;
opin.mounth=time.wMonth;
strcpy(sellername,opin.nameseller);
fwrite(&opin,sizeof (struct opinions), 1, ptc);
fclose(ptc);
fclose (ppp);
}
}
void boss(char nameboss[])
{
system("color e3");
system("cls");
//open file for boss have link list for discount code ,all sold goods and time and percent of every sell
//maby need to create a file just for sold goods and then divide it with name of every seller and for boss show all of them
printf("for create discount num1\nsee all users num 2\nsee all comments num 3/nsee sales num 4\nsee unrecived good num 5");
int a;
scanf("%d",&a);
switch(a)
{
case 1:
bossmangerin("discountkode",nameboss);///add discode
break;
case 2:
user();///delete seller //decrese num good
break;
case 3:
comment(nameboss,"boss");///sort comment &&add comment
break;
case 4:
soldgood("boss",nameboss);///see boss good and all seller good
break;
case 5:
bossmangerin("unrecived",nameboss);///peygiri unrecived bask
}
}
void bossmangerin(char c[],char nameboss)
{
if (strcmp(c,"discountkode")==0)
{
//open boss file declare code and ... in it
printf("if you want to declare discount code num 1\n to declare time to cancel order num2\nwage of order num 3\n to back num -1or 4");
int a;
do
{
scanf("%d",&a);
char g;
gets(g);
if(a==1)
{
FILE *ptr=fopen("dicount.bin","a+b");///add discode
dis discode;
printf("idcard");
scanf("%s",discode.idcard);
printf("year\n");
scanf("%d",&discode.year);
printf("mounth\n");
scanf("%d",&discode.mounth);
printf("day\n");
scanf("%d",&discode.day);
printf("hour\n");
scanf("%d",&discode.hour);
fwrite(&discode,sizeof(struct discount),1,ptr);
fclose(ptr);
}
if(a==2)
{
printf("please inter time recived");
scanf("%d",&timerecived);
}
if(a==3)
{
printf("please inter wage for evry sell");
scanf("%d",&karmozd);
}
if(a==4)
{
boss(nameboss);
}
break;
}
while(a!=-1);
}
else if(c=="unrecived")///peygiri unrecived bask
{
baskets bask;
FILE *ptr=fopen("basknotpay.bin","r+b");
int idgood=0;
while(fread(&bask,sizeof(struct basket),1,ptr)!=0)
{
if(strcmp(bask.status,"unrecived")==0)
{
printf("%s %s %s",bask.name,bask.namecustomer,bask.status);
printf("%d",idgood);
}
}
fclose(ptr);
int a;
int id;
int i;
do
{
printf("if you want to change status num 1 else num 2");
scanf("%d",&a);
FILE *ptr=fopen("basknotpay.bin","r+b");
if(a==1)
{
printf("please inter id good");
scanf("%d",id);
while(fread(&bask,sizeof(struct basket),1,ptr)!=0)
{
if(i==id)
{
break;
}
i++;
}
}
strcpy(bask.status,"buyed");
fseek(ptr,(i)*sizeof(struct basket),SEEK_SET);
fwrite(&bask,sizeof(struct basket),1,ptr);
fclose(ptr);
}
while(a!=2);
}
}
void user()
{
good goods;
memb members;
baskets bask;
FILE *ptr=fopen("memberspe.bin","r+b");
printf("list of all member\n");
while(fread(&members, sizeof (struct member), 1, ptr)!=0)
{
printf("%s %s \n",members.name,members.type);
}
fclose(ptr);
int a;
do
{
memb members;
int k=0;
int t=0;
int i=0;
int j=0;
printf("if you want to sort based on baskets num 1 for customer num 6 for seller\n based on price for customer num 2 for seller num 7\n see seller goods num and decrease goods seller num 3\n delete seller num5 and for exit num -1\n");
int n=0;
int temp;
int temp1;
scanf("%d",&a);
char c[50];
gets(c);
int idgood=0;
if(a==1)///sort by num of basket customer
{
int p[2][100];
FILE *pyu=fopen("memberspe.bin","a+b");
FILE *pre=fopen("basknotpay.bin", "a+b");
while(fread(&members,sizeof(struct member),1,pyu)!=0)
{
p[1][k]=0;
while(fread(&bask,sizeof(struct basket),1,pre)!=0)
{
if(strcmp(bask.namecustomer,members.name)==0&&strcmp(members.type,"customer")==0&&strcmp(bask.status,"remove")!=0)
{
p[0][n]=k;
p[1][n]+=1;
n++;
}
}
k++;
}
for(i=0; i<n; i++)
{
for(j=i; j<n; j++)
{
if(p[1][j]>p[1][i])
{
temp=p[1][j];
p[1][j]=p[1][i];
p[1][i]=temp;
temp1=p[0][j];
p[0][j]=p[0][i];
p[0][i]=temp1;
}
}
}
fclose(pyu);
fclose(pre);
j=0;
for(i=0; i<n; i++)
{
FILE *poi=fopen("memberspe.bin","a+b");
while(fread(&members,sizeof(struct member),1,poi)!=0)
{
if(p[0][i]==j)
{
printf("%s %d",members.name,p[1][i]);
}
j++;
}
fclose(poi);
}
}
if(a==2)///sort basket base on num and customer
{
int p[2][100];
FILE *pyu=fopen("memberspe.bin","a+b");
FILE *pre=fopen("basknotpay.bin", "a+b");
while(fread(&members,sizeof(struct member),1,pyu)!=0)
{
p[1][k]=0;
while(fread(&bask,sizeof(struct basket),1,pre)!=0)
{
if(strcmp(bask.namecustomer,members.name)==0&&strcmp(members.type,"customer")==0&&strcmp(bask.status,"remove")!=0)
{
p[0][n]=k;
p[1][n]+=bask.price;
n++;
}
}
k++;
}
for(i=0; i<n; i++)
{
for(j=i; j<n; j++)
{
if(p[1][j]>p[1][i])
{
temp=p[1][j];
p[1][j]=p[1][i];
p[1][i]=temp;
temp1=p[0][j];
p[0][j]=p[0][i];
p[0][i]=temp1;
}
}
}
fclose(pyu);
fclose(pre);
j=0;
for(i=0; i<n; i++)
{
FILE *poi=fopen("memberspe.bin","a+b");
while(fread(&members,sizeof(struct member),1,poi)!=0)
{
if(p[0][i]==j)
{
printf("%s %d",members.name,p[1][i]);
}
j++;
}
fclose(poi);
}
}
if(a==3)///see seller good and decrease num of good
{
FILE *pyu=fopen("good.bin","a+b");
while(fread(&goods,sizeof(struct goodprofile),1,pyu)!=0)
{
printf("%s %s %s",goods.name,goods.nameseller,goods.num);
printf("%d\n",idgood);
}
puts("if you want to decrese number of good num 1");
fclose(pyu);
int num;
scanf("%d",&num);
char c[50];///alaki
gets(c);
if(num==1)
{
printf("please inter id of good you want ");
int id;
scanf("%d",&id);
FILE *ptt=fopen("good.bin","r+b");
i=0;
while(fread(&goods,sizeof(struct goodprofile),1,ptt)!=0)
{
i++;
if(i==id)
{
break;
}
}
printf("please inter number of good you want to decrese ");
int number;
scanf("%d",&number);
if(number>goods.num)
{
printf("you cant decrese goodsnum<number you want");
continue;
}
goods.num-=number;
fseek(ptt,(id)*sizeof(struct goodprofile),SEEK_SET);
fwrite(&goods,sizeof(struct goodprofile),1,ptt);
fclose(ptt);
}
}
if(a==5)///delete seller
{
printf("please inter name you want to remove");
char name [100];
char namecu[50][50];
char namese[50][50];
int price[2][50];
int pricet=0;
gets(name);
i=0;
j=0;
FILE *pgo=fopen("good.bin","r+b");
while(fread(&goods,sizeof(struct goodprofile),1,pgo)!=0)///delete all goods of seller
{
if(strcmp(goods.nameseller,name)==0)
{
strcpy(goods.status,"removedbyboss");
fseek(pgo,(i)*sizeof(struct goodprofile),SEEK_SET);
fwrite(&goods,sizeof(struct goodprofile),1,pgo);
j++;
}
i++;
}
fclose(pgo);
j=0;
FILE *pyy=fopen("memberspe.bin","r+b");
int j=0;
while(fread(&members,sizeof(struct member),1,pyy)!=0)///delete seller member
{
if(strcmp(members.name,name)==0)
{
printf("%s %s",members.name,members.status);
strcpy(members.status,"removedbyboss");
fseek(pyy,(j)*sizeof(struct member),SEEK_SET);
fwrite(&members,sizeof(struct member),1,pyy);
}
j++;
}
fclose(pyy);
FILE *plk=fopen ("basknotpay.bin", "a+b");
i=0;
j=0;
///esafe kardan khesarat be moshtary
while(fread(&bask,sizeof(struct basket),1,plk)!=0&&strcmp(bask.status,"removed")!=0&&strcmp(bask.status,"removedbyboss")!=0&&strcmp(bask.status,"buyed")!=0)
{
if(strcmp(bask.nameseller,name)==0)///hesab kol
{
strcpy(namecu[i],bask.namecustomer);
strcpy(namese[i],bask.nameseller);
price[0][i]=i;
price[1][i]=bask.price;
pricet+=bask.price;
i++;
}
fclose(plk);
}
card idcard;
int numg;
for(j=0; j<i; j++)
{
FILE *puu=fopen("idcard.bin","r+b");
while(fread(&idcard,sizeof(struct card),1,puu)!=0)
{
if(strcmp(namecu[j],idcard.user)==0)
{
break;
}
numg++;
}
idcard.mojody+=price[1][j];///esafe kardan pool be moshtary
fseek(puu,(numg)*sizeof(struct card),SEEK_SET);
fwrite(&idcard,sizeof(struct card),1,puu);
numg=0;
fclose(puu);
}
numg=0;
FILE *piu=fopen("idcard.bin","r+b");
for(j=0; j<i; j++)
{
card idcard;
while(fread(&idcard,sizeof(struct card),1,piu)!=0)
{
if(strcmp(namese[j],idcard.user)==0)
{
break;
}
numg++;
}
idcard.mojody-=(price[1][j]-price[1][j]*karmozd/100);///kam kardan poll as seller
fseek(piu,(numg)*sizeof(struct card),SEEK_SET);
fwrite(&idcard,sizeof(struct card),1,piu);
numg=0;
}
numg=0;
fclose(piu);
FILE *pmk=fopen("idcard.bin","r+b");
for(j=0; j<i; j++)
{
card id;
while(fread(&id,sizeof(struct card),1,pmk)!=0)
{
if(strcmp("boss",id.user)==0)
{
break;
}
numg++;
}
id.mojody-=(pricet*karmozd/100);///kamkardan pool as boss
fseek(pmk,(numg)*sizeof(struct card),SEEK_SET);
fwrite(&id,sizeof(struct card),1,pmk);
numg=0;
}
fclose(pmk);
}
if(a==6)///sort by num of basket base seller
{
int p[2][100];
FILE *pyu=fopen("memberspe.bin","a+b");
FILE *pre=fopen("basknotpay.bin", "a+b");
while(fread(&members,sizeof(struct member),1,pyu)!=0)
{
p[1][k]=0;
while(fread(&bask,sizeof(struct basket),1,pre)!=0)
{
if(strcmp(bask.nameseller,members.name)==0&&strcmp(members.type,"seller")==0&&strcmp(bask.status,"remove")!=0)
{
p[0][k]=k;
p[1][k]+=1;
n++;
}
}
k++;
}
for(i=0; i<n; i++)
{
for(j=i; j<n; j++)
{
if(p[1][j]>p[1][i])
{
temp=p[1][j];
p[1][j]=p[1][i];
p[1][i]=temp;
temp1=p[0][j];
p[0][j]=p[0][i];
p[0][i]=temp1;
}
}
}
fclose(pyu);
fclose(pre);
j=0;
for(i=0; i<n; i++)
{
FILE *poi=fopen("memberspe.bin","a+b");
while(fread(&members,sizeof(struct member),1,poi)!=0)
{
if(p[0][i]==j)
{
printf("%s %d",members.name,p[1][i]);
}