void ResetButtons() { int j; for(j = 0;j < HUDBUTTONS;j++) { ModifyButton(&hud.buttons[j],B_Normal,0); } }
Liveinfo::Liveinfo(int getroom,QWidget *parent) : QDialog(parent), Leavebool(true),Liveinbool(true) { RoomNum = getroom; QSqlQueryModel roomtable;// = new QSqlQueryModel; roomtable.setQuery("select * from Room;"); QSqlQueryModel recordtable;// = new QSqlQueryModel; recordtable.setQuery("select * from Record,Guest;"); int Check_live = 0; QString Snum; QString Sname; QString SID; QString Scontact; QString Stime; QString Etime; for (int i = 0; i < roomtable.rowCount(); ++i) { QSqlRecord roomrecord = roomtable.record(i); int Rnum = roomrecord.value("Num").toInt(); if( Rnum == getroom ) { Check_live = roomrecord.value("Live").toInt(); Snum = roomrecord.value("Num").toString(); Sprice = roomrecord.value("Price").toString(); if(Check_live == 1) { for (int j = 0; j < recordtable.rowCount(); ++j) { QSqlRecord Recordrecord = recordtable.record(j); Rnum = Recordrecord.value("Num").toInt(); if( Rnum == getroom ) { Sname = Recordrecord.value("Name").toString(); Sdays = Recordrecord.value("Days").toString(); Sdeposit = Recordrecord.value("Deposit").toString(); SID = Recordrecord.value("ID").toString(); Scontact = Recordrecord.value("Contact").toString(); Stime = Recordrecord.value("Stime").toString(); Etime = Recordrecord.value("Etime").toString(); } } } break; } }//Got the roon num and chek if the room have lived QGridLayout* mainlayout = new QGridLayout; QGridLayout* buttonlayout = new QGridLayout; QLabel* Name = new QLabel("Name"); QLabel* Contact = new QLabel("Contact"); QLabel* ID = new QLabel("ID"); QLabel* Days = new QLabel("Days"); QLabel* Despoit = new QLabel("Despoit"); QLabel* RoomNum = new QLabel("Room Num"); QLabel* Price = new QLabel("Price"); QLabel* Livein = new QLabel("Live in day"); QLabel* LeaveDay = new QLabel("Leave day"); NameEdit = new QLineEdit; ContactEdit = new QLineEdit; IDEdit = new QLineEdit; DaysEdit = new QLineEdit; DespoitEdit = new QLineEdit; RoomNumEdit = new QLineEdit; /* PriceEdit = new QLineEdit; LiveinEdit = new QLineEdit; LeaveEdit = new QLineEdit; */ QLineEdit* PriceEdit = new QLineEdit; QLineEdit* LiveinEdit = new QLineEdit; QLineEdit* LeaveEdit = new QLineEdit; QPushButton* Modify = new QPushButton("Modify"); QPushButton* Check_out = new QPushButton("Check Out"); QPushButton* Submit = new QPushButton("Submit"); QPushButton* Cancel = new QPushButton("Cancel"); PriceEdit->setText(Sprice); RoomNumEdit->setText(Snum); QDate a = QDate::currentDate(); Estime = a.toString("yyyy-MM-dd"); if(Check_live == 1) //show the Record infomation { leave(); NameEdit->setText(Sname); ContactEdit->setText(Scontact); IDEdit->setText(SID); DaysEdit->setText(Sdays); DespoitEdit->setText(Sdeposit); LiveinEdit->setText(Stime); LeaveEdit->setText(Etime); } else { livein(); LiveinEdit->setText(Estime); } LeaveDay->setEnabled(Liveinbool); LeaveEdit->setEnabled(Liveinbool); Modify->setEnabled(false); Check_out->setEnabled(Liveinbool); Submit->setEnabled(Leavebool); connect(Submit, SIGNAL(clicked()), this, SLOT(SubmitButton())); connect(Modify, SIGNAL(clicked()), this, SLOT(ModifyButton())); connect(Check_out, SIGNAL(clicked()), this, SLOT(CheckoutButton())); connect(Cancel, SIGNAL(clicked()), this, SLOT(CancelButton())); mainlayout->addWidget(Name,0,0,1,1); mainlayout->addWidget(Contact,0,2,1,1); mainlayout->addWidget(ID,1,0,1,1); mainlayout->addWidget(Days,2,0,1,1); mainlayout->addWidget(Despoit,2,2,1,1); mainlayout->addWidget(RoomNum,3,0,1,1); mainlayout->addWidget(Price,3,2,1,1); mainlayout->addWidget(Livein,4,0,1,1); mainlayout->addWidget(NameEdit,0,1,1,1); mainlayout->addWidget(ContactEdit,0,3,1,1); mainlayout->addWidget(IDEdit,1,1,1,3); mainlayout->addWidget(DaysEdit,2,1,1,1); mainlayout->addWidget(DespoitEdit,2,3,1,1); mainlayout->addWidget(RoomNumEdit,3,1,1,1); mainlayout->addWidget(PriceEdit,3,3,1,1); mainlayout->addWidget(LiveinEdit,4,1,1,1); mainlayout->addWidget(LeaveDay,4,2,1,1); mainlayout->addWidget(LeaveEdit,4,3,1,1); buttonlayout->addWidget(Submit,0,0,1,1); buttonlayout->addWidget(Modify,0,1,1,1); buttonlayout->addWidget(Check_out,0,2,1,1); buttonlayout->addWidget(Cancel,0,3,1,1); QVBoxLayout *Layout = new QVBoxLayout; Layout->addLayout(mainlayout); Layout->addLayout(buttonlayout); setLayout(Layout); // setWindow(200,300,400,500); setWindowTitle("Record"); }