[odb-users] odb value Type

qgjie qgjie at 163.com
Tue Jun 23 04:17:55 EDT 2015



my code: 


class     nurse
{
public:
    nurse(long i): id(i),city(0),sex(2),star(5),birthday(0),outTotal(0),inTotal(0)
    {
    }
    virtual ~nurse() {}
    bool                    setUnfilledOrderStatus(nurse_type p, long appid, int s);

private:
friend  class   odb::access;
 set<unfilledOrder>          orders;
};

class    unfilledOrder
{
public:
    unfilledOrder(long appid, long pat): appointid(appid), patient(pat)
    {}
   void             setStatus(int s)   {  status = s; }
private:
    friend class nurse;
    friend class odb::access;
    unfilledOrder(){}

    long            appointid;
    long            patient;
    long            hospital;
    long            btime;
    int             type;
    int             paytype;
    int             money;
    int             status;
    string          patientname;
    string          patientphone;
};

#ifdef ODB_COMPILER
#pragma    db  value(unfilledOrder)

#pragma    db  object(nurse)
#pragma    db  member(nurse::id)    id 

#endif 

I want to modify  the status value  of the unfilledOrder, why it not ?
who can help me!
the code:
bool        nurse::setUnfilledOrderStatus(nurse_type p, long appid, int s)
{
    unfilledOrder  u;
    set<unfilledOrder>::iterator it;
    for(it = orders.begin(); it != orders.end(); ++it)
    {
        if(it->getAppointId() == appid)
        {
            u = (*it);
            orders.erase(it);
            u.setStatus(s);
            orders.insert(u);
            odb::core::transaction t (getDatabase()->begin ());
            try {
                update(p);
                return true;
            } catch (const odb::exception& e) {
                std::cout << "nurse::setUnfilledOrderStatus:"<< e.what() << std::endl;
            }
            t.commit ();
            return false;
        }
    }
    return false;
}




More information about the odb-users mailing list