Compare commits

..

No commits in common. "86a9ed38b63444d2baa3955de2d2b905d54976b8" and "2e6e2f9c091883f91fb256c3745c8bcb3d4518e6" have entirely different histories.

6 changed files with 9 additions and 34 deletions

View file

@ -186,8 +186,6 @@ void Database::beginTransaction() { exec("BEGIN TRANSACTION"); }
void Database::endTransaction() { exec("END TRANSACTION"); }
void Database::rollbackTransaction() { exec("ROLLBACK TRANSACTION"); }
unsigned int Database::storeSellers(std::vector<std::unique_ptr<Seller>>& sellers, bool onlyDelete)
{
int retCode{};
@ -223,9 +221,8 @@ unsigned int Database::storeSellers(std::vector<std::unique_ptr<Seller>>& seller
retCode = sqlite3_step(stmt);
if (retCode != SQLITE_DONE) {
//rollbackTransaction();
std::string errMsg(sqlite3_errmsg(db_));
errMsg += "\nSellerNo: " + std::to_string(seller->getSellerNo());
sqlite3_finalize(stmt);
throw std::runtime_error(errMsg);
}

View file

@ -31,7 +31,6 @@ class Database
void init();
void beginTransaction();
void endTransaction();
void rollbackTransaction();
void createNew();
int getVersion();
unsigned int storeArticles(std::vector<Article*> articles);

View file

@ -31,24 +31,18 @@ void JsonUtil::exportSellers(const fs::path& filePath, Marketplace* market)
writer->write(root, &file);
}
void JsonUtil::importSellers(const fs::path& filePath, Marketplace* market, bool cleanup)
void JsonUtil::importSellers(const fs::path& filePath, Marketplace* market)
{
if (cleanup) {
for (auto& seller : market->getSellers()) {
seller->setState(Seller::State::DELETE);
}
market->storeToDb(true);
for (auto& seller : market->getSellers()) {
seller->setState(Seller::State::DELETE);
}
market->storeToDb(true);
Json::Value jsonValues;
std::ifstream file(filePath);
file >> jsonValues;
for (auto val : jsonValues["sellers"]) {
auto sellerExist = market->findSellerWithUuid(val["uuid"].asString());
if (sellerExist) {
continue;
}
auto seller = std::make_unique<Seller>();
seller->setUuidFromString(val["uuid"].asString());
seller->setSellerNo(val["seller_no"].asInt());
@ -86,17 +80,6 @@ void JsonUtil::exportSales(const fs::path& filePath, Marketplace* market, int ca
std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
// Do export sellers (maybe there are new sellers created during sale)
for (const auto& seller : market->getSellers()) {
Json::Value newEntry;
newEntry["uuid"] = seller->getUuidAsString();
newEntry["seller_no"] = seller->getSellerNo();
newEntry["last_name"] = seller->getLastName();
newEntry["first_name"] = seller->getFirstName();
newEntry["num_offered_articles"] = seller->numArticlesOffered();
root["sellers"].append(newEntry);
}
root["source_no"] = cashPointNo;
for (const auto& sale : market->getSales()) {
@ -127,9 +110,6 @@ void JsonUtil::exportSales(const fs::path& filePath, Marketplace* market, int ca
void JsonUtil::importSales(const fs::path& filePath, Marketplace* market, int cashPointNo)
{
// First import newly created sellers during the sale phase
importSellers(filePath, market, false);
Json::Value jsonValues;
std::ifstream file(filePath);
file >> jsonValues;

View file

@ -10,7 +10,7 @@ class JsonUtil
{
public:
static void exportSellers(const std::filesystem::path& filePath, Marketplace* market);
static void importSellers(const std::filesystem::path& filePath, Marketplace* market, bool cleanup = true);
static void importSellers(const std::filesystem::path& filePath, Marketplace* market);
static void exportSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
static void importSales(const std::filesystem::path& filePath, Marketplace* market, int cashPointNo);
};

View file

@ -503,7 +503,6 @@ void MainWindow::onImportSalesJsonActionTriggered()
QMessageBox(QMessageBox::Icon::Warning, "Import nicht möglich", err.what(), QMessageBox::Ok,
this)
.exec();
marketplace_->loadFromDb();
}
setSaleModel();
}

View file

@ -25,14 +25,14 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
void SellerDialog::on_newButton_clicked()
{
// Don't allow new seller if market has already started
/* if (market_->getSales().size() > 0) {
if (market_->getSales().size() > 0) {
QMessageBox(QMessageBox::Icon::Warning, "Hinweis",
"Da die Verkaufsphase schon begonnen hat (Artikel wurden bereits verkauft) "
"können Sie keine Verkäufer mehr hinzufügen.",
QMessageBox::StandardButton::Ok, this)
.exec();
return;
} */
}
ui_.tableView->reset();
ui_.tableView->model()->insertRows(ui_.tableView->model()->rowCount(), 1);