Subversion Repositories OpenInventory

Rev

Rev 6 | Rev 16 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#include "mainwindowimpl.h"
//ïðîâåðêà
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
        : QMainWindow(parent, f)
{
       


        setupUi(this);
        fEnable_component_add = false; //ðåæèì äîáîâëåíèÿ êîìïîíåíòà îòêëþ÷åí
        fEnable_naznachit_otvetstv = false;
        curr_task = no_task;
        readSettings();
        lineEdit->insert(baseName);
        metaDataAction = new QAction(tr("Èçìåíèòü"), treeWidget);
        addMemoryAction = new QAction(tr("Íîâûé ìîäóëü ïàìÿòè"), treeWidget);
        MB_na_skladAction = new QAction(tr("Ñäàòü íà ñêëàä"), treeWidget);
        new_sotrydnikAction = new QAction(tr("Íîâûé ñîòðóäíèê"), treeWidget);
        novoe_oborydovanieAction = new QAction(tr("Íîâîå îáîðóäîâàíèå"), treeWidget);
        pereimenovat_otdelAction = new QAction(tr("Ïåðåèìåíîâàòü îòäåë"), treeWidget);
        perevesti_sotrydnika_v_drygo1_otdelAction = new QAction(tr("Ïåðåâåñòè â äðóãîé îòäåë"), treeWidget);
        yvolit_sotrydnikaAction = new QAction(tr("Óâîëèòü ñîòðóäíèêà"), treeWidget);
        SpliterAction = new QAction(tr("Ïåðñîíàë"), treeWidget);
        naznachit_otvetstvennim_za_oborydovanieAction = new QAction(tr("Íàçíà÷èòü îòâåòñòâåííûì çà îáîðóäîâàíèå"), treeWidget);
        ystanovit_novie_complektyushieAction = new QAction(tr("Óñòàíîâèòü íîâûå êîìïëåêòóþùèå"), treeWidget);
        sozdat_otdelAction = new QAction(tr("Ñîçäàòü íîâûé îòäåë"), treeWidget);
       
        novaya_SYSTEM_BLOCK_na_skladAction = new QAction(tr("Äîáàâèòü íîâûé ñèñòåìíûé áëîê íà ñêëàä"), treeWidget);
        novaya_MB_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ ìàòåðèíñêóþ ïëàòó íà ñêëàä"), treeWidget);
        novaya_RAM_na_skladAction = new QAction(tr("Äîáàâèòü íîâûé ìîäóëü ïàìÿòè íà ñêëàä"),  treeWidget);
        novaya_CPU_na_skladAction = new QAction(tr("Äîáàâèòü íîâûé ïðîöåññîð íà ñêëàä"),  treeWidget);
        novaya_HDD_na_skladAction = new QAction(tr("Äîáàâèòü íîâûé âèí÷åñòåð íà ñêëàä"),  treeWidget);
        novaya_CD_DVD_na_skladAction = new QAction(tr("Äîáàâèòü íîâûé ïðèâîä íà ñêëàä"),  treeWidget);
        novaya_VIDEO_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ âèäåîêàðòó íà ñêëàä"),  treeWidget);
        novaya_SoundCard_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ çâóêîâóþ êàðòó íà ñêëàä"),  treeWidget);
        novaya_LAN_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ ñåòåâóþ êàðòó íà ñêëàä"),  treeWidget);
        peredat_sys_block_pod_otveystvennostAction = new QAction(tr("Ïåðåäàòü ñèñòåìíûé áëîê ïîä îòâåòñòâåííîñòü ñîòðóäíèêà"),  treeWidget);


//      novaya_SoundCard_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ çâóêîâóþ êàðòó íà ñêëàä"),  treeWidget);
//      novaya_LAN_na_skladAction = new QAction(tr("Äîáàâèòü íîâóþ ñåòåâóþ êàðòó íà ñêëàä"),  treeWidget);
       
        insert_MB_to_system_blockAction = new QAction(tr("Óñòàíîâèòü â ñèñòåìíûé áëîê"), treeWidget);
       
        treeWidget->addAction(metaDataAction);
        treeWidget->addAction(addMemoryAction);
       
       
        connect(insert_MB_to_system_blockAction, SIGNAL(triggered()), SLOT(insert_MB_to_system_block()));
        connect(novaya_MB_na_skladAction, SIGNAL(triggered()), SLOT(novaya_MB_na_sklad()));
        connect(novaya_RAM_na_skladAction, SIGNAL(triggered()), SLOT(novaya_RAM_na_sklad()));
        connect(novaya_CPU_na_skladAction, SIGNAL(triggered()), SLOT(novaya_CPU_na_sklad()));
        connect(novaya_HDD_na_skladAction, SIGNAL(triggered()), SLOT(novaya_HDD_na_sklad()));
        connect(novaya_CD_DVD_na_skladAction, SIGNAL(triggered()), SLOT(novaya_CD_DVD_na_sklad()));
        connect(novaya_VIDEO_na_skladAction, SIGNAL(triggered()), SLOT(novaya_VIDEO_na_sklad()));
        connect(novaya_SoundCard_na_skladAction, SIGNAL(triggered()), SLOT(novaya_SoundCard_na_sklad()));
        connect(novaya_LAN_na_skladAction, SIGNAL(triggered()), SLOT(novaya_LAN_na_sklad()));
        connect(novaya_SYSTEM_BLOCK_na_skladAction, SIGNAL(triggered()), SLOT(novaya_SYSTEM_BLOCK_na_sklad()));
       
        connect(peredat_sys_block_pod_otveystvennostAction, SIGNAL(triggered()), SLOT(peredat_sys_block_pod_otveystvennost()));
       
        connect(sozdat_otdelAction, SIGNAL(triggered()), SLOT(addNewOtdel()));
       
       
        connect(metaDataAction, SIGNAL(triggered()), SLOT(editTreeWidget()));
        connect(addMemoryAction, SIGNAL(triggered()), SLOT(addNewMemory()));
        connect(MB_na_skladAction, SIGNAL(triggered()), SLOT(move_to_sklad()));
        connect(new_sotrydnikAction, SIGNAL(triggered()), SLOT(new_sotrydnik()));
        connect(novoe_oborydovanieAction, SIGNAL(triggered()), SLOT(novoe_oborydovanie()));
        connect(pereimenovat_otdelAction, SIGNAL(triggered()), SLOT(pereimenovft_otdel()));
        connect(yvolit_sotrydnikaAction, SIGNAL(triggered()), SLOT(yvolit_sotrydnika()));
        connect(naznachit_otvetstvennim_za_oborydovanieAction, SIGNAL(triggered()), SLOT(naznachit_otvetstvennim_za_oborydovanie()));
        connect(ystanovit_novie_complektyushieAction, SIGNAL(triggered()), SLOT(ystanovit_novie_complektyushie()));
        treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);      
        connect(openBaseAct, SIGNAL(triggered()), this, SLOT(openBase()));
        connect(openMemoryTableAct, SIGNAL(triggered()), this, SLOT(openMemoryTable()));
        connect(getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting()));
        connect(addStringAct, SIGNAL(triggered()), this, SLOT(addString()));
        connect(delStringAct, SIGNAL(triggered()), this, SLOT(delString()));
        connect(FiltrButton, SIGNAL(clicked()), this, SLOT(filter()));
        connect(hiddenButton, SIGNAL(clicked()), this, SLOT(hiddenRow()));
        connect(showButton, SIGNAL(clicked()), this, SLOT(showRow()));
        connect(appyButton, SIGNAL(clicked()), this, SLOT(dbUpdate()));
        connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *item, int column)), this, SLOT(dblClick(QTreeWidgetItem *item, int column)));
        connect(&addmemFrm, SIGNAL(componentAdd()), this, SLOT(refreshTree()));//ïðè çàêðûòèè ôîðìû addmemFrm îáíîâëÿåì treeWidget
        connect(&addotdelFrm, SIGNAL(componentAdd()), this, SLOT(refreshTree()));//ïðè çàêðûòèè ôîðìû addotdelFrm îáíîâëÿåì treeWidget
        connect(&addsotrydnikFrm, SIGNAL(componentAdd()), this, SLOT(refreshTree()));//ïðè çàêðûòèè ôîðìû addsotFrm îáíîâëÿåì treeWidget
        connect(&addsysblockFrm, SIGNAL(componentAdd()), this, SLOT(refreshTree()));//ïðè çàêðûòèè ôîðìû addsysblockFrm îáíîâëÿåì treeWidget

        connect(&addmemFrm, SIGNAL(formClose()), this, SLOT(on_addmemoryForm_formClose()));
        connect(&addotdelFrm, SIGNAL(formClose()), this, SLOT(on_addmemoryForm_formClose()));
        connect(&addsotrydnikFrm, SIGNAL(formClose()), this, SLOT(on_addmemoryForm_formClose()));
        connect(&addsysblockFrm, SIGNAL(formClose()), this, SLOT(on_addmemoryForm_formClose()));
       
        connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
       
        comp_icon.addFile("./pc.png");
