Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6 | pingvin | 1 | #include "addmemoryform.h" |
2 | #include "mainwindowimpl.h" |
||
3 | |||
4 | // place your code here |
||
5 | addmemoryForm::addmemoryForm( ) |
||
6 | : QWidget() |
||
7 | { |
||
8 | // QStringList proizv_list; // |
||
9 | setupUi(this); |
||
10 | // proizv_list = getManufacturiesList(); |
||
11 | // comboBox->addItems(proizv_list); |
||
12 | // TODO |
||
13 | } |
||
14 | |||
15 | QStringList addmemoryForm::getManufacturiesList(){ |
||
16 | QStringList mnfctrlist; |
||
17 | QString mnfctSqlText, tmp; |
||
18 | QSqlQuery qproiz; |
||
19 | int field_proizvoditel; |
||
17 | pingvin | 20 | mnfctSqlText = tr("select * from proizvoditeli_pamyati"); |
6 | pingvin | 21 | // QSqlQuery qns(tr("SET NAMES utf8")); |
22 | qproiz.prepare(mnfctSqlText); |
||
23 | qproiz.exec(); |
||
17 | pingvin | 24 | // QSqlQuery qproiz("SELECT * FROM _"); |
6 | pingvin | 25 | field_proizvoditel = qproiz.record().indexOf(tr("")); |
26 | mnfctrlist.clear(); |
||
27 | while (qproiz.next()){ |
||
28 | tmp = qproiz.value(field_proizvoditel).toString(); |
||
29 | // comboBox->addItem(tmp); |
||
30 | mnfctrlist.append (tmp); |
||
31 | } |
||
32 | // comboBox->addItems(mnfctrlist); |
||
33 | return mnfctrlist; |
||
34 | } |
||
35 | |||
36 | |||
37 | QStringList addmemoryForm::getManufacturiesListVIDEO(){ |
||
38 | QStringList mnfctrlist; |
||
39 | QString mnfctSqlText, tmp; |
||
40 | QSqlQuery qproiz; |
||
41 | int field_proizvoditel; |
||
17 | pingvin | 42 | mnfctSqlText = tr("select * from proizvoditeli_video"); |
6 | pingvin | 43 | // QSqlQuery qns(tr("SET NAMES utf8")); |
44 | qproiz.prepare(mnfctSqlText); |
||
45 | qproiz.exec(); |
||
17 | pingvin | 46 | // QSqlQuery qproiz("SELECT * FROM _"); |
6 | pingvin | 47 | field_proizvoditel = qproiz.record().indexOf(tr("")); |
48 | mnfctrlist.clear(); |
||
49 | while (qproiz.next()){ |
||
50 | tmp = qproiz.value(field_proizvoditel).toString(); |
||
51 | // comboBox->addItem(tmp); |
||
52 | mnfctrlist.append (tmp); |
||
53 | } |
||
54 | // comboBox->addItems(mnfctrlist); |
||
55 | return mnfctrlist; |
||
56 | } |
||
57 | |||
58 | |||
59 | |||
60 | |||
61 | QStringList addmemoryForm::getManufacturiesListMB(){ |
||
62 | QStringList mnfctrlist; |
||
63 | QString mnfctSqlText, tmp; |
||
64 | QSqlQuery qproiz; |
||
65 | int field_proizvoditel; |
||
17 | pingvin | 66 | mnfctSqlText = tr("select * from proizvoditeli_mb"); |
6 | pingvin | 67 | // QSqlQuery qns(tr("SET NAMES utf8")); |
68 | qproiz.prepare(mnfctSqlText); |
||
69 | qproiz.exec(); |
||
17 | pingvin | 70 | // QSqlQuery qproiz("SELECT * FROM _"); |
6 | pingvin | 71 | field_proizvoditel = qproiz.record().indexOf(tr("")); |
72 | mnfctrlist.clear(); |
||
73 | while (qproiz.next()){ |
||
74 | tmp = qproiz.value(field_proizvoditel).toString(); |
||
75 | // comboBox->addItem(tmp); |
||
76 | mnfctrlist.append (tmp); |
||
77 | } |
||
78 | // comboBox->addItems(mnfctrlist); |
||
79 | return mnfctrlist; |
||
80 | } |
||
81 | |||
82 | |||
83 | QStringList addmemoryForm::getManufacturiesListHDD(){ |
||
84 | QStringList mnfctrlist; |
||
85 | QString mnfctSqlText, tmp; |
||
86 | QSqlQuery qproiz; |
||
87 | int field_proizvoditel; |
||
17 | pingvin | 88 | mnfctSqlText = tr("select * from proizvoditeli_hdd"); |
6 | pingvin | 89 | // QSqlQuery qns(tr("SET NAMES utf8")); |
90 | qproiz.prepare(mnfctSqlText); |
||
91 | qproiz.exec(); |
||
17 | pingvin | 92 | // QSqlQuery qproiz("SELECT * FROM _"); |
6 | pingvin | 93 | field_proizvoditel = qproiz.record().indexOf(tr("")); |
94 | mnfctrlist.clear(); |
||
95 | while (qproiz.next()){ |
||
96 | tmp = qproiz.value(field_proizvoditel).toString(); |
||
97 | // comboBox->addItem(tmp); |
||
98 | mnfctrlist.append (tmp); |
||
99 | } |
||
100 | // comboBox->addItems(mnfctrlist); |
||
101 | return mnfctrlist; |
||
102 | } |
||
103 | |||
104 | QStringList addmemoryForm::getManufacturiesListCPU(){ |
||
105 | QStringList mnfctrlist; |
||
106 | QString mnfctSqlText, tmp; |
||
107 | QSqlQuery qproiz; |
||
108 | int field_proizvoditel; |
||
17 | pingvin | 109 | mnfctSqlText = tr("select * from proizvoditeli_cpu"); |
6 | pingvin | 110 | // QSqlQuery qns(tr("SET NAMES utf8")); |
111 | qproiz.prepare(mnfctSqlText); |
||
112 | qproiz.exec(); |
||
17 | pingvin | 113 | // QSqlQuery qproiz("SELECT * FROM _"); |
6 | pingvin | 114 | field_proizvoditel = qproiz.record().indexOf(tr("")); |
115 | mnfctrlist.clear(); |
||
116 | while (qproiz.next()){ |
||
117 | tmp = qproiz.value(field_proizvoditel).toString(); |
||
118 | // comboBox->addItem(tmp); |
||
119 | mnfctrlist.append (tmp); |
||
120 | } |
||
121 | // comboBox->addItems(mnfctrlist); |
||
122 | return mnfctrlist; |
||
123 | } |
||
124 | |||
125 | |||
126 | |||
127 | QStringList addmemoryForm::getModelListMB(QString proizvoditel){ |
||
128 | QStringList modelList; |
||
129 | QString SqlText, tmp; |
||
130 | QSqlQuery qmodel; |
||
131 | int field_model; |
||
17 | pingvin | 132 | SqlText = tr("select * from __ where __. = \""); |
6 | pingvin | 133 | SqlText.append(proizvoditel); |
134 | SqlText.append(tr("\"")); |
||
135 | qmodel.prepare(SqlText); |
||
136 | qmodel.exec(); |
||
137 | field_model = qmodel.record().indexOf(tr("")); |
||
138 | modelList.clear(); |
||
139 | while (qmodel.next()){ |
||
140 | tmp = qmodel.value(field_model).toString(); |
||
141 | // comboBox->addItem(tmp); |
||
142 | modelList.append (tmp); |
||
143 | } |
||
144 | // comboBox->addItems(mnfctrlist); |
||
145 | return modelList; |
||
146 | } |
||
147 | |||
148 | |||
149 | |||
150 | QStringList addmemoryForm::getModelListVIDEO(QString proizvoditel){ |
||
151 | QStringList modelList; |
||
152 | QString SqlText, tmp; |
||
153 | QSqlQuery qmodel; |
||
154 | int field_model; |
||
17 | pingvin | 155 | SqlText = tr("select * from video_models where video_models. = \""); |
6 | pingvin | 156 | SqlText.append(proizvoditel); |
157 | SqlText.append(tr("\"")); |
||
158 | qmodel.prepare(SqlText); |
||
159 | qmodel.exec(); |
||
160 | field_model = qmodel.record().indexOf(tr("")); |
||
161 | modelList.clear(); |
||
162 | while (qmodel.next()){ |
||
163 | tmp = qmodel.value(field_model).toString(); |
||
164 | // comboBox->addItem(tmp); |
||
165 | modelList.append (tmp); |
||
166 | } |
||
167 | // comboBox->addItems(mnfctrlist); |
||
168 | return modelList; |
||
169 | } |
||
170 | |||
171 | |||
172 | |||
173 | QStringList addmemoryForm::getModelListCPU(QString proizvoditel){ |
||
174 | QStringList modelList; |
||
175 | QString SqlText, tmp; |
||
176 | QSqlQuery qmodel; |
||
177 | int field_model; |
||
17 | pingvin | 178 | SqlText = tr("select * from processor_models where processor_models. = \""); |
6 | pingvin | 179 | SqlText.append(proizvoditel); |
180 | SqlText.append(tr("\"")); |
||
181 | qmodel.prepare(SqlText); |
||
182 | qmodel.exec(); |
||
183 | field_model = qmodel.record().indexOf(tr("")); |
||
184 | modelList.clear(); |
||
185 | while (qmodel.next()){ |
||
186 | tmp = qmodel.value(field_model).toString(); |
||
187 | // comboBox->addItem(tmp); |
||
188 | modelList.append (tmp); |
||
189 | } |
||
190 | // comboBox->addItems(mnfctrlist); |
||
191 | return modelList; |
||
192 | } |
||
193 | |||
194 | |||
195 | QStringList addmemoryForm::getSystemBlockList(){ |
||
196 | QStringList sysBlockList; |
||
197 | bool b1, b2; |
||
198 | QString tmp, SerialNum, InventarNum, DataPokypki, SrokGarantii, UserId, Identifikator; |
||
199 | int field_identifikator, field_serial_num, field_inventar_num, field_data_pokypki, field_srok_garantii, field_user_id; |
||
17 | pingvin | 200 | QSqlQuery qysBlockList(tr("select * from system_blocks")); |
6 | pingvin | 201 | field_serial_num = qysBlockList.record().indexOf(tr("_")); |
202 | field_inventar_num = qysBlockList.record().indexOf(tr("_")); |
||
203 | field_data_pokypki = qysBlockList.record().indexOf(tr("_")); |
||
204 | field_srok_garantii = qysBlockList.record().indexOf(tr("_")); |
||
205 | field_user_id = qysBlockList.record().indexOf(tr("__")); |
||
206 | field_identifikator = qysBlockList.record().indexOf(tr("")); |
||
207 | while (qysBlockList.next()){ |
||
208 | tmp = ""; |
||
209 | SerialNum = qysBlockList.value(field_serial_num).toString(); |
||
210 | InventarNum = qysBlockList.value(field_inventar_num).toString(); |
||
211 | DataPokypki = qysBlockList.value(field_data_pokypki).toString(); |
||
212 | SrokGarantii = qysBlockList.value(field_srok_garantii).toString(); |
||
213 | UserId = qysBlockList.value(field_user_id).toString(); |
||
214 | Identifikator = qysBlockList.value(field_identifikator).toString(); |
||
215 | b1 = (SerialNum !=""); |
||
216 | b2 = (SerialNum !=tr("")); |
||
217 | // if (SerialNum == tr("")){continue;} |
||
218 | // if (SerialNum == tr("")){sysBlockList << tr(" "); continue;} |
||
219 | // if (SerialNum !="") {tmp.append(tr("S/N: ")); |
||
220 | // tmp.append(SerialNum); } |
||
221 | if (InventarNum == tr("")){continue;} |
||
222 | if (InventarNum == tr("")){sysBlockList << tr(" "); continue;} |
||
223 | if (InventarNum !="") {tmp.append(tr(".:")); |
||
224 | tmp.append(InventarNum); } |
||
225 | tmp.append(addmemoryForm::getUserInfo(UserId)); |
||
226 | // if (InventarNum !=""){tmp.append(tr(" .: ")); |
||
227 | // tmp.append(InventarNum);} |
||
228 | if (tmp !="") sysBlockList << tmp; |
||
229 | |||
230 | } |
||
231 | return sysBlockList; |
||
232 | |||
233 | } |
||
234 | |||
235 | QString addmemoryForm::getUserInfo(QString userID){ |
||
236 | QString rslt, tmp, sqlQueryText; |
||
237 | QString identifikator_polzovatela, fio_polzovatela, identifikator_otdela; |
||
238 | int field_identifikator, field_fio, field_id_otdela; |
||
239 | QSqlQuery qSqlUserInfo; |
||
17 | pingvin | 240 | sqlQueryText = tr("select * from where = "); |
6 | pingvin | 241 | sqlQueryText.append(userID); |
242 | qSqlUserInfo.prepare(sqlQueryText); |
||
243 | qSqlUserInfo.exec(); |
||
244 | field_identifikator = qSqlUserInfo.record().indexOf(tr("")); |
||
245 | field_fio = qSqlUserInfo.record().indexOf(tr("")); |
||
246 | field_id_otdela = qSqlUserInfo.record().indexOf(tr("_")); |
||
247 | tmp=""; |
||
248 | while(qSqlUserInfo.next()){ |
||
249 | identifikator_polzovatela = qSqlUserInfo.value(field_identifikator).toString(); |
||
250 | fio_polzovatela = qSqlUserInfo.value(field_fio).toString(); |
||
251 | identifikator_otdela = qSqlUserInfo.value(field_id_otdela).toString(); |
||
252 | if (fio_polzovatela !="") { |
||
253 | tmp.append(tr(" ")); |
||
254 | tmp.append(fio_polzovatela); |
||
255 | tmp.append(addmemoryForm::getOtdelName(identifikator_otdela)); |
||
256 | } |
||
257 | |||
258 | } |
||
259 | rslt.append(tmp); |
||
260 | return rslt; |
||
261 | |||
262 | } |
||
263 | |||
264 | |||
265 | QString addmemoryForm::getOtdelName(QString otdelID){ |
||
266 | QString otdel, sqlText, tmp; |
||
267 | QSqlQuery query; |
||
268 | int field_name; |
||
17 | pingvin | 269 | sqlText = (tr("select . from where = ")); |
6 | pingvin | 270 | sqlText.append(otdelID); |
271 | query.prepare(sqlText); |
||
272 | query.exec(); |
||
273 | field_name = query.record().indexOf(tr("")); |
||
274 | tmp=""; |
||
275 | while(query.next()){ |
||
276 | tmp.append(tr(" ")); |
||
277 | tmp.append( query.value(field_name).toString()); |
||
278 | } |
||
279 | otdel = tmp; |
||
280 | return otdel; |
||
281 | } |
||
282 | |||
283 | void addmemoryForm::initTreeWidgrt(){ |
||
284 | int fieldName, fieldID; |
||
285 | QTreeWidgetItem *otdelItem; |
||
286 | QSqlQuery q(tr("select * from "));// |
||
287 | QString otdel, otdel_id; |
||
288 | fieldName = q.record().indexOf(tr("")); |
||
289 | fieldID = q.record().indexOf(tr("")); |
||
290 | while (q.next()){ |
||
291 | otdel = q.value(fieldName).toString(); |
||
292 | otdel_id = q.value(fieldID).toString(); |
||
293 | otdelItem = new QTreeWidgetItem(addmemoryForm::treeWidget); |
||
294 | otdelItem->setText(0, otdel); |
||
295 | addmemoryForm::SotrydnikiOtdela(otdel_id, otdelItem); |
||
296 | } |
||
297 | |||
298 | } |
||
299 | |||
300 | void addmemoryForm::SotrydnikiOtdela(QString id_otdela, QTreeWidgetItem * itemOtdela){ |
||
301 | int field_fio_sotrydnika, field_id_sotrydnika; |
||
302 | QString fio_sotrydnika_otdela, id_sotrydnika_otdela, oboryd; |
||
303 | QSqlQuery qsotrydnikiOtdela; |
||
304 | QString sqlQueryString; |
||
305 | QTreeWidgetItem *treeItem_sotrydnika; |
||
306 | sqlQueryString = tr("select , from where _="); |
||
307 | sqlQueryString.append(id_otdela); |
||
308 | qsotrydnikiOtdela.prepare(sqlQueryString); |
||
309 | qsotrydnikiOtdela.exec(); |
||
310 | field_fio_sotrydnika = qsotrydnikiOtdela.record().indexOf(tr("")); |
||
311 | field_id_sotrydnika = qsotrydnikiOtdela.record().indexOf(tr("")); |
||
312 | while (qsotrydnikiOtdela.next()) |
||
313 | { |
||
314 | fio_sotrydnika_otdela = qsotrydnikiOtdela.value(field_fio_sotrydnika).toString(); |
||
315 | id_sotrydnika_otdela = qsotrydnikiOtdela.value(field_id_sotrydnika).toString(); |
||
316 | treeItem_sotrydnika = new QTreeWidgetItem(itemOtdela); |
||
317 | treeItem_sotrydnika->setText(1, fio_sotrydnika_otdela ); |
||
318 | // treeItem_sotrydnika->setText(2, id_sotrydnika_otdela ); |
||
319 | // oboryd = oborydovanie(id_sotrydnika_otdela, treeItem_sotrydnika); |
||
320 | // treeItem_sotrydnika->setText(3, oboryd ); |
||
321 | } |
||
322 | } |
||
323 | |||
324 | void addmemoryForm::on_pushButton_clicked(){ |
||
325 | QSqlQuery q; |
||
326 | QString sqlText; |
||
327 | if (lineEdit->text() == "") |
||
328 | { |
||
329 | QMessageBox::critical( // . |
||
330 | this, // . |
||
331 | QObject::tr(" "), // . |
||
332 | tr(" ")); // . |
||
333 | return; |
||
334 | } |
||
335 | switch (tabWidget->currentIndex()) |
||
336 | { |
||
337 | case 0: // |
||
338 | { |
||
339 | QString id; |
||
340 | |||
341 | id = getIdentifikator(label_7->text()); |
||
342 | q.prepare(tr("insert into memory (, , , __, _, _) " |
||
343 | "values (:proizvoditel, :tip, :obem, :sys_id, :inv_num, :serial_num)")); |
||
344 | // q.bindValue(":ident", "default"); |
||
345 | q.bindValue(tr(":proizvoditel"), comboBox->currentText()); |
||
346 | q.bindValue(tr(":tip"), comboBox_3->currentText()); |
||
347 | q.bindValue(tr(":obem"), comboBox_2->currentText()); |
||
348 | // q.bindValue(tr(":chastota"), "default"); |
||
349 | q.bindValue(tr(":sys_id"), id); |
||
350 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
351 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
352 | // query.bindValue(":surname", "Simpson"); |
||
353 | // sqlText = tr("insert into vflue()"); |
||
354 | q.exec(); |
||
355 | add_mem_proizvoditel(comboBox->currentText()); // , |
||
356 | emit componentAdd(); |
||
357 | close(); |
||
358 | // MainWindowImpl::initTreeWidget(); |
||
359 | } |
||
360 | break; |
||
361 | |||
362 | case 1: // |
||
363 | { |
||
364 | QString id; |
||
365 | |||
366 | id = getIdentifikator(label_7->text()); |
||
367 | q.prepare(tr("insert into harddiscs (, , , __, _, _) " |
||
368 | "values (:proizvoditel, :interface, :obem, :sys_id, :inv_num, :serial_num)")); |
||
369 | // q.bindValue(":ident", "default"); |
||
370 | q.bindValue(tr(":proizvoditel"), comboBox_13->currentText()); |
||
371 | q.bindValue(tr(":interface"), comboBox_14->currentText()); |
||
372 | q.bindValue(tr(":obem"), comboBox_15->currentText()); |
||
373 | // q.bindValue(tr(":chastota"), "default"); |
||
374 | q.bindValue(tr(":sys_id"), id); |
||
375 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
376 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
377 | // query.bindValue(":surname", "Simpson"); |
||
378 | // sqlText = tr("insert into vflue()"); |
||
379 | q.exec(); |
||
380 | add_hdd_proizvoditel(comboBox_13->currentText()); // , |
||
381 | emit componentAdd(); |
||
382 | close(); |
||
383 | // MainWindowImpl::initTreeWidget(); |
||
384 | } |
||
385 | break; |
||
386 | |||
387 | |||
388 | case 2: // |
||
389 | { |
||
390 | QString id; |
||
391 | id = getIdentifikator(label_7->text()); |
||
392 | q.prepare(tr("insert into processors (, , , , __, _, _) " |
||
393 | "values (:proizvoditel, :model, :fqr, :slot, :sys_id, :inv_num, :serial_num)")); |
||
394 | q.bindValue(tr(":proizvoditel"), comboBox_9->currentText()); |
||
395 | q.bindValue(tr(":model"), comboBox_12->currentText()); |
||
396 | q.bindValue(tr(":slot"), comboBox_11->currentText()); |
||
397 | q.bindValue(tr(":fqr"), comboBox_10->currentText()); |
||
398 | q.bindValue(tr(":sys_id"), id); |
||
399 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
400 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
401 | q.exec(); |
||
402 | add_mb_proizvoditel(comboBox_5->currentText()); |
||
403 | add_cpu_proizvoditel(comboBox_9->currentText()); |
||
404 | add_mb_model(comboBox_5->currentText(), comboBox_6->currentText()); |
||
405 | add_cpu_model(comboBox_9->currentText(), comboBox_12->currentText()); |
||
406 | |||
407 | emit componentAdd(); |
||
408 | close(); |
||
409 | } |
||
410 | break; |
||
411 | |||
412 | case 3: // |
||
413 | { |
||
414 | QString id; |
||
415 | id = getIdentifikator(label_7->text()); |
||
416 | q.prepare(tr("insert into matheboards (, , , _, __, _, _) " |
||
417 | "values (:proizvoditel, :model, :slot, :bus_fqr, :sys_id, :inv_num, :serial_num)")); |
||
418 | q.bindValue(tr(":proizvoditel"), comboBox_5->currentText()); |
||
419 | q.bindValue(tr(":model"), comboBox_6->currentText()); |
||
420 | q.bindValue(tr(":slot"), comboBox_7->currentText()); |
||
421 | q.bindValue(tr(":bus_fqr"), comboBox_8->currentText()); |
||
422 | q.bindValue(tr(":sys_id"), id); |
||
423 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
424 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
425 | q.exec(); |
||
426 | add_mb_proizvoditel(comboBox_5->currentText()); |
||
427 | add_mb_model(comboBox_5->currentText(), comboBox_6->currentText()); |
||
428 | emit componentAdd(); |
||
429 | close(); |
||
430 | } |
||
431 | break; |
||
432 | |||
433 | case 4: //CD/DVD |
||
434 | { |
||
435 | QString id; |
||
436 | id = getIdentifikator(label_7->text()); |
||
437 | q.prepare(tr("insert into cd_dvd (, , , __, _, _) " |
||
438 | "values (:tip, :proizvoditel, :skorost, :sys_id, :inv_num, :serial_num)")); |
||
439 | q.bindValue(tr(":tip"), comboBox_16->currentText()); |
||
440 | q.bindValue(tr(":proizvoditel"), comboBox_17->currentText()); |
||
441 | q.bindValue(tr(":skorost"), comboBox_18->currentText()); |
||
442 | q.bindValue(tr(":sys_id"), id); |
||
443 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
444 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
445 | q.exec(); |
||
446 | add_mb_proizvoditel(comboBox_5->currentText()); |
||
447 | add_mb_model(comboBox_5->currentText(), comboBox_6->currentText()); |
||
448 | emit componentAdd(); |
||
449 | close(); |
||
450 | } |
||
451 | |||
452 | |||
453 | break; |
||
454 | |||
455 | case 5: // |
||
456 | { |
||
457 | |||
458 | QString id; |
||
459 | id = getIdentifikator(label_7->text()); |
||
460 | q.prepare(tr("insert into videocards (, , , , __, _, _) " |
||
461 | "values (:proizvoditel, :model, :interface, :memory, :sys_id, :inv_num, :serial_num)")); |
||
462 | q.bindValue(tr(":proizvoditel"), comboBox_19->currentText()); |
||
463 | q.bindValue(tr(":model"), comboBox_20->currentText()); |
||
464 | q.bindValue(tr(":interface"), comboBox_21->currentText()); |
||
465 | q.bindValue(tr(":memory"), comboBox_22->currentText()); |
||
466 | q.bindValue(tr(":sys_id"), id); |
||
467 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
468 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
469 | q.exec(); |
||
470 | add_video_proizvoditel(comboBox_19->currentText()); |
||
471 | add_video_model(comboBox_19->currentText(), comboBox_20->currentText()); |
||
472 | emit componentAdd(); |
||
473 | close(); |
||
474 | } |
||
475 | break; |
||
476 | |||
477 | case 6: // |
||
478 | { |
||
479 | |||
480 | QString id; |
||
481 | id = getIdentifikator(label_7->text()); |
||
482 | q.prepare(tr("insert into soundcards (, , __, _, _) " |
||
483 | "values (:proizvoditel, :model, :sys_id, :inv_num, :serial_num)")); |
||
484 | q.bindValue(tr(":proizvoditel"), comboBox_23->currentText()); |
||
485 | q.bindValue(tr(":model"), comboBox_24->currentText()); |
||
486 | q.bindValue(tr(":sys_id"), id); |
||
487 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
488 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
489 | q.exec(); |
||
490 | add_mb_proizvoditel(comboBox_5->currentText()); |
||
491 | add_mb_model(comboBox_5->currentText(), comboBox_6->currentText()); |
||
492 | emit componentAdd(); |
||
493 | close(); |
||
494 | |||
495 | } |
||
496 | break; |
||
497 | case 7: // |
||
498 | { |
||
499 | |||
500 | QString id; |
||
501 | id = getIdentifikator(label_7->text()); |
||
502 | q.prepare(tr("insert into lancards (, , __, __, _, _) " |
||
503 | "values (:proizvoditel, :model, :spd, :sys_id, :inv_num, :serial_num)")); |
||
504 | q.bindValue(tr(":proizvoditel"), comboBox_25->currentText()); |
||
505 | q.bindValue(tr(":model"), comboBox_26->currentText()); |
||
506 | q.bindValue(tr(":spd"), comboBox_27->currentText()); |
||
507 | q.bindValue(tr(":sys_id"), id); |
||
508 | q.bindValue(tr(":inv_num"), lineEdit->text()); |
||
509 | q.bindValue(tr(":serial_num"), lineEdit_2->text()); |
||
510 | q.exec(); |
||
511 | add_mb_proizvoditel(comboBox_5->currentText()); |
||
512 | add_mb_model(comboBox_5->currentText(), comboBox_6->currentText()); |
||
513 | emit componentAdd(); |
||
514 | close(); |
||
515 | |||
516 | } |
||
517 | break; |
||
518 | |||
519 | default: |
||
520 | |||
521 | |||
522 | break; |
||
523 | } |
||
524 | |||
525 | void componentAdd(); |
||
526 | |||
527 | |||
528 | |||
529 | |||
530 | |||
531 | |||
532 | } |
||
533 | |||
534 | QString addmemoryForm::getIdentifikator(QString inventar_num){ |
||
535 | QSqlQuery q; |
||
536 | QString sqltext; |
||
537 | int field_id; |
||
538 | QString identifikator; |
||
539 | if (inventar_num == tr(" ")) return tr("1"); |
||
540 | sqltext = tr("select * from system_blocks where system_blocks._ = \""); |
||
541 | sqltext.append(inventar_num); |
||
542 | sqltext.append(tr("\"")); |
||
543 | q.prepare(sqltext); |
||
544 | q.exec(); |
||
545 | field_id = q.record().indexOf(tr("")); |
||
546 | if (q.next()) {identifikator = q.value(field_id).toString();} |
||
547 | else { |
||
548 | QMessageBox::critical( // . |
||
549 | this, // . |
||
550 | QObject::tr(" "), // . |
||
551 | tr(" ")); // . |
||
552 | return identifikator; |
||
553 | |||
554 | |||
555 | }; |
||
556 | return identifikator; |
||
557 | } |
||
558 | |||
559 | |||
560 | |||
561 | |||
562 | |||
563 | |||
564 | void addmemoryForm::add_video_proizvoditel(QString brend){ |
||
565 | QSqlQuery q; |
||
566 | QString sqltext; |
||
567 | int field_proizvoditel; |
||
568 | QString proizv; |
||
569 | sqltext = tr("select * from proizvoditeli_video where proizvoditeli_video. = \""); |
||
570 | sqltext.append(brend); |
||
571 | sqltext.append(tr("\"")); |
||
572 | q.prepare(sqltext); |
||
573 | q.exec(); |
||
574 | field_proizvoditel = q.record().indexOf(tr("")); |
||
575 | if (q.next()) {return;} |
||
576 | else { |
||
577 | q.prepare(tr("insert into proizvoditeli_video () " |
||
578 | "values (:proizvoditel)")); |
||
579 | q.bindValue(tr(":proizvoditel"), brend); |
||
580 | q.exec(); |
||
581 | } |
||
582 | |||
583 | } |
||
584 | |||
585 | |||
586 | void addmemoryForm::add_mem_proizvoditel(QString brend){ |
||
587 | QSqlQuery q; |
||
588 | QString sqltext; |
||
589 | int field_proizvoditel; |
||
590 | QString proizv; |
||
591 | sqltext = tr("select * from proizvoditeli_pamyati where proizvoditeli_pamyati. = \""); |
||
592 | sqltext.append(brend); |
||
593 | sqltext.append(tr("\"")); |
||
594 | q.prepare(sqltext); |
||
595 | q.exec(); |
||
596 | field_proizvoditel = q.record().indexOf(tr("")); |
||
597 | if (q.next()) {return;} |
||
598 | else { |
||
599 | q.prepare(tr("insert into proizvoditeli_pamyati () " |
||
600 | "values (:proizvoditel)")); |
||
601 | q.bindValue(tr(":proizvoditel"), brend); |
||
602 | q.exec(); |
||
603 | } |
||
604 | |||
605 | } |
||
606 | |||
607 | |||
608 | void addmemoryForm::add_mb_proizvoditel(QString brend){ |
||
609 | QSqlQuery q; |
||
610 | QString sqltext; |
||
611 | int field_proizvoditel; |
||
612 | QString proizv; |
||
613 | sqltext = tr("select * from proizvoditeli_mb where proizvoditeli_mb. = \""); |
||
614 | sqltext.append(brend); |
||
615 | sqltext.append(tr("\"")); |
||
616 | q.prepare(sqltext); |
||
617 | q.exec(); |
||
618 | field_proizvoditel = q.record().indexOf(tr("")); |
||
619 | if (q.next()) {return;} |
||
620 | else { |
||
621 | q.prepare(tr("insert into proizvoditeli_mb () " |
||
622 | "values (:proizvoditel)")); |
||
623 | q.bindValue(tr(":proizvoditel"), brend); |
||
624 | q.exec(); |
||
625 | } |
||
626 | |||
627 | } |
||
628 | |||
629 | void addmemoryForm::add_hdd_proizvoditel(QString brend){ |
||
630 | QSqlQuery q; |
||
631 | QString sqltext; |
||
632 | int field_proizvoditel; |
||
633 | QString proizv; |
||
634 | sqltext = tr("select * from proizvoditeli_hdd where proizvoditeli_hdd. = \""); |
||
635 | sqltext.append(brend); |
||
636 | sqltext.append(tr("\"")); |
||
637 | q.prepare(sqltext); |
||
638 | q.exec(); |
||
639 | field_proizvoditel = q.record().indexOf(tr("")); |
||
640 | if (q.next()) {return;} |
||
641 | else { |
||
642 | q.prepare(tr("insert into proizvoditeli_hdd () " |
||
643 | "values (:proizvoditel)")); |
||
644 | q.bindValue(tr(":proizvoditel"), brend); |
||
645 | q.exec(); |
||
646 | } |
||
647 | |||
648 | } |
||
649 | |||
650 | void addmemoryForm::add_cpu_proizvoditel(QString brend){ |
||
651 | QSqlQuery q; |
||
652 | QString sqltext; |
||
653 | int field_proizvoditel; |
||
654 | QString proizv; |
||
655 | sqltext = tr("select * from proizvoditeli_cpu where proizvoditeli_hdd. = \""); |
||
656 | sqltext.append(brend); |
||
657 | sqltext.append(tr("\"")); |
||
658 | q.prepare(sqltext); |
||
659 | q.exec(); |
||
660 | field_proizvoditel = q.record().indexOf(tr("")); |
||
661 | if (q.next()) {return;} |
||
662 | else { |
||
663 | q.prepare(tr("insert into proizvoditeli_cpu () " |
||
664 | "values (:proizvoditel)")); |
||
665 | q.bindValue(tr(":proizvoditel"), brend); |
||
666 | q.exec(); |
||
667 | } |
||
668 | |||
669 | } |
||
670 | |||
671 | void addmemoryForm::add_mb_model(QString brend, QString model){ |
||
672 | QSqlQuery q; |
||
673 | QString sqltext; |
||
674 | int field_proizvoditel; |
||
675 | QString proizv; |
||
676 | sqltext = tr("select * from __ where __. = \""); |
||
677 | sqltext.append(brend); |
||
678 | sqltext.append(tr("\" and __. = \"")); |
||
679 | sqltext.append(model); |
||
680 | sqltext.append(tr("\"")); |
||
681 | q.prepare(sqltext); |
||
682 | q.exec(); |
||
683 | field_proizvoditel = q.record().indexOf(tr("")); |
||
684 | if (q.next()) {return;} |
||
685 | else { |
||
686 | q.prepare(tr("insert into __ (, ) " |
||
687 | "values (:model, :proizvoditel)")); |
||
688 | q.bindValue(tr(":model"), model); |
||
689 | q.bindValue(tr(":proizvoditel"), brend); |
||
690 | q.exec(); |
||
691 | } |
||
692 | |||
693 | } |
||
694 | |||
695 | |||
696 | |||
697 | void addmemoryForm::add_cpu_model(QString brend, QString model){ |
||
698 | QSqlQuery q; |
||
699 | QString sqltext; |
||
700 | int field_proizvoditel; |
||
701 | QString proizv; |
||
702 | sqltext = tr("select * from processor_models where processor_models. = \""); |
||
703 | sqltext.append(brend); |
||
704 | sqltext.append(tr("\" and processor_models. = \"")); |
||
705 | sqltext.append(model); |
||
706 | sqltext.append(tr("\"")); |
||
707 | q.prepare(sqltext); |
||
708 | q.exec(); |
||
709 | field_proizvoditel = q.record().indexOf(tr("")); |
||
710 | if (q.next()) {return;} |
||
711 | else { |
||
712 | q.prepare(tr("insert into processor_models (, ) " |
||
713 | "values (:model, :proizvoditel)")); |
||
714 | q.bindValue(tr(":model"), model); |
||
715 | q.bindValue(tr(":proizvoditel"), brend); |
||
716 | q.exec(); |
||
717 | } |
||
718 | |||
719 | } |
||
720 | |||
721 | void addmemoryForm::add_video_model(QString brend, QString model){ |
||
722 | QSqlQuery q; |
||
723 | QString sqltext; |
||
724 | int field_proizvoditel; |
||
725 | QString proizv; |
||
726 | sqltext = tr("select * from video_models where video_models. = \""); |
||
727 | sqltext.append(brend); |
||
728 | sqltext.append(tr("\" and video_models. = \"")); |
||
729 | sqltext.append(model); |
||
730 | sqltext.append(tr("\"")); |
||
731 | q.prepare(sqltext); |
||
732 | q.exec(); |
||
733 | field_proizvoditel = q.record().indexOf(tr("")); |
||
734 | if (q.next()) {return;} |
||
735 | else { |
||
736 | q.prepare(tr("insert into video_models (, ) " |
||
737 | "values (:model, :proizvoditel)")); |
||
738 | q.bindValue(tr(":model"), model); |
||
739 | q.bindValue(tr(":proizvoditel"), brend); |
||
740 | q.exec(); |
||
741 | } |
||
742 | |||
743 | } |
||
744 | |||
745 | |||
746 | //void addmemoryForm::hide (){ |
||
747 | // treeWidget->setEnabled(true); |
||
748 | //} |
||
749 | |||
750 | void addmemoryForm::closeEvent ( QCloseEvent * event ) { |
||
751 | emit formClose(); |
||
752 | } |
||
753 | |||
754 |