-
Notifications
You must be signed in to change notification settings - Fork 1
/
RiwayatTransaksiFunc.c
67 lines (65 loc) · 1.92 KB
/
RiwayatTransaksiFunc.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
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include "header.h"
void riwayattransaksi(struct daftarbarang arrbarang[],int bnykdata){
int tgl1=0,tgl2=32,bln1=0,bln2=13,thn1=1990,thn2=3000;
while (1){
system("cls");
cetakinterface();
int i;
for(i=1;i<bnykdata;i++){
arrbarang[i].jumlah=0;
}
FILE *fp;
struct riwayat client = { 0, "", 0,"",0,0,0};
if ( ( fp = fopen( "RiwayatTransaksi.dat", "rb" ) ) == NULL ) {
printf( "File could not be opened.\n" );
}
printf( "%-6s|%-20s|%-10s|%-25s\n", "Id", "Nama Barang","Jumlah", "waktu");
int penanda=0;
while ( !feof( fp ) ) {
fread( &client, sizeof( struct riwayat ), 1, fp );
if(client.id==penanda)continue;
penanda=client.id;
if ( client.id != 0 ) {
if(client.tanggal<=tgl2&&client.tanggal>=tgl1&&client.bulan<=bln2&&client.bulan>=bln1&&client.tahun<=thn2&&client.tahun>=thn1){
int i;
for(i=1;i<bnykdata;i++){
if(client.id==arrbarang[i].id){
arrbarang[i].jumlah+=client.jumlah;
break;
}
}
printf( "%-6d|%-20s|%-10d|%-25s", client.id, client.nama,client.jumlah,client.time);
}
}
}
cetakgaris();
printf("Accumulation : \n");
for(i=1;i<bnykdata;i++){
if(arrbarang[i].jumlah!=0){
printf( "%-6d|%-20s|%-10d\n", arrbarang[i].id, arrbarang[i].nama,arrbarang[i].jumlah);
}
}
fclose( fp );
getchar();
printf("Command (search/exit) : ");
char command[7];
scanf("%s",command);
if(strcmp(command,"exit")==0){
break;
}
else if(strcmp(command,"search")==0){
printf("Input awal (dd mm yyyy) : ");
scanf("%d %d %d",&tgl1,&bln1,&thn1);
printf("Input akhir (dd mm yyyy) : ");
scanf("%d %d %d",&tgl2,&bln2,&thn2);
}
else{
printf("Nai");
}
}
}