/////   hdd_icon.addFile("./gnome-dev-harddisk.png");
        hdd_icon.addFile("./hdd5.png");
        memory_icon.addFile("./memory1.png");
        cd_dvd_icon.addFile("./cd_dvd3.png");
//      memory_icon.addFile("./gnome-dev-memory.png");
        matheboard_icon.addFile("./icon_motherboard.png");
        cpu_icon.addFile("./cpu3.png");
        vidio_card_icon.addFile("./vidiocard2.png");
        sound_card_icon.addFile("./soundcard1.png");
        lan_card_icon.addFile("./lan1.png");
        appyButton->setIcon(comp_icon);
        wmiFrm.show();
/////    for (int i = 0; i < 10; ++i)
/////     items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
/////    treeWidget->insertTopLevelItems(0, items);
//////items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(tr("ÑÃÑÕÌ: %1")).arg(0))));
/////////items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(tr("ÑÃÑÕÌ:")))));
/////////items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(tr("ÇÀÎ:")))));
/////////treeWidget->insertTopLevelItems(0, items);

//->itm = new QTreeWidgetItem(treeWidget);
//->itm->setText(0, tr("ÑÃÑÕÌ"));
/////////itm->setText(1, "hello1");
//->QTreeWidgetItem *itm1 = new QTreeWidgetItem(itm);
//->itm1->setText(1, tr("M1"));
//->QTreeWidgetItem *itm1_1 = new QTreeWidgetItem(itm1);
//->itm1_1->setText(2, tr("Þð÷åíêî"));
//->QTreeWidgetItem *itm1_2 = new QTreeWidgetItem(itm1);
//->itm1_2->setText(2, tr("Þøêîâ"));

//->QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm);
//->itm2->setText(1, tr("M2"));
//////treeWidget->insertTopLevelItem(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString(tr("ÑÃÑÕÌ:")))));
}

MainWindowImpl::~MainWindowImpl()
{
        db.close();
//      delete setFrm;
}


void MainWindowImpl::delString()
{
        QModelIndex index;
        int column, row;
        QSqlRecord record;
        index=view.currentIndex();
        column=view.currentIndex().column();
        row=view.currentIndex().row();
        record = model->record(row);
        int UserNameIndex = record.indexOf(tr("Ïîëüçîâàòåëü"));
        QString ls_UserName=record.value(UserNameIndex).toString();
        model->removeRows(row, 1);
}

//
void MainWindowImpl::openBase()
{
        lineEdit->insert(tr("Îòêðûòü áàçó "));
//      db = new QSqlDatabase("QMYSQL");
        db = QSqlDatabase::addDatabase("QMYSQL");
        pdb = &db;
        raportFrm.pdb = &db;
//      db->addDatabase("QMYSQL");
//db = QSqlDatabase::addDatabase("QSQLITE");
        pdb->setHostName(hostName);
        pdb->setDatabaseName(baseName);
        pdb->setUserName(userName);
        pdb->setPassword(password);
        bool ok = pdb->open();
        if (!ok) {
                                QMessageBox::critical( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
                                                                                this,                      // Ðîäèòåëüñêèé âèäæåò.
                                                                                QObject::tr("Database Error"),   // Çàãîëîâîê.  
                                                                                pdb->lastError().text());          // Òåêñò ñîîáùåíèÿ.
                         }
        if (ok)  
        {lineEdit-> insert(tr("Áàçà óñïåøíî îòêðûòà"));
        }
        else {lineEdit-> insert(tr("Áàçà íåäîñòóïíà. Êîä îøèáêè: "));
                  lineEdit-> insert(pdb->lastError().text());
                 }
//      QSqlQuery q;
//      q.prepare(tr("set NAMES cp1251"));
       
//      ok = q.exec();
        model = new QSqlTableModel();
        model->setTable(tableName);

        model->setEditStrategy(QSqlTableModel::OnFieldChange);
//      model->setEditStrategy(QSqlTableModel::OnManualSubmit);
        model->setSort(0, Qt::AscendingOrder);
        model->select();
//      model->setHeaderData(0, Qt::Horizontal,
//                              QObject::tr("Èìÿ\nïîëüçîâàòåëÿ"));
//      model->setHeaderData(1, Qt::Horizontal,
//                             QObject::tr("Îòäåë"));
//      model->setHeaderData(2, Qt::Horizontal,
//                             QObject::tr("IP àäðåñ"));
//      model->setHeaderData(3, Qt::Horizontal,
//                             QObject::tr("Èíâåíòàííûé\níîìåð"));
//      model->setHeaderData(4, Qt::Horizontal,
//                             QObject::tr("Îïåðàöèîííàÿ\nñèñòåìà"));
//      view = new QTableView();
        view.setModel(model);
        view.setAlternatingRowColors(true);
//      view->resizeRowsToContents();
        view.resizeColumnsToContents();
        view.show();
        initTreeWidget();
}

void MainWindowImpl::openMemoryTable()
{
        memory_model = new QSqlTableModel();
        memory_model->setTable(tr("Ïàìÿòü"));
//      memory_model->setTable(tableName);
        memory_model->setEditStrategy(QSqlTableModel::OnFieldChange);
//      model->setEditStrategy(QSqlTableModel::OnManualSubmit);
        memory_model->setSort(0, Qt::AscendingOrder);
        memory_model->select();
        tableView->setModel(memory_model);
        tableView->setAlternatingRowColors(true);
        tableView->resizeColumnsToContents();
        tableView->show();
/////   memory_view.setModel(memory_model);
/////   memory_view.setAlternatingRowColors(true);
//      view->resizeRowsToContents();
/////           memory_view.resizeColumnsToContents();
/////   memory_view.show();
}


void MainWindowImpl::applySetting()
{
        int i;
        i=5;
        lineEdit->insert(tr("Íàñòðîéêè ïîëó÷åíû!"));
        baseName = setFrm->lineEdit->text();
        userName = setFrm->lineEdit_2->text();
        password = setFrm->lineEdit_3->text();
        tableName = setFrm->lineEdit_4->text();
        hostName = setFrm->lineEdit_5->text();
        i+=1;
        writeSettings();
        setFrm->close();
        delete setFrm;
}

