-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform3.cpp
More file actions
116 lines (92 loc) · 2.5 KB
/
form3.cpp
File metadata and controls
116 lines (92 loc) · 2.5 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "form3.h"
#include "ui_form3.h"
Form3::Form3(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form3)
{
ui->setupUi(this);
QSqlDatabase db;
db=QSqlDatabase ::addDatabase("QSQLITE");
db.setDatabaseName("c:\\market\\product.db");
db.open();
}
Form3::~Form3()
{
delete ui;
}
void Form3::on_pushButton_4_clicked()
{
QSqlQuery q;
q.exec("SELECT * FROM pro");
QSqlQueryModel *m=new QSqlQueryModel;
m->setQuery(q);
ui->tableView->setModel(m);
}
void Form3::on_pushButton_5_clicked()
{
QSqlQuery q;
q.exec("SELECT * FROM reg");
QSqlQueryModel *m=new QSqlQueryModel;
m->setQuery(q);
ui->tableView_2->setModel(m);
}
void Form3::on_pushButton_2_clicked()
{
QSqlQuery q;
QString s;
s= ui->lineEdit->text();
q.exec("DELETE FROM pro WHERE name= '"+s+"' ");
}
void Form3::on_pushButton_6_clicked()
{
QSqlQuery q;
QString sid,sname,snum,sprice,scategory;
sid=ui->lineEdit_9->text();
sname=ui->lineEdit_10->text();
snum=ui->lineEdit_11->text();
sprice=ui->lineEdit_12->text();
scategory=ui->lineEdit_6->text();
q.exec("INSERT INTO pro VALUES('"+sid+"','"+scategory+"','"+sname+"','"+snum+"','"+sprice+"')");
}
void Form3::on_pushButton_3_clicked()
{
QSqlQuery q;
QString sid,sname,snum,sprice,scategory;
sid=ui->lineEdit_4->text();
sname=ui->lineEdit_2->text();
snum=ui->lineEdit_3->text();
sprice=ui->Price->text();
scategory=ui->lineEdit_5->text();
q.exec("UPDATE pro SET name='"+sname+"' WHERE id='"+sid+"' ");
q.exec("UPDATE pro SET number='"+snum+"' WHERE id='"+sid+"' ");
q.exec("UPDATE pro SET price='"+sprice+"' WHERE id='"+sid+"' ");
q.exec("UPDATE pro SET Category='"+scategory+"' WHERE id='"+sid+"' ");
}
void Form3::on_pushButton_7_clicked()
{
QSqlQuery q;
QString s;
s=ui->lineEdit_8->text();
q.exec("SELECT id,number,price,Category FROM pro WHERE name='"+s+"'");
if(q.first())
{
ui->label_16->setText((q.value(0).toString()));
ui->label_17->setText((q.value(1).toString()));
ui->label_18->setText((q.value(2).toString()));
ui->label_26->setText((q.value(3).toString()));
}
else {
ui->label_16->setText("don't exist");
ui->label_17->setText("don't exist");
ui->label_18->setText("don't exist");
ui->label_26->setText("don't exist");
}
}
void Form3::on_pushButton_clicked()
{
this->close();
}
void Form3::on_pushButton_8_clicked()
{
this->showMinimized();
}