void modify_account(int n) { int found=0; fstream File; File.open("account.dat",ios::binary|ios::in|ios::out); if(!File) { cout<<"File could not be open !! Press any Key..."; return; } while(!File.eof() && found==0) { File.read((char*)&ac, sizeof(ac)); if(ac.retacno()==n) { ac.show_account(); cout<<"\n\nEnter The New Details of account"<<endl; ac.modify(); int pos=(-1)*static_cast<int>(sizeof(account)); File.seekp(pos,ios::cur); File.write((char*) &ac, sizeof(ac)); cout<<"\n\n\t Record Updated"; found=1; } } File.close(); if(found==0) cout<<"\n\n Record Not Found "; }
void display_sp(int n) { int flag=0; ifstream fin; fin.open("account.dat",ios::binary); if(!fin) { cout<<"File could not be open !! Press any Key..."; return; } cout<<"\nBALANCE DETAILS\n"; fin.read((char*)&ac, sizeof(ac)); while(fin) { if(ac.retacno()==n) { ac.show_account(); flag=1; } } fin.close(); if(flag==0) cout<<"\n\nAccount number does not exist"; }
void loader::writeaccdata(const account& acc, QString typeacc, QDomNode& user, QDomDocument root){ username* usernameacc=acc.user(); QDomNode userdata=root.createElement(QString("userdata")); user.appendChild(userdata); QDomNode usern=root.createElement(QString("username")), passw=root.createElement(QString("password")), typ=root.createElement(QString("type")), acctype=root.createElement(QString("acctype")); userdata.appendChild(usern); userdata.appendChild(passw); userdata.appendChild(typ); userdata.appendChild(acctype); QString _user=usernameacc->user(), _pass=usernameacc->pass(), _acctype; _acctype.setNum(acc.type()); QDomText usertemp=root.createTextNode(_user), passtemp=root.createTextNode(_pass), typetemp=root.createTextNode(typeacc), acctypetemp=root.createTextNode(_acctype); usern.appendChild(usertemp); passw.appendChild(passtemp); typ.appendChild(typetemp); acctype.appendChild(acctypetemp); if(dynamic_cast<useraccount*>(const_cast<account*>(&acc))){ QDomNode admin=root.createElement(QString("admin")); useraccount* tempacc=dynamic_cast<useraccount*>(const_cast<account*>(&acc)); QString _admin; _admin=_admin.setNum(tempacc->getadmin()); QDomText admintemp=root.createTextNode(_admin); userdata.appendChild(admin); admin.appendChild(admintemp); } }
void delete_account(int n) { ifstream fin; ofstream fout; fin.open("account.dat",ios::binary); if(!fin) { cout<<"File could not be open !! Press any Key..."; return; } fout.open("Temp.dat",ios::binary); fin.seekg(0,ios::beg); while(fin.read((char*)&ac, sizeof(ac))) { if(ac.retacno()!=n) { fout.write((char*)&ac, sizeof(ac)); } } fin.close(); fout.close(); remove("account.dat"); rename("Temp.dat","account.dat"); cout<<"\n\n\tRecord Deleted .."; }
void write_account() { ofstream fout; fout.open("account.dat",ios::binary|ios::app); ac.create_account(); fout.write((char*)&ac, sizeof(ac)); fout.close(); }
void deposit_withdraw(int n, int option) { int amt; int found=0; fstream File; File.open("account.dat", ios::binary|ios::in|ios::out); if(!File) { cout<<"File could not be open !! Press any Key..."; return; } while(!File.eof() && found==0) { File.read((char*)&ac, sizeof(ac)); if(ac.retacno()==n) { ac.show_account(); if(option==1) { cout<<"\n\n\tTO DEPOSITE AMOUNT "; cout<<"\n\nEnter The amount to be deposited"; cin>>amt; ac.dep(amt); } if(option==2) { cout<<"\n\n\tTO WITHDRAW AMOUNT "; cout<<"\n\nEnter The amount to be withdraw"; cin>>amt; int bal=ac.retdeposit()-amt; if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C')) cout<<"Insufficience balance"; else ac.draw(amt); }
void display_all() { ifstream fin; fin.open("account.dat",ios::binary); if(!fin) { cout<<"File could not be open !! Press any Key..."; return; } cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n"; cout<<"====================================================\n"; cout<<"A/c no. NAME Type Balance\n"; cout<<"====================================================\n"; while(fin.read((char*)&ac, sizeof(ac))) { ac.report(); } fin.close(); }
void loader::writepayments(const account & acc, QDomNode & payments, QDomDocument root){ QVector<payment*> paytemp= const_cast<account*>(&acc)->payments(); for(QVector<payment*>::iterator it=paytemp.begin(); it!=paytemp.end();++it){ QDomNode payment= root.createElement(QString("payment")); payments.appendChild(payment); QString _daytemp, _monthtemp, _yeartemp, _requestedtemp, _approvedtemp; _daytemp=_daytemp.setNum((*it)->date().day()); _monthtemp=_monthtemp.setNum((*it)->date().month()); _yeartemp=_yeartemp.setNum((*it)->date().year()); _approvedtemp=_approvedtemp.setNum((*it)->approved()); _requestedtemp=_requestedtemp.setNum((*it)->request()); QDomText requestertemp=root.createTextNode(acc.user()->user()), requestedtemp=root.createTextNode(_requestedtemp), daytemp=root.createTextNode(_daytemp), monthtemp=root.createTextNode(_monthtemp), yeartemp=root.createTextNode(_yeartemp), approvedtemp=root.createTextNode(_approvedtemp); QDomNode requester= root.createElement(QString("applicant")), requested=root.createElement(QString("typerequested")), day=root.createElement(QString("dayrequest")), month=root.createElement(QString("monthrequest")), year=root.createElement(QString("yearrequest")), approved=root.createElement(QString("approved")); requester.appendChild(requestertemp); requested.appendChild(requestedtemp); day.appendChild(daytemp); month.appendChild(monthtemp); year.appendChild(yeartemp); approved.appendChild(approvedtemp); payment.appendChild(requester); payment.appendChild(requested); payment.appendChild(day); payment.appendChild(month); payment.appendChild(year); payment.appendChild(approved); } }
bool db_wallet::write_account(const std::string & name, account & acct) { if (m_Db == 0) { return false; } if (m_is_read_only) { assert(!"Write called on database in read-only mode!"); } data_buffer key_data; std::string key_prefix = "acc"; key_data.write_var_int(key_prefix.size()); key_data.write((void *)key_prefix.data(), key_prefix.size()); key_data.write_var_int(name.size()); key_data.write((void *)name.data(), name.size()); Dbt dat_key( (void *)key_data.data(), static_cast<std::uint32_t> (key_data.size()) ); data_buffer value_data; acct.encode(value_data); Dbt dat_value( (void *)value_data.data(), static_cast<std::uint32_t> (value_data.size()) ); auto ret = m_Db->put(m_DbTxn, &dat_key, &dat_value, 0); std::memset(dat_key.get_data(), 0, dat_key.get_size()); std::memset(dat_value.get_data(), 0, dat_value.get_size()); return ret == 0; }
void main() { char ch1,ch2; while(1) { clrscr(); gotoxy(30,5); cout<<"ABHISHEK TELECOM PVT. LTD."; gotoxy(30,6); cout<<"__________________________"; gotoxy(30,8); cout<<"`M'anage Customer Records"; gotoxy(30,10); cout<<"`D'isplay Customer List"; gotoxy(30,12); cout<<"`G'enerate Bill"; gotoxy(30,14); cout<<"`E'xit"; gotoxy(30,24); cout<<"Enter your choice:"; ch1=getch(); ch1=toupper(ch1); switch(ch1) { case('D'): obj.display(); break; case('G'): obj.generate(); break; case('E'): clrscr(); exit(1); break; case('M'): ch2='A'; do { clrscr(); gotoxy(30,5); cout<<"ABHISHEK TELECOM PVT. LTD."; gotoxy(30,6); cout<<"__________________________"; gotoxy(30,8); cout<<"`A'dd Customer Records"; gotoxy(30,10); cout<<"`M'odify existing Records"; gotoxy(30,12); cout<<"`D'elete existing record"; gotoxy(30,14); cout<<"`E'xit"; gotoxy(30,24); cout<<"Enter your choice:"; ch2=getch(); ch2=toupper(ch2); switch(ch2) { case('A'): obj.add(); break; case('M'): obj.modify(); break; case('D'): obj.del(); break; case('E'): break; }//End of inner switch-case block }while(ch2!='E');//End of do-while block }//End of outer switch-case block }//End of while block }//End of main()
staccount::staccount (sfield::ref n, account const& v) : stblob (n) { peekvalue ().insert (peekvalue ().end (), v.begin (), v.end ()); }