void MainWindowImpl::writeSettings()
{
        QSettings settings("Trolltech", "Application Example");
        settings.setValue("baseName", baseName);
        settings.setValue("userName", userName);
        settings.setValue("password", password);
        settings.setValue("tableName", tableName);
        settings.setValue("hostName", hostName);
}


void MainWindowImpl::readSettings()
{
        QSettings settings("Trolltech", "Application Example");
        baseName = settings.value("baseName", "an_db").toString();
        userName = settings.value("userName", "an").toString();
        password = settings.value("password", "393939").toString();
        tableName = settings.value("tableName", "inventar").toString();
        hostName = settings.value("hostName", "server").toString();
//     resize(size);
//     move(pos);tableName
}

void MainWindowImpl::getSetting()
{
        setFrm = new settingForm;
        connect(setFrm->pushButton, SIGNAL(clicked()), this, SLOT(applySetting()));
        setFrm->lineEdit->setText(baseName);
        setFrm->lineEdit_2->setText(userName);
        setFrm->lineEdit_3->setText(password);
        setFrm->lineEdit_4->setText(tableName);
        setFrm->lineEdit_5->setText(hostName);
        setFrm->show();

       
       
}


void MainWindowImpl::addString()
{
        QString query_begin=(tr("INSERT INTO "));
//      QString query_end=(tr(" VALUES('íå çàäàíî','íå çàäàíî','íå çàäàíî','íå çàäàíî',default)"));
        QString query_end=(tr(" VALUES()"));
        query_begin.append(tableName);
        query_begin.append(query_end);
        QSqlQuery query;
        query.prepare(query_begin);
//      query.prepare(tr("INSERT INTO inventar VALUES('íå çàäàíî','íå çàäàíî','íå çàäàíî','íå çàäàíî',default)"));
//      query.bindValue(":tab", "inventar");
//       if (!query.execBatch())
//              qDebug() << query.lastError();
        query.exec();
        model->select();
//      view->close();
        view.setModel(model);
        //view->show();
        lineEdit->insert(tr("Äîáàâèòü ñòðîêó!"));
}

//Ïðîöåäóðà ïðèìèíåíèÿ ôèëòðàöèè
void MainWindowImpl::filter()
{
//      int i;
//      i++;
        model->setFilter(tr("Ïðèìå÷àíèÿ='Ìèõàéëåíêî'"));
        model->select();
//      view->close();
        view.setModel(model);
}
//TEST CVS gh
void MainWindowImpl::hiddenRow()
{
        int n;
        for(n=0;n<20;n++) view.setRowHidden(n,true);
}


void MainWindowImpl::showRow()
{
        int n;
        for(n=0;n<20;n++) view.setRowHidden(n,false);
}

void MainWindowImpl::dbUpdate()
{
        model->submitAll();
        addString();
}


void  MainWindowImpl::novaya_MB_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(3);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}

void  MainWindowImpl::novaya_HDD_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(1);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}


void  MainWindowImpl::novaya_CD_DVD_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(4);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}

void  MainWindowImpl::novaya_VIDEO_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(5);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}


void  MainWindowImpl::novaya_RAM_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(0);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}


void  MainWindowImpl::novaya_SoundCard_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(6);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}

void  MainWindowImpl::novaya_LAN_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(7);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
}




void  MainWindowImpl::novaya_CPU_na_sklad(){
        addmemFrm.tabWidget->setCurrentIndex(2);
        addmemFrm.pushButton->setEnabled(true);
        addmemFrm.show();
        addmemFrm.label_7->setText(tr("Íà ñêëàä"));
        addNewMemory(tr("Íà ñêëàä"));
       
       
}

void  MainWindowImpl::peredat_sys_block_pod_otveystvennost(){
       
        QMessageBox::information( // Äèàëîã ñ ñîîáùåíèåì îá îøèáêå.
                                                                                this,                      // Ðîäèòåëüñêèé âèäæåò.
                                                                                QObject::tr("Óêàæèòå ñîòðóäíèêà "),   // Çàãîëîâîê.  
//                                                                              db.lastError().text());          // Òåêñò ñîîáùåíèÿ.
                                                                                tr("Òåïåðü âèáåðèòå ñîòðóäíèêà (äâîéíûì êëèêîì ìûøêè), êîòîðûé áóäåò îòâåòñòâåííåí çà ñèñòåìíûé áëîê."));
        fEnable_naznachit_otvetstv = true;
        curr_sys_block_id = treeWidget-> currentItem ()->text(12);
}



void MainWindowImpl::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
{
        QString tmp;
        tmp = item->text(3);
        if (tmp !=""){
                addmemFrm.pushButton->setEnabled(true);
                }
        else addmemFrm.pushButton->setEnabled(false);
        addmemFrm.label_7->setText(tmp);
}



void MainWindowImpl::editTreeWidget()
{
        QString inventar_num;
        QTreeWidgetItem * currItem;
        int currColomn;
        int top_item_index;
        lineEdit->insert(tr("Ðåäàêòèðîâàòü"));
        currItem = treeWidget->currentItem ();
        top_item_index = treeWidget->indexOfTopLevelItem(currItem);
        currColomn = treeWidget->currentColumn();
        MainWindowImpl::on_treeWidget_itemClicked(currItem, 3); //âûâîäèì íîìåð ñèñòåìíèêà íà ôîðìó
//      inventar_num = tr("Èíâ.íîì: ");
        inventar_num.append(currItem ->text(3));
        if (currColomn == 1){
                addmemFrm.tabWidget->setCurrentIndex(4);
                addmemFrm.show();
        };
        if (inventar_num == "") return;
        lineEdit->insert(currItem ->text(currColomn));
        switch(currColomn)
        {
                case 1://Ñîòðóäíèêè
                {
                addmemFrm.tabWidget->setCurrentIndex(4);
                addmemFrm.show();
                       
                }
                break;


                case 4: //Ïðîöåññîð
                {
                addmemFrm.tabWidget->setCurrentIndex(2);
                addmemFrm.show();
                }  
                break;

                case 5: //Ìàòåðèíñêèå ïëàòû
                {
                addmemFrm.tabWidget->setCurrentIndex(3);
                addmemFrm.show();
                }  
                break;

                case 6: //Ïàìÿòü
                {
                addmemFrm.tabWidget->setCurrentIndex(0);
                addNewMemory(inventar_num);
//              addmemFrm.show();
                }  
                break;

                case 7: //Âèí÷åñòåð
                {
                addmemFrm.tabWidget->setCurrentIndex(1);
                addmemFrm.show();      
                }
                break;


                case 2: break;
                defaul: break;
        }
        addmemFrm.treeWidget->clear();
//      addmemFrm.initTreeWidgrt();
}

