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 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); } }