-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.cpp
77 lines (60 loc) · 1.26 KB
/
product.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "product.h"
#include <QDebug>
Product::Product()
{
}
QSqlQuery Product::getQuery()
{
QSqlQuery qry;
qry.prepare("insert into products values(?,?,?)");
qry.addBindValue(prodCode);
qry.addBindValue(prodName);
qry.addBindValue(prodUniPrice.toDouble());
return qry;
}
bool Product::validateProd()
{
//on a minimum a product should have a code,name and unit price -check for nullness
if(prodCode.isEmpty() || prodName.isEmpty() || prodUniPrice.isEmpty())
return false;
return true;
}
bool Product::validatePrice()
{
//check if the price is a valid number by casting it to double;
bool * isValid=new bool;
prodUniPrice.toDouble(isValid);
return (*isValid) ? true :false;
}
QString Product::getProdCode() const
{
return prodCode;
}
void Product::setProdCode(const QString &value)
{
prodCode = value;
}
QString Product::getProdName() const
{
return prodName;
}
void Product::setProdName(const QString &value)
{
prodName = value;
}
QString Product::getProdUniPrice() const
{
return prodUniPrice;
}
void Product::setProdUniPrice(const QString &value)
{
prodUniPrice = value;
}
int Product::getProdQty() const
{
return prodQty;
}
void Product::setProdQty(int value)
{
prodQty = value;
}