本文整理汇总了C++中QSqlTableModel::submit方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlTableModel::submit方法的具体用法?C++ QSqlTableModel::submit怎么用?C++ QSqlTableModel::submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlTableModel
的用法示例。
在下文中一共展示了QSqlTableModel::submit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SubmitButton
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();
}
}
示例2: printBill
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;
}
示例3: userLogout
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();
}
}