[Fix #12] Excel-Import: Show a message with number of imported sellers

This commit is contained in:
Martin Brodbeck 2019-02-25 09:26:21 +01:00
parent 2fb42d5365
commit 32da117468
3 changed files with 16 additions and 4 deletions

View file

@ -6,7 +6,7 @@
namespace fs = std::filesystem;
void ExcelReader::readSellersFromFile(const fs::path& filePath, Marketplace* market)
std::size_t ExcelReader::readSellersFromFile(const fs::path& filePath, Marketplace* market)
{
xlnt::workbook wb;
std::ifstream mystream(filePath, std::ios::binary);
@ -63,4 +63,6 @@ void ExcelReader::readSellersFromFile(const fs::path& filePath, Marketplace* mar
market->sortSellers();
market->storeToDb();
return market->getSellers().size() - 1; // minus 1 because we don't count the "special" seller
}

View file

@ -12,7 +12,7 @@
class ExcelReader
{
public:
static void readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market);
static std::size_t readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market);
};
#endif

View file

@ -17,6 +17,7 @@
#include <exception>
#include <filesystem>
#include <regex>
#include <string>
#include <QFileDialog>
#include <QMessageBox>
@ -388,7 +389,8 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
}
if (printer->isValid())
printer->printSaleReceipt(sale.get(), settings.value("global/commune", "Dettingen").toString().toStdString());
printer->printSaleReceipt(
sale.get(), settings.value("global/commune", "Dettingen").toString().toStdString());
}
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
@ -449,8 +451,16 @@ void MainWindow::onImportSellerExcelActionTriggered()
fs::path filePath(filename.toStdWString());
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
std::size_t numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
updateStatLabel();
using namespace std::string_literals;
std::ostringstream msg;
msg << "Aus der Excel-Datei wurden <b>"s << std::to_string(numImported)
<< "</b> Verkäufer importiert.";
QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert",
msg.str().c_str(), QMessageBox::StandardButton::Ok, this)
.exec();
}
void MainWindow::onImportSellerJsonActionTriggered()