Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6 | pingvin | 1 | #include "addsotrydnikform.h" |
2 | #include "mainwindowimpl.h" |
||
3 | // place your code here |
||
4 | |||
5 | addsotrydnikForm::addsotrydnikForm() |
||
6 | : QDialog() |
||
7 | { |
||
8 | // QStringList proizv_list; // |
||
9 | setupUi(this); |
||
10 | // proizv_list = getManufacturiesList(); |
||
11 | // comboBox->addItems(proizv_list); |
||
12 | // TODO |
||
13 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(addNewSotrydnikSlot())); |
||
14 | |||
15 | } |
||
16 | |||
17 | |||
18 | |||
19 | void addsotrydnikForm::closeEvent ( QCloseEvent * event ) { |
||
20 | emit formClose(); |
||
21 | } |
||
22 | |||
23 | void addsotrydnikForm::addNewSotrydnikSlot(){ |
||
24 | QSqlQuery q; |
||
25 | QString sqltext; |
||
26 | int field_fio, field_identifikator, field_identifikator_otdela; |
||
27 | QString id, fio, id_otdela; |
||
28 | bool ok; |
||
29 | if (lineEdit->text()==""){ |
||
30 | QMessageBox::critical( // . |
||
31 | this, // . |
||
32 | QObject::tr(" "), // . |
||
33 | tr(" !")); // . |
||
34 | return; |
||
35 | } |
||
36 | |||
37 | |||
38 | sqltext = tr("select * from sotrydniki where sotrydniki. = \""); |
||
39 | sqltext.append(lineEdit->text()); |
||
40 | sqltext.append(tr("\"")); |
||
41 | q.prepare(sqltext); |
||
42 | ok = q.exec(); |
||
43 | field_fio = q.record().indexOf(tr("")); |
||
44 | if (q.next()) { |
||
45 | QMessageBox::critical( // . |
||
46 | this, // . |
||
47 | QObject::tr(" "), // . |
||
48 | tr(" !")); // . |
||
49 | return; |
||
50 | } |
||
51 | else { |
||
52 | q.clear(); |
||
53 | q.prepare(tr("insert into sotrydniki (, _) " |
||
54 | "values (:fio, :id_otd)")); |
||
55 | q.bindValue(tr(":fio"), lineEdit->text()); |
||
56 | q.bindValue(tr(":id_otd"), IdOtdela); |
||
57 | ok = q.exec(); |
||
58 | emit componentAdd(); |
||
59 | close();} |
||
60 | |||
61 | } |