void MainWindowImpl::initTreeWidget()//íàñòðàèâàåì âèäæåò
{
        QStringList treeHeaders;//ñïèñîê çàãîëîâêîâ treeWidget
        treeWidget->setColumnCount(15);
        treeHeaders << tr("Îòäåëû")                                     //0  ñòîëáåö
                                << tr("Ïåðñîíàë")                               //1  ñòîëáåö
                                << tr("Îïèñàíèå")                       //2  ñòîëáåö
                                << tr("Îáîðóäîâàíèå")                   //3  ñòîëáåö
                                << tr("Ïðîöåññîð")                                      //4  ñòîëáåö
                                << tr("Ìàòåðèíêà")                                      //5  ñòîëáåö
                                << tr("Ïàìÿòü")                                         //6  ñòîëáåö
                                << tr("Âèí÷åñòåð")                                      //7  ñòîëáåö
                                << tr("Ïðèâîä")                                         //8  ñòîëáåö
                                << tr("Âèäåîêàðòà")                                     //9  ñòîëáåö
                                << tr("Çâóêîâàÿ êàðòà")                         //10 ñòîëáåö
                                << tr("Ñåòåâàÿ êàðòà")                          //11 ñòîëáåö
                                << tr("Èäåíòèôèêàòîð")                          //12 ñòîëáåö
                                << tr("Èäåíòèôèêàòîð ñèñòåíîãî áëîêà")  //13 ñòîëáåö
                                << tr("ID îòâåòñòâííîãî ëèöà"); //14 ñòîëáåö
        treeWidget->setHeaderLabels(QStringList (treeHeaders));
//      treeWidget->setColumnHidden(2, true);
//      treeWidget->setColumnHidden(12, true);
//      treeWidget->setColumnHidden(13, true);
        treeWidget->clear();
        addOtdels();
        treeWidget->sortItems(0, Qt::AscendingOrder);
}

void MainWindowImpl::addOtdels()
{
        int fieldName, fieldID;
        QTreeWidgetItem *otdelItem;
        QSqlQuery q(tr("select * from otdeli"));// ïîëó÷àåì ñïèñîê îòäåëîâ
        QString otdel, otdel_id;
        fieldName = q.record().indexOf(tr("Íàçâàíèå"));
        fieldID = q.record().indexOf(tr("Èäåíòèôèêàòîð"));
        while (q.next()){
                otdel = q.value(fieldName).toString();
                otdel_id = q.value(fieldID).toString();
                otdelItem = new QTreeWidgetItem(treeWidget);
                if (otdel == tr("Ñêëàä")) { otdelItem->setText(0, otdel);
                        otdelItem->setText(2, tr("Ñêëàä"));
                        otdelItem->setText(12, otdel_id);
                        SotrydnikiOtdela(otdel_id, otdelItem);
                        continue;
                         }
                otdelItem->setText(0, otdel);
                otdelItem->setText(2, tr("Îòäåë"));
                otdelItem->setText(12, otdel_id);
                SotrydnikiOtdela(otdel_id, otdelItem);
        }
}


void MainWindowImpl::SotrydnikiOtdela(QString id_otdela, QTreeWidgetItem * itemOtdela) // ôîðìèðóåì ñïèñîê ñîòðóäíèêîâ îòäåëà
{
        int field_fio_sotrydnika, field_id_sotrydnika;
        int kolichestvo_sotrudnikov=0;
        QString fio_sotrydnika_otdela, id_sotrydnika_otdela, oboryd;
        QSqlQuery qsotrydnikiOtdela;
        QString sqlQueryString;
        QTreeWidgetItem *treeItem_sotrydnika;
        sqlQueryString = tr("select Èäåíòèôèêàòîð, ÔÈÎ from sotrydniki where Èäåíòèôèêàòîð_îòäåëà=");
        sqlQueryString.append(id_otdela);
        qsotrydnikiOtdela.prepare(sqlQueryString);
        qsotrydnikiOtdela.exec();
        field_fio_sotrydnika = qsotrydnikiOtdela.record().indexOf(tr("ÔÈÎ"));
        field_id_sotrydnika = qsotrydnikiOtdela.record().indexOf(tr("Èäåíòèôèêàòîð"));
        while (qsotrydnikiOtdela.next())
        {
                fio_sotrydnika_otdela = qsotrydnikiOtdela.value(field_fio_sotrydnika).toString();
                id_sotrydnika_otdela = qsotrydnikiOtdela.value(field_id_sotrydnika).toString();


                treeItem_sotrydnika = new QTreeWidgetItem(itemOtdela);
                treeItem_sotrydnika->setText(1, fio_sotrydnika_otdela );
                treeItem_sotrydnika->setText(2, tr("Ñîòðóäíèê"));
                treeItem_sotrydnika->setText(14, id_sotrydnika_otdela );
                if (id_sotrydnika_otdela == "1"){
                        itm_sklad_system_blocks = new QTreeWidgetItem(treeItem_sotrydnika);
                        itm_sklad_system_blocks->setText(2, tr("ÑÈÑÒÅÌÍÛÅ ÁËÎÊÈ"));
                        itm_sklad_orgtehnika = new QTreeWidgetItem(treeItem_sotrydnika);
                        itm_sklad_orgtehnika->setText(2, tr("ÎÐÃÒÅÕÍÈÊÀ"));
                        itm_sklad_orgtehnika_printers =  new QTreeWidgetItem(itm_sklad_orgtehnika);
                        itm_sklad_orgtehnika_printers->setText(2, tr("ÏÐÈÍÒÅÐÛ"));
                        itm_sklad_orgtehnika_mfy =   new QTreeWidgetItem(itm_sklad_orgtehnika);
                        itm_sklad_orgtehnika_mfy->setText(2, tr("ÌÔÓ"));
                        itm_sklad_komplectyushie = new QTreeWidgetItem(treeItem_sotrydnika);
                        itm_sklad_komplectyushie->setText(2, tr("ÊÎÌÏËÅÊÒÓÞÙÈÅ"));
                        itm_sklad_orgtehnika_scaners = new QTreeWidgetItem(itm_sklad_orgtehnika);
                        itm_sklad_orgtehnika_scaners->setText(2, tr("ÑÊÀÍÅÐÛ"));
                        itm_sklad_rashodniki = new QTreeWidgetItem(treeItem_sotrydnika);
                        itm_sklad_rashodniki->setText(2, tr("ÐÀÑÕÎÄÍÛÅ ÌÀÒÅÐÈÀËÛ"));
                }
                oboryd = oborydovanie(id_sotrydnika_otdela, treeItem_sotrydnika);
//              treeItem_sotrydnika->setText(3, oboryd );
                ++kolichestvo_sotrudnikov;
        }
        itemOtdela->setText(13, QVariant(kolichestvo_sotrudnikov).toString());
}

