[Fix #12] Excel-Import: Show a message with number of imported sellers
This commit is contained in:
parent
2fb42d5365
commit
32da117468
3 changed files with 16 additions and 4 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
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;
|
xlnt::workbook wb;
|
||||||
std::ifstream mystream(filePath, std::ios::binary);
|
std::ifstream mystream(filePath, std::ios::binary);
|
||||||
|
@ -63,4 +63,6 @@ void ExcelReader::readSellersFromFile(const fs::path& filePath, Marketplace* mar
|
||||||
|
|
||||||
market->sortSellers();
|
market->sortSellers();
|
||||||
market->storeToDb();
|
market->storeToDb();
|
||||||
|
|
||||||
|
return market->getSellers().size() - 1; // minus 1 because we don't count the "special" seller
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
class ExcelReader
|
class ExcelReader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market);
|
static std::size_t readSellersFromFile(const std::filesystem::path& filePath, Marketplace* market);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -17,6 +17,7 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -388,7 +389,8 @@ void MainWindow::onPrintSaleReceiptButtonClicked([[maybe_unused]] bool checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (printer->isValid())
|
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)
|
void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked)
|
||||||
|
@ -449,8 +451,16 @@ void MainWindow::onImportSellerExcelActionTriggered()
|
||||||
|
|
||||||
fs::path filePath(filename.toStdWString());
|
fs::path filePath(filename.toStdWString());
|
||||||
|
|
||||||
ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
std::size_t numImported = ExcelReader::readSellersFromFile(filePath, marketplace_.get());
|
||||||
updateStatLabel();
|
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()
|
void MainWindow::onImportSellerJsonActionTriggered()
|
||||||
|
|
Loading…
Reference in a new issue