iword found_id=0;
-iword baka_id; //work order numer
-byte baka_name[64]; //name of client
-byte baka_phone[64]; //name of client
-byte baka_address[64]; //name of client
+iword baka_id; //work order number
+iword bakacust_id; //customer id
+byte bakacust_lastname[64]; //name of client
+byte bakacust_firstname[64]; //name of client
+byte bakacust_phone[64]; //phopne number of client
+byte bakacust_address[64]; //address of client
+byte bakacust_zipcode[64]; //zipcode
byte baka_desc[4096]; //Description of the problem
time_t baka_date;
byte baka_price; //price
void bdwr(void)
{
- byte str[BAKAPEE], buff[BAKAPEE], st[24];
+ byte str[BAKAPEE], strc[BAKAPEE], buff[BAKAPEE], st[24];
byte *pc = NULL;
byte *p;
- FILE *in = fopen ( "baka.db", "r+" );
- FILE *out = NULL;
- if(in == NULL)
+ FILE *inbaka = fopen ( BAKADB, "r+" );
+ FILE *outbaka = NULL;
+ FILE *incust = fopen ( CUSTDB, "r+" );
+ FILE *outcust = NULL;
+ if(inbaka == NULL)
{
newdb:
- fclose(in);
- out = fopen ( "baka.db", "w+" );
+ fclose(inbaka);
+ outbaka = fopen ( BAKADB, "w+" );
printf("\nNew database being made ^^;\n");
printf("Work order number: ");
scanf("%ud\n", &baka_id); // input~
}
else
{
- fgets(buff, 1, in);
+ fgets(buff, 1, inbaka);
if(buff==NULL)
{
- unlink("baka.db");
+ unlink(BAKADB);
goto newdb;
}
- while ( fgets ( buff, sizeof buff, in ) != NULL );
- fclose(in);
+ while ( fgets ( buff, sizeof buff, inbaka) != NULL );
+ fclose(inbaka);
pc = strtok(buff, SEPE);
baka_id = atoi(pc);
baka_id++;
- out = fopen ( "baka.db", "a+" );
+ outbaka = fopen ( BAKADB, "a+" );
+ outcust = fopen ( CUSTDB, "a+" );
//printf(" baka_id=%u\n", baka_id);
}
sprintf(st, "%u", baka_id);
strcpy(str, st);
strcat(str,SEPE);
- printf("Client's name: ");
- scanf("%s", &(baka_name)); // input~
+ strcpy(str, st);
+ strcat(strc,SEPE);
+
+ //input 1st and last~
+ printf("Client's name Last Name: ");
+ scanf("%s", &(bakacust_lastname)); // input~
+ printf("Client's name First Name: ");
+ scanf("%s", &(bakacust_firstname)); // input~
//TODO make uppercased names
found_id=0;
- cmpstrfromdb(1);
+ cmpstrfromdb(1); //++++update
- strcat(str,baka_name); strcat(str,SEPE);
+ strcat(str,bakacust_lastname); strcat(str,SEPE);
+ strcat(str,bakacust_lastname); strcat(str,SEPE);
+ strcat(str,bakacust_lastname); strcat(str,SEPE);
if(found_id==0)
{
printf("Client's Phone Number: ");
- scanf("%s", &(baka_phone)); // input~
+ scanf("%s", &(bakacust_phone)); // input~
}else getstrfromdb(2);
strcat(str,baka_phone); strcat(str,SEPE);
if(found_id==0)
strcat(str,SEPE);
strcat(str,"\n");
//bdmksheet(&bddb);
- fwrite(str, strlen(str), 1, out);
- fclose(out);
+ fwrite(str, strlen(str), 1, outbaka);
+ fclose(outbaka);
found_id=0;
free(pc);
}
byte *p;
siword eed;
- FILE *in = fopen ( "baka.db", "r" );
+ FILE *in = fopen ( BAKADB, "r" );
FILE *out = NULL;
while ( fgets ( buff, sizeof buff, in ) != (NULL) )
{
}
}
fclose(in);
- out = fopen ( "baka.db", "w+" );
+ out = fopen ( BAKADB, "w+" );
fwrite(str, strlen(str), 1, out);
fclose(out);
free(p);
byte *p;
siword eed;
- FILE *in = fopen ( "baka.db", "r" );
+ FILE *in = fopen ( BAKADB, "r" );
FILE *out = NULL;
dbvar(t);
found_id=id;
}
}
fclose(in);
- out = fopen ( "baka.db", "w+" );
+ out = fopen ( BAKADB, "w+" );
fwrite(str, strlen(str), 1, out);
fclose(out);
free(p);
{
byte buff[BAKAPEE];
word q;
- FILE *in = fopen ( "baka.db", "r+" );
+ FILE *in = fopen ( BAKADB, "r+" );
if(found_id>0) dbvar(i);
while ( fgets ( buff, sizeof buff, in ) != NULL )
{
byte buff[BAKAPEE];
byte pee[16];
word q;
- FILE *in = fopen ( "baka.db", "r+" );
+ FILE *in = fopen ( BAKADB, "r+" );
dbvar(i);
while ( fgets ( buff, sizeof buff, in ) != NULL )
{