Ejemplo n.º 1
0
void Liveinfo::SubmitButton()
{
//	bool a,b,c;
	if(NameEdit->text().isEmpty() || ContactEdit->text().isEmpty() || IDEdit->text().isEmpty() || 
                DaysEdit->text().isEmpty() || DespoitEdit->text().isEmpty())
	{
                QMessageBox::critical(0,QObject::tr("Error!"),QObject::tr("Please Fill them all!"),QMessageBox::Cancel);
	}
	else
	{
		QString Ename = NameEdit->text();
		QString Econtact = ContactEdit->text();
		QString EID = IDEdit->text();
		QString Edays = DaysEdit->text();
		QString Edeposit = DespoitEdit->text();
		QDate cudate = QDate::currentDate();
		cudate = cudate.addDays(Edays.toInt());
		Eetime = cudate.toString("yyyy-MM-dd");
		
		QSqlTableModel *insertGuest = new QSqlTableModel;		//修改Guest中的记录
		insertGuest->setTable("Guest");
	    insertGuest->select();			// 只要指定Row=0即可插入新行
	    int row = 0;
	    insertGuest->insertRows(row,1);
	    insertGuest->setData(insertGuest->index(row, 0), QVariant(Ename));
	    insertGuest->setData(insertGuest->index(row, 1), QVariant(EID));
	    insertGuest->setData(insertGuest->index(row, 2), QVariant(Econtact));
	    insertGuest->setData(insertGuest->index(row, 3), QVariant(RoomNum));
	//  a = insertGuest->submit();
	  	insertGuest->submit();
	    
	    QSqlTableModel *insertRecord = new QSqlTableModel;		//修改Record中的记录
	    insertRecord->setTable("Record");
	    insertRecord->select();
	    insertRecord->insertRows(row,1);
	    insertRecord->setData(insertRecord->index(row,0),QVariant(Ename));
	    insertRecord->setData(insertRecord->index(row,1),QVariant(RoomNum));
	    insertRecord->setData(insertRecord->index(row,2),QVariant(Edays));
	    insertRecord->setData(insertRecord->index(row,3),QVariant(Edeposit));
	    insertRecord->setData(insertRecord->index(row,4),QVariant(Estime));
	    insertRecord->setData(insertRecord->index(row,5),QVariant(Eetime));
	//  b = insertRecord->submit();
		insertRecord->submit();
		
		UpdateRoom(RoomNum,1);    //修改已入住的房间
	
	//	if(a && b && c)
	//	{	
			QMessageBox msgBox;
			msgBox.setText("Succeed to live in! Welcome");
			msgBox.exec();
	//	}	
		 QDialog::accept();
	 }
}
Ejemplo n.º 2
0
void PatientAccounter::printBill(const QDate& date)
{
	QString Document;

	addRTFHeader(Document);
	addDocumentHeader(Document);
	addPatientHeader(Document);
	addInfoText(Document);

	QString billFile = createBillFile(date);
	//std::cerr << "Target: " << billFile.toStdString() << std::endl;
	if (!addTreatments(Document))
	{
		//Again nothing to account, simple return
		return;
	}
	addDocumentFooter(Document);
	finishRTF(Document);

	//Get The document Footer
	std::ofstream outStream;
	outStream.open(billFile.toStdString().c_str());
	outStream << Document.toStdString();

	//Increment the Bill Identifier
	QSqlTableModel* miscTable = new QSqlTableModel;
	miscTable->setTable("misc");
	miscTable->select();
	QSqlRecord miscRecord = miscTable->record(0);
	miscRecord.setValue(BillNumber, m_billNumber + 1);
	miscTable->setRecord(0, miscRecord);
	miscTable->submit();
	delete miscTable;
}
Ejemplo n.º 3
0
void MainPage::userLogout(){
    qDebug()<<"userLogout...";
    if(!isLogin()){
        ToolUtil::ShowMessageBoxInfo("您还没有登录",this);
        return;
    }
    int result = ToolUtil::ShowMessageBoxQuesion("确定要退出登录吗?",this);
    if (1 == result) {
        //处理结束工作
        QSqlTableModel *model = Dbconnect::getTbModel("remuser");
        model->select();
        model->removeRows(0,model->rowCount());
        model->submit();

        delete model;
        model = NULL;
        this->updateUi("");
        Dbconnect::clearUser();
    }
}