QString MainWindowImpl::oborydovanie(QString id_sotrydnika, QTreeWidgetItem * itemSotrydnika){
        QString result, prResult;
        QString sqlQueryText;
        QString serial_num, inventar_num, proizvoditel, model, system_block_id;
        QSqlQuery quer;
        QString MB_information, Memory_information, CPU_information, HDD_information, CD_DVD_information, Vidio_information;
        QString Sound_card_information, Lan_card_information;
        int field_serialNum, field_inventarNum, field_proizvoditel, field_model, field_system_block_id;
//      QSqlQuery qns(tr("SET NAMES utf8"));// ïîëó÷àåì ñïèñîê îòäåëîâ
        QTreeWidgetItem *itemSysBlock;
//      sqlQueryText.reserve(300);
        sqlQueryText = tr("select system_blocks.Ñåðèéíûé_íîìåð, system_blocks.Èíâåíòàðíûé_íîìåð, system_blocks.Èäåíòèôèêàòîð"
        " from system_blocks"
        " where system_blocks.Èäåíòèôèêàòîð_îòâåòñòâåííîãî_ëèöà =");
        sqlQueryText.append(id_sotrydnika);
//      sqlQueryText.append(tr(" AND Ìàòåðèíñêèå_ïëàòû.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = Ñèñòåìíûå_áëîêè.Èäåíòèôèêàòîð"));
        quer.prepare(sqlQueryText);
//      quer.prepare(tr("select Ñèñòåìíûå_áëîêè.Ñåðèéíûé_íîìåð, Ñèñòåìíûå_áëîêè.Èíâåíòàðíûé_íîìåð,Ìàòåðèíñêèå_ïëàòû.Ïðîèçâîäèòåëü, Ìàòåðèíñêèå_ïëàòû.Ìîäåëü from Ñèñòåìíûå_áëîêè,Ìàòåðèíñêèå_ïëàòû where Ñèñòåìíûå_áëîêè.Èäåíòèôèêàòîð_îòâåòñòâåííîãî_ëèöà = 4 AND Ìàòåðèíñêèå_ïëàòû.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = Ñèñòåìíûå_áëîêè.Èäåíòèôèêàòîð;"));
        quer.exec();
        field_serialNum = quer.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
        field_inventarNum = quer.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_system_block_id = quer.record().indexOf(tr("Èäåíòèôèêàòîð"));
//      field_proizvoditel = quer.record().indexOf(tr("Ïðîèçâîäèòåëü"));
//      field_model = quer.record().indexOf(tr("Ìîäåëü"));
        while(quer.next()){
        system_block_id = quer.value(field_system_block_id).toString();                                 //èäåíòèôèêàòîð ñèñòåìíîãî áëîêà
        prResult = ""; 
        serial_num = quer.value(field_serialNum).toString();
        inventar_num = quer.value(field_inventarNum).toString();
////    if (serial_num != "") {prResult.append(tr("s/n: "));
////            prResult.append(serial_num);}
        if (inventar_num != "") {
////    prResult.append(tr(" èíâ.íîì: "));
        prResult.append(inventar_num);
////    prResult.append(tr(" "));
}

//      result.append(q.value(field_proizvoditel).toString());
//      result.append(tr(" "));
//      result.append(q.value(field_model).toString());
       
       


       
//      if (id_sotrydnika == "1" & system_block_id == "1") itemSysBlock->setText(2, tr("Êîìïëåêòóþùèå"));// ýòî ñêëàä
        if (id_sotrydnika == "1" && system_block_id == "1") itemSysBlock = itm_sklad_komplectyushie;// ýòî ñêëàä
        else if (id_sotrydnika == "1" ){
                itemSysBlock = new QTreeWidgetItem(itm_sklad_system_blocks); // íà ñêëàä ñèñòåìíèê
                itemSysBlock->setText(2, tr("Ñèñòåìíûé áëîê"));
                itemSysBlock->setIcon(3, comp_icon);
                if (system_block_id !="") itemSysBlock->setText(12, system_block_id);  
                if (id_sotrydnika !="") itemSysBlock->setText(14, id_sotrydnika);
        }
               
        else {
                itemSysBlock = new QTreeWidgetItem(itemSotrydnika);
                itemSysBlock->setText(2, tr("Ñèñòåìíûé áëîê"));
                itemSysBlock->setIcon(3, comp_icon);
                if (system_block_id !="") itemSysBlock->setText(12, system_block_id);  
                if (id_sotrydnika !="") itemSysBlock->setText(14, id_sotrydnika);
               
                }
               
        MB_information = addMatheBoardInformation (id_sotrydnika, system_block_id, itemSysBlock);               //ïîëó÷àåì èíôîðìàöèþ î ìàòåðèíñêîé ïëàòå
////    prResult.append(MB_information);
        Memory_information = addMemoryInformation(id_sotrydnika, system_block_id, itemSysBlock);                //ïîëó÷àåì èíôîðìàöèþ î ïàìÿòè
////    prResult.append(Memory_information);
        CPU_information = addCpuInformation(id_sotrydnika, system_block_id, itemSysBlock);
////    prResult.append(CPU_information);
        HDD_information = addHDDInformation(id_sotrydnika, system_block_id, itemSysBlock);
////    prResult.append(HDD_information);
        CD_DVD_information = add_CD_DVD_Information(id_sotrydnika, system_block_id, itemSysBlock);
////    prResult.append(CD_DVD_information);
        Vidio_information = add_Vidio_Information(id_sotrydnika, system_block_id, itemSysBlock);
        Sound_card_information = add_Sound_Card_Information(id_sotrydnika, system_block_id, itemSysBlock);
        Lan_card_information = add_Lan_Card_Information(id_sotrydnika, system_block_id, itemSysBlock);
        if (system_block_id != "1"){
               
                itemSysBlock->setText(3, prResult);      
                result.append(prResult);
}
       
       
        }
        return result;
}

QString MainWindowImpl::addMatheBoardInformation(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock)
{
        QString result, tmp;
        QString MB_proizvoditel, MB_model, MB_identifikator, MB_serial_num, MB_inventar_num;
        QString MatheBoardSqlQueryText;
        QSqlQuery MatheBoardQuery;
        int field_proizvoditel, field_model, field_identifikator, field_serial_num, field_inventar_num;
        QTreeWidgetItem *itemMB, *itmMB_block;
        MatheBoardSqlQueryText = tr("select * "
        " from matheboards where matheboards.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        MatheBoardSqlQueryText.append(id_systemBlock);
        MatheBoardQuery.prepare(MatheBoardSqlQueryText);
        MatheBoardQuery.exec();
        field_identifikator = MatheBoardQuery.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = MatheBoardQuery.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_model = MatheBoardQuery.record().indexOf(tr("Ìîäåëü"));
        field_serial_num = MatheBoardQuery.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
        field_inventar_num = MatheBoardQuery.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itmMB_block = new QTreeWidgetItem(itm_sklad_komplectyushie);
                itmMB_block->setText(2, tr("ÌÀÒÅÐÈÍÑÊÈÅ ÏËÀÒÛ"));
//              itmMB_block->setIcon(3, matheboard_icon);
                }
       
        while(MatheBoardQuery.next()){
                tmp = "";
                MB_identifikator = MatheBoardQuery.value(field_identifikator).toString();
                MB_proizvoditel = MatheBoardQuery.value(field_proizvoditel).toString();
                MB_model = MatheBoardQuery.value(field_model).toString();
                MB_serial_num = MatheBoardQuery.value(field_serial_num).toString();
                MB_inventar_num = MatheBoardQuery.value(field_inventar_num).toString();
               
        if (MB_proizvoditel != "") {
//              tmp.append(tr("MB: "));
                tmp.append(MB_proizvoditel);
                }
        if (MB_model != "") {tmp.append(tr(" "));
        tmp.append(MB_model);
        tmp.append(tr(" "));}
        result.append(tmp);
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1") {itemMB = new QTreeWidgetItem(itmMB_block);
        }
        else itemMB = new QTreeWidgetItem(itemSysBlock);
        itemMB->setIcon(4, matheboard_icon);
        itemMB->setText(4, tmp);
        itemMB->setText(12, MB_identifikator);
        itemMB->setText(13, id_systemBlock);
        itemMB->setText(14, id_otvetstvennogo_lica);
        itemMB->setText(2, tr("Ìàòåðèíñêàÿ ïëàòà"));
        itemMB->setText(3, MB_inventar_num);
        if (id_systemBlock !="1") itemSysBlock->setText(5, tmp);
       
                }
        return result;
}


