|
yafeilinux 发表于 2016-4-6 19:15
建议查看下setItem帮助文档。
model->setTable("sys_sale");
int j=0;
if(j==model->rowCount())
{
QSqlRecord record = model->record(j);
record.setValue("order_sn",orderStr);
record.setValue("pay_sn",orderStr);
record.setValue("store_id",GlobalVariable::AgencyId);
record.setValue("store_name",GlobalVariable::AgencyName);
record.setValue("buyer_id",_map["buyerId"]);
record.setValue("buyer_name",_map["buyerName"]);
record.setValue("buyer_email",_map["buyerEmail"].toString()!=""?_map["buyerEmail"].toString():"custom@email.com");
record.setValue("add_time",timeStr);
record.setValue("payment_code",_map["payMethod"]);
record.setValue("payment_time",timeStr);
record.setValue("finished_time",timeStr);
record.setValue("goods_amount",_map["totalPrice"]);
record.setValue("order_amount",_map["realPrice"]);
//计算会员卡金额
double cardamount;
if(_map["payMethod"]=="custom")
{
cardamount = ui->cardEdit->text().toDouble();
record.setValue("pd_amount",ui->cardEdit->text());
}
else if(_map["payMethod"]=="member")
{
cardamount = cashLineEdit->text().toDouble();
record.setValue("pd_amount",cashLineEdit->text());
}
else
{
cardamount = ui->cardEdit->text().toDouble();
record.setValue("pd_amount",ui->cardEdit->text());
}
record.setValue("seller",GlobalVariable::SaleManName);
model->insertRecord(-1,record);
int id = 0;
if(model->submitAll())
{
QString sql = "select max(order_id) from sys_sale";
query.exec(sql);
query.next();
id = query.record().value(0).toInt();
}
else{
QMessageBox::information(this,"提示","更新销售表失败",QMessageBox::Yes);
}
大神写的setValue提交不上去, |
|