dPrinter = new DymoPrinter();
dPrinter->printOneLabel("000346050493");
dPrinter = new DymoPrinter();
dPrinter->printOneLabel("000346050493");
To copy to clipboard, switch view to plain text mode
That makes no sense to me at all...
dymoPrinter.h
---------------------------------
#ifndef DYMOPRINTER_H
#define DYMOPRINTER_H
#include <QString>
#include <QSqlQuery>
#include "dymosdk.h"
class DymoPrinter
{
public:
DymoPrinter();
~DymoPrinter();
bool printOneLabel
(const QString productId
) const;
private:
DYMO_DLS_SDK::ISDKDymoAddin *dymoAddIn;
DYMO_DLS_SDK::ISDKDymoLabels *dymoLabels;
};
#endif // DYMOPRINTER_H
dymoPrinter.h
---------------------------------
#ifndef DYMOPRINTER_H
#define DYMOPRINTER_H
#include <QString>
#include <QSqlQuery>
#include "dymosdk.h"
class DymoPrinter
{
public:
DymoPrinter();
~DymoPrinter();
bool printOneLabel(const QString productId) const;
private:
QSqlQuery *rockQuery;
DYMO_DLS_SDK::ISDKDymoAddin *dymoAddIn;
DYMO_DLS_SDK::ISDKDymoLabels *dymoLabels;
};
#endif // DYMOPRINTER_H
To copy to clipboard, switch view to plain text mode
dymoPrinter.cpp
-----------------------------
#include <QMessageBox>
#include <QSqlDatabase>
#include "dymoPrinter.h"
#include "dymosdk.h"
DymoPrinter::DymoPrinter()
{
dymoAddIn = new DYMO_DLS_SDK::ISDKDymoAddin();
dymoAddIn->setControl("{09DAFAE2-8EB0-11D2-8E5D-00A02415E90F}");
dymoAddIn->Open("d:/abe/catalog/abe_catalog/BinLabelKAWDIB-New.label");
dymoLabels = new DYMO_DLS_SDK::ISDKDymoLabels;
dymoLabels->setControl("{3AAD7661-8F83-11D2-8E5D-00A02415E90F}");
else
QMessageBox::critical( 0,
"Error!",
"Unable to connect to database! Are you sure you set up the correct paths?" );
}
DymoPrinter::~DymoPrinter()
{
delete rockQuery;
}
bool DymoPrinter
::printOneLabel(const QString productId
) const {
bool result = false;
rockQuery->clear();
rockQuery->exec("SELECT p.cdeProduct, " \
"p.cdeV1SKU, " \
"p.dscDescription, " \
"uom.dscUOM, " \
"p.curStnd_price, " \
"p.numORD_MULT1, " \
"p.numORD_MULT2, " \
"p.numORD_MULT3, " \
"p.cdeMSKU " \
"FROM tProducts AS p INNER JOIN tUOM AS uom ON p.cdeUOM = uom.cdeUOM " \
"WHERE cdeProduct = '" + productId + "';");
if (rockQuery->isActive())
{
if (rockQuery->next())
{
dymoLabels->SetField("Vendor 1 SKU", rockQuery->value(1).toString());
dymoLabels->SetField("Description", rockQuery->value(2).toString());
dymoLabels->SetField("UOM", rockQuery->value(3).toString());
dymoLabels->SetField("Product Code", productId);
dymoLabels->SetField("Standard Retail Price", "$" + rockQuery->value(4).toString());
dymoLabels->SetField("OrdMult", rockQuery->value(5).toString() + "-" +
rockQuery->value(6).toString() + "-" +
rockQuery->value(7).toString());
dymoLabels->SetField("cdeMSKU", rockQuery->value(8).toString());
if( dymoAddIn->Print(1,true) )
result = true;
else
result = false;
}
}
return result;
}
dymoPrinter.cpp
-----------------------------
#include <QMessageBox>
#include <QSqlDatabase>
#include "dymoPrinter.h"
#include "dymosdk.h"
DymoPrinter::DymoPrinter()
{
dymoAddIn = new DYMO_DLS_SDK::ISDKDymoAddin();
dymoAddIn->setControl("{09DAFAE2-8EB0-11D2-8E5D-00A02415E90F}");
dymoAddIn->Open("d:/abe/catalog/abe_catalog/BinLabelKAWDIB-New.label");
dymoLabels = new DYMO_DLS_SDK::ISDKDymoLabels;
dymoLabels->setControl("{3AAD7661-8F83-11D2-8E5D-00A02415E90F}");
if (QSqlDatabase::database("rock").isValid())
rockQuery = new QSqlQuery(QSqlDatabase::database("rock"));
else
QMessageBox::critical( 0, "Error!", "Unable to connect to database! Are you sure you set up the correct paths?" );
}
DymoPrinter::~DymoPrinter()
{
QSqlDatabase::database().close();
delete rockQuery;
}
bool DymoPrinter::printOneLabel(const QString productId) const
{
bool result = false;
rockQuery->clear();
rockQuery->exec("SELECT p.cdeProduct, " \
"p.cdeV1SKU, " \
"p.dscDescription, " \
"uom.dscUOM, " \
"p.curStnd_price, " \
"p.numORD_MULT1, " \
"p.numORD_MULT2, " \
"p.numORD_MULT3, " \
"p.cdeMSKU " \
"FROM tProducts AS p INNER JOIN tUOM AS uom ON p.cdeUOM = uom.cdeUOM " \
"WHERE cdeProduct = '" + productId + "';");
if (rockQuery->isActive())
{
if (rockQuery->next())
{
dymoLabels->SetField("Vendor 1 SKU", rockQuery->value(1).toString());
dymoLabels->SetField("Description", rockQuery->value(2).toString());
dymoLabels->SetField("UOM", rockQuery->value(3).toString());
dymoLabels->SetField("Product Code", productId);
dymoLabels->SetField("Standard Retail Price", "$" + rockQuery->value(4).toString());
dymoLabels->SetField("OrdMult", rockQuery->value(5).toString() + "-" +
rockQuery->value(6).toString() + "-" +
rockQuery->value(7).toString());
dymoLabels->SetField("cdeMSKU", rockQuery->value(8).toString());
if( dymoAddIn->Print(1,true) )
result = true;
else
result = false;
}
}
return result;
}
To copy to clipboard, switch view to plain text mode
Bookmarks