QString MainWindowImpl::addMemoryInformation(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock)
{
        QString result, tmp;
        QString Memiry_id, Memory_proizvoditel, Memory_type, Memory_obem, Memory_inventar_num, Memory_serial_num;
        QString MemorySqlQueryText;
        QSqlQuery MemoryQuery;
        int field_proizvoditel, field_type, field_obem, field_id, field_inventar_num, field_sereal_num;
        QTreeWidgetItem *itemMemory, *itemMemory_block;
        MemorySqlQueryText = tr("select memory.* "
        " from memory where memory.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        MemorySqlQueryText.append(id_systemBlock);
        MemoryQuery.prepare(MemorySqlQueryText);
        MemoryQuery.exec();
        field_id = MemoryQuery.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = MemoryQuery.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_type = MemoryQuery.record().indexOf(tr("Òèï"));
        field_obem = MemoryQuery.record().indexOf(tr("Îáúåì"));
        field_inventar_num = MemoryQuery.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_sereal_num = MemoryQuery.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
                if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemMemory_block = new QTreeWidgetItem(itm_sklad_komplectyushie);
                itemMemory_block->setText(2, tr("ÌÎÄÓËÈ ÏÀÌßÒÈ"));
        }
        while(MemoryQuery.next()){
//              tmp = tr("RAM: ");
                tmp = tr("");
                Memiry_id = MemoryQuery.value(field_id).toString();
                Memory_proizvoditel = MemoryQuery.value(field_proizvoditel).toString();
                Memory_type = MemoryQuery.value(field_type).toString();
                Memory_obem = MemoryQuery.value(field_obem).toString();
                Memory_inventar_num = MemoryQuery.value(field_inventar_num).toString();
                Memory_serial_num = MemoryQuery.value(field_sereal_num).toString();
////    if (Memory_proizvoditel != "") {
////            tmp.append(Memory_proizvoditel);}
        if (Memory_type != "") {tmp.append(tr(" "));
        tmp.append(Memory_type);
        tmp.append(tr(" "));}
        if (Memory_obem != "") {tmp.append(tr(" "));
        tmp.append(Memory_obem);
        tmp.append(tr("MB; "));}
        result.append(tmp);
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemMemory = new QTreeWidgetItem(itemMemory_block);
        }
        else itemMemory = new QTreeWidgetItem(itemSysBlock);
        itemMemory->setIcon(4, memory_icon);
        itemMemory->setText(4, tmp);
       
        itemMemory->setText(2, tr("Ìîäóëü ïàìÿòè"));
        itemMemory->setText(12, Memiry_id);
        itemMemory->setText(13, id_systemBlock);
        itemMemory->setText(14, id_otvetstvennogo_lica);
        itemMemory->setText(3, Memory_inventar_num);

                }
        if (id_systemBlock !="1") itemSysBlock->setText(6, result);
        return result;
}


QString MainWindowImpl::addCpuInformation(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock)
{
        QString result, tmp;
        QString CPU_id, CPU_proizvoditel, CPU_slot, CPU_fqr, CPU_inventar_num, CPU_serial_num;
        QString CpuSqlQueryText;
        QSqlQuery CpuQuery;
        int field_id, field_proizvoditel, field_slot, field_fqr, field_inventar_num, field_serial_num;
        QTreeWidgetItem *itemCpu, *itemCpu_block;
        CpuSqlQueryText = tr("select processors.* "
        " from processors where processors.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        CpuSqlQueryText.append(id_systemBlock);
        CpuQuery.prepare(CpuSqlQueryText);
        CpuQuery.exec();
        field_id = CpuQuery.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = CpuQuery.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_slot = CpuQuery.record().indexOf(tr("Ñëîò"));
        field_fqr = CpuQuery.record().indexOf(tr("×àñòîòà"));
        field_inventar_num = CpuQuery.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_serial_num = CpuQuery.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemCpu_block = new QTreeWidgetItem(itemSysBlock);
                itemCpu_block->setText(2, tr("ÏÐÎÖÅÑÑÎÐÛ"));
                itemCpu_block->setText(14, id_otvetstvennogo_lica);
        }


        while(CpuQuery.next()){
//              tmp = tr("CPU: ");
        tmp = tr("");
                CPU_id = CpuQuery.value(field_id).toString();
                CPU_proizvoditel = CpuQuery.value(field_proizvoditel).toString();
                CPU_slot = CpuQuery.value(field_slot).toString();
                CPU_fqr = CpuQuery.value(field_fqr).toString();
                CPU_inventar_num =  CpuQuery.value(field_inventar_num).toString();
                CPU_serial_num = CpuQuery.value(field_serial_num).toString();
               
        if (CPU_proizvoditel != "") {
                tmp.append(CPU_proizvoditel);}
//      if (CPU_slot != "") {tmp.append(tr(" "));
//      tmp.append(CPU_slot);
//      tmp.append(tr(" "));}
        if (CPU_fqr != "") {tmp.append(tr(" "));
        tmp.append(CPU_fqr);
        tmp.append(tr("MGz "));}
        result.append(tmp);
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemCpu = new QTreeWidgetItem(itemCpu_block);
        }
        else itemCpu = new QTreeWidgetItem(itemSysBlock);


//      itemCpu = new QTreeWidgetItem(itemSysBlock);
        itemCpu->setText(2, tr("Ïðîöåññîð"));
        itemCpu->setText(12, CPU_id);
        itemCpu->setText(13, id_systemBlock);
        itemCpu->setText(14, id_otvetstvennogo_lica);

        itemCpu->setIcon(4, cpu_icon);
        itemCpu->setText(4, tmp);
       
        itemCpu->setText(3, CPU_inventar_num);
                }
        if (id_systemBlock !="1") itemSysBlock->setText(4, tmp);
        return result;
}

QString MainWindowImpl::addHDDInformation(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock)
{
        QString result, tmp;
        QString HDD_id, HDD_proizvoditel, HDD_interfeis, HDD_obem, HDD_inventar_num, HDD_serial_num;
        QString HDDSqlQueryText;
        QSqlQuery HDDQuery;
        int field_id, field_proizvoditel, field_interfeis, field_obem, field_inventar_num, field_serial_num;
        QTreeWidgetItem *itemHDD;
        QTreeWidgetItem *itemHDD_block;
        HDDSqlQueryText = tr("select harddiscs.* "
        " from harddiscs where harddiscs.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        HDDSqlQueryText.append(id_systemBlock);
        HDDQuery.prepare(HDDSqlQueryText);
        HDDQuery.exec();
        field_id = HDDQuery.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = HDDQuery.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_interfeis = HDDQuery.record().indexOf(tr("Èíòåðôåéñ"));
        field_obem = HDDQuery.record().indexOf(tr("Îáúåì"));
        field_inventar_num = HDDQuery.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_serial_num = HDDQuery.record().indexOf(tr("Ñåðèéíûé_íîìåð"));

        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemHDD_block = new QTreeWidgetItem(itemSysBlock);
                itemHDD_block->setText(2, tr("ÂÈÍ×ÅÑÒÅÐÛ"));
                itemHDD_block->setText(14, id_otvetstvennogo_lica);
        }


        while(HDDQuery.next()){
//              tmp = tr("HDD: ");
                tmp = tr("");
                HDD_id = HDDQuery.value(field_id).toString();
                HDD_proizvoditel = HDDQuery.value(field_proizvoditel).toString();
                HDD_interfeis = HDDQuery.value(field_interfeis).toString();
                HDD_obem = HDDQuery.value(field_obem).toString();
                HDD_inventar_num =  HDDQuery.value(field_inventar_num).toString();
                HDD_serial_num = HDDQuery.value(field_serial_num).toString();
        if (HDD_proizvoditel != "") {
                tmp.append(HDD_proizvoditel);}
        if (HDD_interfeis != "") {tmp.append(tr(" "));
        tmp.append(HDD_interfeis);
        tmp.append(tr(" "));}
        if (HDD_obem != "") {tmp.append(tr(" "));
        tmp.append(HDD_obem);
        tmp.append(tr("GB; "));}
        result.append(tmp);

        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                itemHDD  = new QTreeWidgetItem(itemHDD_block);
        }
        else itemHDD  = new QTreeWidgetItem(itemSysBlock);

       
//      itemHDD = new QTreeWidgetItem(itemSysBlock);
       
        itemHDD->setText(2, tr("Æåñòêèé äèñê"));
        itemHDD->setText(12, HDD_id);
        itemHDD->setText(13, id_systemBlock);
        itemHDD->setText(14, id_otvetstvennogo_lica);

        itemHDD->setIcon(4, hdd_icon);
        itemHDD->setText(4, tmp);
        itemHDD->setText(3, HDD_inventar_num);
                }
