#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include "menu.h"
#include "dialog.h"
#include "interact.h"
#define max 30
void setupdate();
void newscrip();
void newclient();
void checkscrip();
void checkclient();
void buyorsell();
void cleanup();
void cleanfiles();
void getclient();
void getscrip();
void getquantity();
void getrate();
void getsetno();
void getdate();
void checkwhich();
void getmouse();
void killmouse();
void showmenu();
void dataentry();
void getinfo();
void entryloop();
void checkbuying();
void writefiles();
void clientinfo();
void getclientdetail();
void displayinfo(int);
void scripinfo();
void getscripdetail();
void callexit();
void setfile();
void initialvalues();
void sidekick();
void exitchoice();
void updatestatus();
void readstatus();
void dateupdate();
void fetchdateset();
void xit();
void prompt();
void balancit(int);
void showbalance(int);
void clientscreen(int);
void printc(int,int,int);
void printb(int,int);
void scrollit(int);
void keyscroll(int);
void delarray(int);
void delet(int);
void modifi(int,int);
void makethechange();
void changechoice();
void changescrip();
void changeclient();
void changerate();
void changequantity();
void assigntemp();
void appendtemp();
void addclient();
void comeval();
void balanscreen();
void printnew(int);
void statbar(int);
int makesure();
void printweekly();
void printdaily();
void printclients();
void printscrips();
void printbalance();
void printzoudha();
void key();
void trykey();
void newkey();
void altkey();
void setup();
void zip(char*,char*);
void unzip(char*,char*);
void zipall();
void unzipall();
void reports();
void about();
//---------------------------------------------------------------------------
struct theeyathi
{
int day;
int month;
int year;
}date;
struct stock
{
int serno;
char choice;
char scrip[25];
char cname[25]; int cno;
int quan;
int rate;
float comm;
float net;
int setn;
}soudha,temp;
struct sharenames
{
char name[25];
int lf;
}scrips,clients;
int xslno[max],
xclientlf[max],
xday[30],
xmonth[max],
xyear[max],
xquan[max],
xrate[max],
xsetno[max];
float xcomm[max],
xnet[max];
char xchoice[max],
xscrip[max][25],
xclient[max][25];
int setno,ret,l,lptn,maxlines,trialset,errorflag=0,tryflag=0;
int scriplf,clientlf,check=0,passedvalue,passedoption;
int flag=0,flag1=0,flag2=0,clflag=0,scflag=0,stflag=0,j1,k;
char clname[25],scname[25],tempchoice[2];
char client[50][25],chstr[13];
float clienttotal[50],csetotal=0,commtotal=0,credit,debit;
FILE *sp,*cp,*fp,*np,*statfp,*datfp,*printfp,*fpass;
//--------------------------------------------------------------------------
void main(void)
{
int i,ret;
gotoxy(1,1);
clrscr();
cursize(16,0);
unzip("p5.mok","pass.wrd");
//key();
unzipall();
getmouse();
soudha.choice='b';
showmenu();
killmouse();
}
//-------------------------------------------------------------------------
void unzipall()
{
unzip("z1.mok","zledger");
unzip("s2.mok","sledger");
unzip("c3.mok","cledger");
unzip("s4.mok","status");
}
//--------------------------------------------------------------------------
void zipall()
{
zip("zledger","z1.mok");
zip("sledger","s2.mok");
zip("cledger","c3.mok");
zip("status","s4.mok");
zip("pass.wrd","p5.mok");
system("del zledger");
system("del cledger");
system("del sledger");
system("del status");
system("del pass.wrd");
}
//-------------------------------------------------------------------------
void zip(char one[12],char two[12])
{
FILE *fp1,*fp2;
int ch,i=1;
fp1=fopen(one,"rb");
fp2=fopen(two,"wb");
while((ch=fgetc(fp1))!=EOF)
{
if(ch==32)
{
while((ch=fgetc(fp1))==32)
i++;
fputc(i+=127,fp2);
i=1;
}
fputc(127-ch,fp2);
}
fclose(fp1);
fclose(fp2);
}
//---------------------------------------------------------------------------
void unzip(char one[12],char two[12])
{
FILE *fp1,*fp2;
int ch,i=1;
fp1=fopen(one,"rb");
fp2=fopen(two,"wb");
while((ch=fgetc(fp1))!=EOF)
{
if(ch>127)
{
ch-=127;
for(i=1;i<=ch;i++)
fputc(' ',fp2);
}
else
fputc(127-ch,fp2);
}
fclose(fp1);
fclose(fp2);
}
//--------------------------------------------------------------------------
void trykey()
{
int ch=0,i=1,j=20,kh;
fpass=fopen("pass.wrd","r");
do
{
ch=getch();
if((i==1)&&(tryflag!=0))
{
textbackground(0);
gotoxy(35,13);
cprintf(" \n");
textbackground(7);
}
fscanf(fpass,"%d ",&kh);
kh=(kh+j)/i;
if(ch!=kh)
{
errorflag=1;
}
i++;j--;
}while(ch!=13);
}
//-------------------------------------------------------------------------
void key()
{
textbackground(7);
textcolor(1);
gotoxy(35,12);
cprintf("PASSWORD PLEASE");
trykey();
if(errorflag==0)
{
tryflag=0;
fclose(fpass);
}
else if(tryflag<3)
{
tryflag++;
errorflag=0;
gotoxy(35,13);
cprintf(" RETRY \n");
key();
}
else if(tryflag>=3)
{
gotoxy(35,12);
cprintf(" ACCESS DENIED ");
fclose(fpass);
exit(0);
}
}
//-------------------------------------------------------------------------
void newkey()
{
textbackground(7);
textcolor(1);
gotoxy(33,12);
cprintf("ENTER OLD PASSWORD");
trykey();
if(errorflag==1)
{
gotoxy(33,12);
cprintf(" ACCESS DENIED ");
getch();
textbackground(0);
gotoxy(35,12);
cprintf(" ");
errorflag=0;
}
else altkey();
}
//-------------------------------------------------------------------------
void altkey()
{
FILE *fpass;
int ch=0,i=1,j=20,kh=0,newflag=0,maxi;
int newk[20];
gotoxy(33,12);
cprintf("TYPE IN NEW PASSWORD");
do
{
ch=getch();
if(i<20)
{
newk[i]=ch;
i++;
}
else if(i>=20)
putchar(7);
}while(ch!=13);
maxi=i-1;
i=1;
gotoxy(33,12);
cprintf("RETYPE NEW PASSWORD ");
do
{
ch=getch();
if(newk[i]!=ch)
{
newflag=1;
}
if(i<maxi) i++;
}while(ch!=13);
if(newflag==0)
{
i=1;
fpass=fopen("pass.wrd","w");
do
{
ch=newk[i];
kh=(ch*i)-j;
fprintf(fpass,"%d ",kh);
i++;j--;
} while(ch!=13);
fclose(fpass);
gotoxy(33,12);
cprintf(" PASSWORD CHANGED ");
getch();
textbackground(0);
gotoxy(33,12);
cprintf(" ");
}
else
{
newflag=0;
gotoxy(33,12);
cprintf("RETYPED INCORRECTLY ");
getch();
textbackground(0);
gotoxy(33,12);
cprintf(" ");
}
}
//-------------------------------------------------------------------------
void prompt()
{
clrscr();
printf("ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍTYPE EXIT TO GET BACK TO MOKSHAÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ");
system("command.com");
system("march2");
}
//---------------------------------------------------------------------------
void showmenu()
{
textbackground(BLACK);
clrscr();
textbackground(BLACK);
ret=tmenu(15,7,11,1,0,31,10,8,"OPTIONS",
"Data Entry",
"View-Edit",
"Trial Balance",
"Analysis",
"Reports",
"Set Up",
"Dos Prompt",
"Exit");
switch(ret)
{
case 1:dataentry();
showmenu(); break;
case 2:getinfo();
showmenu();break;
case 3:balancit(1);
showmenu();
break;
case 5:reports();
showmenu();
break;
case 6:setup();
showmenu();break;
case 7:prompt();break;
case 8:zipall();
killmouse();
exit(0);break;
default:showmenu();break;
}
}
//--------------------------------------------------------------------------
void setup()
{
ret=tmenu(15,7,11,1,0,31,10,4,"SET UP",
"Clean All Files",
"Change Password",
"About",
"Exit Set up");
switch(ret)
{
case 1:cleanfiles();
setup();
break;
case 2:newkey();
setup();
break;
case 3:about();
break;
default:break;
}
}
//---------------------------------------------------------------------------
void about()
{
clrscr();
ret=tmenu(15,7,11,1,0,31,10,6,"THE MINDZONE",
"kishan p thomas",
"rahul sekhar",
"shiji cherian",
"treesa zacharia",
" the base ",
" ok ");
switch(ret)
{
case 1:dialoguebox(23,10,3,0,7,"wild rose cochin-34",0);
getch();
about();
break;
case 2:dialoguebox(23,10,3,0,7,"varickolil mavelikara-4",0);
getch();
about();
break;
case 3:dialoguebox(23,10,3,0,7,"kadiyamkuttiyil trivandrum-1",0);
getch();
about();
break;
case 4:dialoguebox(23,10,3,0,7,"lakaparambil changanachery-4",0);
getch();
about();
break;
case 5:dialoguebox(23,10,3,0,7,"uni: of kerala trivandrum-81",0);
getch();
about();
break;
default:break;
}
}
//---------------------------------------------------------------------------
void reports()
{
ret=tmenu(15,7,11,1,0,31,10,7,"SELECT REPORT",
"WEEKLY STATEMENT",
"DAILY STATEMENT",
"TRIAL BALANCE",
"CLIENT LIST",
"SCRIP LIST",
"ZOUDHA BOOK",
"EXIT REPORTS");
switch(ret)
{
case 1:printweekly();
reports();
break;
case 2:printdaily();
reports();
break;
case 3:balancit(2);
reports();
break;
case 4:printclients();
reports();
break;
case 5:printscrips();
reports();
break;
case 6:printzoudha();
reports();
break;
default:break;
}
}
//---------------------------------------------------------------------------
void printweekly()
{
char theclient[20],printen[20];
int serialno=0,thesetno;
printfp=fopen("tempfile","w");
fp=fopen("zledger","r");
dialoguebox(23,10,3,0,7,"ENTER THE SETNO:",2);
thesetno=atoi(getit(wherex(),wherey(),20));
dialoguebox(23,10,3,0,7,"ENTER THE CLIENT NAME",20);
strcpy(theclient,getit(wherex(),wherey(),20));
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"-----------------------------------------------------------------------------\n");
fprintf(printfp,"TO:\n");
fprintf(printfp," %s\n",theclient);
fprintf(printfp," I/We have on this Settlement period done by your Settlment# %2d \n",
thesetno);
fprintf(printfp," order and on your account the following transactions\n");
fprintf(printfp,"-----------------------------------------------------------------------------\n");
fprintf(printfp,"|SLNO|LFNO| DATE |SET| SCRIPNAME | | QTTY | RATE| COMM: | NETAMOUNT |\n");
fprintf(printfp,"-----------------------------------------------------------------------------\n");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if((strcmp(theclient,soudha.cname)==0)&&(soudha.setn==thesetno))
{
strcpy(printen,soudha.scrip);
printen[10]='\0';
serialno++;
fprintf(printfp,"|%3d |%3d |%2d/%2d/%2d |%2d | %-10s|%c |%5d |%4d |%8.2f |%12.2f |\n",
serialno,
soudha.serno,
date.day,
date.month,
date.year,
soudha.setn,
printen,
soudha.choice,
soudha.quan,
soudha.rate,
soudha.comm,
soudha.net);
}
}
fprintf(printfp,"----------------------------------------------------------------------------\n\n");
fprintf(printfp," Yours Faithfully, \n\n");
fprintf(printfp," For PINNACLE STOCK & SHARES. \n");
fclose(fp);
fclose(printfp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void printdaily()
{
char theclient[20];
char printen[20];
int serialno=0,thesetno,thedate;
printfp=fopen("tempfile","w");
fp=fopen("zledger","r");
dialoguebox(23,10,3,0,7,"ENTER THE SETNO:",2);
thesetno=atoi(getit(wherex(),wherey(),20));
dialoguebox(23,10,3,0,7,"ENTER THE DATE:",2);
thedate=atoi(getit(wherex(),wherey(),20));
dialoguebox(23,10,3,0,7,"ENTER THE CLIENT NAME",20);
strcpy(theclient,getit(wherex(),wherey(),20));
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"-------------------------------------------------------------------\n");
fprintf(printfp,"TO:\n");
fprintf(printfp," %s\n",theclient);
fprintf(printfp," I/We have this day done by your order and Dated%2d/%2d/%2d\n",
date.day,date.month,date.year);
fprintf(printfp," on your account the following transactions\n");
fprintf(printfp,"-------------------------------------------------------------------\n");
fprintf(printfp,"|SLNO|LFNO| SCRIPNAME | | QTTY | RATE| COMMISSION | NETAMOUNT |\n");
fprintf(printfp,"-------------------------------------------------------------------\n");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if((strcmp(theclient,soudha.cname)==0)
&&(date.day==thedate)
&&(soudha.setn==thesetno))
{
strcpy(printen,soudha.scrip);
printen[10]='\0';
serialno++;
fprintf(printfp,"|%3d |%3d | %-10s|%c |%5d |%4d |%12.2f |%12.2f |\n",
serialno,
soudha.serno,
printen,
soudha.choice,
soudha.quan,
soudha.rate,
soudha.comm,
soudha.net);
}
}
fprintf(printfp,"-------------------------------------------------------------------\n\n");
fprintf(printfp," Yours Faithfully, \n\n");
fprintf(printfp," For PINNACLE STOCK & SHARES. \n");
fclose(fp);
fclose(printfp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void printbalance()
{
float printamount;
printfp=fopen("tempfile","w");
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp," TRIAL BALANCE FOR THE SETTLEMENT NO: %2d\n",trialset);
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp,"| PARTICULARS | DEBIT | CREDIT |\n");
fprintf(printfp,"---------------------------------------------------\n");
for(int l=1;l<=maxlines;l++)
{
if(clienttotal[l]<0)
{
printamount=clienttotal[l]*(-1.0);
fprintf(printfp,"| %-20s|%12.2f | |\n",client[l],printamount);
}
else
fprintf(printfp,"| %-20s| |%12.2f |\n",client[l],clienttotal[l]);
}
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp," |%12.2f |%12.2f |\n",debit,credit);
fprintf(printfp,"---------------------------------------------------\n");
fclose(printfp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void printscrips()
{
printfp=fopen("tempfile","w");
sp=fopen("sledger","r");
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp," SCRIPLIST \n");
fprintf(printfp,"---------------------------------------------------\n\n");
fprintf(printfp,"------------------------------\n");
fprintf(printfp,"| No: | SCRIPNAME |\n");
fprintf(printfp,"------------------------------\n");
while(!feof(sp))
{
fscanf(sp,"%d %[^\n]",&scrips.lf,scrips.name);
fprintf(printfp,"| %3d | %-20s |\n",scrips.lf,scrips.name);
}
fprintf(printfp,"------------------------------\n");
fclose(printfp);
fclose(sp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void printclients()
{
printfp=fopen("tempfile","w");
cp=fopen("cledger","r");
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp," CLIENT LIST\n");
fprintf(printfp,"---------------------------------------------------\n");
fprintf(printfp,"------------------------------\n");
fprintf(printfp,"| No: | CLIENTNAME |\n");
fprintf(printfp,"------------------------------\n");
while(!feof(cp))
{
fscanf(cp,"%d %[^\n]",&clients.lf,clients.name);
fprintf(printfp,"| %3d | %-20s |\n",clients.lf,clients.name);
}
fprintf(printfp,"------------------------------\n");
fclose(printfp);
fclose(cp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void printzoudha()
{
int serialno=0,thesetno;
char printen1[20],printen2[20];
printfp=fopen("tempfile","w");
fp=fopen("zledger","r");
dialoguebox(23,10,3,0,7,"ENTER THE SETNO:",2);
thesetno=atoi(getit(wherex(),wherey(),20));
fprintf(printfp,"PINNACLE STOCK & SHARES M.G.Road Cochin Ph:361660 \n");
fprintf(printfp,"------------------------------------------------------------------------------\n");
fprintf(printfp," ZOUDHA LEDGER \n");
fprintf(printfp,"------------------------------------------------------------------------------\n");
fprintf(printfp,"ENTRIES FOR THE SETTLEMENT NO:%2d\n",thesetno);
fprintf(printfp,"------------------------------------------------------------------------------\n");
fprintf(printfp,"|SL#| DATE |S#|CLIENTNAME|SCRIPNAME | | QTTY|RATE| COMMISSION | NETAMOUNT |\n");
fprintf(printfp,"------------------------------------------------------------------------------\n");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if(soudha.setn==thesetno)
{
strcpy(printen1,soudha.cname);
printen1[10]='\0';
strcpy(printen2,soudha.scrip);
printen2[10]='\0';
serialno++;
fprintf(printfp,"|%3d|%2d/%2d/%2d|%2d|%-10s|%-10s|%c|%5d|%4d|%12.2f|%12.2f|\n",
serialno,
date.day,
date.month,
date.year,
soudha.setn,
printen1,
printen2,
soudha.choice,
soudha.quan,
soudha.rate,
soudha.comm,
soudha.net);
}
}
fprintf(printfp,"------------------------------------------------------------------------------\n");
fclose(fp);
fclose(printfp);
ret=tmenu(15,1,0,10,4,24,10,2,"SETUP PRINTER.READY TO PRINT ?",
"OK",
"Cancel");
if(ret==1) system("type >prn tempfile.");
}
//---------------------------------------------------------------------------
void getinfo()
{
gotoxy(1,1);
ret=tmenu(15,1,0,10,4,35,10,3,"OPTIONS",
"Clients",
"Scrips",
"Exit");
switch(ret)
{
case 1:clientinfo();getinfo();break;
case 2:scripinfo();getinfo();break;
case 3:showmenu();break;
default:showmenu();break;
}
}
//---------------------------------------------------------------------------
void fetchdateset()
{
datfp=fopen("dates","r");
fscanf(datfp,"%d%*c%d%*c%d %d",&date.day,&date.month,&date.year);
fclose(datfp);
}
//--------------------------------------------------------------------------
void dataentry()
{
if(stflag==0)
readstatus();
textbackground(BLACK);
drawinterface(18,5);
if(soudha.choice=='b') buying(2);
else selling(2);
entryloop();
}
//--------------------------------------------------------------------------
void readstatus()
{
statfp=fopen("status","r");
fscanf(statfp,"%d %d %d",&i,&j1,&k);
fclose(statfp);
soudha.serno=i;
scriplf=j1;
clientlf=k;
}
//-------------------------------------------------------------------------
void sidekick()
{
ret=tmenu(15,1,0,10,4,34,9,5,"OPTIONS",
"Continue",
"Cancel",
"Set No:",
"Date",
"Exit");
switch(ret)
{
case 1:flag=0;
writefiles();
stflag=1;
dataentry();
stflag=0;
break;
case 2:flag=0;
dataentry();
break;
case 3:flag=0;
setupdate();
break;
case 4:flag=0;
dateupdate();
break;
case 5:exitchoice();
break;
default:break;
}
}
//--------------------------------------------------------------------------
void xit()
{
ret=tmenu(15,1,0,10,4,34,11,2,"DATAENTRY",
"Exit",
"Continue");
switch(ret)
{
case 1 :updatestatus();
showmenu();
break;
case 2 :flag=0;
stflag=1;
dataentry();
stflag=0;
break;
default:break;
}
}
//--------------------------------------------------------------------------
void setupdate()
{
datfp=fopen("dates","r");
fscanf(datfp,"%d%*c%d%*c%d %d",&date.day,&date.month,&date.year,&setno);
fclose(datfp);
writesetno(2);
// printf("\b\b\b\b\b");
scanf("%d",&setno);
setfile();
sidekick();
}
//--------------------------------------------------------------------------
void dateupdate()
{
datfp=fopen("dates","r");
fscanf(datfp,"%d%*c%d%*c%d %d",&date.day,&date.month,&date.year,&setno);
fclose(datfp);
writedate(2);
scanf("%d%*c%d%*c%d",&date.day,&date.month,&date.year);
setfile();
sidekick();
}
//-------------------------------------------------------------------------
void setfile()
{
datfp=fopen("dates","w");
fprintf(datfp,"%2d:%2d:%d %2d",date.day,date.month,date.year,setno);
fclose(datfp);
}
//--------------------------------------------------------------------------
void exitchoice()
{
int exret;
exret=tmenu(15,1,0,10,4,30,9,2,"BEFORE EXITTING",
"Save",
"Cancel");
switch(exret)
{
case 1 :writefiles();
updatestatus();
showmenu();
break;
case 2 :
default:updatestatus();
showmenu();
break;
}
}
//--------------------------------------------------------------------------
void updatestatus()
{
statfp=fopen("status","w");
fprintf(statfp,"%d\n%d\n%d\n",soudha.serno,scriplf,clientlf);
fclose(statfp);
}
//--------------------------------------------------------------------------
void entryloop()
{
esc:
writesetno(2);
getsetno();
writedate(2);
getdate();
if(soudha.choice=='b') buying(2);
else selling(2);
checkbuying();
getscrip();
if(flag==1)
{
flag=0;
scripname(1);
goto esc;
}
getclient();
if(flag==1)
{
flag=0;
clientname(1);
scripname(1);
goto esc;
}
getquantity();
getrate();
sidekick();
if(flag!=0)
{
clientname(1);
scripname(1);
quantity(1);
rate(1);
writesetno(1);
writedate(1);
if(flag==1)
{
flag=0;
goto esc;
}
flag=0;
}
}
//--------------------------------------------------------------------------
void checkbuying()
{
int cho;
cho=getch();
switch(cho)
{
case 8 :if(soudha.choice=='b')
{
selling(1);
soudha.choice='s';
}
else if(soudha.choice=='s')
{
buying(1);
soudha.choice='b';
} break;
case 27 :xit();
break;
default :if(soudha.choice=='b') buying(1);
else if(soudha.choice=='s') selling(1); break;
}
}
//--------------------------------------------------------------------------
void getscrip()
{
scripname(2);
strcpy(soudha.scrip,getit(wherex(),wherey(),25));
if(atoi(soudha.scrip)==-27)
xit();
else
{
if(atoi(soudha.scrip)== -13)
getscrip();
else
{
checkscrip();
if(check==0)
{
do
{
ret=tmenu(15,1,0,10,4,lftx+14,atopy+6,3,"ENTER AS A NEW SCRIP?",
"Yes",
"No",
"Cancel");
switch(ret)
{
case 1:newscrip();break;
case 2:getscrip();break;
case 3:flag=1;break;
}
}while(ret==0);
}
scripname(3);
}
}
}
//-------------------------------------------------------------------------
void getclient()
{
clientname(2);
strcpy(soudha.cname,getit(wherex(),wherey(),25));
if(atoi(soudha.cname)==-27)
xit();
else
{
if(atoi(soudha.cname)==-13)
getclient();
else
{
checkclient();
if(check==0)
{
do
{
ret=tmenu(15,1,0,10,4,lftx+14,atopy+8,3,"ENTER AS A NEW CLIENT?",
"Yes",
"No",
"Cancel");
switch(ret)
{
case 1:newclient();break;
case 2:getclient();break;
case 3:flag=1;break;
}
}while(ret==0);
}
clientname(3);
}
}
}
//--------------------------------------------------------------------------
void getquantity()
{
quantity(2);
soudha.quan=atoi(getit(wherex(),wherey(),6));
if(soudha.quan==-27)
xit();
else
if(soudha.quan==-13)
getquantity();
quantity(3);
}
//---------------------------------------------------------------------------
void getrate()
{
rate(2);
soudha.rate=atoi(getit(wherex(),wherey(),10));
if(soudha.rate==-27) xit();
else if(soudha.rate==-13) getrate();
rate(3);
}
//-------------------------------------------------------------------------
void getsetno()
{
datfp=fopen("dates","r");
fscanf(datfp,"%d%*c%d%*c%d %d",&date.day,&date.month,&date.year,&setno);
printf("%d",setno);
fclose(datfp);
}
//------------------------------------------------------------------------
void getdate()
{
printf(" ");
datfp=fopen("dates","r");
fscanf(datfp,"%d%*c%d%*c%d %d",&date.day,&date.month,&date.year,&setno);
printf("\b\b\b\b\b\b\b\b\b\b%d:%d:%d",date.day,date.month,date.year);
fclose(datfp);
}
//-------------------------------------------------------------------------
void newscrip()
{
strcpy(scrips.name,soudha.scrip);
scrips.lf=scriplf;
scflag=1;
}
//---------------------------------------------------------------------------
void newclient()
{
strcpy(clients.name,soudha.cname);
clients.lf=clientlf;
clflag=1;
}
//---------------------------------------------------------------------------
void checkscrip(void)
{
sp=fopen("sledger","r");
check=0;
if(feof(sp))
check=0;
while(!feof(sp))
{
fscanf(sp,"%d %[^\n]",&scrips.lf,scrips.name);
if(strcmp(scrips.name,soudha.scrip)==0)
check=1;
}
fclose(sp);
}
//---------------------------------------------------------------------------
void checkclient()
{
cp=fopen("cledger","r+");
check=0;
if(feof(cp))
check=0;
while(!feof(cp))
{
fscanf(cp,"%d %[^\n]",&clients.lf,clients.name);
if(strcmp(clients.name,soudha.cname)==0)
check=1;
}
fclose(cp);
}
//--------------------------------------------------------------------------
void writefiles()
{
fp=fopen("zledger","a");
sp=fopen("sledger","a");
cp=fopen("cledger","a");
soudha.comm = (1.5*soudha.quan*soudha.rate)/100.00;
switch(soudha.choice)
{
case 'b': soudha.net =(float(soudha.quan)*float(soudha.rate)) + soudha.comm;
break;
case 's': soudha.net =(float(soudha.quan)*float(soudha.rate)) - soudha.comm;
break;
}
if (scflag==1)
{
scriplf+=1;
scrips.lf=scriplf;
fprintf(sp,"%d %s\n",scrips.lf,scrips.name);
scflag=0;
}
if (clflag==1)
{
clientlf+=1;
clients.lf=clientlf;
fprintf(cp,"%d %s\n",clients.lf,clients.name);
clflag=0;
}
soudha.serno+=1;
fprintf(fp,"%d.\n %d:%d:%d %d\n %s\n %s\n %c %d %d %d %5.2f %5.2f\n",
soudha.serno,date.day,date.month,
date.year,setno,soudha.scrip,soudha.cname,
soudha.choice,clientlf,soudha.quan,soudha.rate,
soudha.comm,soudha.net);
fclose(sp);
fclose(cp);
fclose(fp);
}
//---------------------------------------------------------------------------
void clientinfo()
{
getclientdetail();
displayinfo(1);
if(sca==60) showmenu(); //Alt-F1
else getinfo();
}
//--------------------------------------------------------------------------
void scripinfo()
{
getscripdetail();
displayinfo(2);
if(sca==60) showmenu(); //Alt-F1
else getinfo();
/*dialoguebox(23,10,3,0,7,"ENTER SCRIP NAME",25);
getscripdetail();
displayscripinfo();*/
}
//-------------------------------------------------------------------------
void getclientdetail()
{
dialoguebox(23,10,3,0,7,"ENTER CLIENT NAME",25);
strcpy(clname,getit(wherex(),wherey(),25));
if(atoi(clname)==-27)
showmenu();
}
//------------------------------------------------------------------------
void getscripdetail()
{
dialoguebox(23,10,3,0,7,"ENTER SCRIP NAME",25);
strcpy(scname,getit(wherex(),wherey(),25));
if(atoi(scname)==-27)
showmenu();
}
//-------------------------------------------------------------------------
void clientscreen(int pv)
{
textbackground(LIGHTGRAY);
textcolor(BLACK);
cprintf("ÉÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÑÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍ»");
if(pv==1)
cprintf("ºSl#³ DATE*SETNO³*³ CLIENTNAME ³ QTTY: ³ RATE ³ COMM: ³ NETAMOUNT º");
else
cprintf("ºSl#³ DATE*SETNO³*³ SCRIPNAME ³ QTTY: ³ RATE ³ COMM: ³ NETAMOUNT º");
cprintf("ÌÍÍÍØÍÍÍÍÍÍÍÍÑÍÍØÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍØÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍ͹");
gotoxy(1,4);
for(int i=4;i<24;i++)
cprintf("º ³ ³ ³ ³ ³ ³ ³ ³ º");
cprintf("ÈÍÍÍÏÍÍÍÍÍÍÍÍÏÍÍÏÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍͼ");
statbar(pv);
}
//-------------------------------------------------------------------------
void statbar(int pv)
{
textbackground(GREEN);
textcolor(WHITE);
cprintf(" %c%c Scrool Del Delete F10 Modify F1 Menu F2 MainMenu Alt-F8 Exit ",25,24);
gotoxy(24,24);
textbackground(RED);
textcolor(WHITE);
switch(pv){
case(1):cprintf(" CLIENT: %20s ",clname);
break;
case(2):cprintf(" SCRIP: %20s ",scname);
break;
default:break;}
}
//-------------------------------------------------------------------------
void displayinfo(int pv)
{
int l=1;
clrscr();
textbackground(WHITE);
textcolor(BLACK);
clientscreen(pv);
fp=fopen("zledger","r");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&xslno[l],
&xday[l],&xmonth[l],&xyear[l],&xsetno[l],xscrip[l],xclient[l],
&xchoice[l],&xclientlf[l],&xquan[l],&xrate[l],
&xcomm[l],&xnet[l]);
if(pv==1)
{
if(strcmp(xclient[l],clname)==0) l+=1;
}
else if(pv==2)
{
if(strcmp(xscrip[l],scname)==0) l+=1;
}
}
gotoxy(1,4);
lptn=0;
maxlines=l-1;
for(l=1;l<=maxlines;l++)
{
if(l<=20)
{
lptn++;
printc(l,1,pv);
}
}
scrollit(pv);
fclose(fp);
//gotoxy(35,25);
//cprintf("PRESS ANY KEY");
//getch();
}
//---------------------------------------------------------------------------
void printc(int lp,int col,int opt)
{
gotoxy(1,lptn+3);
textbackground(LIGHTGRAY);
textcolor(BLACK);
cprintf("%c",186);
if(col==2)
{
textbackground(BLUE);
textcolor(WHITE);
}
cprintf("%3d",xslno[lp]);
cprintf("%c%2d:%2d:%2d",179,xday[lp],xmonth[lp],xyear[lp]);
cprintf("%c%2d",179,xsetno[lp]);
cprintf("%c%c",179,xchoice[lp]);
switch(opt){
case(1):cprintf("%c%22s",179,xscrip[lp]);
break;
case(2):cprintf("%c%22s",179,xclient[lp]);
break;
default:break;}
cprintf("%c%7d",179,xquan[lp]);
cprintf("%c%6d",179,xrate[lp]);
cprintf("%c%9.2f",179,xcomm[lp]);
cprintf("%c%12.2f",179,xnet[lp]);
textbackground(LIGHTGRAY);
textcolor(BLACK);
cprintf("%c",186);
}
//--------------------------------------------------------------------------
void balanscreen()
{
gotoxy(17,1);
cprintf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍ»");gotoxy(17,2);
cprintf("º PARTICULARS ³ DEBIT ³ CREDIT º");gotoxy(17,3);
cprintf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍ͹");
for(int i=4;i<24;i++)
{
gotoxy(17,i);
cprintf("º ³ ³ º");
}
gotoxy(17,24);
cprintf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍ͹");
gotoxy(17,25);
cprintf("º");
gotoxy(18,25);
textbackground(GREEN);
textcolor(WHITE);
cprintf(" F1 AGAIN F2 ESCAPE ");
}
//--------------------------------------------------------------------------
void printb(int lp,int col)
{
float printamount;
gotoxy(18,lptn+3);
if(col==2)
{
textbackground(BLUE);
textcolor(WHITE);
}
if(clienttotal[lp]<0)
{
printamount=clienttotal[lp]*(-1.0);
cprintf("%20s³%12.2f³ ",client[lp],printamount);
}
else
cprintf("%20s³ ³%12.2f",client[lp],clienttotal[lp]);
textbackground(LIGHTGRAY);
textcolor(BLACK);
}
//--------------------------------------------------------------------------
void scrollit(int pv)
{
gotoxy(1,4);
l=1;
lptn=l;
sca=0;
if(pv==3) printb(l,2);
else printc(l,2,pv);
do
{
if(kbhit())
{
keybochar(&ski,&sca);
keyscroll(pv);
}
}while((sca!=59)&&(sca!=60)); //F1 or F2
}
//--------------------------------------------------------------------------
void keyscroll(int pv)
{
switch(sca){
case 80:if((lptn<20)&&(l<maxlines)) //DOWNARROW
{
if(pv==3) printb(l,1);
else printc(l,1,pv);
l++;lptn++;
if(pv==3) printb(l,2);
else printc(l,2,pv);
}
else if(l<maxlines)
{
lptn=1;
gotoxy(1,3);
int init=l-18;
for(int i=init;i<=l;i++)
{
if(pv==3) printb(i,1);
else printc(i,1,pv);
lptn++;
}
l++;
if(pv==3) printb(l,1);
else printc(l,2,pv);
}
break;
case 72:if(lptn>1) //UPARROW
{
if(pv==3) printb(l,1);
else printc(l,1,pv);
l--;lptn--;
if(pv==3) printb(l,2);
else printc(l,2,pv);
}
else if(l>1)
{
lptn=1;
gotoxy(1,3);
int init=l-1;
int end=l+18;
for(int i=init;i<=end;i++)
{
if(pv==3) printb(i,1);
else printc(i,1,pv);
lptn++;
}
lptn=1;
l=init;
if(pv==3) printb(l,2);
else printc(l,2,pv);
}
break;
case 83:if(pv!=3) //DELETE
{
if(makesure()==1)
{
delet(xslno[l]);
if(l==maxlines)
{
lptn--;
l--;
maxlines=l;
printc(l,2,pv);
cprintf("º ³ ³ ³ ³ ³ ³ ³ ³ º");
}
else
{
delarray(l);
printc(l,2,pv);
int curlptn=lptn;
int curl=l;
while((lptn<20))
{
lptn++;
l++;
if(l<=maxlines) printc(l,1,pv);
else cprintf("º ³ ³ ³ ³ ³ ³ ³ ³ º");
}
lptn=curlptn;
l=curl;
}
}
}
break;
case 68:if(pv!=3)
{
modifi(xslno[l],1); //F10
printnew(l);
//lptn--;
printc(l,2,pv);
sca=0;
}
break;
default:break;}
}
//--------------------------------------------------------------------------
int makesure()
{
ret=tmenu(15,1,0,10,4,35,10,2,"ARE YOU SURE",
"Yes",
"No");
if(ret==1) return(1);
else return(0);
}
//--------------------------------------------------------------------------
void printnew(int lp)
{
xslno[lp]=temp.serno;
//xclientlf[lp],
//xday[30],
//xmonth[lp],
//xyear[lp],
xquan[lp]=temp.quan;
xrate[lp]=temp.rate;
xsetno[lp]=temp.setn;
xcomm[lp]=temp.comm;
xnet[lp]=temp.net;
xchoice[lp]=temp.choice;
strcpy(xscrip[lp],temp.scrip);
strcpy(xclient[lp],temp.cname);
}
//--------------------------------------------------------------------------
void delarray(int lp)
{
for(int i=lp;i<maxlines;i++)
{
xslno[i]=xslno[i+1];
xclientlf[i]=xclientlf[i+1];
xday[i]=xday[i+1];
xmonth[i]=xmonth[i+1];
xyear[i]=xyear[i+1];
xquan[i]=xquan[i+1];
xrate[i]=xrate[i+1];
xsetno[i]=xsetno[i+1];
xcomm[i]=xcomm[i+1];
xnet[i]=xnet[i+1];
xchoice[i]=xchoice[i+1];
strcpy(xscrip[i],xscrip[i+1]);
strcpy(xclient[i],xclient[i+1]);
}
maxlines--;
}
//--------------------------------------------------------------------------
void delet(int recno)
{
fp=fopen("zledger","r");
np=fopen("nledger","w");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if(soudha.serno!=recno)
fprintf(np,"%d.\n %d:%d:%d %d\n %s\n %s\n %c %d %d %d %f %f\n",soudha.serno,
date.day,date.month,date.year,soudha.setn,soudha.scrip,soudha.cname,
soudha.choice,clientlf,soudha.quan,soudha.rate,
soudha.comm,soudha.net);
}
fclose(fp);
fclose(np);
fp=fopen("zledger","w");
np=fopen("nledger","r");
while(!feof(np))
{
fscanf(np,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
fprintf(fp,"%d.\n %d:%d:%d %d\n %s\n %s\n %c %d %d %d %f %f\n",soudha.serno,
date.day,date.month,date.year,soudha.setn,soudha.scrip,soudha.cname,
soudha.choice,clientlf,soudha.quan,soudha.rate,
soudha.comm,soudha.net);
}
fclose(fp);
fclose(np);
system("del nledger");
}
//--------------------------------------------------------------------------
void balancit(int opt)
{
int cno,i=0;
credit=0;debit=0;
dialoguebox(35,15,3,0,7,"ENTER SETNO",2);
trialset=atoi(getit(wherex(),wherey(),2));
fp=fopen("zledger","r");
cp=fopen("cledger","r");
csetotal=0;
commtotal=0;
while(!feof(cp))
{
i++;
fscanf(cp,"%d %[^\n]",&cno,client[i]);
clienttotal[i]=0;
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if((soudha.setn==trialset) && (strcmp(client[i],soudha.cname)==0))
{
float temptotal=1.0*soudha.quan*soudha.rate;
switch(soudha.choice)
{
case 's':csetotal+=temptotal;
clienttotal[i]-=soudha.net;break;
case 'b':csetotal-=temptotal;
clienttotal[i]+=soudha.net;
break;
default:break;
}
commtotal+=soudha.comm;
}
}
if(clienttotal[i]<0)
{
float temptotal=clienttotal[i]*-1.0;
credit+=temptotal;
}
else
debit+=clienttotal[i];
rewind(fp);
}
if(csetotal<0)
{
float temptotal=csetotal*-1.0;
credit+=temptotal;
}
else
debit+=csetotal;
credit+=commtotal;
strcpy(client[i],"CSE");
clienttotal[i]=csetotal;
i++;
strcpy(client[i],"BROKERAGE");
clienttotal[i]=commtotal;
maxlines=i;
fclose(fp);
fclose(cp);
if(opt==1) showbalance(i);
else printbalance();
}
//--------------------------------------------------------------------------
void showbalance(int l)
{
clrscr();
balanscreen();
gotoxy(1,4);
lptn=0;
maxlines=l;
for( l=1;l<=maxlines;l++)
{
if(l<=20)
{
lptn++;
printb(l,1);
}
}
gotoxy(38,25);
textcolor(RED);
textbackground(7);
printf("³%12.2f³%12.2fº",debit,credit);
scrollit(3);
if(sca==59) balancit(1);
}
//-------------------------------------------------------------------------
void cleanup()
{
fp=fopen("zledger","w");
fclose(fp);
sp=fopen("sledger","w");
fclose(sp);
cp=fopen("cledger","w");
fclose(cp);
statfp=fopen("status","w");
fclose(statfp);
statfp=fopen("status","w");
fprintf(statfp,"0\n0\n0\n");
fclose(statfp);
}
//--------------------------------------------------------------------------
void cleanfiles()
{
ret=tmenu(15,1,0,10,4,30,10,2,"WANT TO CLEAN ALL FILES",
"OK [ALL FILES WILL BE LOST]",
"CANCEL");
switch(ret)
{
case 1 : cleanup();
printf("CLEANED UP\n");
break;
default : break;
}
}
//---------------------------------------------------------------------------
void getmouse()
{
union REGS regs;
regs.x.ax=0;
int86(0x33,®s,®s);
if(regs.x.ax==0) printf("No mouse");
regs.x.ax=1;
int86(0x33,®s,®s);
}
//---------------------------------------------------------------------------
void killmouse()
{
regs.x.ax=2;
int86(0x33,®s,®s);
textbackground(BLACK);
}
//---------------------------------------------------------------------------
void modifi(int pv,int po)
{
passedvalue=pv;
passedoption=po;
assigntemp();
//makethechange();
}
//--------------------------------------------------------------------------
void makethechange()
{
int a;
//clrscr();
switch(passedoption)
{
case 2 :strcpy(chstr,"CLIENTNAME");break;
case 1 :strcpy(chstr,"SCRIPNAME");break;
default:break;
}
do
{
ret=tmenu(15,1,0,10,4,33,10,5,"CHANGE",
chstr,
"CHOICE",
"QUANTITY",
"RATE",
"EXIT");
switch(ret)
{
case 1:switch(passedoption)
{
case 1: dialoguebox(35,15,7,0,3,"EXISTING NAME",0);
gotoxy(40,17);
cprintf("%s",temp.scrip);
a=atoi(getit(wherex(),wherey(),1));
if(a==-13)
makethechange();
else if(a==-27)
{
changescrip();
makethechange();
}
break;
case 2: dialoguebox(35,15,7,0,3,"EXISTING NAME",0);
gotoxy(42,17);
cprintf("%s",temp.cname);
a=atoi(getit(wherex(),wherey(),1));
if(a==-13)
makethechange();
else if(a==-27)
{
changeclient();
makethechange();
}
break;
default: break;
}break;
case 2: dialoguebox(35,15,1,15,3,"EXISTING CHOICE",0);
gotoxy(43,17);
cprintf("%c",temp.choice);
a=atoi(getit(wherex(),wherey(),1));
if(a==-13)
makethechange();
else if(a==-27)
{
changechoice();
makethechange();
}
break;
case 3: dialoguebox(35,15,1,15,3,"EXISTING QUANTITY",0);
gotoxy(43,17);
cprintf("%d",temp.quan);
a=atoi(getit(wherex(),wherey(),1));
if(a==-13)
makethechange();
else if(a==-27)
{
changequantity();
makethechange();
}
break;
case 4: dialoguebox(35,15,1,15,3,"EXISTING RATE",0);
gotoxy(41,17);
cprintf("%d",temp.rate);
a=atoi(getit(wherex(),wherey(),1));
if(a==-13)
makethechange();
else if(a==-27)
{
changerate();
makethechange();
}
break;
case 5: delet(passedvalue);
appendtemp();
//showmenu();
break;
default:break;
}
}while(ret==0);
}
//---------------------------------------------------------------------------
void changescrip()
{
dialoguebox(35,15,1,15,3,"ENTER NEW NAME",25);
strcpy(temp.scrip,getit(wherex(),wherey(),25));
}
//---------------------------------------------------------------------------
void changeclient()
{
dialoguebox(35,15,1,15,3,"ENTER NEW NAME",25);
strcpy(temp.cname,getit(wherex(),wherey(),25));
}
//--------------------------------------------------------------------------
void changechoice()
{
dialoguebox(35,15,1,15,3,"ENTER NEW CHOICE",2);
strcpy(tempchoice,getit(wherex(),wherey(),25));
temp.choice=tempchoice[0];
}
//---------------------------------------------------------------------------
void changequantity()
{
dialoguebox(35,15,1,15,3,"ENTER NEW QUANTITY",6);
temp.quan=atoi(getit(wherex(),wherey(),6));
comeval();
}
//---------------------------------------------------------------------------
void changerate()
{
dialoguebox(35,15,1,15,3,"ENTER NEW RATE",6);
temp.rate=atoi(getit(wherex(),wherey(),6));
comeval();
}
//--------------------------------------------------------------------------
void assigntemp()
{
fp=fopen("zledger","r");
while(!feof(fp))
{
fscanf(fp,"%d%*c %d%*c%d%*c%d %d %[^\n] %[^\n] %c %d %d %d %f %f\n",&soudha.serno,
&date.day,&date.month,&date.year,&soudha.setn,soudha.scrip,soudha.cname,
&soudha.choice,&clientlf,&soudha.quan,&soudha.rate,
&soudha.comm,&soudha.net);
if(soudha.serno==passedvalue)
{
temp.setn=soudha.setn;
strcpy(temp.cname,soudha.cname);
strcpy(temp.scrip,soudha.scrip);
temp.choice=soudha.choice;
temp.quan=soudha.quan;
temp.rate=soudha.rate;
temp.comm=soudha.comm;
temp.net=soudha.net;
// fseek(fp,0L,2);
}
}
fclose(fp);
makethechange();
}
//---------------------------------------------------------------------------
void appendtemp()
{
fp=fopen("zledger","a");
fprintf(fp,"%d.\n %d:%d:%d %d\n %s\n %s\n %c %d %d %d %f %f\n",passedvalue,
date.day,date.month,date.year,temp.setn,temp.scrip,temp.cname,
temp.choice,clientlf,temp.quan,temp.rate,
temp.comm,temp.net);
fclose(fp);
}
//---------------------------------------------------------------------------
void addclient()
{
cp=fopen("cledger","a");
fprintf(cp,"%d %s",clientlf,temp.cname);
fclose(cp);
}
//--------------------------------------------------------------------------
void comeval()
{
temp.comm = (1.5*temp.quan*temp.rate)/100.00;
//int temptotal=temp.quan*temp.rate;
switch(temp.choice)
{
case 'b': temp.net =(float(temp.quan)*float(temp.rate)) + temp.comm;
break;
case 's': temp.net =(float(temp.quan)*float(temp.rate)) - temp.comm;
break;
default : break;
}
}
//--------------------------------------------------------------------------
syntax highlighted by Code2HTML, v. 0.9