Blood Donation System Report in C++
Blood Donation System Report in C++
On
BLOOD DONATION
SYSTEM
.
ACKNOWLEDGEMENT
2. Source Code
3. Output
4. Requirement
6. Conclusion
7. System design
This project BLOOD DONATION SYSTEM includes some facilities
for the patients to search and get the required blood from the
blood bank and if there is no blood available for the patients
the blood bank provide the other group blood that is
compatible for the patients and the patient can also search the
donars according to their blood group and can directly contact
to the donars also on the basis of city or blood group.
This software keep the records of all the donars and their
information about how many time they donated the blood to
the blood bank with the dates of donation of blood.
The blood bank keep the records of the patient to whom the
blood is given for the future records if needed by the
management.
//***************************************************************
// HEADER FILE USED IN PROJECT
//****************************************************************
#include<stdio.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
#include<iomanip.h>
#include<string.h>
#include<ctype.h>
struct otherinfo
{
char mobno[15];
char email[70];
char bloodgroup[5];
char status;
};
//name structure
struct nameinfo
{
char fname[20];
char lname[20];
int age;
};
// address structure
struct address
{
int hno;
char city[35];
char state[15];
};
//date structure
struct dateinfo
{
int dd;
int mm;
int yy;
};
struct donardate
{
char donarreg[25];
dateinfo dt;
};
//******************FUNCTION PROTOTYPE****************
void intromain();
int getdonarno();
int checkpass();
void intro();
void donar_new_old();
void admin_menu();
void donar_menu();
char *getreg();
char *getpatno();
void donar_report_menu();
void display_bloodstock();
void write_donars();
void patients_menu();
void write_donar_ALREDYREG(char rgno[15]);
void displaydonarwithlist(char rgno[15]);
void displaybloodgroupwise(char bgp[5]);
void searchdonarcitywise(char city[15]);
void display_bloodavailable(char blgrp[5]);
int display_bloodavailable2(char blgrp[5]);
void modify_donarinfo(char regno[5]);
void patients_menu(char brg[5]);
void write_bloodstock(char bldgr[5]);
void decrease_bloodstock(char bldgr[5]);
void patients_menu(char brg[5]);
void displaypatientdetails(dateinfo bgp);
void delete_donarinfo(char regno[5]);
//******************FUNCTION PROTOTYPE****************
}
//blood stock class
struct storeblood
{
char blno[10];
char bloodgroup[5];
int qty;
};
//FILE NAME bloodstock.dat
void stockbloodonetime()
{
storeblood stockbl[8]={{"BL01","A+",1},{"BL02","A-",1},{"BL03","B+",1},{"BL04","B-",1},{"BL05","AB+",1},{"BL06","AB-",1},
{"BL07","O+",1},{"BL08","O-",1}};
ifstream objiff("bloodstock.dat",ios::binary);
storeblood st;
if(!objiff)
{
gotoxy(10,20);
cout<<"File could not be open !! Press any Key...";
getch();
ofstream objoff("bloodstock.dat",ios::binary);
clrscr();
intromain();
for(int x=0;x<8;x++)
{
st=stockbl[x];
objoff.write((char*)&st,sizeof(storeblood));
}
objoff.close();
}
clrscr();
intromain();
gotoxy(5,7);
cout<<"----------------The Blood Group System-------------------------";
gotoxy(2,8);
cout<<"There are four major blood groups determined by the presence or";
gotoxy(2,9);
cout<<"absence of two antigens A and B on the surface of red blood cells:";
gotoxy(2,11);
cout<<"Group A has only the A antigen on red cells (and B antibody in the plasma)";
gotoxy(2,13);
cout<<"Group B has only the B antigen on red cells (and A antibody in the plasma)";
gotoxy(2,15);
cout<<"Group AB has both A and B antigens on red cells (but neither A nor B antibody in the plasma)";
gotoxy(2,18);
cout<<"Group O has neither A nor B antigens on red cells (but both A and B antibody are in the plasma)";
gotoxy(5,20);
cout<<"================================================================";
objiff.close();
//***************donar's class**********************************
class donar
{
int dono;
char donar_regist[15];
nameinfo nm;
address add;
dateinfo date1;
otherinfo other;
public:
donar()
{
dono=0;
};
char *getdonarreg()
{
return donar_regist;
}
dateinfo getdate()
{
return date1;
}
char *getbloodname()
{
return other.bloodgroup;
}
//input fuction for donar information
void create_donar(int dn1)
{
gotoxy(5,7);
cout<<"======================================================================";
gotoxy(1,8);
cout<<"DONAR NO:";
dono=dn1;
gotoxy(10,8);
cout<<dono;
gotoxy(20,8);
cout<<"DONAR/'S REGISTRATION:";
gotoxy(48,8);
cin>>donar_regist;
gotoxy(20,9);
cout<<"FIRST NAME:";
gotoxy(32,9);
cin>>nm.fname;
gotoxy(48,9);
cout<<"LAST NAME:";
gotoxy(60,9);
cin>>nm.lname;
gotoxy(10,10);
cout<<"AGE:";
gotoxy(20,10);
cin>>nm.age;
gotoxy(10,11);
cout<<"-----------------DONAR'S ADDRESS DETAIL'S---------------------";
gotoxy(1,13);
cout<<"HOUSE NO:";
gotoxy(12,13);
cin>>add.hno;
gotoxy(18,13);
cout<<"city:";
gotoxy(30,13);
cin>>add.city;
gotoxy(55,13);
cout<<"STATE:";
gotoxy(65,13);
cin>>add.state;
gotoxy(10,15);
cout<<"-----------------DATE OF BLOOD DONATION----------------------";
gotoxy(10,16);
cout<<"DATE(dd/mm/yyyy):";
gotoxy(30,16);
cin>>date1.dd;
gotoxy(35,16);
cout<<"/";
gotoxy(40,16);
cin>>date1.mm;
gotoxy(45,16);
cout<<"/";
gotoxy(50,16);
cin>>date1.yy;
gotoxy(10,18);
cout<<"-----------------OTHER INFORMATION----------------------";
gotoxy(1,19);
cout<<"MOBILE NO:";
gotoxy(15,19);
cin>>other.mobno;
gotoxy(1,20);
cout<<"E-MAIL(IF NO ENTER \"NO\"):";
gotoxy(30,20);
cin>>other.email;
if(strcmp(other.email,"NO")==0||strcmp(other.email,"no")==0)
strcpy(other.email,"NO EMAIL ID");
gotoxy(1,21);
cout<<"BLOOD GROUP(A+ , A- , B+ , B- , O+ , O- , AB+ , AB- ):";
gotoxy(5,22);
cin>>other.bloodgroup;
other.status='Y';
}
cout<<donar_regist<<setw(8)<<nm.fname<<"-"<<nm.lname<<setw(10)<<nm.age<<setw(5)<<add.hno<<"-"<<add.city<<","<<a
dd.state<<setw(15)<<other.mobno<<setw(5)<<other.bloodgroup;
gotoxy(1,c+1);
cout<<"------------------------------------------------------------------------";
}
//****************show all donars with blood groups row wise
int getdono()
{
return dono;
}
char *getfname()
{
return nm.fname;
}
char *getgroup()
{
return other.bloodgroup;
}
char *getcity()
{
return add.city;
}
char getstatus()
{
return other.status;
}
};
//***************donar's class**********************************
//**************
//***************patient's class**********************************
class patient
{
char pno[15];
nameinfo pnm;
address padd;
otherinfo pother;
int no_of_bottle;
dateinfo pdate1;
public:
cout<<pno<<setw(8)<<pnm.fname<<"-"<<pnm.lname<<setw(10)<<pnm.age<<setw(5)<<padd.hno<<"-"<<padd.city<<","<<pad
d.state<<setw(15)<<pother.mobno<<setw(5)<<pother.bloodgroup;
gotoxy(1,c+1);
cout<<"------------------------------------------------------------------------";
}
//****************show all donars with blood groups row wise
//input fuction for patients information
void create_patient(char bloodgr[5])
{
gotoxy(5,7);
cout<<"====================PATIENT'S INFORMATION==============================";
gotoxy(1,8);
cout<<"PAT.NO:";
gotoxy(10,8);
cin>>pno;
gotoxy(20,8);
cout<<"FIRST NAME:";
gotoxy(32,8);
cin>>pnm.fname;
gotoxy(48,8);
cout<<"LAST NAME:";
gotoxy(60,8);
cin>>pnm.lname;
gotoxy(10,9);
cout<<"AGE:";
gotoxy(20,9);
cin>>pnm.age;
gotoxy(10,10);
cout<<"-----------------PATIENT'S ADDRESS DETAIL'S---------------------";
gotoxy(1,12);
cout<<"HOUSE NO:";
gotoxy(12,12);
cin>>padd.hno;
gotoxy(18,12);
cout<<"ADDRESS:";
gotoxy(30,12);
cin>>padd.city;
gotoxy(55,12);
cout<<"STATE:";
gotoxy(65,12);
cin>>padd.state;
gotoxy(10,14);
cout<<"-----------------DATE OF BLOOD GIVEN TO PATIENT--------------------";
gotoxy(10,15);
cout<<"DATE(dd/mm/yyyy):";
gotoxy(30,15);
cin>>pdate1.dd;
gotoxy(35,15);
cout<<"/";
gotoxy(40,15);
cin>>pdate1.mm;
gotoxy(45,15);
cout<<"/";
gotoxy(50,15);
cin>>pdate1.yy;
gotoxy(10,17);
cout<<"-----------------OTHER INFORMATION----------------------";
gotoxy(1,18);
cout<<"MOBILE NO:";
gotoxy(15,18);
cin>>pother.mobno;
gotoxy(1,19);
cout<<"E-MAIL(IF NO ENTER \"NO\"):";
gotoxy(30,19);
cin.getline(pother.email,70);
if(strcmp(pother.email,"NO")==0||strcmp(pother.email,"no")==0)
strcpy(pother.email,"NO EMAIL ID");
gotoxy(1,20);
no_of_bottle=1;
strcpy(pother.bloodgroup,bloodgr);;
pother.status='Y';
}
char *getpno()
{
return pno;
}
dateinfo getdate()
{
return pdate1;
}
int pdd()
{
return pdate1.dd;
}
int pmm()
{
return pdate1.mm;
}
int pyy()
{
return pdate1.yy;
}
char getstatus()
{
return pother.status;
}
};
//***************patient's class**********************************
char getstatus()
{
return status;
}
char *getbloodgroup()
{
return bloodgroup;
}
};
//***************blood storage class**********************************
//***************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************
void main()
{
char ch;
intro();
if(checkpass()==0)
{
do
{
//****************TEMPORARY***********************
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================MAIN MENU====================";
gotoxy(28,7);
cout<<"01. BLOOD DONATION INFO./creating blood qty file";
gotoxy(28,8);
cout<<"02. ADMINISTRATOR";
gotoxy(28,9);
cout<<"03. EXIT";
gotoxy(20,10);
cout<<"==============================================";
gotoxy(25,12);
cout<<"Please Select Your Option (1-3) ";
gotoxy(30,14);
ch=getche();
switch(ch)
{
case '1': clrscr();
stockbloodonetime();
getch();
break;
case '2': admin_menu();
break;
case '3':exit(0);
default :cout<<"\a";
}
}while(ch!='3');
}else
{
exit(0);
}
}
//***************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************
//***************main intro
void intromain()
{ clrscr();
gotoxy(1,2);
cout<<"*************************BLOOD******DONATION********SYSTEM********************";
gotoxy(1,3);
cout<<"******************************************************************************";
}
//***************main intro
//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************
void intro()
{ clrscr();
gotoxy(4,2);
cout<<"****************************BLOOD DONATION******************************";
gotoxy(12,4);
cout<<"===========================================================";
gotoxy(5,5);
cout<<"****************************S=Y=S=T=E=M********************************";
gotoxy(50,10);
cout<<"PROJECT:";
gotoxy(50,12);
cout<<"MADE BY : --------------------";
gotoxy(10,14);
cout<<"---------------CLASS : XII A--------------------";
getch();
}
//***************************************************************
// ADMINSTRATOR MENU FUNCTION
//****************************************************************
void admin_menu()
{
clrscr();
char ch2;
//int num;
//************************************************************
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================ADMIN MENU====================";
gotoxy(22,7);
cout<<"1.DONAR INFORMATION";
gotoxy(22,8);
cout<<"2.BLOOD TO PATIENTS INFORMATION";
gotoxy(22,9);
cout<<"3.REPORTS";
gotoxy(22,10);
cout<<"4.BACK TO MAIN MENU";
gotoxy(22,11);
cout<<"Please Enter Your Choice (1-4) ";
gotoxy(22,12);
//**********************************************************
ch2=getche();
switch(ch2)
{
case '1':
donar_menu();
break;
case '2':
//*****************search for blood
char bldgroup[15];
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE BLOOD GROUP(QTY) TO BE SEARCHED(WITH COMPATIBILITY):";
gotoxy(55,9);
cin>>bldgroup;
//display_bloodavailable(bldgroup);
if(display_bloodavailable2(bldgroup)==0)
{
patients_menu(bldgroup);
}else
{
gotoxy(5,18);
cout<<"SORRY BLOOD NOT IN STOCK";
}
break;
case '3':
donar_report_menu();
break;
default:
cout<<"\a";//admin_menu();
}
}
//***************************************************************
// DONARS INFORMATION ADD / MODIFY / DELETE
//****************************************************************
void donar_menu()
{
clrscr();
char ch2;
char regno[5];
//************************************************************
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================DONAR'S MENU====================";
gotoxy(22,7);
cout<<"1.ADD DONAR INFORMATION";
gotoxy(22,8);
cout<<"2.MODIFY DONAR INFORMATION";
gotoxy(22,9);
cout<<"3.DELETE DONAR INFORMATION";
gotoxy(22,10);
cout<<"4.BACK TO MAIN MENU";
gotoxy(22,11);
cout<<"Please Enter Your Choice (1-4) ";
gotoxy(22,12);
//**********************************************************
ch2=getche();
switch(ch2)
{
case '1': clrscr();
donar_new_old();
break;
case '2':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE REG. NO. OF DONAR TO BE SEARCHED:";
gotoxy(55,9);
cin>>regno;
modify_donarinfo(regno);
break;
case '3':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE REG. NO. OF DONAR TO BE SEARCHED AND DELETE:";
gotoxy(55,9);
cin>>regno;
delete_donarinfo(regno);
break;
default:
cout<<"\a";//admin_menu();
}
}
//***************************************************************
//*************donars registration or already registered
void donar_new_old()
{
clrscr();
char ch2;
//int num;
char regno[15];
//************************************************************
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================DONAR'S MENU====================";
gotoxy(22,7);
cout<<"1.NEW DONAR REGISTRATION";
gotoxy(22,8);
cout<<"2.ALREADY REGISTERED";
gotoxy(22,9);
cout<<"3.BACK TO MAIN MENU";
gotoxy(22,10);
cout<<"Please Enter Your Choice (1-4) ";
gotoxy(22,11);
//**********************************************************
ch2=getche();
switch(ch2)
{
case '1': clrscr();
write_donars();
break;
case '2':
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================ALREADY REGISTERED====================";
gotoxy(5,7);
cout<<"ENTER THE DONARS REGISTERED NO:";
gotoxy(40,7);
cin>>regno;
write_donar_ALREDYREG(regno);
break;
default:
cout<<"\a";//admin_menu();
}
}
//*************donars registration or already registered
//***************************************************************
// donar's reports
//****************************************************************
void donar_report_menu()
{
clrscr();
char ch2;
char regno[15];
char bldgroup[5],cty[35];
dateinfo dtvalue2;
//************************************************************
clrscr();
intromain();
gotoxy(20,6);
cout<<"=================REPORTS====================";
gotoxy(22,7);
cout<<"1.ALL DONAR INFORMATION BLOOD GROUP WISE";
gotoxy(22,8);
cout<<"2.ALL DONAR INFORMATION CITY WISE";
gotoxy(22,9);
cout<<"3.ALL BLOOD GROUP WITH AVAILABILITY";
gotoxy(22,10);
cout<<"4.DISPLAY DONAR INFORMATION WITH DATE OF DONATIONS";
gotoxy(22,11);
cout<<"5.DISPLAY PATIENTS INFORMATION WITH BLOOD INFO. DATE WISE";
gotoxy(22,12);
cout<<"6.DISPLAY BLOOD GROUP WITH QUANTITY";
gotoxy(22,13);
cout<<"7.BACK TO MAIN MENU";
gotoxy(22,14);
cout<<"Please Enter Your Choice (1-7) ";
gotoxy(22,15);
//**********************************************************
ch2=getche();
switch(ch2)
{
case '1':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE BLOOD GROUP TO BE SEARCHED(WITH COMPATIBILITY):";
gotoxy(55,9);
cin>>bldgroup;
displaybloodgroupwise(bldgroup);
break;
case '2':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE CITY WISE SEARCH OF DONARS:";
gotoxy(55,9);
cin>>cty;
searchdonarcitywise(cty);
break;
case '6':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE BLOOD GROUP(QTY) TO BE SEARCHED(WITH COMPATIBILITY):";
gotoxy(55,9);
cin>>bldgroup;
display_bloodavailable(bldgroup);
break;
case '4':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE REG. NO. OF DONAR TO BE SEARCHED:";
gotoxy(55,9);
cin>>regno;
displaydonarwithlist(regno);
break;
case '5':
clrscr();
intromain();
gotoxy(10,8);
cout<<"*****ENTER THE DATE OF BLOOD GIVEN TO PATIENTS:";
gotoxy(10,10);
cout<<"DATE(dd/mm/yyyy):";
gotoxy(30,10);
cin>>dtvalue2.dd;
gotoxy(35,10);
cout<<"/";
gotoxy(40,10);
cin>>dtvalue2.mm;
gotoxy(45,10);
cout<<"/";
gotoxy(50,10);
cin>>dtvalue2.yy;
displaypatientdetails(dtvalue2);
break;
case '3':
display_bloodstock();
default:
cout<<"\a";//admin_menu();
}
}
//*****************add new registered donars information
void write_donars()
{
ofstream objoff;
donar donarobj;
donardate donalist;
objoff.open("donars.dat",ios::binary|ios::app);
ofstream objofflist("donarlist.dat",ios::binary|ios::app);
clrscr();
intromain();
int rnn=getdonarno();
char getprv_regno[15];
strcpy(getprv_regno,getreg());
if(strcmp(getprv_regno,"NULL")!=0)
{
gotoxy(5,4);
cout<<"Previous REGNO: "<<getprv_regno;
}
if(rnn>10000)
{
rnn=1;
}
donarobj.create_donar(rnn);
objoff.write((char*)&donarobj,sizeof(donarobj));
//************write to donar list also
strcpy(donalist.donarreg,donarobj.getdonarreg());
donalist.dt=donarobj.getdate();
objofflist.write((char*)&donalist,sizeof(donalist));
objoff.close();
objofflist.close();
gotoxy(10,24);
cout<<"***************DONARS RECORD SAVED******************* ";
//********send the blood group to the bloodstock file
write_bloodstock(donarobj.getbloodname());
//************************************************
cin.ignore();
getch();
}
//*****************add new registered donars information
//************get thje donars last number****************
char *getreg()
{
ifstream objiff;
donar st;
int count=0;
char tmpregno[15];
objiff.open("donars.dat",ios::binary);
objiff.seekg(0,ios::beg);
if(!objiff)
{
cout<<"File could not be open !! Press any Key...";
getch();
}
//**************temporary hiding these lines
while(objiff.read((char *) &st, sizeof(donar)))
{
count++;
}
//***********jump to the last line
objiff.seekg(count-sizeof(st),ios::beg);
objiff.read((char *) &st, sizeof(donar));
strcpy(tmpregno,st.getdonarreg());
objiff.close();
if(count!=0)
return tmpregno;
else
return "NULL";
}
//************get thje donars last number****************
getch();
return;
}
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getdonarreg(),rgno)==0)
{
clrscr();
intromain();
dr.display_donar_rectangle();
flag=1;
strcpy(donalist.donarreg,dr.getdonarreg());
}
}
fp.close();
if(flag==0)
{cout<<"\n\nrecord not exist";
getch();
}else
{
gotoxy(5,14);
cout<<"ENTER THE DATE OF BLOOD DOATION:";
gotoxy(10,16);
cout<<"DATE(dd/mm/yyyy):";
gotoxy(30,16);
cin>>date1.dd;
gotoxy(35,16);
cout<<"/";
gotoxy(40,16);
cin>>date1.mm;
gotoxy(45,16);
cout<<"/";
gotoxy(50,16);
cin>>date1.yy;
donalist.dt.dd=date1.dd;
donalist.dt.mm=date1.mm;
donalist.dt.yy=date1.yy;
objoff.write((char*)&donalist,sizeof(donalist));
objoff.close();
//********send the blood group to the bloodstock file
write_bloodstock(dr.getbloodname());
//************************************************
}
}
//**************write the donars dates who is already registered
//**********donar name and list of blood donation
void displaydonarwithlist(char rgno[15])
{
ifstream fp;
fp.open("donars.dat",ios::binary);
ifstream objiff("donarlist.dat",ios::binary);
donardate donalist;
donar dr;
int flag=-1;
if(!fp)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getdonarreg(),rgno)==0)
{
clrscr();
intromain();
dr.display_donar_rectangle();
flag=1;
strcpy(donalist.donarreg,dr.getdonarreg());
}
}
fp.close();
if(flag==1)
{
gotoxy(5,13);
cout<<"-------------------LIST OF BLOOD DONATED BY DONAR---------------------";
int c1=14;
int no1=1;
int y1=0;
while(objiff.read((char*)&donalist,sizeof(donardate)))
{
if(strcmp(rgno,donalist.donarreg)==0)
{
if(y1<=2)
{
donarlist(c1,donalist,y1,no1);
y1++;
no1++;
}else
{
y1=0;
c1++;
no1++;
}
}
}
}
objiff.close();
getch();
}
//**********donar name and list of blood donation
storeblood blstk;
if(!objiff)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
clrscr();
intromain();
int c1=5;
gotoxy(5,c1);
c1++;
cout<<"BLOODNO"<<setw(18)<<"BLOOD GROUP"<< setw(20)<<"QUANTITY";
while(objiff.read((char*)&blstk,sizeof(blstk)))
{
gotoxy(5,c1);
cout<<blstk.blno<<setw(18)<<blstk.bloodgroup<<setw(20)<<blstk.qty;
c1++;
}
objiff.close();
getch();
}
//************blood stock list
if(strcmp(dr.getbloodname(),bgp)==0)
{
dr.showalldonarsrowwise(c1);
c1++;
}
}
fp.close();
fp.open("donars.dat",ios::binary);
gotoxy(1,c1);
cout<<"========================================================================";
c1++;
gotoxy(1,c1);
cout<<"==========OTHER BLOOD COMPATIBLE BLOOD GROUPS===========================";
c1++;
//-------for A+
if(strcmp(bgp,"A+")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getbloodname(),"O-")==0)
{
dr.showalldonarsrowwise(c1);
c1++;
}
}
}
//for B+
else if(strcmp(bgp,"B+")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
}
//**for B-
else if(strcmp(bgp,"B-")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getbloodname(),"B-")==0 ||strcmp(dr.getbloodname(),"O-")==0)
{
dr.showalldonarsrowwise(c1);
c1++;
}
}
}
//**for AB+
else if(strcmp(bgp,"AB+")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
}
//**for AB-
else if(strcmp(bgp,"AB-")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
}
//**for O+
else if(strcmp(bgp,"O+")==0)
{
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getbloodname(),"O-")==0)
{
dr.showalldonarsrowwise(c1);
c1++;
}
}
}
//**for O-
else if(strcmp(bgp,"O-")==0)
{
gotoxy(5,c1);
cout<<"*****************ONLY O - *************************";
}
//**************************ends here************************
fp.close();
getch();
}
//*******************display blood group wise with compatibility
//***************donars information city wise
void searchdonarcitywise(char city[15])
{
ifstream fp;
fp.open("donars.dat",ios::binary);
donar dr;
if(!fp)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
clrscr();
intromain();
int c1=7;
gotoxy(1,5);
cout<<"REG No."<<setw(15)<<"NAME OF DONAR"<<setw(5)<<"AGE"<<setw(12)<<"------
ADDRESS-------"<<setw(18)<<"MOBILE NO."<<setw(12)<<"BLOOD GROUP";
gotoxy(1,6);
cout<<"========================================================================";
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getcity(),city)==0)
{
dr.showalldonarsrowwise(c1);
c1++;
}
}
fp.close();
getch();
}
storeblood blstk;
if(!objiff)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
clrscr();
intromain();
int c1=5;
gotoxy(5,c1);
c1++;
cout<<"BLOODNO"<<setw(18)<<"BLOOD GROUP"<< setw(20)<<"QUANTITY";
while(objiff.read((char*)&blstk,sizeof(blstk)))
{
if( strcmp(blstk.bloodgroup,blgrp)==0)
{
gotoxy(5,c1);
cout<<blstk.blno<<setw(18)<<blstk.bloodgroup<<setw(20)<<blstk.qty;
c1++;
}
}
objiff.close();
c1++;
gotoxy(1,c1);
cout<<"==========OTHER BLOOD COMPATIBLE BLOOD GROUPS===========================";
c1++;
//-------for A+
if(strcmp(blgrp,"A+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
if(strcmp(dr.bloodgroup,"O-")==0)
{
gotoxy(5,c1);
cout<<dr.blno<<setw(18)<<dr.bloodgroup<<setw(20)<<dr.qty;
c1++;
}
}
}
//for B+
else if(strcmp(blgrp,"B+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for B-
else if(strcmp(blgrp,"B-")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
if(strcmp(dr.bloodgroup,"B-")==0 ||strcmp(dr.bloodgroup,"O-")==0)
{
gotoxy(5,c1);
cout<<dr.blno<<setw(18)<<dr.bloodgroup<<setw(20)<<dr.qty;
c1++;
}
}
}
//**for AB+
else if(strcmp(blgrp,"AB+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for AB-
else if(strcmp(blgrp,"AB-")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for O+
else if(strcmp(blgrp,"O+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
if(strcmp(dr.bloodgroup,"O-")==0)
{
gotoxy(5,c1);
cout<<dr.blno<<setw(18)<<dr.bloodgroup<<setw(20)<<dr.qty;
c1++;
}
}
}
//**for O-
else if(strcmp(blgrp,"O-")==0)
{
gotoxy(5,c1);
cout<<"*****************ONLY O - *************************";
}
//**************************ends here************************
fp.close();
getch();
getch();
return;
}
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getdonarreg(),regno)==0)
{
flag=1;
//fpos=(int)fp.tellg();
break;
}
}
char ch;
if(flag==0)
{ cout<<"\n\nrecord not exist";
fp.close();
}else
{
// fp.seekp(fpos-sizeof(donar),ios::beg);
dr.display_donar_rectangle();
fp.close();
//*******deletion of the records starts from here
gotoxy(1,15);
cout<<"*****************************************************************************";
gotoxy(5,16);
cout<<"======DO YOU WANT TO DELETE THE RECORDS GIVEN ABOVE[YES(Y) OR NO (N)========";
gotoxy(2,17);
cin>>ch;
if (toupper(ch)=='Y')
{
ofstream outFile;
outFile.open("Temp1.dat",ios::binary);
ifstream objiff("donars.dat",ios::binary);
objiff.seekg(0,ios::beg);
while(objiff.read((char *) &dr, sizeof(donar)))
{
if(strcmp(dr.getdonarreg(),regno)!=0)
{
outFile.write((char *) &dr, sizeof(donar));
}
}
outFile.close();
objiff.close();
remove("donars.dat");
rename("Temp1.dat","donars.dat");
//againopenandclose();
gotoxy(30,20);
cout<<"----------------------------Record Deleted----------------------------------";
getch();
}
}
}
//***************delete donars information
clrscr();
intromain();
fstream fp;
fp.open("donars.dat",ios::binary|ios::in|ios::out);
//donardate donalist;
donar dr;
nameinfo nminfo;
address ad1;
char mb[15],eid[75],bg[5];
int fpos=-1,ag=0;
int flag=-1,flagblood=-1;
if(!fp)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
while(fp.read((char*)&dr,sizeof(donar)))
{
if(strcmp(dr.getdonarreg(),regno)==0)
{
//clrscr();
//intromain();
//dr.display_donar_rectangle();
flag=1;
//strcpy(donalist.donarreg,dr.getdonarreg());
fpos=(int)fp.tellg();
break;
}
}
// fp.close();
if(flag==1)
{
fp.seekp(fpos-sizeof(donar),ios::beg);
dr.display_donar_rectangle();
//fp.write((char *) &dr, sizeof(donar));
//--------------------------------------------
gotoxy(20,13);
cout<<"==========DONAR'S MODIFICATION MENU====================";
gotoxy(22,14);
cout<<"1.MODIFY NAME";
gotoxy(22,15);
cout<<"2.MODIFY AGE";
gotoxy(22,16);
cout<<"3.MODIFY ADDRESS";
gotoxy(22,17);
cout<<"4.MODIFY MOBILE NO.";
gotoxy(22,18);
cout<<"5.MODIFY EMAIL";
gotoxy(22,19);
cout<<"6.MODIFY BLOOD GROUP";
//gotoxy(22,20);
//cout<<"7.BACK TO MAIN MENU";
gotoxy(22,21);
cout<<"Please Enter Your Choice (1-6) ";
gotoxy(22,22);
//**********************************************************
ch2=getche();
clrscr();
intromain();
dr.display_donar_rectangle();
switch(ch2)
{
case '1':
gotoxy(20,13);
cout<<"===ENTER THE FIRST NAME TO MODIFY: ";cin>>nminfo.fname;
gotoxy(20,14);
cout<<"===ENTER THE LAST NAME TO MODIFY: ";cin>>nminfo.lname;
dr.setfullname(nminfo);
break;
case '2':
gotoxy(20,13);
cout<<"===ENTER THE AGE TO MODIFY: ";cin>>ag;
dr.setage(ag);
break;
case '3':
gotoxy(20,13);
cout<<"===ENTER THE HNO TO MODIFY: ";cin>>ad1.hno;
gotoxy(20,14);
cout<<"===ENTER THE CITY TO MODIFY: ";cin>>ad1.city;
gotoxy(20,15);
cout<<"===ENTER THE STATE TO MODIFY: ";cin>>ad1.state;
dr.setaddress(ad1);
break;
case '4':
gotoxy(20,13);
cout<<"===ENTER THE MOBILE TO MODIFY: ";cin>>mb;
dr.setmobileno(mb);
break;
case '5':
gotoxy(20,13);
cout<<"===ENTER THE EMAIL TO MODIFY: ";cin>>eid;
dr.setemail(eid);
break;
case '6':
gotoxy(20,13);
cout<<"===ENTER THE BLOOD GROUP TO MODIFY: ";cin>>bg;
dr.setblodgrp(bg);
flagblood=1;
break;
default:
cout<<"\a";//admin_menu();
}
fp.write((char *) &dr, sizeof(donar));
}
fp.close();
gotoxy(10,24);
if(flagblood==1)
{
gotoxy(20,15);
cout<<"old blood:"<<dr.getbloodname()<<" new blood::"<<bg;
write_bloodstock(bg);
decrease_bloodstock(dr.getbloodname());
flagblood=-1;
}
cout<<"*****************modified the record******************";
getch();
}
}
//****************************************************************************
//****************decrease the blood stock by 1******************************
//****************increase the blood qty by 1
void decrease_bloodstock(char bldgr[5])
{
int fpos=-1;
fstream File;
storeblood st,tmp;
File.open("bloodstock.dat",ios::binary|ios::in|ios::out);
if(!File)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
while(File.read((char *) &st, sizeof(storeblood)))
{
if(strcmp(st.bloodgroup,bldgr)==0)
{ fpos=(int)File.tellg();
break;
}
}
File.seekp(fpos-sizeof(storeblood),ios::beg);
tmp=st;
tmp.qty=tmp.qty-1;
File.write((char *) &tmp, sizeof(storeblood));
File.close();
//************************************************************************
storeblood blstk;
if(!objiff)
{
cout<<"File could not be open !! Press any Key...";
getch();
//return;
}
clrscr();
intromain();
int c1=5;
gotoxy(5,c1);
c1++;
cout<<"BLOODNO"<<setw(18)<<"BLOOD GROUP"<< setw(20)<<"QUANTITY";
while(objiff.read((char*)&blstk,sizeof(blstk)))
{
if( strcmp(blstk.bloodgroup,blgrp)==0 && blstk.qty>0)
{
gotoxy(5,c1);
cout<<blstk.blno<<setw(18)<<blstk.bloodgroup<<setw(20)<<blstk.qty;
c1++;
returnvalue=0;
}
}
objiff.close();
if((strcmp(dr.bloodgroup,"O-")==0)&& dr.qty>0)
{
gotoxy(5,c1);
cout<<dr.blno<<setw(18)<<dr.bloodgroup<<setw(20)<<dr.qty;
c1++;
returnvalue=0;
}
}
}
//for B+
else if(strcmp(blgrp,"B+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for B-
else if(strcmp(blgrp,"B-")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for AB+
else if(strcmp(blgrp,"AB+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for AB-
else if(strcmp(blgrp,"AB-")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
}
//**for O+
else if(strcmp(blgrp,"O+")==0)
{
while(fp.read((char*)&dr,sizeof(storeblood)))
{
if((strcmp(dr.bloodgroup,"O-")==0)&& dr.qty>0)
{
gotoxy(5,c1);
cout<<dr.blno<<setw(18)<<dr.bloodgroup<<setw(20)<<dr.qty;
c1++;
returnvalue=0;
}
}
}
//**for O-
else if((strcmp(blgrp,"O-")==0)&& dr.qty>0)
{
gotoxy(5,c1);
cout<<"*****************ONLY O - *************************";
returnvalue=0;
}
//**************************ends here************************
fp.close();
return returnvalue;
//******************compatibility ends here
}
//*************function to search for blood and compatibility and return true
//************function to display all patients details date wise
void displaypatientdetails(dateinfo bgp)
{
ifstream fp;
fp.open("patientsinfo.dat",ios::binary);
patient dr;
if(!fp)
{
cout<<"File could not be open !! Press any Key...";
getch();
return;
}
clrscr();
intromain();
//***********display date
gotoxy(10,5);
cout<<"DATE(dd/mm/yyyy): "<<bgp.dd<<"/"<<bgp.mm<<"/"<<bgp.yy;
//**********************
int c1=9;
gotoxy(1,6);
cout<<"REG No."<<setw(15)<<"NAME OF PATIENT"<<setw(5)<<"AGE"<<setw(12)<<"------
ADDRESS-------"<<setw(18)<<"MOBILE NO."<<setw(12)<<"BLOOD GROUP";
gotoxy(1,7);
cout<<"========================================================================";
while(fp.read((char*)&dr,sizeof(patient)))
{
patient patobj;
ofstream objoff;
char getprv_patno[15];
objoff.open("patientsinfo.dat",ios::binary|ios::app);
//************************************************************
clrscr();
intromain();
strcpy(getprv_patno,getpatno());
if(strcmp(getprv_patno,"NULL")!=0)
{
gotoxy(5,4);
cout<<"Previous REGNO: "<<getprv_patno;
}
//**************************************
patobj.create_patient(brg);
objoff.write((char*)&patobj,sizeof(patient));
objoff.close();
//*********now decrease one from the stock of blood
clrscr();
intromain();
//***********check the available with compatibility and decrease one from it
display_bloodavailable(brg);
char blgroup[5];
//************************************************************************
gotoxy(10,15);
cout<<"Enter the blood group ::";
gotoxy(60,15);
cin>>blgroup;
decrease_bloodstock(blgroup);
//*********now decrease one from the stock of blood
getch();
}
//**************patient previous no
//************get thje donars last number****************
char *getpatno()
{
ifstream objiff;
patient st;
int count=0;
char tmpregno[15];
objiff.open("patientsinfo.dat",ios::binary);
objiff.seekg(0,ios::beg);
if(!objiff)
{
cout<<"File could not be open !! Press any Key...";
getch();
}
//**************temporary hiding these lines
while(objiff.read((char *) &st, sizeof(patient)))
{
count++;
}
//***********jump to the last line
objiff.seekg(count-sizeof(st),ios::beg);
objiff.read((char *) &st, sizeof(patient));
strcpy(tmpregno,st.getpno());
objiff.close();
if(count!=0)
return tmpregno;
else
return "NULL";
}
//************get thje donars last number****************
//**************patient previous no
if choice 2:
If choice is 3
Choice 1:
Choice 2:
Choice 3:
Choice 4:
Choice 5:
Choice 6:
REQUIREMENTS
HARDWARE REQUIRED
SOFTWARE REQUIRED
DISADVANTAGES
This system suitable for only small blood banks.
Online facility is not available.
CONCLUSION
This software is efficient in maintaining donars details and
can easily perform operations on blood donations records.
This software also reduces the work load of the blood bank
management to know how much blood is available and also
keep the records of how many patients get the blood from the
blood bank.
In future, this system can launch web site for easy online blood
banking system.
SYSTEM DESIGN
Then we began with the design phase of the system. System design is a solution, a
HOW TO approach to the creation of a new system. It translates system
requirements into ways by which they can be made operational. It is a
translational from a user oriented document to a document oriented
programmers. For that, it provides the understanding and procedural details
necessary for the implementation. Here we use Flowchart to supplement the
working of the new system. The system thus made should be reliable, durable and
above all should have least possible maintenance costs. It should overcome all the
drawbacks of the Old existing system and most important of all meet the user
requirements.