//      if (result!="") itemSysBlock->setIcon(7, hdd_icon);
        if (id_systemBlock !="1") itemSysBlock->setText(7, result);
        return result;
}

QString MainWindowImpl::add_CD_DVD_Information(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock)
{
        QString result, tmp;
        QString CD_DVD_id, CD_DVD_proizvoditel, CD_DVD_type, CD_DVD_speed, CD_DVD_serial_num, CD_DVD_inventar_num;
        QString CD_DVD_SqlQueryText;
        QSqlQuery CD_DVD_Query;
        int field_id, field_proizvoditel, field_type, field_speed, field_serial_num, field_inventar_num;
        QTreeWidgetItem *item_CD_DVD;
        QTreeWidgetItem *item_CD_DVD_block;
        CD_DVD_SqlQueryText = tr("select cd_dvd.* "
        " from cd_dvd where cd_dvd.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        CD_DVD_SqlQueryText.append(id_systemBlock);
        CD_DVD_Query.prepare(CD_DVD_SqlQueryText);
        CD_DVD_Query.exec();
        field_id = CD_DVD_Query.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = CD_DVD_Query.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_type = CD_DVD_Query.record().indexOf(tr("Òèï"));
        field_speed = CD_DVD_Query.record().indexOf(tr("Ñêîðîñòü"));
        field_inventar_num = CD_DVD_Query.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_serial_num = CD_DVD_Query.record().indexOf(tr("Ñåðèéíûé_íîìåð"));

        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_CD_DVD_block = new QTreeWidgetItem(itemSysBlock);
                item_CD_DVD_block->setText(2, tr("ÏÐÈÂÎÄÛ"));
                item_CD_DVD_block->setText(14, id_otvetstvennogo_lica);
        }


        while(CD_DVD_Query.next()){
//              tmp = tr("CD/DVD: ");
        tmp = tr("");
                CD_DVD_id = CD_DVD_Query.value(field_id).toString();
                CD_DVD_proizvoditel = CD_DVD_Query.value(field_proizvoditel).toString();
                CD_DVD_type = CD_DVD_Query.value(field_type).toString();
                CD_DVD_speed = CD_DVD_Query.value(field_speed).toString();
                CD_DVD_serial_num = CD_DVD_Query.value(field_serial_num).toString();
                CD_DVD_inventar_num = CD_DVD_Query.value(field_inventar_num).toString();
               
        if (CD_DVD_type != "") {
                tmp.append(CD_DVD_type);}
        if (CD_DVD_proizvoditel != "") {tmp.append(tr(" "));
        tmp.append(CD_DVD_proizvoditel);
        tmp.append(tr(" "));}
        if (CD_DVD_speed != "") {tmp.append(tr(" "));
        tmp.append(CD_DVD_speed);
        tmp.append(tr(" "));}
        result.append(tmp);
       
if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_CD_DVD  = new QTreeWidgetItem(item_CD_DVD_block);
        }
        else item_CD_DVD = new QTreeWidgetItem(itemSysBlock);
       
        item_CD_DVD->setText(2, tr("Ïðèâîä"));
        item_CD_DVD->setText(12, CD_DVD_id);
        item_CD_DVD->setText(13, id_systemBlock);
        item_CD_DVD->setText(14, id_otvetstvennogo_lica);
        item_CD_DVD->setIcon(4, cd_dvd_icon);
        item_CD_DVD->setText(4, tmp);
        item_CD_DVD->setText(3, CD_DVD_inventar_num);
                }
        if (id_systemBlock !="1") itemSysBlock->setText(8, result);
        return result;
}

QString MainWindowImpl::add_Vidio_Information(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock){
       
        QString result, tmp;
        QString Vidio_id, Vidio_proizvoditel, Vidio_model, Vidio_interfeis, Vidio_ram, Vidio_inventar_num, Vidio_sereal_num;
        QString Vidio_SqlQueryText;
        QSqlQuery Vidio_Query;
        int field_id, field_proizvoditel, field_model, field_interfeis, field_ram, field_inventar_num, field_sereal_num;
        QTreeWidgetItem *item_Vidio, *item_Vidio_block;
        Vidio_SqlQueryText = tr("select videocards.* "
        " from videocards where videocards.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        Vidio_SqlQueryText.append(id_systemBlock);
        Vidio_Query.prepare(Vidio_SqlQueryText);
        Vidio_Query.exec();
        field_id = Vidio_Query.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = Vidio_Query.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_model = Vidio_Query.record().indexOf(tr("Ìîäåëü"));
        field_interfeis  = Vidio_Query.record().indexOf(tr("Èíòåðôåéñ"));
        field_ram = Vidio_Query.record().indexOf(tr("Ïàìÿòü"));
        field_inventar_num = Vidio_Query.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_sereal_num = Vidio_Query.record().indexOf(tr("Ñåðèéíûé_íîìåð"));

        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Vidio_block = new QTreeWidgetItem(itemSysBlock);
                item_Vidio_block->setText(2, tr("ÂÈÄÅÎÊÀÐÒÛ"));
                item_Vidio_block->setText(14, id_otvetstvennogo_lica);
        }



        while(Vidio_Query.next()){
//              tmp = tr("CD/DVD: ");
        tmp = tr("");
                Vidio_id = Vidio_Query.value(field_id).toString();
                Vidio_proizvoditel = Vidio_Query.value(field_proizvoditel).toString();
                Vidio_model = Vidio_Query.value(field_model).toString();
                Vidio_interfeis = Vidio_Query.value(field_interfeis).toString();
                Vidio_ram = Vidio_Query.value(field_ram).toString();
                Vidio_inventar_num = Vidio_Query.value(field_inventar_num).toString();
                Vidio_sereal_num =  Vidio_Query.value(field_sereal_num).toString();
        if (Vidio_interfeis != "") {tmp.append(tr(" "));
        tmp.append(Vidio_interfeis);}
        if (Vidio_proizvoditel != "") {tmp.append(tr(" "));
        tmp.append(Vidio_proizvoditel);}
        if (Vidio_model != "") {tmp.append(tr(" "));
                tmp.append(Vidio_model);}
       
        if (Vidio_ram !=""){tmp.append(tr(" "));
        tmp.append(Vidio_ram);
        tmp.append(tr(" Mb"));
               
        }
        result.append(tmp);
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Vidio  = new QTreeWidgetItem(item_Vidio_block);
        }
        else item_Vidio = new QTreeWidgetItem(itemSysBlock);


//      item_Vidio = new QTreeWidgetItem(itemSysBlock);

        item_Vidio->setText(2, tr("Âèäåîêàðòà"));
        item_Vidio->setText(12, Vidio_id);
        item_Vidio->setText(13, id_systemBlock);
        item_Vidio->setText(14, id_otvetstvennogo_lica);
        item_Vidio->setIcon(4, vidio_card_icon);
        item_Vidio->setText(4, tmp);
        item_Vidio->setText(3, Vidio_inventar_num);
                }
        if (id_systemBlock !="1") itemSysBlock->setText(9, result);
        return result;
}


