1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Monthly Salary wages

Discussion in 'C++' started by knavkannu, Aug 25, 2008.

Thread Status:
Not open for further replies.
  1. knavkannu

    knavkannu New Member

    Joined:
    Jan 19, 2008
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<string.h>
    #include<math.h>
    #include<conio.h>
    #include<iostream.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<fstream.h>
    #include<iomanip.h>
    typedef char mon[44];
    mon m[]={
    	  "January",
    	  "February",
    	  "March",
    	  "April",
    	  "May",
    	  "June",
    	  "July",
    	  "August",
    	  "September",
    	  "October",
    	  "November",
    	  "December"
    	  };
    
    class table
    {
    char c1,c,c2,c3,c4,c5;
    public:
    void showtable();
    };
    void table::showtable()
    {
    c1=218;c=179;c2=196;c3=191;c4=217;c5=192;
    gotoxy(1,1);
    cout<<"Salary and wages sheet for the Month";
    gotoxy(72,1);
    cout<<"Unit-II";
    gotoxy(2,3);
    cout<<"S.";
    gotoxy(2,4);
    cout<<"No";
    for(int a=3;a<=24;a++)
    {
    gotoxy(4,a);
    cout<<c;
    }
    gotoxy(10,3);
    cout<<"Name";
    for(a=3;a<=24;a++)
    {
    gotoxy(18,a);
    cout<<c;
    }
    gotoxy(19,3);
    cout<<"T.No";
    for(a=3;a<=24;a++)
    {
    gotoxy(23,a);
    cout<<c;
    }
    gotoxy(25,3);
    cout<<"Rate";
    for(a=3;a<=24;a++)
    {
    gotoxy(30,a);
    cout<<c;
    }
    gotoxy(31,3);
    cout<<"Days";
    for(a=3;a<=24;a++)
    {
    gotoxy(35,a);
    cout<<c;
    }
    gotoxy(37,3);
    cout<<"Sal";
    for(a=3;a<=24;a++)
    {
    gotoxy(43,a);
    cout<<c;
     }
    gotoxy(44,3);
    cout<<"O.T";
    for(a=3;a<=24;a++)
    {
    gotoxy(48,a);
    cout<<c;
    }
    gotoxy(51,3);
    cout<<"O.T";
    gotoxy(51,4);
    cout<<"Sal";
    for(a=3;a<=24;a++)
    {
    gotoxy(57,a);
    cout<<c;
    }
    gotoxy(58,3);
    cout<<"Add";
    for(a=3;a<=24;a++)
    {
    gotoxy(62,a);
    cout<<c;
    }
    gotoxy(65,3);
    cout<<"Net";
    for(a=3;a<=24;a++)
    {
    gotoxy(72,a);
    cout<<c;
    }
    gotoxy(73,3);
    cout<<"Sign.";
    }
    void box(int x,int y,int xx,int yy)
    {
    gotoxy(x,y);
    printf("%c",218);
    gotoxy(xx,y);
    printf("%c",191);
    gotoxy(x,yy);
    printf("%c",192);
    gotoxy(xx,yy);
    printf("%c",217);
    x++;
    for(int s=x;s<xx;s++)
    {
    gotoxy(s,y);
    printf("%c",196);
    gotoxy(s,yy);
    printf("%c",196);
    }
    x--;
    y++;
    for(int d=y;d<yy;d++)
    {
    gotoxy(x,d);
    printf("%c",179);
    gotoxy(xx,d);
    printf("%c",179);
    }
    y+=2;
    x++;
    /*for(d=x;d<xx;d++)
    {
    gotoxy(d,y);
    printf("%c",196);
    } */
    }
    
    void normalvideo(int x,int y,char s[44])
    {
    gotoxy(x,y);
    cprintf("%s",s);
    }
    void reversevideo(int x,int y,char s[44])
    {
    textcolor(5+143);
    textbackground(3);
    gotoxy(x,y);
    cprintf("%s",s);
    textcolor(BLUE);
    textbackground(GREEN);
    }
    class date
    {
    public:
    int month,year;
    void entermonth();
    void enteryear();
    int returnmonth();
    int returnyear();
    };
    
    
    class personid
    {
    double rate,token;
    int sno;
    char name[33];
    public:
    void readfile();
    void addtopersonid(int,char[20],double,double);
    int returnserialpersonid();
    void deletepersonid(double);
    double returntokensno(double);
    char *returnname(double);
    double returnrate(double);
    int valid(double);
    int token_valid(double);
    int token_valid2(double,double);
    void modify_record(double);
    void modified(int,char[20],double,double);
    };
    class rec
    {
    char name[33];
    double token,rate,days,sal,ot,otsal,deduct,add,net;
    int sno;
    public:
    int returnsno(int,int);
    void addrec();
    void addtofile(int,char[20],double,double,double,double,double,double,
    double,double,double,int,int);
    void deletefromfile(int,int,double);
    void readfile();
    void menu();
    int monno();
    void indi_record();
    };
    void personid::addtopersonid(int s,char a[20],double d, double r)
    {
    sno=s;
    strcpy(name,a);
    token=d;
    rate=r;
    fstream f;
    f.open("Pers",ios::out|ios::app);
    f.write((char*)this,sizeof(personid));
    f.close();
    }
    
    void personid::readfile()
    {
    rec rr;
    int count=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    start:
    int r=6;
    while(f.read((char*)this,sizeof(personid)))
    {
    count++;
    gotoxy(3,4);
    cout<<"S.No";
    gotoxy(12,4);
    cout<<"Name";
    gotoxy(32,4);
    cout<<"Token";
    gotoxy(45,4);
    cout<<"Rate";
    gotoxy(3,r);
    cout<<sno;
    gotoxy(12,r);
    cout<<name;
    gotoxy(32,r);
    cout<<token;
    gotoxy(45,r);
    cout<<rate;
    r+=2;
    if(r==26)
    {
    getch();
    clrscr();
    goto start;
    }
    }
    if(count==0)
    {
    gotoxy(24,4);
    cout<<"No record found";
    }
    
    f.clear();
    f.close();
    }
    double personid::returntokensno(double t)
    {
    double s=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    s=sno;
    break;
    }
    }
    f.clear();
    f.close();
    return(s);
    }
    void personid::deletepersonid(double t)
    {
    int count=0;
    rec r;
    fstream f,ff;
    f.open("Pers",ios::in);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    count++;
    }
    }
    f.clear();
    f.close();
    if(count==0)
    {
    cout<<"There is no such token number";
    }
    else
    {
    double sn=returntokensno(t);
    f.open("Temp",ios::out);
    ff.open("Pers",ios::in);
    ff.seekg(0);
    while(!ff.eof())
    {
    ff.read((char*)this,sizeof(personid));
    if(ff.eof())
    break;
    if(token!=t)
    {
    //f.write((char*)this,sizeof(personid));
    if(sno>sn)
    {
    sno--;
    f.write((char*)this,sizeof(personid));
    }
    else
    {
    f.write((char*)this,sizeof(personid));
    }
    }
    }
    f.close();
    ff.clear();
    ff.close();
    f.open("Temp",ios::in);
    ff.open("Pers",ios::out);
    f.seekg(0);
    while(!f.eof())
    {
    f.read((char*)this,sizeof(personid));
    if(f.eof())
    break;
    ff.write((char*)this,sizeof(personid));
    }
    f.clear();
    f.close();
    ff.close();
    }
    }
    int personid::returnserialpersonid()
    {
    int w=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    w=sno;
    }
    f.clear();
    f.close();
    return(w);
    }
    char *personid::returnname(double t)
    {
    char indi_name[20];
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    strcpy(indi_name,name);
    }
    }
    f.close();
    f.clear();
    return(indi_name);
    }
    double personid::returnrate(double t)
    {
    double r;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    r=rate;
    }
    }
    f.clear();
    f.close();
    return(r);
    }
    int personid::valid(double t)
    {
    int c=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    c++;
    }
    }
    f.clear();
    f.close();
    if(c==1)
    return 1;
    else
    return 0;
    }
    int personid::token_valid(double t)
    {
    int c=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t==token)
    {
    c++;
    }
    }
    f.clear();
    f.close();
    if(c==0)
    return 1;
    else
    return 0;
    }
    int personid::token_valid2(double t,double tt)
    {
    int c=0;
    fstream f;
    f.open("Pers",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(personid)))
    {
    if(t!=tt&&tt==token)
    {
    c++;
    }
    }
    f.clear();
    f.close();
    if(c==0)
    return 1;
    else
    return 0;
    }
    
    void personid::modify_record(double t)
    {
    rec r;
    if(!valid(t))
    {
    clrscr();
    gotoxy(33,7);
    cout<<"No such token number exist";
    }
    else
    {
    clrscr();
    int sn=returntokensno(t);
    char a[20],s[20];
    double tok,rat;
    gotoxy(3,5);
    strcpy(a,returnname(t));
    cout<<"Name = "<<a;
    gotoxy(3,7);
    cout<<"Rate = "<<returnrate(t);
    gotoxy(26,12);
    cout<<"Enter Name  = ";
    gotoxy(26,14);
    cout<<"Enter Token  = ";
    gotoxy(26,16);
    cout<<"Enter Rate = ";
    gotoxy(40,12);
    cin>>s;
    double h,first,second,items[20];
    int x=0,num,v,g,no[4];
    char cc;
    int row=14,col=40;
    for(int ss=0;ss<=1;ss++)
    {
    s2:
    x=0;
    col=40;
    sss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==8&&x==0)
    {
    gotoxy(40,14);
    goto s2;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto sss;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    r.menu();
    }
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13&&cc!=46);
    if(cc==46)
    {
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    first=h;
    s3:
    x=0;
    //col=25;
    ssss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==72)
    {
    gotoxy(40,row);
    cout<<"                    ";
    row-=2;
    gotoxy(40,row);
    cout<<"                    ";
    ss--;
    goto s3;
    }
    else if(cc==8&&x==0)
    {
    gotoxy(40,14);
    goto s3;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto ssss;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    r.menu();
    }
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13);
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    second=h;
    second=second/(pow(10,x));
    items[ss]=first+second;
    }
    else
    {
    double g=x-1,h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    items[ss]=h;
    }
    if(ss==0)
    {
    if(!token_valid2(t,items[0]))
    {
    clrscr();
    gotoxy(25,7);
    cout<<"That Token number is already in use";
    getch();
    r.menu();
    }
    }
    row+=2;
    }
    char hh;
    do
    {
    gotoxy(48,5);
    cout<<"Want to add record: -";
    gotoxy(50,7);
    cout<<"Press y for yes";
    gotoxy(50,9);
    cout<<"Press n for no";
    gotoxy(68,8);
    hh=getch();
    if(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N')
    {
    gotoxy(68,8);
    cout<<" ";
    }
    else
    {
    gotoxy(68,8);
    cout<<hh;
    getch();
    }
    }while(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N');
    if(hh=='y'||hh=='Y')
    {
    modified(sn,s,items[0],items[1]);
    clrscr();
    gotoxy(33,4);
    cout<<"Record Modified";
    }
    }
    }
    void personid::modified(int sn,char n[20],double t,double r)
    {
    sno=sn;
    strcpy(name,n);
    token=t;
    rate=r;
    fstream f;
    f.open("Pers",ios::out|ios::ate);
    f.seekp((sn-1)*sizeof(personid));
    f.write((char*)this,sizeof(personid));
    }
    void rec::readfile()
    {
    date d;
    int month=d.returnmonth();
    int year= d.returnyear();
    if(month==0&&year==0)
    {
    clrscr();
    gotoxy(15,5);
    cout<<"First select month and enter year from the main menu";
    getch();
    clrscr();
    menu();
    }
    else if(year==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Month="<<m[d.month-1];
    gotoxy(20,5);
    cout<<"First please enter year";
    getch();
    clrscr();
    menu();
    }
    else if(month==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Year="<<d.year;
    gotoxy(20,5);
    cout<<"First please enter month";
    getch();
    clrscr();
    menu();
    }
    else
    {
    table t;
    char s[20],ss[20];
    itoa(month,s,10);
    itoa(year,ss,10);
    strcat(s,ss);
    //cout<<s;getch();
    fstream f;
    f.open(s,ios::in);
    f.seekg(0);
    int count=0;
    start:
    int r=6;
    while(f.read((char*)this,sizeof(rec)))
    {
    box(1,2,79,25);
    for(int dd=2;dd<79;dd++)
    {
    gotoxy(dd,5);
    printf("%c",196);
    }
    t.showtable();
    gotoxy(38,1);
    cout<<m[month-1];
    cout<<" and year ";
    cout<<year;
    count++;
    gotoxy(2,r);
    cout<<sno;
    gotoxy(5,r);
    cout<<name;
    gotoxy(19,r);
    cout<<token;
    gotoxy(24,r);
    cout<<rate;
    gotoxy(31,r);
    cout<<days;
    gotoxy(36,r);
    cout<<sal;
    gotoxy(44,r);
    cout<<ot;
    gotoxy(49,r);
    cout<<otsal;
    gotoxy(58,r);
    cout<<add;
    gotoxy(63,r);
    cout.setf(ios::fixed);
    cout<<setprecision(2)<<net;
    r++;
    for(int ddd=2;ddd<79;ddd++)
    {
    gotoxy(ddd,r);
    printf("%c",196);
    }
    r++;
    if(r==26)
    {
    getch();
    clrscr();
    goto start;
    }
    }
    if(count==0)
    {
    gotoxy(24,4);
    cout<<"No record found for "<<m[month-1]<<" "<<year;
    getch();
    clrscr();
    menu();
    }
    f.clear();
    f.close();
    }
    }
    void rec::addtofile(int nn,char n[20],double t,double r,double d,double sa,
    double over,double oversal,double a,double dd,double ne,int m,int y)
    {
    sno=nn;
    strcpy(name,n);
    token=t;
    rate=r;
    days=d;
    sal=sa;
    ot=over;
    otsal=oversal;
    add=a;
    deduct=dd;
    net=ne;
    char s[20],ss[20];
    itoa(m,s,10);
    itoa(y,ss,10);
    strcat(s,ss);
    fstream f;
    f.open(s,ios::out|ios::app);
    f.write((char*)this,sizeof(rec));
    f.close();
    //cout<<s;getch();
    }
    void rec::deletefromfile(int month,int year,double t)
    {
    char s[20],ss[20];
    itoa(month,s,10);
    itoa(year,ss,10);
    strcat(s,ss);
    fstream f,ff;
    f.open(s,ios::in);
    ff.open("abc",ios::out);
    f.seekg(0);
    while(!f.eof())
    {
    f.read((char*)this,sizeof(rec));
    if(f.eof())
    break;
    if(token!=t)
    ff.write((char*)this,sizeof(rec));
    }
    f.clear();
    f.close();
    ff.close();
    f.open(s,ios::out);
    ff.open("abc",ios::in);
    ff.seekg(0);
    while(!ff.eof())
    {
    ff.read((char*)this,sizeof(rec));
    if(ff.eof())
    break;
    if(token!=t)
    f.write((char*)this,sizeof(rec));
    }
    ff.clear();
    ff.close();
    f.close();
    }
    
    int date::returnyear()
    {
    int y=0;
    fstream f;
    f.open("year",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(date)))
    {
    y=year;
    }
    f.clear();
    f.close();
    return (y);
    }
    
    
    
    int date::returnmonth()
    {
    int s=0;
    fstream f;
    f.open("month",ios::in);
    f.seekg(0);
    while(f.read((char*)this,sizeof(date)))
    {
    s=month;
    }
    f.clear();
    f.close();
    return (s);
    }
    
    void date::entermonth()
    {
    int s=0,d;
    rec r;
    d=r.monno();
    month=s+d;
    fstream f;
    f.open("month",ios::trunc|ios::out);
    f.write((char*)this,sizeof(date));
    f.close();
    }
    
    void date::enteryear()
    {
    start:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    rec r;
    gotoxy(10,3);
    cout<<"Enter year";
    char w;
    int y1,y2,y3,y4,s,a;
    gotoxy(22,4);
    w=getch();
    if(w==27)
    {
    clrscr();
    r.menu();
    }
    cout<<w;
    y1=int(w);
    s=-1;
    for(a=48;a<=57;a++)
    {
    s++;
    if(a==y1)
    break;
    }
    y1=s;
    if(y1!=2)
    {
    clrscr();
    gotoxy(27,10);
    cout<<"Please enter year between 2000-2099";
    getch();
    clrscr();
    goto start;
    }
    gotoxy(23,4);
    w=getch();
    if(w==27)
    {
    clrscr();
    r.menu();
    }
    cout<<w;
    y2=int(w);
    s=-1;
    for(a=48;a<=57;a++)
    {
    s++;
    if(a==y2)
    break;
    }
    y2=s;
    gotoxy(24,4);
    w=getch();
    if(w==27)
    {
    clrscr();
    r.menu();
    }
    cout<<w;
    y3=int(w);
    s=-1;
    for(a=48;a<=57;a++)
    {
    s++;
    if(a==y3)
    break;
    }
    y3=s;
    gotoxy(25,4);
    w=getch();
    if(w==27)
    {
    clrscr();
    r.menu();
    }
    cout<<w;
    y4=int(w);
    s=-1;
    for(a=48;a<=57;a++)
    {
    s++;
    if(a==y4)
    break;
    }
    y4=s;
    year=(y1*1000)+(y2*100)+(y3*10)+y4;
    fstream f;
    f.open("year",ios::out);
    f.write((char*)this,sizeof(date));
    f.close();
    }
    
    int rec::returnsno(int month,int year)
    {
    char s[10],ss[10];
    itoa(month,s,10);
    itoa(year,ss,10);
    strcat(s,ss);
    fstream f;
    f.open(s,ios::in);
    f.seekg(0);
    int w=0;
    while(f.read((char*)this,sizeof(rec)))
    {
    w=sno;
    }
    f.clear();
    f.close();
    return(w);
    }
    void rec::indi_record()
    {
    start:
    date d;
    int month=d.returnmonth();
    int year= d.returnyear();
    char s[20],ss[20];
    itoa(month,s,10);
    itoa(year,ss,10);
    strcat(s,ss);
    if(month==0&&year==0)
    {
    clrscr();
    gotoxy(15,5);
    cout<<"First select month and enter year from the main menu";
    getch();
    clrscr();
    menu();
    }
    else if(year==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Month="<<m[d.month-1];
    gotoxy(20,5);
    cout<<"First please enter year";
    getch();
    clrscr();
    menu();
    }
    else if(month==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Year="<<d.year;
    gotoxy(20,5);
    cout<<"First please enter month";
    getch();
    clrscr();
    menu();
    }
    
    else
    {
    personid pi;
    int ssno=returnsno(month,year);
    ssno++;
    int sn=pi.returnserialpersonid();
    sn++;
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    gotoxy(20,2);
    cout<<m[month-1];
    char cc;
    box(9,2,45,20);
    gotoxy(60,2);
    cout<<m[month-1]<<","<<year;
    gotoxy(26,4);
    cout<<"Enter";
    gotoxy(12,6);
    cout<<"Name";
    gotoxy(12,8);
    cout<<"T.No.";
    gotoxy(12,10);
    cout<<"Rate";
    gotoxy(12,12);
    cout<<"Days";
    gotoxy(12,14);
    cout<<"OT";
    gotoxy(12,16);
    cout<<"Deduction";
    gotoxy(12,18);
    cout<<"Add";
    int cou=0;
    double tok;
    do
    {
    gotoxy(25,8);
    cout<<"Enter token number";
    getch();
    cou++;
    }while(cou!=1);
    start2:
    gotoxy(10,22);
    cout<<"                                               ";
    gotoxy(25,8);
    cout<<"                    ";
    gotoxy(25,10);
    cout<<"                    ";
    gotoxy(25,8);
    cin>>tok;
    char abc[20];
    if(!pi.valid(tok))
    {
    gotoxy(25,8);
    cout<<"No such token number";
    gotoxy(25,10);
    cout<<"exist in the record";
    gotoxy(10,22);
    cout<<"Exit = 'Menu'";
    gotoxy(26,22);
    cout<<"Continue = 'Any Key'";
    cc=getch();
    if(cc==27)
    {
    menu();
    }
    goto start2;
    }
    else
    {
    gotoxy(10,22);
    cout<<"                                               ";
    gotoxy(25,6);
    strcpy(abc,pi.returnname(tok));
    cout<<abc;
    gotoxy(25,10);
    cout<<pi.returnrate(tok);
    }
    char nname[20];
    int ddays;
    int col=25,row=6;
    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
    {
    ddays=31;
    }
    else if(month==4||month==6||month==9||month==11)
    {
    ddays=30;
    }
    else if(month==2)
    {
    if((year%4)==0)
    {
    ddays=29;
    }
    else
    {
    ddays=28;
    }
    }
    
    double first,second,g,h,aa,x,v,num,no[20],items[6]={0},column[22];
    verystart:
    row=12;col=25;
    for(int ss=0;ss<=3;ss++)
    {
    s2:
    x=0;
    col=25;
    sss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==27)
    {
    clrscr();
    goto start;
    }
    if(ss!=0)
    {
    if(cc==72)
    {
    gotoxy(25,row);
    cout<<"                    ";
    row-=2;
    gotoxy(25,row);
    cout<<"                    ";
    aa=items[ss];
    ss--;
    items[ss+1]=aa;
    goto s2;
    }
    }
    else if(cc==8&&x==0)
    {
    gotoxy(25,12);
    goto s2;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto sss;
    }
    
    else if(cc==113||cc==81)
    {
    clrscr();
    menu();
    }
    
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13&&cc!=46);
    if(cc==46)
    {
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    first=h;
    s3:
    x=0;
    //col=25;
    ssss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==27)
    {
    clrscr();
    goto start;
    }
    else if(cc==72)
    {
    gotoxy(25,row);
    cout<<"                    ";
    row-=2;
    gotoxy(25,row);
    cout<<"                    ";
    aa=items[ss];
    ss--;
    items[ss+1]=aa;
    goto s3;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto ssss;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    menu();
    }
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13);
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    second=h;
    second=second/(pow(10,x));
    items[ss]=first+second;
    }
    else
    {
    double g=x-1,h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    items[ss]=h;
    }
    //gotoxy(35,row);
    //cout<<items[ss];
    row+=2;
    column[ss]=col;
    if(ss==0)
    {
    if(items[ss]>ddays)
    {
    ss--;
    gotoxy(25,12);
    cout<<m[month-1]<<" month has";
    gotoxy(25,14);
    cout<<"only "<<ddays<<" days";
    getch();
    gotoxy(25,12);
    cout<<"                   ";
    gotoxy(25,14);
    cout<<"                   ";
    row-=2;
    }
    }
    }
    gotoxy(35,12);
    cout<<items[0];
    gotoxy(35,14);
    cout<<items[1];
    gotoxy(35,16);
    cout<<items[2];
    gotoxy(35,18);
    cout<<items[3];
    double day=pi.returnrate(tok)/ddays;
    double dddays=items[0];
    double ssal=dddays*day;
    double oot=items[1];
    double overtimesal=day/8;
    double ootsal=oot*overtimesal;
    double ddeduct=items[2];
    double aadd=items[3];
    double nnet=ssal+ootsal+aadd-ddeduct;
    gotoxy(40,40);
    cout<<nnet;
    char hh;
    do
    {
    gotoxy(48,5);
    cout<<"Want to add record: -";
    gotoxy(50,7);
    cout<<"Press y for yes";
    gotoxy(50,9);
    cout<<"Press n for no";
    gotoxy(68,8);
    hh=getch();
    if(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N')
    {
    gotoxy(68,8);
    cout<<" ";
    }
    else
    {
    gotoxy(68,8);
    cout<<hh;
    getch();
    }
    }while(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N');
    if(hh=='y'||hh=='Y')
    {
    addtofile(ssno,pi.returnname(tok),tok,pi.returnrate(tok),dddays,ssal,oot,ootsal,aadd,ddeduct,nnet,
    month,year);
    //pi.addtopersonid(sn,nname,ttoken,rrate);
    }
    clrscr();
    gotoxy(15,30);
    cout<<"<Enter>=Continue";
    gotoxy(50,30);
    cout<<"Escape=<Esc>";
    do
    {
    hh=getch();
    }while(hh!=13&&hh!=27);
    if(hh==13)
    goto start;
    else if(hh==27)
    menu();
    }
    }
    
    void rec::addrec()
    {
    start:
    date d;
    int month=d.returnmonth();
    int year= d.returnyear();
    char s[20],ss[20];
    itoa(month,s,10);
    itoa(year,ss,10);
    strcat(s,ss);
    if(month==0&&year==0)
    {
    clrscr();
    gotoxy(15,5);
    cout<<"First select month and enter year from the main menu";
    getch();
    clrscr();
    menu();
    }
    else if(year==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Month="<<m[d.month-1];
    gotoxy(20,5);
    cout<<"First please enter year";
    getch();
    clrscr();
    menu();
    }
    else if(month==0)
    {
    clrscr();
    gotoxy(5,3);
    cout<<"Year="<<d.year;
    gotoxy(20,5);
    cout<<"First please enter month";
    getch();
    clrscr();
    menu();
    }
    
    else
    {
    personid pi;
    int ssno=returnsno(month,year);
    ssno++;
    if(ssno==1)
    {
    addtofile(0,"Gaurav",0,0,0,0,0,0,0,0,0,month,year);
    deletefromfile(month,year,0);
    }
    int sn=pi.returnserialpersonid();
    sn++;
    if(sn==1)
    {
    pi.addtopersonid(0,"Anil",0,0);
    pi.deletepersonid(0);
    }
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    gotoxy(20,2);
    cout<<m[month-1];
    char cc;
    box(9,2,45,20);
    gotoxy(60,2);
    cout<<m[month-1]<<","<<year;
    gotoxy(26,4);
    cout<<"Enter";
    gotoxy(12,6);
    cout<<"Name";
    gotoxy(12,8);
    cout<<"T.No.";
    gotoxy(12,10);
    cout<<"Rate";
    gotoxy(12,12);
    cout<<"Days";
    gotoxy(12,14);
    cout<<"OT";
    gotoxy(12,16);
    cout<<"Deduction";
    gotoxy(12,18);
    cout<<"Add";
    int col=25,row=6;
    /*do
    {
    gotoxy(col,row);
    cc=getch();
    cout<<cc;
    a[c++]=cc;
    col++;
    if(cc==27)
    {
    clrscr();
    goto start;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    menu();
    }
    }while(cc!=13);*/
    char nname[20];
    gotoxy(col,row);
    gets(nname);
    int ddays;
    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
    {
    ddays=31;
    }
    else if(month==4||month==6||month==9||month==11)
    {
    ddays=30;
    }
    else if(month==2)
    {
    if((year%4)==0)
    {
    ddays=29;
    }
    else
    {
    ddays=28;
    }
    }
    
    double first,second,g,h,aa,x,v,num,no[20],items[6]={0},column[22];
    verystart:
    row=8;col=25;
    for(int ss=0;ss<=5;ss++)
    {
    s2:
    x=0;
    col=25;
    sss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==27)
    {
    clrscr();
    goto start;
    }
    else if(cc==72)
    {
    gotoxy(25,row);
    cout<<"                    ";
    row-=2;
    gotoxy(25,row);
    cout<<"                    ";
    aa=items[ss];
    ss--;
    items[ss+1]=aa;
    goto s2;
    }
    else if(cc==8&&x==0)
    {
    gotoxy(25,12);
    goto s2;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto sss;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    menu();
    }
    
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13&&cc!=46);
    if(cc==46)
    {
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    first=h;
    s3:
    x=0;
    //col=25;
    ssss:
    gotoxy(col,row);
    do
    {
    cc=getch();
    if(cc==27)
    {
    clrscr();
    goto start;
    }
    else if(cc==72)
    {
    gotoxy(25,row);
    cout<<"                    ";
    row-=2;
    gotoxy(25,row);
    cout<<"                    ";
    aa=items[ss];
    ss--;
    items[ss+1]=aa;
    goto s3;
    }
    else if(cc==8)
    {
    x--;
    col--;
    gotoxy(col,row);
    cout<<" ";
    goto ssss;
    }
    else if(cc==113||cc==81)
    {
    clrscr();
    menu();
    }
    cout<<cc;
    col++;
    num=-1;
    for(v=48;v<=57;v++)
    {
    num++;
    if(cc==v)
    {
    no[x++]=num;
    break;
    }
    }
    }while(cc!=13);
    g=x-1;h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    second=h;
    second=second/(pow(10,x));
    items[ss]=first+second;
    }
    else
    {
    double g=x-1,h=0;
    for(v=0;v<x;v++)
    {
    h=h+no[v]*pow(10,g);
    g--;
    }
    items[ss]=h;
    }
    //gotoxy(35,row);
    //cout<<items[ss];
    row+=2;
    column[ss]=col;
    if(ss==2)
    {
    if(items[ss]>ddays)
    {
    ss--;
    gotoxy(25,12);
    cout<<m[month-1]<<" month has";
    gotoxy(25,14);
    cout<<"only "<<ddays<<" days";
    getch();
    gotoxy(25,12);
    cout<<"                   ";
    gotoxy(25,14);
    cout<<"                   ";
    row-=2;
    }
    }
    if(!pi.token_valid(items[0]))
    {
    gotoxy(25,8);
    cout<<"That Token number";
    gotoxy(25,10);cout<<"is already in use";
    getch();
    //break;
    gotoxy(25,8);
    cout<<"                    ";
    gotoxy(25,10);
    cout<<"                    ";
    goto verystart;
    }
    }
    gotoxy(35,8);
    cout<<items[0];
    gotoxy(35,10);
    cout<<items[1];
    gotoxy(35,12);
    cout<<items[2];
    gotoxy(35,14);
    cout<<items[3];
    gotoxy(35,16);
    cout<<items[4];
    gotoxy(35,18);
    cout<<items[5];
    double ttoken=items[0];
    double rrate=items[1];
    double day=rrate/ddays;
    double dddays=items[2];
    double ssal=dddays*day;
    double oot=items[3];
    double overtimesal=day/8;
    double ootsal=oot*overtimesal;
    double ddeduct=items[4];
    double aadd=items[5];
    double nnet=ssal+ootsal+aadd-ddeduct;
    gotoxy(40,40);
    cout<<nnet;
    char hh;
    do
    {
    gotoxy(48,5);
    cout<<"Want to add record: -";
    gotoxy(50,7);
    cout<<"Press y for yes";
    gotoxy(50,9);
    cout<<"Press n for no";
    gotoxy(68,8);
    hh=getch();
    if(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N')
    {
    gotoxy(68,8);
    cout<<" ";
    }
    else
    {
    gotoxy(68,8);
    cout<<hh;
    }
    }while(hh!='y'&&hh!='n'&&hh!='Y'&&hh!='N');
    if(hh=='y'||hh=='Y')
    {
    getch();
    addtofile(ssno,nname,ttoken,rrate,dddays,ssal,oot,ootsal,aadd,ddeduct,nnet,
    month,year);
    pi.addtopersonid(sn,nname,ttoken,rrate);
    }
    }
    }
    int rec::monno()
    {
    rec re;
    textcolor(BLUE);
    textbackground(GREEN);
    box(19,1,29,25);
    int c=20;
    for(int s=0,r=2;r<=24;r+=2,s++)
    {
    normalvideo(c,r,m[s]);
    }
    reversevideo(c,2,m[0]);
    r=2;                 s=0;
    int v=0;
    int k;
    do
    {
    k=getch();
    switch(k)
    {
    case 00:
    k=getch();
    switch(k)
    {
    case 80:
    normalvideo(20,r,m[s]);
    r+=2;
    s++;
    if(s==12)
    {
    r=2;
    s=0;
    }
    reversevideo(20,r,m[s]);
    break;
    case 72:
    normalvideo(20,r,m[s]);
    r-=2;
    s--;
    if(s<0)
    {
    r=24;
    s=11;
    }
    reversevideo(20,r,m[s]);
    break;
    }
    break;
    case 13:
    v=1;
    break;
    case 27:
    v=1;
    re.menu();
    }}while(v!=1);
    return(s+1);
    }
    
    typedef char option[44];
    option o[]={
    	     "What you want to do",
    	     "Enter New Record",
    	     "Enter Individual Record",
    	     "View Month Record",
    	     "View Person Record",
    	     "Delete Individual Record",
    	     "Modify Individual Record",
    	     "Enter month",
    	     "Enter year",
    	     "Exit"
    	     };
    
    
    int options()
    {
    box(30,2,55,24);
    for(int d=31;d<55;d++)
    {
    gotoxy(d,5);
    printf("%c",196);
    }
    textcolor(BLUE);
    textbackground(GREEN);
    for(int s=0,r=4;r<=22;r+=2,s++)
    {
    normalvideo(31,r,o[s]);
    }
    reversevideo(31,6,o[1]);
    s=1;
    r=6;
    int v=0;
    int k;
    do
    {
    k=getch();
    switch(k)
    {
    case 00:
    k=getch();
    switch(k)
    {
    case 80:
    normalvideo(31,r,o[s]);
    r+=2;
    s++;
    if(r==24)
    {
    r=6;
    s=1;
    }
    reversevideo(31,r,o[s]);
    break;
    case 72:
    normalvideo(31,r,o[s]);
    r-=2;
    s--;
    if(r==4)
    {
    r=22;
    s=9;
    }
    reversevideo(31,r,o[s]);
    break;
    }
    break;
    case 13:
    v=1;
    }}while(v!=1);
    return(s);
    }
    
    void rec::menu()
    {
    personid p;
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    date d;
    int month=d.returnmonth();
    int year=d.returnyear();
    int o;
    table t;
    rec r;
    o=options();
    switch(o)
    {
    case 1:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    r.addrec();
    r.menu();
    break;
    case 2:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    r.indi_record();
    getch();
    clrscr();
    r.menu();
    break;
    case 3:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    readfile();
    getch();
    menu();
    break;
    case 4:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    p.readfile();
    getch();
    clrscr();
    menu();
    break;
    case 5:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    gotoxy(4,3);
    cout<<"Enter token number of a row to be deleted";
    double t;
    gotoxy(46,3);
    cin>>t;
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    p.deletepersonid(t);
    getch();
    clrscr();
    menu();
    break;
    case 6:
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    gotoxy(3,4);
    cout<<"Enter token number of which the record is to be modified";
    double tt;
    gotoxy(60,4);
    cin>>tt;
    p.modify_record(tt);
    getch();
    clrscr();
    menu();
    break;
    case 7:
    date d;
    textcolor(WHITE);
    textbackground(BLACK);
    clrscr();
    d.entermonth();
    clrscr();
    menu();
    break;
    case 8:
    d.enteryear();
    clrscr();
    menu();
    break;
    case 9:
    exit(0);
    break;
    }
    }
    void main()
    {
    clrscr();
    rec r;
    r.menu();
    }
     
    Last edited by a moderator: Aug 25, 2008
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page