QString MainWindowImpl::add_Sound_Card_Information(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock){
       

        QString result, tmp;
        QString Sound_card_id, Sound_card_proizvoditel, Sound_card_model, Sound_card_inventar_num, Sound_card_serial_num;
        QString Sound_card_SqlQueryText;
        QSqlQuery Sound_card_Query;
        int field_id, field_proizvoditel, field_model, field_inventar_num, field_serial_num;
        QTreeWidgetItem *item_Sound_card, *item_Sound_card_block;
        Sound_card_SqlQueryText = tr("select soundcards.* "
        " from soundcards where soundcards.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        Sound_card_SqlQueryText.append(id_systemBlock);
        Sound_card_Query.prepare(Sound_card_SqlQueryText);
        Sound_card_Query.exec();
        field_id = Sound_card_Query.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = Sound_card_Query.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_model = Sound_card_Query.record().indexOf(tr("Ìîäåëü"));
        field_inventar_num =  Sound_card_Query.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
        field_serial_num = Sound_card_Query.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
       

        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Sound_card_block = new QTreeWidgetItem(itemSysBlock);
                item_Sound_card_block->setText(2, tr("ÇÂÓÊÎÂÛÅ ÊÀÐÒÛ"));
                item_Sound_card_block->setText(14, id_otvetstvennogo_lica);
        }

        while(Sound_card_Query.next()){
//              tmp = tr("CD/DVD: ");
        tmp = tr("");
                Sound_card_id = Sound_card_Query.value(field_id).toString();
                Sound_card_proizvoditel = Sound_card_Query.value(field_proizvoditel).toString();
                Sound_card_model = Sound_card_Query.value(field_model).toString();
                Sound_card_inventar_num = Sound_card_Query.value(field_inventar_num).toString();
                Sound_card_serial_num = Sound_card_Query.value(field_serial_num).toString();
               
//              Vidio_interfeis = Vidio_Query.value(field_interfeis).toString();
//              Vidio_ram = Vidio_Query.value(field_ram).toString();
        if (Sound_card_proizvoditel != "") {tmp.append(tr(" "));
        tmp.append(Sound_card_proizvoditel);}

        if (Sound_card_model != "") {tmp.append(tr(" "));
                tmp.append(Sound_card_model);}
       
///     if (Vidio_ram !=""){tmp.append(tr(" "));
///     tmp.append(Vidio_ram);
///     tmp.append(tr(" Mb"));
               
///     }
        result.append(tmp);
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Sound_card  = new QTreeWidgetItem(item_Sound_card_block);
        }
        else item_Sound_card = new QTreeWidgetItem(itemSysBlock);

       
//      item_Sound_card = new QTreeWidgetItem(itemSysBlock);
       
       
        item_Sound_card->setText(2, tr("Çâóêîâàÿ êàðòà"));
        item_Sound_card->setText(12, Sound_card_id);
        item_Sound_card->setText(13, id_systemBlock);
        item_Sound_card->setText(14, id_otvetstvennogo_lica);
        item_Sound_card->setIcon(4, sound_card_icon);
        item_Sound_card->setText(4, tmp);
        item_Sound_card->setText(3, Sound_card_inventar_num);
                }
        if (id_systemBlock !="1") itemSysBlock->setText(10, result);
        return result; 
               
}

QString MainWindowImpl::add_Lan_Card_Information(QString id_otvetstvennogo_lica, QString id_systemBlock, QTreeWidgetItem * itemSysBlock){
       

        QString result, tmp;
        QString Lan_card_id, Lan_card_proizvoditel, Lan_card_model, Lan_speed, Lan_inventar_num, Lan_serial_num;
        QString Lan_card_SqlQueryText;
        QSqlQuery Lan_card_Query;
        int field_id, field_proizvoditel, field_model, field_speed, field_serial_num, field_inventar_num;
        QTreeWidgetItem *item_Lan_card, *item_Lan_card_block;
        Lan_card_SqlQueryText = tr("select lancards.* "
        " from lancards where lancards.Èäåíòèôèêàòîð_ñèñòåìíîãî_áëîêà = "
        );
        Lan_card_SqlQueryText.append(id_systemBlock);
        Lan_card_Query.prepare(Lan_card_SqlQueryText);
        Lan_card_Query.exec();
        field_id = Lan_card_Query.record().indexOf(tr("Èäåíòèôèêàòîð"));
        field_proizvoditel = Lan_card_Query.record().indexOf(tr("Ïðîèçâîäèòåëü"));
        field_model = Lan_card_Query.record().indexOf(tr("Ìîäåëü"));
        field_speed = Lan_card_Query.record().indexOf(tr("Ñêîðîñòü_ïåðåäà÷è_äàííûõ"));
        field_serial_num = Lan_card_Query.record().indexOf(tr("Ñåðèéíûé_íîìåð"));
        field_inventar_num = Lan_card_Query.record().indexOf(tr("Èíâåíòàðíûé_íîìåð"));
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Lan_card_block = new QTreeWidgetItem(itemSysBlock);
                item_Lan_card_block->setText(2, tr("ÑÅÒÅÂÛÅ ÊÀÐÒÛ"));
                item_Lan_card_block->setText(14, id_otvetstvennogo_lica);
        }
       
        while(Lan_card_Query.next()){
//              tmp = tr("CD/DVD: ");
        tmp = tr("");
                Lan_card_id = Lan_card_Query.value(field_id).toString();
                Lan_card_proizvoditel = Lan_card_Query.value(field_proizvoditel).toString();
                Lan_card_model = Lan_card_Query.value(field_model).toString();
                Lan_speed = Lan_card_Query.value(field_speed).toString();
                Lan_inventar_num =  Lan_card_Query.value(field_inventar_num).toString();
                Lan_serial_num = Lan_card_Query.value(field_serial_num).toString();
               
               
//              Vidio_interfeis = Vidio_Query.value(field_interfeis).toString();
//              Vidio_ram = Vidio_Query.value(field_ram).toString();
        if (Lan_card_proizvoditel != "") {tmp.append(tr(" "));
        tmp.append(Lan_card_proizvoditel);}

        if (Lan_card_model != "") {tmp.append(tr(" "));
                tmp.append(Lan_card_model);}
               
        if (Lan_speed != "") {tmp.append(tr(" "));
                tmp.append(Lan_speed);
                tmp.append(tr(" Mbit"));}
       
///     if (Vidio_ram !=""){tmp.append(tr(" "));
///     tmp.append(Vidio_ram);
///     tmp.append(tr(" Mb"));
               
///     }
        result.append(tmp);
       
        if (id_otvetstvennogo_lica == "1" && id_systemBlock == "1"){
                item_Lan_card  = new QTreeWidgetItem(item_Lan_card_block);
        }
        else item_Lan_card = new QTreeWidgetItem(itemSysBlock);
       
//      item_Lan_card = new QTreeWidgetItem(itemSysBlock);
       
       
        item_Lan_card->setText(2, tr("Ñåòåâàÿ êàðòà"));
        item_Lan_card->setText(12, Lan_card_id);
        item_Lan_card->setText(13, id_systemBlock);
        item_Lan_card->setText(14, id_otvetstvennogo_lica);
        item_Lan_card->setIcon(4, lan_card_icon);
        item_Lan_card->setText(4, tmp);
        item_Lan_card->setText(3, Lan_inventar_num);
                }
        if (id_systemBlock !="1") itemSysBlock->setText(11, result);
        return result; 
               
}

void MainWindowImpl::refreshTree(){
       
        initTreeWidget();
}

int MainWindowImpl::select_system_block(){
        return 1;
}