diff --git a/ParserZP.pro b/ParserZP.pro index 4dd6873..aa6b5b0 100644 --- a/ParserZP.pro +++ b/ParserZP.pro @@ -1,47 +1,47 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2015-04-08T15:22:10 -# -#------------------------------------------------- - -QT += core gui sql - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = ParserZP -TEMPLATE = app - - -SOURCES += main.cpp\ - mainform.cpp \ - parser.cpp \ - bankform.cpp \ - personform.cpp \ - selectimportform.cpp \ - aboutform.cpp \ - insertactiveform.cpp \ - minimalzpform.cpp - -HEADERS += mainform.h \ - parser.h \ - bankform.h \ - personform.h \ - selectimportform.h \ - aboutform.h \ - insertactiveform.h \ - minimalzpform.h - -FORMS += mainform.ui \ - bankform.ui \ - personform.ui \ - selectimportform.ui \ - aboutform.ui \ - insertactiveform.ui \ - insertactiveform.ui \ - minimalzpform.ui - -RESOURCES += \ - resources.qrc - -OTHER_FILES += \ - version.txt +#------------------------------------------------- +# +# Project created by QtCreator 2015-04-08T15:22:10 +# +#------------------------------------------------- + +QT += core gui sql + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = ParserZP +TEMPLATE = app + + +SOURCES += main.cpp\ + mainform.cpp \ + parser.cpp \ + bankform.cpp \ + personform.cpp \ + selectimportform.cpp \ + aboutform.cpp \ + insertactiveform.cpp \ + minimalzpform.cpp + +HEADERS += mainform.h \ + parser.h \ + bankform.h \ + personform.h \ + selectimportform.h \ + aboutform.h \ + insertactiveform.h \ + minimalzpform.h + +FORMS += mainform.ui \ + bankform.ui \ + personform.ui \ + selectimportform.ui \ + aboutform.ui \ + insertactiveform.ui \ + insertactiveform.ui \ + minimalzpform.ui + +RESOURCES += \ + resources.qrc + +OTHER_FILES += \ + version.txt diff --git a/ReadMe.txt b/ReadMe.txt index 9cbea3a..582698f 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,10 +1,10 @@ - Alias("ParserZP") (db\database.mdb). - - Alias: --> ->-> (ODBC); - - "odbcad32"; - DSN->; - "Driver do Microsoft Access (*.mdb)"; - "ParserZP"; + Alias("ParserZP") (db\database.mdb). + + Alias: +-> ->-> (ODBC); + + "odbcad32"; + DSN->; + "Driver do Microsoft Access (*.mdb)"; + "ParserZP"; ->, (db\database.mdb). \ No newline at end of file diff --git a/aboutform.cpp b/aboutform.cpp index e74c25b..73e5f35 100644 --- a/aboutform.cpp +++ b/aboutform.cpp @@ -1,19 +1,19 @@ -#include "aboutform.h" -#include "ui_aboutform.h" - -AboutForm::AboutForm(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutForm) -{ - ui->setupUi(this); -} - -AboutForm::~AboutForm() -{ - delete ui; -} - -void AboutForm::on_pushButton_clicked() -{ - close(); -} +#include "aboutform.h" +#include "ui_aboutform.h" + +AboutForm::AboutForm(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutForm) +{ + ui->setupUi(this); +} + +AboutForm::~AboutForm() +{ + delete ui; +} + +void AboutForm::on_pushButton_clicked() +{ + close(); +} diff --git a/aboutform.h b/aboutform.h index 3a4c895..f9f5c1e 100644 --- a/aboutform.h +++ b/aboutform.h @@ -1,25 +1,25 @@ -#ifndef ABOUTFORM_H -#define ABOUTFORM_H - -#include - -namespace Ui { -class AboutForm; -} - -class AboutForm : public QDialog -{ - Q_OBJECT - -public: - explicit AboutForm(QWidget *parent = 0); - ~AboutForm(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::AboutForm *ui; -}; - -#endif // ABOUTFORM_H +#ifndef ABOUTFORM_H +#define ABOUTFORM_H + +#include + +namespace Ui { +class AboutForm; +} + +class AboutForm : public QDialog +{ + Q_OBJECT + +public: + explicit AboutForm(QWidget *parent = 0); + ~AboutForm(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::AboutForm *ui; +}; + +#endif // ABOUTFORM_H diff --git a/aboutform.ui b/aboutform.ui index 62a9785..6ed306d 100644 --- a/aboutform.ui +++ b/aboutform.ui @@ -1,99 +1,99 @@ - - - AboutForm - - - - 0 - 0 - 315 - 216 - - - - - 315 - 216 - - - - - 315 - 216 - - - - О программе - - - - - - - 12 - 75 - true - - - - ParserZP v1.0.4 - - - Qt::AlignCenter - - - - - - - - 10 - - - - Программа предназначена для хранения данных о лицевых счетах сотрудников и преобразования списка заработной платы в формат для БеларусБанка, БелАгроПромБанка, ПриорБанка - - - Qt::AlignCenter - - - true - - - - - - - - 10 - - - - Разработчик: Тихонов Максим - - - - - - - - 10 - - - - e-mail: maxiprogram@gmail.com - - - - - - - OK - - - - - - - - + + + AboutForm + + + + 0 + 0 + 315 + 216 + + + + + 315 + 216 + + + + + 315 + 216 + + + + О программе + + + + + + + 12 + 75 + true + + + + ParserZP v1.0.5 + + + Qt::AlignCenter + + + + + + + + 10 + + + + Программа предназначена для хранения данных о лицевых счетах сотрудников и преобразования списка заработной платы в формат для БеларусБанка, БелАгроПромБанка, ПриорБанка + + + Qt::AlignCenter + + + true + + + + + + + + 10 + + + + Разработчик: Тихонов Максим + + + + + + + + 10 + + + + e-mail: maxiprogram@gmail.com + + + + + + + OK + + + + + + + + diff --git a/bankform.cpp b/bankform.cpp index f4da29a..af87023 100644 --- a/bankform.cpp +++ b/bankform.cpp @@ -1,51 +1,51 @@ -#include "bankform.h" -#include "ui_bankform.h" - -BankForm::BankForm(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::BankForm) -{ - ui->setupUi(this); -} - -BankForm::~BankForm() -{ - delete ui; -} - -void BankForm::Init() -{ - bank_model = new QSqlTableModel(this); - bank_model->setEditStrategy(QSqlTableModel::OnManualSubmit); - bank_model->setTable("bank"); - bank_model->setHeaderData(1, Qt::Horizontal, "Наименование"); - //bank_model->setSort(1, Qt::AscendingOrder); - ui->tableBank->setModel(bank_model); - ui->tableBank->hideColumn(0); - bank_model->select(); - ui->tableBank->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void BankForm::on_action_exit_triggered() -{ - close(); -} - -void BankForm::on_action_add_triggered() -{ - bank_model->insertRow(bank_model->rowCount()); -} - -void BankForm::on_action_del_triggered() -{ - bank_model->removeRow(ui->tableBank->currentIndex().row()); -} - -void BankForm::on_action_save_triggered() -{ - if (!bank_model->submitAll()) - { - QMessageBox::information(this, "Невозможно сохранить изменения", bank_model->lastError().text()); - } - ui->tableBank->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} +#include "bankform.h" +#include "ui_bankform.h" + +BankForm::BankForm(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::BankForm) +{ + ui->setupUi(this); +} + +BankForm::~BankForm() +{ + delete ui; +} + +void BankForm::Init() +{ + bank_model = new QSqlTableModel(this); + bank_model->setEditStrategy(QSqlTableModel::OnManualSubmit); + bank_model->setTable("bank"); + bank_model->setHeaderData(1, Qt::Horizontal, "Наименование"); + //bank_model->setSort(1, Qt::AscendingOrder); + ui->tableBank->setModel(bank_model); + ui->tableBank->hideColumn(0); + bank_model->select(); + ui->tableBank->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void BankForm::on_action_exit_triggered() +{ + close(); +} + +void BankForm::on_action_add_triggered() +{ + bank_model->insertRow(bank_model->rowCount()); +} + +void BankForm::on_action_del_triggered() +{ + bank_model->removeRow(ui->tableBank->currentIndex().row()); +} + +void BankForm::on_action_save_triggered() +{ + if (!bank_model->submitAll()) + { + QMessageBox::information(this, "Невозможно сохранить изменения", bank_model->lastError().text()); + } + ui->tableBank->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} diff --git a/bankform.h b/bankform.h index c751a03..d78804c 100644 --- a/bankform.h +++ b/bankform.h @@ -1,36 +1,36 @@ -#ifndef BANKFORM_H -#define BANKFORM_H - -#include -#include -#include -#include - -namespace Ui { -class BankForm; -} - -class BankForm : public QMainWindow -{ - Q_OBJECT - -public: - explicit BankForm(QWidget *parent = 0); - ~BankForm(); - void Init(); - -private slots: - void on_action_exit_triggered(); - - void on_action_add_triggered(); - - void on_action_del_triggered(); - - void on_action_save_triggered(); - -private: - Ui::BankForm *ui; - QSqlTableModel* bank_model; -}; - -#endif // BANKFORM_H +#ifndef BANKFORM_H +#define BANKFORM_H + +#include +#include +#include +#include + +namespace Ui { +class BankForm; +} + +class BankForm : public QMainWindow +{ + Q_OBJECT + +public: + explicit BankForm(QWidget *parent = 0); + ~BankForm(); + void Init(); + +private slots: + void on_action_exit_triggered(); + + void on_action_add_triggered(); + + void on_action_del_triggered(); + + void on_action_save_triggered(); + +private: + Ui::BankForm *ui; + QSqlTableModel* bank_model; +}; + +#endif // BANKFORM_H diff --git a/bankform.ui b/bankform.ui index 692ef51..f7a0099 100644 --- a/bankform.ui +++ b/bankform.ui @@ -1,115 +1,115 @@ - - - BankForm - - - Qt::WindowModal - - - - 0 - 0 - 539 - 343 - - - - Банки - - - - - - - QAbstractScrollArea::AdjustToContents - - - true - - - - - - - - - 0 - 0 - 539 - 20 - - - - - Действия - - - - - - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - - - - :/ico/add.png:/ico/add.png - - - Добавить запись - - - Добавить запись - - - - - - :/ico/delete.png:/ico/delete.png - - - Удалить запись - - - Удалить запись - - - - - - :/ico/save.png:/ico/save.png - - - Сохранить все - - - Сохранить все - - - - - Выход - - - - - - - - + + + BankForm + + + Qt::WindowModal + + + + 0 + 0 + 539 + 343 + + + + Банки + + + + + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + + + + + 0 + 0 + 539 + 20 + + + + + Действия + + + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + + :/ico/add.png:/ico/add.png + + + Добавить запись + + + Добавить запись + + + + + + :/ico/delete.png:/ico/delete.png + + + Удалить запись + + + Удалить запись + + + + + + :/ico/save.png:/ico/save.png + + + Сохранить все + + + Сохранить все + + + + + Выход + + + + + + + + diff --git a/db/database.mdb b/db/database.mdb index 36af7cf..75765c1 100644 Binary files a/db/database.mdb and b/db/database.mdb differ diff --git a/insertactiveform.cpp b/insertactiveform.cpp index 1ce1197..b567bbf 100644 --- a/insertactiveform.cpp +++ b/insertactiveform.cpp @@ -1,65 +1,72 @@ -#include "insertactiveform.h" -#include "ui_insertactiveform.h" - -InsertActiveForm::InsertActiveForm(QWidget *parent) : - QDialog(parent), - ui(new Ui::InsertActiveForm) -{ - ui->setupUi(this); -} - -InsertActiveForm::~InsertActiveForm() -{ - delete ui; -} - -void InsertActiveForm::Init() -{ - QString query_string = "SELECT id, fio FROM persona ORDER BY fio ASC;"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - ui->comboBox->clear(); - if (query.isSelect()) - query.first(); - if (query.isValid()) - { - do - { - ui->comboBox->addItem(query.value(1).toString(), query.value(0)); - }while(query.next()); - } - - query_string = "SELECT id, name FROM bank ORDER BY name ASC;"; - query.clear(); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - ui->comboBox_2->clear(); - if (query.isSelect()) - query.first(); - if (query.isValid()) - { - do - { - ui->comboBox_2->addItem(query.value(1).toString(), query.value(0)); - }while(query.next()); - } - ui->lineEdit->setText(""); -} - -void InsertActiveForm::on_pushButton_2_clicked() -{ - this->close(); -} - -void InsertActiveForm::on_pushButton_clicked() -{ - emit ADD_RECORD(ui->comboBox->currentData().toString(), ui->comboBox_2->currentData().toString(), ui->lineEdit->text()); - this->close(); -} +#include "insertactiveform.h" +#include "ui_insertactiveform.h" + +InsertActiveForm::InsertActiveForm(QWidget *parent) : + QDialog(parent), + ui(new Ui::InsertActiveForm) +{ + ui->setupUi(this); +} + +InsertActiveForm::~InsertActiveForm() +{ + delete ui; +} + +void InsertActiveForm::Init() +{ + QString query_string = "SELECT id, fio FROM persona ORDER BY fio ASC;"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + ui->comboBox->clear(); + if (query.isSelect()) + query.first(); + if (query.isValid()) + { + do + { + ui->comboBox->addItem(query.value(1).toString(), query.value(0)); + }while(query.next()); + } + + query_string = "SELECT id, name FROM bank ORDER BY name ASC;"; + query.clear(); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + ui->comboBox_2->clear(); + if (query.isSelect()) + query.first(); + if (query.isValid()) + { + do + { + ui->comboBox_2->addItem(query.value(1).toString(), query.value(0)); + }while(query.next()); + } + ui->lineEdit->setText(""); +} + +void InsertActiveForm::on_pushButton_2_clicked() +{ + this->close(); +} + +void InsertActiveForm::on_pushButton_clicked() +{ + bool flag = false; + ui->lineEdit->text().toDouble(&flag); + if (flag==false) + { + QMessageBox::warning(this, "Ошибка", "Невозможно преобразовать cумму в число!"); + return; + } + emit ADD_RECORD(ui->comboBox->currentData().toString(), ui->comboBox_2->currentData().toString(), ui->lineEdit->text()); + this->close(); +} diff --git a/insertactiveform.h b/insertactiveform.h index 64c0492..5323df7 100644 --- a/insertactiveform.h +++ b/insertactiveform.h @@ -1,35 +1,35 @@ -#ifndef INSERTACTIVEFORM_H -#define INSERTACTIVEFORM_H - -#include -#include -#include -#include -#include - -namespace Ui { -class InsertActiveForm; -} - -class InsertActiveForm : public QDialog -{ - Q_OBJECT - -public: - explicit InsertActiveForm(QWidget *parent = 0); - void Init(); - ~InsertActiveForm(); - -private slots: - void on_pushButton_2_clicked(); - - void on_pushButton_clicked(); - -signals: - void ADD_RECORD(QString id_persona, QString id_bank, QString summa); - -private: - Ui::InsertActiveForm *ui; -}; - -#endif // INSERTACTIVEFORM_H +#ifndef INSERTACTIVEFORM_H +#define INSERTACTIVEFORM_H + +#include +#include +#include +#include +#include + +namespace Ui { +class InsertActiveForm; +} + +class InsertActiveForm : public QDialog +{ + Q_OBJECT + +public: + explicit InsertActiveForm(QWidget *parent = 0); + void Init(); + ~InsertActiveForm(); + +private slots: + void on_pushButton_2_clicked(); + + void on_pushButton_clicked(); + +signals: + void ADD_RECORD(QString id_persona, QString id_bank, QString summa); + +private: + Ui::InsertActiveForm *ui; +}; + +#endif // INSERTACTIVEFORM_H diff --git a/insertactiveform.ui b/insertactiveform.ui index 37812ac..290ba48 100644 --- a/insertactiveform.ui +++ b/insertactiveform.ui @@ -1,93 +1,93 @@ - - - InsertActiveForm - - - - 0 - 0 - 453 - 262 - - - - - 453 - 262 - - - - - 453 - 262 - - - - Добавление записи в активный список - - - - - - - - Выберите фамилию сотрудника: - - - - - - - - - - - - - - Выберите банк: - - - - - - - - - - - - - - Введите сумму: - - - - - - - - - - - - - - Добавить - - - - - - - Отмена - - - - - - - - - - + + + InsertActiveForm + + + + 0 + 0 + 453 + 262 + + + + + 453 + 262 + + + + + 453 + 262 + + + + Добавление записи в активный список + + + + + + + + Выберите фамилию сотрудника: + + + + + + + + + + + + + + Выберите банк: + + + + + + + + + + + + + + Введите сумму: + + + + + + + + + + + + + + Добавить + + + + + + + Отмена + + + + + + + + + + diff --git a/main.cpp b/main.cpp index d3a435a..63ba96c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,11 @@ -#include "mainform.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainForm w; - w.show(); - - return a.exec(); -} +#include "mainform.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainForm w; + w.show(); + + return a.exec(); +} diff --git a/mainform.cpp b/mainform.cpp index 9dcb4d9..7fea354 100644 --- a/mainform.cpp +++ b/mainform.cpp @@ -1,895 +1,895 @@ -#include "mainform.h" -#include "ui_mainform.h" - -MainForm::MainForm(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainForm) -{ - ui->setupUi(this); - - setting=new QSettings("settings.ini",QSettings::IniFormat,this); - - bank_form = new BankForm(this); - persona_form = new PersonForm(this); - insert_form = new InsertActiveForm(this); - - insert_form->connect(insert_form, SIGNAL(ADD_RECORD(QString,QString,QString)), this, SLOT(on_add_record(QString,QString,QString))); - - QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); - //qDebug()<tableActive->connect(ui->tableActive->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(on_header_clicked(int,Qt::SortOrder))); - - ui->tableArchiv->hideColumn(0); - ui->action_add_record->setEnabled(true); - ui->action_del_record->setEnabled(true); - ui->action_import->setEnabled(true); - ui->action_export->setEnabled(true); - ui->action_new->setEnabled(true); - - ui->action_del_archiv->setEnabled(false); - ui->action_del_all_archiv->setEnabled(false); -} - -MainForm::~MainForm() -{ - delete setting; - delete ui; - delete parser; - QSqlDatabase::database().close(); -} - -void MainForm::Clear(QTableWidget *table) -{ - int count = table->rowCount(); - for (int i=0; iremoveRow(0); - } - table->setRowCount(0); -} - -void MainForm::PrintArchiv() -{ - ui->tableArchiv->setRowCount(0); - QString query_string = "SELECT id, date, name, summa FROM archiv;"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - if (query.isSelect()) - query.first(); - if (query.isValid()) - { - int i = 0; - do - { - ui->tableArchiv->insertRow(i); - - ui->tableArchiv->setItem(i, 0, new QTableWidgetItem(query.value(0).toString())); - ui->tableArchiv->item(i, 0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchiv->setItem(i, 1, new QTableWidgetItem(query.value(1).toDate().toString("dd.MM.yyyy"))); - ui->tableArchiv->item(i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchiv->setItem(i, 2, new QTableWidgetItem(query.value(2).toString())); - ui->tableArchiv->item(i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchiv->setItem(i, 3, new QTableWidgetItem(query.value(3).toString())); - ui->tableArchiv->item(i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - i++; - }while(query.next()); - } - ui->tableArchiv->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void MainForm::PrintArchivData(QString id) -{ - ui->tableArchivData->setRowCount(0); - QString query_string = "SELECT persona.fio, schet.kod, schet.schet, archiv_data.summa " - "FROM persona " - "INNER JOIN (schet INNER JOIN archiv_data ON schet.id = archiv_data.id_schet) ON persona.id = schet.id_persona " - "WHERE id_archiv="+id+";"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - if (query.isSelect()) - query.first(); - if (query.isValid()) - { - int i = 0; - do - { - ui->tableArchivData->insertRow(i); - - ui->tableArchivData->setItem(i, 0, new QTableWidgetItem(query.value(0).toString())); - ui->tableArchivData->item(i, 0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchivData->setItem(i, 1, new QTableWidgetItem(query.value(1).toString())); - ui->tableArchivData->item(i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchivData->setItem(i, 2, new QTableWidgetItem(query.value(2).toString())); - ui->tableArchivData->item(i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableArchivData->setItem(i, 3, new QTableWidgetItem(query.value(3).toString())); - ui->tableArchivData->item(i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - i++; - }while(query.next()); - } - ui->tableArchivData->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void MainForm::on_header_clicked(int index, Qt::SortOrder asc) -{ - if (index==0) - { - if (asc==Qt::AscendingOrder) - { - //QMessageBox::information(this, "asc", QString::number(index)); - for (int i=0; itableActive->rowCount(); i++) - { - ui->tableActive->item(i, 0)->setCheckState(Qt::Checked); - } - } - else - { - //QMessageBox::information(this, "desc", QString::number(index)); - for (int i=0; itableActive->rowCount(); i++) - { - ui->tableActive->item(i, 0)->setCheckState(Qt::Unchecked); - } - } - } -} - -void MainForm::on_action_bank_triggered() -{ - bank_form->Init(); - bank_form->show(); -} - -void MainForm::on_action_persona_triggered() -{ - persona_form->Init(); - persona_form->show(); -} - -void MainForm::on_action_import_triggered() -{ - ui->label_bank->setText("Формирование списка для:"); - SelectImportForm f; - int bank = f.exec(); - //qDebug()<Load(filename)) - { - QMessageBox::warning(this, "Импорт", "Не удалось импортировать данные!"); - return; - } - - QString query_string; - switch(for_bank) - { - case 1: - { - query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " - "INNER JOIN schet on schet.id_persona=persona.id " - "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БеларусБанк') and persona.fio="; - ui->label_bank->setText("Формирование списка для: БеларусБанк"); - break; - } - case 2: - { - query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " - "INNER JOIN schet on schet.id_persona=persona.id " - "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БелАгроПромБанк') and persona.fio="; - ui->label_bank->setText("Формирование списка для: БелАгроПромБанк"); - break; - } - case 3: - { - query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " - "INNER JOIN schet on schet.id_persona=persona.id " - "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='ПриорБанк') and persona.fio="; - ui->label_bank->setText("Формирование списка для: ПриорБанк"); - break; - } - case 4: - { - query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " - "INNER JOIN schet on schet.id_persona=persona.id " - "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БеларусБанк') and persona.fio="; - ui->label_bank->setText("Формирование списка для: Минимальная ЗП БеларусБанк"); - break; - } - case 5: - { - query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " - "INNER JOIN schet on schet.id_persona=persona.id " - "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БелАгроПромБанк') and persona.fio="; - ui->label_bank->setText("Формирование списка для: Минимальная ЗП БелАгроПромБанк"); - break; - } - } - - count_rec = count_rec_sel = summa = summa_sel = 0; - ui->tableActive->setRowCount(0); - QSqlQuery query(QSqlDatabase::database()); - - QList list = parser->GetList(); - for (int i=0; i id_schet; - if (dop_query.isValid()) - { - do - { - id_schet.append(dop_query.value(0).toInt()); - }while(dop_query.next()); - } - dop_query.clear(); - - int flag = 0; - for(int i=0; itableActive->rowCount(); - ui->tableActive->insertRow(row_i); - - ui->tableActive->setItem(row_i, 0, new QTableWidgetItem()); - ui->tableActive->item(row_i, 0)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); - ui->tableActive->item(row_i, 0)->setCheckState(Qt::Unchecked); - if (flag==1) - ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::red)); - if (flag==2) - ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::green)); - if (flag==3) - ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::yellow)); - - ui->tableActive->setItem(row_i, 1, new QTableWidgetItem(query.value(0).toString())); - ui->tableActive->item(row_i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - if (flag==1) - ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::red)); - if (flag==2) - ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::green)); - if (flag==3) - ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::yellow)); - - ui->tableActive->setItem(row_i, 2, new QTableWidgetItem(query.value(1).toString())); - ui->tableActive->item(row_i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - if (flag==1) - ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::red)); - if (flag==2) - ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::green)); - if (flag==3) - ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::yellow)); - - ui->tableActive->setItem(row_i, 3, new QTableWidgetItem(query.value(2).toString())); - ui->tableActive->item(row_i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - if (flag==1) - ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::red)); - if (flag==2) - ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::green)); - if (flag==3) - ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::yellow)); - - if (for_bank==4 || for_bank==5) - { - ui->tableActive->setItem(row_i, 4, new QTableWidgetItem(QString::number(setting->value("min_zp").toInt()))); - }else - { - ui->tableActive->setItem(row_i, 4, new QTableWidgetItem(QString::number(list.at(i).summa.toInt()-summa_oplat))); - if (flag==1) - ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::red)); - if (flag==2) - ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::green)); - if (flag==3) - ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::yellow)); - } - - if (for_bank==4 || for_bank==5) - summa+=setting->value("min_zp").toInt(); - else - summa+=list.at(i).summa.toInt()-summa_oplat; - count_rec++; - } - - } - ui->tableActive->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - ui->label_count->setText("Всего записей: "+QString::number(count_rec_sel)+" из "+QString::number(count_rec)); - ui->label_summa->setText("Всего сумма: "+QString::number(summa_sel)+" из "+QString::number(summa)); -} - -void MainForm::on_action_export_triggered() -{ - QString str; - switch(for_bank) - { - case 0: - { - QMessageBox::information(this, "Экспорт списка", "Не известно для какого банка делать экспорт!"); - return; - } - case 1: - { - str = "БеларусБанк.txt"; - break; - } - case 2: - { - str = "БелАгроПромБанк.txt"; - break; - } - case 3: - { - str = "ПриорБанк.txt"; - break; - } - case 4: - { - str = "МинЗПБеларусБанк.txt"; - break; - } - case 5: - { - str = "МинЗПБелАгроПромБанк.txt"; - break; - } - } - QString filename = QFileDialog::getSaveFileName(this, "Экспорт списка", "out/"+str, "Список (*.txt)"); - if (filename=="") - return; - QFile f(filename); - if (!f.open(QIODevice::WriteOnly)) - { - QMessageBox::information(this, "Экспорт списка", "Не удаеться создать файл!"); - return; - } - QTextStream stream(&f); - int count_record = 0; - int summa = 0; - switch(for_bank) - { - case 1: - { - QString query_string = "INSERT INTO archiv ([date], name, summa) " - "VALUES ('"+QDate::currentDate().toString("dd.MM.yyyy")+"', 'БеларусБанк список на зачисление', 0);"; - //qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - stream<tableActive->item(i, 2)->text()<<" " - <tableActive->item(i, 3)->text()<<" " - <tableActive->item(i, 4)->text()<<" " - <tableActive->item(i, 1)->text() - <<"\r\n"; - count_record++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - - query_string = "SELECT id FROM schet WHERE kod='"+ - ui->tableActive->item(i, 2)->text()+ - "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; - //qDebug()<tableActive->item(i, 4)->text()+");"; - qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - stream<tableActive->item(i, 2)->text()<<"," - <tableActive->item(i, 3)->text()<<"," - <tableActive->item(i, 1)->text()<<"," - <tableActive->item(i, 4)->text() - <<"\r\n"; - count_record++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - - query_string = "SELECT id FROM schet WHERE kod='"+ - ui->tableActive->item(i, 2)->text()+ - "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; - //qDebug()<tableActive->item(i, 4)->text()+");"; - qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - stream<tableActive->item(i, 2)->text()<<"," - <tableActive->item(i, 3)->text()<<"," - <tableActive->item(i, 1)->text()<<"," - <tableActive->item(i, 4)->text() - <<"\r\n"; - count_record++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - - query_string = "SELECT id FROM schet WHERE kod='"+ - ui->tableActive->item(i, 2)->text()+ - "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; - //qDebug()<tableActive->item(i, 4)->text()+");"; - qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - stream<tableActive->item(i, 2)->text()<<" " - <tableActive->item(i, 3)->text()<<" " - <tableActive->item(i, 4)->text()<<" " - <tableActive->item(i, 1)->text() - <<"\r\n"; - count_record++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - - query_string = "SELECT id FROM schet WHERE kod='"+ - ui->tableActive->item(i, 2)->text()+ - "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; - //qDebug()<tableActive->item(i, 4)->text()+");"; - qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - stream<tableActive->item(i, 2)->text()<<"," - <tableActive->item(i, 3)->text()<<"," - <tableActive->item(i, 1)->text()<<"," - <tableActive->item(i, 4)->text() - <<"\r\n"; - count_record++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - - query_string = "SELECT id FROM schet WHERE kod='"+ - ui->tableActive->item(i, 2)->text()+ - "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; - //qDebug()<tableActive->item(i, 4)->text()+");"; - qDebug()<tableActive->rowCount(); i++) - { - if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) - { - summa_sel+=ui->tableActive->item(i, 4)->text().toInt(); - count_rec_sel++; - } - count_rec++; - summa+=ui->tableActive->item(i, 4)->text().toInt(); - } - ui->label_count->setText("Всего записей: "+QString::number(count_rec_sel)+" из "+QString::number(count_rec)); - ui->label_summa->setText("Всего сумма: "+QString::number(summa_sel)+" из "+QString::number(summa)); -} - -void MainForm::on_action_triggered() -{ - AboutForm f; - f.exec(); -} - -void MainForm::on_tabWidget_currentChanged(int index) -{ - switch(index) - { - case 0: - { - ui->action_add_record->setEnabled(true); - ui->action_del_record->setEnabled(true); - ui->action_import->setEnabled(true); - ui->action_export->setEnabled(true); - ui->action_new->setEnabled(true); - - ui->action_del_archiv->setEnabled(false); - ui->action_del_all_archiv->setEnabled(false); - - break; - } - case 1: - { - ui->action_add_record->setEnabled(false); - ui->action_del_record->setEnabled(false); - ui->action_import->setEnabled(false); - ui->action_export->setEnabled(false); - ui->action_new->setEnabled(false); - - ui->action_del_archiv->setEnabled(true); - ui->action_del_all_archiv->setEnabled(true); - PrintArchiv(); - break; - } - } -} - -void MainForm::on_tableArchiv_clicked(const QModelIndex &index) -{ - QString id =""; - QTableWidgetItem* item = 0; - item = ui->tableArchiv->item(index.row(), 0); - if (item!=0) - { - id = item->text(); - if (id!="" && id.toInt()!=0) - PrintArchivData(id); - } - //qDebug()<<"PrintArchivData() id="<tableArchiv->currentItem(); - if (item==0) - { - QMessageBox::about(this, "Удаление записи", "Необходимо выбрать запись для удаления!"); - return; - } - id = ui->tableArchiv->item(item->row(), 0)->text(); - if (id!="" && id.toInt()!=0) - { - if (QMessageBox::question(this, "Удаление записи", "Вы уверены что хотите удалить запись?")==QMessageBox::Yes) - { - QString query_string = "DELETE FROM archiv WHERE id="+id+";"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - PrintArchiv(); - ui->tableArchivData->setRowCount(0); - } - } -} - -void MainForm::on_action_del_record_triggered() -{ - QTableWidgetItem* item = 0; - item = ui->tableActive->currentItem(); - if (item==0) - { - QMessageBox::about(this, "Удаление записи", "Необходимо выбрать запись для удаления!"); - return; - } - if (QMessageBox::question(this, "Удаление записи", "Вы уверены что ходите удалить запись?")==QMessageBox::Yes) - { - ui->tableActive->removeRow(item->row()); - QModelIndex index; - this->on_tableActive_clicked(index); - } -} - -void MainForm::on_action_add_record_triggered() -{ - insert_form->Init(); - insert_form->exec(); -} - -void MainForm::on_add_record(QString id_persona, QString id_bank, QString summa) -{ - QString query_string = "SELECT persona.fio, schet.kod, schet.schet " - "FROM persona INNER JOIN schet ON persona.id = schet.id_persona " - "WHERE schet.id_bank="+id_bank+" AND schet.id_persona="+id_persona+";"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - if (query.isSelect()) - query.first(); - if (query.isValid()) - { - int row = ui->tableActive->rowCount(); - ui->tableActive->insertRow(row); - - ui->tableActive->setItem(row, 0, new QTableWidgetItem()); - ui->tableActive->item(row, 0)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); - ui->tableActive->item(row, 0)->setCheckState(Qt::Unchecked); - - ui->tableActive->setItem(row, 1, new QTableWidgetItem(query.value(0).toString())); - ui->tableActive->item(row, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableActive->setItem(row, 2, new QTableWidgetItem(query.value(1).toString())); - ui->tableActive->item(row, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableActive->setItem(row, 3, new QTableWidgetItem(query.value(2).toString())); - ui->tableActive->item(row, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); - - ui->tableActive->setItem(row, 4, new QTableWidgetItem(summa)); - } - QModelIndex index; - this->on_tableActive_clicked(index); -} - -void MainForm::on_action_new_triggered() -{ - ui->label_bank->setText("Формирование списка для:"); - SelectImportForm f; - int bank = f.exec(); - //qDebug()<label_bank->setText("Формирование списка для: БеларусБанк"); - break; - } - case 2: - { - ui->label_bank->setText("Формирование списка для: БелАгроПромБанк"); - break; - } - } - - count_rec = count_rec_sel = summa = summa_sel = 0; - ui->tableActive->setRowCount(0); -} - -void MainForm::on_action_minimal_zp_triggered() -{ - MinimalZPForm f; - f.min_zp = setting->value("min_zp").toInt(); - int flag = f.exec(); - if (flag!=-1) - setting->setValue("min_zp", f.min_zp); -} - -void MainForm::on_action_del_all_archiv_triggered() -{ - - if (QMessageBox::question(this, "Удаление всех записей", "Вы уверены что хотите удалить все записи?")==QMessageBox::Yes) - { - QString query_string = "DELETE FROM archiv;"; - QSqlQuery query(QSqlDatabase::database()); - if (!query.exec(query_string)) - { - QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); - return; - } - PrintArchiv(); - ui->tableArchivData->setRowCount(0); - } -} +#include "mainform.h" +#include "ui_mainform.h" + +MainForm::MainForm(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainForm) +{ + ui->setupUi(this); + + setting=new QSettings("settings.ini",QSettings::IniFormat,this); + + bank_form = new BankForm(this); + persona_form = new PersonForm(this); + insert_form = new InsertActiveForm(this); + + insert_form->connect(insert_form, SIGNAL(ADD_RECORD(QString,QString,QString)), this, SLOT(on_add_record(QString,QString,QString))); + + QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); + //qDebug()<tableActive->connect(ui->tableActive->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(on_header_clicked(int,Qt::SortOrder))); + + ui->tableArchiv->hideColumn(0); + ui->action_add_record->setEnabled(true); + ui->action_del_record->setEnabled(true); + ui->action_import->setEnabled(true); + ui->action_export->setEnabled(true); + ui->action_new->setEnabled(true); + + ui->action_del_archiv->setEnabled(false); + ui->action_del_all_archiv->setEnabled(false); +} + +MainForm::~MainForm() +{ + delete setting; + delete ui; + delete parser; + QSqlDatabase::database().close(); +} + +void MainForm::Clear(QTableWidget *table) +{ + int count = table->rowCount(); + for (int i=0; iremoveRow(0); + } + table->setRowCount(0); +} + +void MainForm::PrintArchiv() +{ + ui->tableArchiv->setRowCount(0); + QString query_string = "SELECT id, date, name, summa FROM archiv;"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + if (query.isSelect()) + query.first(); + if (query.isValid()) + { + int i = 0; + do + { + ui->tableArchiv->insertRow(i); + + ui->tableArchiv->setItem(i, 0, new QTableWidgetItem(query.value(0).toString())); + ui->tableArchiv->item(i, 0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchiv->setItem(i, 1, new QTableWidgetItem(query.value(1).toDate().toString("dd.MM.yyyy"))); + ui->tableArchiv->item(i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchiv->setItem(i, 2, new QTableWidgetItem(query.value(2).toString())); + ui->tableArchiv->item(i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchiv->setItem(i, 3, new QTableWidgetItem(query.value(3).toString())); + ui->tableArchiv->item(i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + i++; + }while(query.next()); + } + ui->tableArchiv->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void MainForm::PrintArchivData(QString id) +{ + ui->tableArchivData->setRowCount(0); + QString query_string = "SELECT persona.fio, schet.kod, schet.schet, archiv_data.summa " + "FROM persona " + "INNER JOIN (schet INNER JOIN archiv_data ON schet.id = archiv_data.id_schet) ON persona.id = schet.id_persona " + "WHERE id_archiv="+id+";"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + if (query.isSelect()) + query.first(); + if (query.isValid()) + { + int i = 0; + do + { + ui->tableArchivData->insertRow(i); + + ui->tableArchivData->setItem(i, 0, new QTableWidgetItem(query.value(0).toString())); + ui->tableArchivData->item(i, 0)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchivData->setItem(i, 1, new QTableWidgetItem(query.value(1).toString())); + ui->tableArchivData->item(i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchivData->setItem(i, 2, new QTableWidgetItem(query.value(2).toString())); + ui->tableArchivData->item(i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableArchivData->setItem(i, 3, new QTableWidgetItem(query.value(3).toString())); + ui->tableArchivData->item(i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + i++; + }while(query.next()); + } + ui->tableArchivData->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void MainForm::on_header_clicked(int index, Qt::SortOrder asc) +{ + if (index==0) + { + if (asc==Qt::AscendingOrder) + { + //QMessageBox::information(this, "asc", QString::number(index)); + for (int i=0; itableActive->rowCount(); i++) + { + ui->tableActive->item(i, 0)->setCheckState(Qt::Checked); + } + } + else + { + //QMessageBox::information(this, "desc", QString::number(index)); + for (int i=0; itableActive->rowCount(); i++) + { + ui->tableActive->item(i, 0)->setCheckState(Qt::Unchecked); + } + } + } +} + +void MainForm::on_action_bank_triggered() +{ + bank_form->Init(); + bank_form->show(); +} + +void MainForm::on_action_persona_triggered() +{ + persona_form->Init(); + persona_form->show(); +} + +void MainForm::on_action_import_triggered() +{ + ui->label_bank->setText("Формирование списка для:"); + SelectImportForm f; + int bank = f.exec(); + //qDebug()<Load(filename)) + { + QMessageBox::warning(this, "Импорт", "Не удалось импортировать данные!"); + return; + } + + QString query_string; + switch(for_bank) + { + case 1: + { + query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " + "INNER JOIN schet on schet.id_persona=persona.id " + "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БеларусБанк') and persona.fio="; + ui->label_bank->setText("Формирование списка для: БеларусБанк"); + break; + } + case 2: + { + query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " + "INNER JOIN schet on schet.id_persona=persona.id " + "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БелАгроПромБанк') and persona.fio="; + ui->label_bank->setText("Формирование списка для: БелАгроПромБанк"); + break; + } + case 3: + { + query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " + "INNER JOIN schet on schet.id_persona=persona.id " + "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='ПриорБанк') and persona.fio="; + ui->label_bank->setText("Формирование списка для: ПриорБанк"); + break; + } + case 4: + { + query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " + "INNER JOIN schet on schet.id_persona=persona.id " + "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БеларусБанк') and persona.fio="; + ui->label_bank->setText("Формирование списка для: Минимальная ЗП БеларусБанк"); + break; + } + case 5: + { + query_string = "SELECT persona.fio, schet.kod, schet.schet, schet.id_bank, persona.id FROM persona " + "INNER JOIN schet on schet.id_persona=persona.id " + "WHERE schet.id_bank=(SELECT id FROM bank WHERE name='БелАгроПромБанк') and persona.fio="; + ui->label_bank->setText("Формирование списка для: Минимальная ЗП БелАгроПромБанк"); + break; + } + } + + count_rec = count_rec_sel = summa = summa_sel = 0; + ui->tableActive->setRowCount(0); + QSqlQuery query(QSqlDatabase::database()); + + QList list = parser->GetList(); + for (int i=0; i id_schet; + if (dop_query.isValid()) + { + do + { + id_schet.append(dop_query.value(0).toInt()); + }while(dop_query.next()); + } + dop_query.clear(); + + int flag = 0; + for(int i=0; itableActive->rowCount(); + ui->tableActive->insertRow(row_i); + + ui->tableActive->setItem(row_i, 0, new QTableWidgetItem()); + ui->tableActive->item(row_i, 0)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); + ui->tableActive->item(row_i, 0)->setCheckState(Qt::Unchecked); + if (flag==1) + ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::red)); + if (flag==2) + ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::green)); + if (flag==3) + ui->tableActive->item(row_i, 0)->setBackground(QColor(Qt::yellow)); + + ui->tableActive->setItem(row_i, 1, new QTableWidgetItem(query.value(0).toString())); + ui->tableActive->item(row_i, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + if (flag==1) + ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::red)); + if (flag==2) + ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::green)); + if (flag==3) + ui->tableActive->item(row_i, 1)->setBackground(QColor(Qt::yellow)); + + ui->tableActive->setItem(row_i, 2, new QTableWidgetItem(query.value(1).toString())); + ui->tableActive->item(row_i, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + if (flag==1) + ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::red)); + if (flag==2) + ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::green)); + if (flag==3) + ui->tableActive->item(row_i, 2)->setBackground(QColor(Qt::yellow)); + + ui->tableActive->setItem(row_i, 3, new QTableWidgetItem(query.value(2).toString())); + ui->tableActive->item(row_i, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + if (flag==1) + ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::red)); + if (flag==2) + ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::green)); + if (flag==3) + ui->tableActive->item(row_i, 3)->setBackground(QColor(Qt::yellow)); + + if (for_bank==4 || for_bank==5) + { + ui->tableActive->setItem(row_i, 4, new QTableWidgetItem(QString::number(setting->value("min_zp").toDouble(), 'f', 2))); + }else + { + ui->tableActive->setItem(row_i, 4, new QTableWidgetItem(QString::number(list.at(i).summa.toDouble()-summa_oplat, 'f', 2))); + if (flag==1) + ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::red)); + if (flag==2) + ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::green)); + if (flag==3) + ui->tableActive->item(row_i, 4)->setBackground(QColor(Qt::yellow)); + } + + if (for_bank==4 || for_bank==5) + summa+=setting->value("min_zp").toDouble(); + else + summa+=list.at(i).summa.toDouble()-summa_oplat; + count_rec++; + } + + } + ui->tableActive->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); + ui->label_count->setText("Всего записей: "+QString::number(count_rec_sel)+" из "+QString::number(count_rec)); + ui->label_summa->setText("Всего сумма: "+QString::number(summa_sel, 'f', 2)+" из "+QString::number(summa, 'f', 2)); +} + +void MainForm::on_action_export_triggered() +{ + QString str; + switch(for_bank) + { + case 0: + { + QMessageBox::information(this, "Экспорт списка", "Не известно для какого банка делать экспорт!"); + return; + } + case 1: + { + str = "БеларусБанк.txt"; + break; + } + case 2: + { + str = "БелАгроПромБанк.txt"; + break; + } + case 3: + { + str = "ПриорБанк.txt"; + break; + } + case 4: + { + str = "МинЗПБеларусБанк.txt"; + break; + } + case 5: + { + str = "МинЗПБелАгроПромБанк.txt"; + break; + } + } + QString filename = QFileDialog::getSaveFileName(this, "Экспорт списка", "out/"+str, "Список (*.txt)"); + if (filename=="") + return; + QFile f(filename); + if (!f.open(QIODevice::WriteOnly)) + { + QMessageBox::information(this, "Экспорт списка", "Не удаеться создать файл!"); + return; + } + QTextStream stream(&f); + int count_record = 0; + double summa = 0; + switch(for_bank) + { + case 1: + { + QString query_string = "INSERT INTO archiv ([date], name, summa) " + "VALUES ('"+QDate::currentDate().toString("dd.MM.yyyy")+"', 'БеларусБанк список на зачисление', 0);"; + //qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + stream<tableActive->item(i, 2)->text()<<" " + <tableActive->item(i, 3)->text()<<" " + <tableActive->item(i, 4)->text()<<" " + <tableActive->item(i, 1)->text() + <<"\r\n"; + count_record++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + + query_string = "SELECT id FROM schet WHERE kod='"+ + ui->tableActive->item(i, 2)->text()+ + "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; + //qDebug()<tableActive->item(i, 4)->text()+");"; + qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + stream<tableActive->item(i, 2)->text()<<"," + <tableActive->item(i, 3)->text()<<"," + <tableActive->item(i, 1)->text()<<"," + <tableActive->item(i, 4)->text() + <<"\r\n"; + count_record++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + + query_string = "SELECT id FROM schet WHERE kod='"+ + ui->tableActive->item(i, 2)->text()+ + "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; + //qDebug()<tableActive->item(i, 4)->text()+");"; + qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + stream<tableActive->item(i, 2)->text()<<"," + <tableActive->item(i, 3)->text()<<"," + <tableActive->item(i, 1)->text()<<"," + <tableActive->item(i, 4)->text() + <<"\r\n"; + count_record++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + + query_string = "SELECT id FROM schet WHERE kod='"+ + ui->tableActive->item(i, 2)->text()+ + "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; + //qDebug()<tableActive->item(i, 4)->text()+");"; + qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + stream<tableActive->item(i, 2)->text()<<" " + <tableActive->item(i, 3)->text()<<" " + <tableActive->item(i, 4)->text()<<" " + <tableActive->item(i, 1)->text() + <<"\r\n"; + count_record++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + + query_string = "SELECT id FROM schet WHERE kod='"+ + ui->tableActive->item(i, 2)->text()+ + "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; + //qDebug()<tableActive->item(i, 4)->text()+");"; + qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + stream<tableActive->item(i, 2)->text()<<"," + <tableActive->item(i, 3)->text()<<"," + <tableActive->item(i, 1)->text()<<"," + <tableActive->item(i, 4)->text() + <<"\r\n"; + count_record++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + + query_string = "SELECT id FROM schet WHERE kod='"+ + ui->tableActive->item(i, 2)->text()+ + "' AND schet='"+ui->tableActive->item(i, 3)->text()+"';"; + //qDebug()<tableActive->item(i, 4)->text()+");"; + qDebug()<tableActive->rowCount(); i++) + { + if (ui->tableActive->item(i, 0)->checkState()==Qt::Checked) + { + summa_sel+=ui->tableActive->item(i, 4)->text().toDouble(); + count_rec_sel++; + } + count_rec++; + summa+=ui->tableActive->item(i, 4)->text().toDouble(); + } + ui->label_count->setText("Всего записей: "+QString::number(count_rec_sel)+" из "+QString::number(count_rec)); + ui->label_summa->setText("Всего сумма: "+QString::number(summa_sel, 'f', 2)+" из "+QString::number(summa, 'f', 2)); +} + +void MainForm::on_action_triggered() +{ + AboutForm f; + f.exec(); +} + +void MainForm::on_tabWidget_currentChanged(int index) +{ + switch(index) + { + case 0: + { + ui->action_add_record->setEnabled(true); + ui->action_del_record->setEnabled(true); + ui->action_import->setEnabled(true); + ui->action_export->setEnabled(true); + ui->action_new->setEnabled(true); + + ui->action_del_archiv->setEnabled(false); + ui->action_del_all_archiv->setEnabled(false); + + break; + } + case 1: + { + ui->action_add_record->setEnabled(false); + ui->action_del_record->setEnabled(false); + ui->action_import->setEnabled(false); + ui->action_export->setEnabled(false); + ui->action_new->setEnabled(false); + + ui->action_del_archiv->setEnabled(true); + ui->action_del_all_archiv->setEnabled(true); + PrintArchiv(); + break; + } + } +} + +void MainForm::on_tableArchiv_clicked(const QModelIndex &index) +{ + QString id =""; + QTableWidgetItem* item = 0; + item = ui->tableArchiv->item(index.row(), 0); + if (item!=0) + { + id = item->text(); + if (id!="" && id.toInt()!=0) + PrintArchivData(id); + } + //qDebug()<<"PrintArchivData() id="<tableArchiv->currentItem(); + if (item==0) + { + QMessageBox::about(this, "Удаление записи", "Необходимо выбрать запись для удаления!"); + return; + } + id = ui->tableArchiv->item(item->row(), 0)->text(); + if (id!="" && id.toInt()!=0) + { + if (QMessageBox::question(this, "Удаление записи", "Вы уверены что хотите удалить запись?")==QMessageBox::Yes) + { + QString query_string = "DELETE FROM archiv WHERE id="+id+";"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + PrintArchiv(); + ui->tableArchivData->setRowCount(0); + } + } +} + +void MainForm::on_action_del_record_triggered() +{ + QTableWidgetItem* item = 0; + item = ui->tableActive->currentItem(); + if (item==0) + { + QMessageBox::about(this, "Удаление записи", "Необходимо выбрать запись для удаления!"); + return; + } + if (QMessageBox::question(this, "Удаление записи", "Вы уверены что ходите удалить запись?")==QMessageBox::Yes) + { + ui->tableActive->removeRow(item->row()); + QModelIndex index; + this->on_tableActive_clicked(index); + } +} + +void MainForm::on_action_add_record_triggered() +{ + insert_form->Init(); + insert_form->exec(); +} + +void MainForm::on_add_record(QString id_persona, QString id_bank, QString summa) +{ + QString query_string = "SELECT persona.fio, schet.kod, schet.schet " + "FROM persona INNER JOIN schet ON persona.id = schet.id_persona " + "WHERE schet.id_bank="+id_bank+" AND schet.id_persona="+id_persona+";"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + if (query.isSelect()) + query.first(); + if (query.isValid()) + { + int row = ui->tableActive->rowCount(); + ui->tableActive->insertRow(row); + + ui->tableActive->setItem(row, 0, new QTableWidgetItem()); + ui->tableActive->item(row, 0)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); + ui->tableActive->item(row, 0)->setCheckState(Qt::Unchecked); + + ui->tableActive->setItem(row, 1, new QTableWidgetItem(query.value(0).toString())); + ui->tableActive->item(row, 1)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableActive->setItem(row, 2, new QTableWidgetItem(query.value(1).toString())); + ui->tableActive->item(row, 2)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableActive->setItem(row, 3, new QTableWidgetItem(query.value(2).toString())); + ui->tableActive->item(row, 3)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); + + ui->tableActive->setItem(row, 4, new QTableWidgetItem(summa)); + } + QModelIndex index; + this->on_tableActive_clicked(index); +} + +void MainForm::on_action_new_triggered() +{ + ui->label_bank->setText("Формирование списка для:"); + SelectImportForm f; + int bank = f.exec(); + //qDebug()<label_bank->setText("Формирование списка для: БеларусБанк"); + break; + } + case 2: + { + ui->label_bank->setText("Формирование списка для: БелАгроПромБанк"); + break; + } + } + + count_rec = count_rec_sel = summa = summa_sel = 0; + ui->tableActive->setRowCount(0); +} + +void MainForm::on_action_minimal_zp_triggered() +{ + MinimalZPForm f; + f.min_zp = setting->value("min_zp").toDouble(); + int flag = f.exec(); + if (flag!=-1) + setting->setValue("min_zp", f.min_zp); +} + +void MainForm::on_action_del_all_archiv_triggered() +{ + + if (QMessageBox::question(this, "Удаление всех записей", "Вы уверены что хотите удалить все записи?")==QMessageBox::Yes) + { + QString query_string = "DELETE FROM archiv;"; + QSqlQuery query(QSqlDatabase::database()); + if (!query.exec(query_string)) + { + QMessageBox::warning(this, "Ошибка запроса", query.lastError().text()); + return; + } + PrintArchiv(); + ui->tableArchivData->setRowCount(0); + } +} diff --git a/mainform.h b/mainform.h index c59840e..dc8a9d0 100644 --- a/mainform.h +++ b/mainform.h @@ -1,80 +1,80 @@ -#ifndef MAINFORM_H -#define MAINFORM_H - -#include -#include -#include -#include -#include -#include -#include - -#include "bankform.h" -#include "personform.h" -#include "selectimportform.h" -#include "insertactiveform.h" -#include "minimalzpform.h" -#include "aboutform.h" -#include "parser.h" - -namespace Ui { -class MainForm; -} - -class MainForm : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainForm(QWidget *parent = 0); - ~MainForm(); - void PrintArchiv(); - void PrintArchivData(QString id); - void Clear(QTableWidget* table); - -private slots: - void on_add_record(QString id_persona, QString id_bank, QString summa); - - void on_header_clicked(int index, Qt::SortOrder asc); - - void on_action_bank_triggered(); - - void on_action_persona_triggered(); - - void on_action_import_triggered(); - - void on_action_export_triggered(); - - void on_tableActive_clicked(const QModelIndex &index); - - void on_action_triggered(); - - void on_tabWidget_currentChanged(int index); - - void on_tableArchiv_clicked(const QModelIndex &index); - - void on_action_del_archiv_triggered(); - - void on_action_del_record_triggered(); - - void on_action_add_record_triggered(); - - void on_action_new_triggered(); - - void on_action_minimal_zp_triggered(); - - void on_action_del_all_archiv_triggered(); - -private: - Ui::MainForm *ui; - BankForm* bank_form; - PersonForm* persona_form; - InsertActiveForm* insert_form; - Parser* parser; - int for_bank; - int count_rec, count_rec_sel; - long long int summa, summa_sel; - QSettings* setting; -}; - -#endif // MAINFORM_H +#ifndef MAINFORM_H +#define MAINFORM_H + +#include +#include +#include +#include +#include +#include +#include + +#include "bankform.h" +#include "personform.h" +#include "selectimportform.h" +#include "insertactiveform.h" +#include "minimalzpform.h" +#include "aboutform.h" +#include "parser.h" + +namespace Ui { +class MainForm; +} + +class MainForm : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainForm(QWidget *parent = 0); + ~MainForm(); + void PrintArchiv(); + void PrintArchivData(QString id); + void Clear(QTableWidget* table); + +private slots: + void on_add_record(QString id_persona, QString id_bank, QString summa); + + void on_header_clicked(int index, Qt::SortOrder asc); + + void on_action_bank_triggered(); + + void on_action_persona_triggered(); + + void on_action_import_triggered(); + + void on_action_export_triggered(); + + void on_tableActive_clicked(const QModelIndex &index); + + void on_action_triggered(); + + void on_tabWidget_currentChanged(int index); + + void on_tableArchiv_clicked(const QModelIndex &index); + + void on_action_del_archiv_triggered(); + + void on_action_del_record_triggered(); + + void on_action_add_record_triggered(); + + void on_action_new_triggered(); + + void on_action_minimal_zp_triggered(); + + void on_action_del_all_archiv_triggered(); + +private: + Ui::MainForm *ui; + BankForm* bank_form; + PersonForm* persona_form; + InsertActiveForm* insert_form; + Parser* parser; + int for_bank; + int count_rec, count_rec_sel; + double summa, summa_sel; + QSettings* setting; +}; + +#endif // MAINFORM_H diff --git a/mainform.ui b/mainform.ui index 980cb09..3e5d663 100644 --- a/mainform.ui +++ b/mainform.ui @@ -1,331 +1,331 @@ - - - MainForm - - - - 0 - 0 - 710 - 472 - - - - ParserZP 1.0.4 - - - - - - - - 10 - - - - Формирование списка для: - - - - - - - 0 - - - - Активный список - - - - - - QAbstractScrollArea::AdjustToContents - - - - Флаг - - - - - ФИО - - - - - Код вклада - - - - - Лицевой счет - - - - - Сумма - - - - - - - - - - - 10 - - - - Всего записей: - - - - - - - - 10 - - - - Всего сумма: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Архив списков - - - - - - Qt::Vertical - - - - - id - - - - - Дата - - - - - Наименование - - - - - Сумма - - - - - - - ФИО - - - - - Код вклада - - - - - Лицевой счет - - - - - Сумма - - - - - - - - - - - - - - - 0 - 0 - 710 - 20 - - - - - Справочники - - - - - - - - Действия - - - - - - - - - - - - - - - - О программе - - - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - - - - - toolBar_2 - - - TopToolBarArea - - - false - - - - - - - Лицевые счета сотрудников - - - - - Банки - - - - - - :/ico/import.png:/ico/import.png - - - Импорт из файла - - - Импорт из файла - - - - - - :/ico/export.png:/ico/export.png - - - Экспорт - - - - - Информация - - - - - - :/ico/add.png:/ico/add.png - - - Добавить запись - - - - - - :/ico/delete.png:/ico/delete.png - - - Удалить запись - - - - - - :/ico/delete_dop.png:/ico/delete_dop.png - - - Удалить из архива - - - - - - :/ico/new.png:/ico/new.png - - - Новый пустой - - - - - Минимальная заработная плата - - - - - - :/ico/cross.png:/ico/cross.png - - - Удалить все из архива - - - - - - - - - + + + MainForm + + + + 0 + 0 + 710 + 472 + + + + ParserZP 1.0.5 + + + + + + + + 10 + + + + Формирование списка для: + + + + + + + 0 + + + + Активный список + + + + + + QAbstractScrollArea::AdjustToContents + + + + Флаг + + + + + ФИО + + + + + Код вклада + + + + + Лицевой счет + + + + + Сумма + + + + + + + + + + + 10 + + + + Всего записей: + + + + + + + + 10 + + + + Всего сумма: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Архив списков + + + + + + Qt::Vertical + + + + + id + + + + + Дата + + + + + Наименование + + + + + Сумма + + + + + + + ФИО + + + + + Код вклада + + + + + Лицевой счет + + + + + Сумма + + + + + + + + + + + + + + + 0 + 0 + 710 + 21 + + + + + Справочники + + + + + + + + Действия + + + + + + + + + + + + + + + + О программе + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + + + toolBar_2 + + + TopToolBarArea + + + false + + + + + + + Лицевые счета сотрудников + + + + + Банки + + + + + + :/ico/import.png:/ico/import.png + + + Импорт из файла + + + Импорт из файла + + + + + + :/ico/export.png:/ico/export.png + + + Экспорт + + + + + Информация + + + + + + :/ico/add.png:/ico/add.png + + + Добавить запись + + + + + + :/ico/delete.png:/ico/delete.png + + + Удалить запись + + + + + + :/ico/delete_dop.png:/ico/delete_dop.png + + + Удалить из архива + + + + + + :/ico/new.png:/ico/new.png + + + Новый пустой + + + + + Минимальная заработная плата + + + + + + :/ico/cross.png:/ico/cross.png + + + Удалить все из архива + + + + + + + + + diff --git a/minimalzpform.cpp b/minimalzpform.cpp index 54e66d6..4cfc475 100644 --- a/minimalzpform.cpp +++ b/minimalzpform.cpp @@ -1,34 +1,34 @@ -#include "minimalzpform.h" -#include "ui_minimalzpform.h" - -MinimalZPForm::MinimalZPForm(QWidget *parent) : - QDialog(parent), - ui(new Ui::MinimalZPForm) -{ - ui->setupUi(this); -} - -MinimalZPForm::~MinimalZPForm() -{ - delete ui; -} - -void MinimalZPForm::on_pushButton_2_clicked() -{ - this->done(-1); -} - -void MinimalZPForm::on_pushButton_clicked() -{ - bool flag = false; - this->min_zp = ui->lineEdit->text().toInt(&flag); - if (flag==false) - QMessageBox::warning(this, "Ошибка", "Невозможно преобразовать в число!"); - else - this->done(1); -} - -void MinimalZPForm::showEvent(QShowEvent *event) -{ - ui->lineEdit->setText(QString::number(this->min_zp)); -} +#include "minimalzpform.h" +#include "ui_minimalzpform.h" + +MinimalZPForm::MinimalZPForm(QWidget *parent) : + QDialog(parent), + ui(new Ui::MinimalZPForm) +{ + ui->setupUi(this); +} + +MinimalZPForm::~MinimalZPForm() +{ + delete ui; +} + +void MinimalZPForm::on_pushButton_2_clicked() +{ + this->done(-1); +} + +void MinimalZPForm::on_pushButton_clicked() +{ + bool flag = false; + this->min_zp = ui->lineEdit->text().toDouble(&flag); + if (flag==false) + QMessageBox::warning(this, "Ошибка", "Невозможно преобразовать в число!"); + else + this->done(1); +} + +void MinimalZPForm::showEvent(QShowEvent *event) +{ + ui->lineEdit->setText(QString::number(this->min_zp)); +} diff --git a/minimalzpform.h b/minimalzpform.h index 8ee0076..a021d9a 100644 --- a/minimalzpform.h +++ b/minimalzpform.h @@ -1,30 +1,30 @@ -#ifndef MINIMALZPFORM_H -#define MINIMALZPFORM_H - -#include -#include - -namespace Ui { -class MinimalZPForm; -} - -class MinimalZPForm : public QDialog -{ - Q_OBJECT - -public: - explicit MinimalZPForm(QWidget *parent = 0); - ~MinimalZPForm(); - void showEvent(QShowEvent *event); - int min_zp; - -private slots: - void on_pushButton_2_clicked(); - - void on_pushButton_clicked(); - -private: - Ui::MinimalZPForm *ui; -}; - -#endif // MINIMALZPFORM_H +#ifndef MINIMALZPFORM_H +#define MINIMALZPFORM_H + +#include +#include + +namespace Ui { +class MinimalZPForm; +} + +class MinimalZPForm : public QDialog +{ + Q_OBJECT + +public: + explicit MinimalZPForm(QWidget *parent = 0); + ~MinimalZPForm(); + void showEvent(QShowEvent *event); + double min_zp; + +private slots: + void on_pushButton_2_clicked(); + + void on_pushButton_clicked(); + +private: + Ui::MinimalZPForm *ui; +}; + +#endif // MINIMALZPFORM_H diff --git a/minimalzpform.ui b/minimalzpform.ui index c1a5c01..f931446 100644 --- a/minimalzpform.ui +++ b/minimalzpform.ui @@ -1,83 +1,83 @@ - - - MinimalZPForm - - - - 0 - 0 - 249 - 121 - - - - Минимальная ЗП - - - - - 40 - 20 - 169 - 41 - - - - - - - Минимальная заработная плата: - - - - - - - - - - - - 20 - 80 - 204 - 25 - - - - - - - OK - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - - Отмена - - - - - - - - - + + + MinimalZPForm + + + + 0 + 0 + 249 + 121 + + + + Минимальная ЗП + + + + + 40 + 20 + 169 + 41 + + + + + + + Минимальная заработная плата: + + + + + + + + + + + + 20 + 80 + 204 + 25 + + + + + + + OK + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + Отмена + + + + + + + + + diff --git a/parser.cpp b/parser.cpp index ce35749..b662249 100644 --- a/parser.cpp +++ b/parser.cpp @@ -1,49 +1,49 @@ -#include "parser.h" - -Parser::Parser() -{ -} - -bool Parser::Load(QString filename) -{ - list.clear(); - summa = 0; - QFile in_f(filename); - if (!in_f.open(QIODevice::ReadOnly)) - return false; - QTextStream in_text; - in_text.setDevice(&in_f); - in_text.setCodec(QTextCodec::codecForName("CP866")); - - while (!in_text.atEnd()) - { - QString tmp_str = in_text.readLine(); - if (tmp_str.size()>=3) - { - if (tmp_str.at(0)==' ' && tmp_str.at(1)=='0' && tmp_str.at(2)=='9') - { - DataRecord tmp_data; - tmp_data.fio = tmp_str.right(tmp_str.size()-3); - in_text.readLine(); - tmp_str = in_text.readLine(); - tmp_data.summa = tmp_str.right(tmp_str.size()-3); - list.append(tmp_data); - summa += tmp_data.summa.toUInt(); - //qDebug()< Parser::GetList() -{ - return list; -} - -uint Parser::GetSumma() -{ - return summa; -} +#include "parser.h" + +Parser::Parser() +{ +} + +bool Parser::Load(QString filename) +{ + list.clear(); + summa = 0; + QFile in_f(filename); + if (!in_f.open(QIODevice::ReadOnly)) + return false; + QTextStream in_text; + in_text.setDevice(&in_f); + in_text.setCodec(QTextCodec::codecForName("CP866")); + + while (!in_text.atEnd()) + { + QString tmp_str = in_text.readLine(); + if (tmp_str.size()>=3) + { + if (tmp_str.at(0)==' ' && tmp_str.at(1)=='0' && tmp_str.at(2)=='9') + { + DataRecord tmp_data; + tmp_data.fio = tmp_str.right(tmp_str.size()-3); + in_text.readLine(); + tmp_str = in_text.readLine(); + tmp_data.summa = tmp_str.right(tmp_str.size()-3); + list.append(tmp_data); + summa += tmp_data.summa.toDouble(); + //qDebug()< Parser::GetList() +{ + return list; +} + +double Parser::GetSumma() +{ + return summa; +} diff --git a/parser.h b/parser.h index 2672360..3ef5714 100644 --- a/parser.h +++ b/parser.h @@ -1,29 +1,29 @@ -#ifndef PARSER_H -#define PARSER_H - -#include -#include -#include -#include - -#include - -struct DataRecord -{ - QString fio; - QString summa; -}; - -class Parser -{ -public: - Parser(); - bool Load(QString filename); - QList GetList(); - uint GetSumma(); -private: - QList list; - uint summa; -}; - -#endif // PARSER_H +#ifndef PARSER_H +#define PARSER_H + +#include +#include +#include +#include + +#include + +struct DataRecord +{ + QString fio; + QString summa; +}; + +class Parser +{ +public: + Parser(); + bool Load(QString filename); + QList GetList(); + double GetSumma(); +private: + QList list; + double summa; +}; + +#endif // PARSER_H diff --git a/personform.cpp b/personform.cpp index 3198fc7..45566c7 100644 --- a/personform.cpp +++ b/personform.cpp @@ -1,123 +1,123 @@ -#include "personform.h" -#include "ui_personform.h" - -PersonForm::PersonForm(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::PersonForm) -{ - ui->setupUi(this); -} - -PersonForm::~PersonForm() -{ - delete ui; -} - -void PersonForm::Init() -{ - persona_model = new QSqlTableModel(this); - persona_model->setEditStrategy(QSqlTableModel::OnManualSubmit); - persona_model->setTable("persona"); - persona_model->setHeaderData(1, Qt::Horizontal, "ФИО"); - //persona_model->setSort(1, Qt::AscendingOrder); - ui->tablePersona->setModel(persona_model); - ui->tablePersona->hideColumn(0); - ui->tablePersona->connect(ui->tablePersona->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_tablePersona_changed(QModelIndex))); - persona_model->select(); - ui->tablePersona->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - - schet_model = new QSqlRelationalTableModel(this); - schet_model->setEditStrategy(QSqlTableModel::OnManualSubmit); - schet_model->setTable("schet"); - schet_model->setHeaderData(1, Qt::Horizontal, "Банк"); - schet_model->setHeaderData(2, Qt::Horizontal, "Код вклада"); - schet_model->setHeaderData(3, Qt::Horizontal, "Лицевой счет"); - schet_model->setRelation(1, QSqlRelation("bank", "id", "name")); - schet_model->relationModel(1)->setSort(1, Qt::AscendingOrder); - schet_model->relationModel(1)->select(); - //schet_model->setSort(1, Qt::AscendingOrder); - ui->tableSchet->setModel(schet_model); - ui->tableSchet->setItemDelegate(new QSqlRelationalDelegate(ui->tableSchet)); - ui->tableSchet->hideColumn(0); - ui->tableSchet->hideColumn(4); - schet_model->select(); - ui->tableSchet->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void PersonForm::on_tablePersona_changed(QModelIndex index) -{ - if (index.isValid()) - { - QSqlRecord rec = persona_model->record(index.row()); - schet_model->setFilter("id_persona="+rec.value(0).toString()); - }else - { - schet_model->setFilter("id_persona=-1"); - } - schet_model->select(); -} - -void PersonForm::on_action_exit_triggered() -{ - close(); -} - -void PersonForm::on_action_add_person_triggered() -{ - persona_model->insertRow(0); - ui->tablePersona->selectRow(0); -} - -void PersonForm::on_action_del_person_triggered() -{ - persona_model->removeRow(ui->tablePersona->currentIndex().row()); -} - -void PersonForm::on_action_save_person_triggered() -{ - if (!persona_model->submitAll()) - { - QMessageBox::information(this, "Невозможно сохранить изменения", persona_model->lastError().text()); - } - ui->tablePersona->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void PersonForm::on_action_add_schet_triggered() -{ - if (ui->tablePersona->currentIndex().row()==-1) - { - QMessageBox::information(this,"Сообщение","Добавление невозможно!\nНе выбран сотрудник"); - } - else - { - schet_model->insertRow(schet_model->rowCount()); - schet_model->setData(schet_model->index(schet_model->rowCount()-1, 4), persona_model->record(ui->tablePersona->currentIndex().row()).value("id")); - } -} - -void PersonForm::on_action_del_schet_triggered() -{ - schet_model->removeRow(ui->tableSchet->currentIndex().row()); -} - -void PersonForm::on_action_save_schet_triggered() -{ - if (!schet_model->submitAll()) - { - QMessageBox::information(this, "Невозможно сохранить изменения", schet_model->lastError().text()); - } - ui->tableSchet->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); -} - -void PersonForm::on_lineEdit_textChanged(const QString &arg1) -{ - if (ui->lineEdit->text().isEmpty()) - { - persona_model->setFilter(""); - persona_model->select(); - }else - { - persona_model->setFilter("fio like '"+ui->lineEdit->text()+"%'"); - persona_model->select(); - } -} +#include "personform.h" +#include "ui_personform.h" + +PersonForm::PersonForm(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::PersonForm) +{ + ui->setupUi(this); +} + +PersonForm::~PersonForm() +{ + delete ui; +} + +void PersonForm::Init() +{ + persona_model = new QSqlTableModel(this); + persona_model->setEditStrategy(QSqlTableModel::OnManualSubmit); + persona_model->setTable("persona"); + persona_model->setHeaderData(1, Qt::Horizontal, "ФИО"); + //persona_model->setSort(1, Qt::AscendingOrder); + ui->tablePersona->setModel(persona_model); + ui->tablePersona->hideColumn(0); + ui->tablePersona->connect(ui->tablePersona->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_tablePersona_changed(QModelIndex))); + persona_model->select(); + ui->tablePersona->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); + + schet_model = new QSqlRelationalTableModel(this); + schet_model->setEditStrategy(QSqlTableModel::OnManualSubmit); + schet_model->setTable("schet"); + schet_model->setHeaderData(1, Qt::Horizontal, "Банк"); + schet_model->setHeaderData(2, Qt::Horizontal, "Код вклада"); + schet_model->setHeaderData(3, Qt::Horizontal, "Лицевой счет"); + schet_model->setRelation(1, QSqlRelation("bank", "id", "name")); + schet_model->relationModel(1)->setSort(1, Qt::AscendingOrder); + schet_model->relationModel(1)->select(); + //schet_model->setSort(1, Qt::AscendingOrder); + ui->tableSchet->setModel(schet_model); + ui->tableSchet->setItemDelegate(new QSqlRelationalDelegate(ui->tableSchet)); + ui->tableSchet->hideColumn(0); + ui->tableSchet->hideColumn(4); + schet_model->select(); + ui->tableSchet->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void PersonForm::on_tablePersona_changed(QModelIndex index) +{ + if (index.isValid()) + { + QSqlRecord rec = persona_model->record(index.row()); + schet_model->setFilter("id_persona="+rec.value(0).toString()); + }else + { + schet_model->setFilter("id_persona=-1"); + } + schet_model->select(); +} + +void PersonForm::on_action_exit_triggered() +{ + close(); +} + +void PersonForm::on_action_add_person_triggered() +{ + persona_model->insertRow(0); + ui->tablePersona->selectRow(0); +} + +void PersonForm::on_action_del_person_triggered() +{ + persona_model->removeRow(ui->tablePersona->currentIndex().row()); +} + +void PersonForm::on_action_save_person_triggered() +{ + if (!persona_model->submitAll()) + { + QMessageBox::information(this, "Невозможно сохранить изменения", persona_model->lastError().text()); + } + ui->tablePersona->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void PersonForm::on_action_add_schet_triggered() +{ + if (ui->tablePersona->currentIndex().row()==-1) + { + QMessageBox::information(this,"Сообщение","Добавление невозможно!\nНе выбран сотрудник"); + } + else + { + schet_model->insertRow(schet_model->rowCount()); + schet_model->setData(schet_model->index(schet_model->rowCount()-1, 4), persona_model->record(ui->tablePersona->currentIndex().row()).value("id")); + } +} + +void PersonForm::on_action_del_schet_triggered() +{ + schet_model->removeRow(ui->tableSchet->currentIndex().row()); +} + +void PersonForm::on_action_save_schet_triggered() +{ + if (!schet_model->submitAll()) + { + QMessageBox::information(this, "Невозможно сохранить изменения", schet_model->lastError().text()); + } + ui->tableSchet->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); +} + +void PersonForm::on_lineEdit_textChanged(const QString &arg1) +{ + if (ui->lineEdit->text().isEmpty()) + { + persona_model->setFilter(""); + persona_model->select(); + }else + { + persona_model->setFilter("fio like '"+ui->lineEdit->text()+"%'"); + persona_model->select(); + } +} diff --git a/personform.h b/personform.h index da966c5..d33139f 100644 --- a/personform.h +++ b/personform.h @@ -1,50 +1,50 @@ -#ifndef PERSONFORM_H -#define PERSONFORM_H - -#include -#include -#include -#include -#include -#include -#include - -namespace Ui { -class PersonForm; -} - -class PersonForm : public QMainWindow -{ - Q_OBJECT - -public: - explicit PersonForm(QWidget *parent = 0); - ~PersonForm(); - void Init(); - -private slots: - void on_tablePersona_changed(QModelIndex index); - - void on_action_exit_triggered(); - - void on_action_add_person_triggered(); - - void on_action_del_person_triggered(); - - void on_action_save_person_triggered(); - - void on_action_add_schet_triggered(); - - void on_action_del_schet_triggered(); - - void on_action_save_schet_triggered(); - - void on_lineEdit_textChanged(const QString &arg1); - -private: - Ui::PersonForm *ui; - QSqlTableModel* persona_model; - QSqlRelationalTableModel* schet_model; -}; - -#endif // PERSONFORM_H +#ifndef PERSONFORM_H +#define PERSONFORM_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class PersonForm; +} + +class PersonForm : public QMainWindow +{ + Q_OBJECT + +public: + explicit PersonForm(QWidget *parent = 0); + ~PersonForm(); + void Init(); + +private slots: + void on_tablePersona_changed(QModelIndex index); + + void on_action_exit_triggered(); + + void on_action_add_person_triggered(); + + void on_action_del_person_triggered(); + + void on_action_save_person_triggered(); + + void on_action_add_schet_triggered(); + + void on_action_del_schet_triggered(); + + void on_action_save_schet_triggered(); + + void on_lineEdit_textChanged(const QString &arg1); + +private: + Ui::PersonForm *ui; + QSqlTableModel* persona_model; + QSqlRelationalTableModel* schet_model; +}; + +#endif // PERSONFORM_H diff --git a/personform.ui b/personform.ui index 8cb29f9..d55c845 100644 --- a/personform.ui +++ b/personform.ui @@ -1,179 +1,179 @@ - - - PersonForm - - - Qt::WindowModal - - - - 0 - 0 - 647 - 423 - - - - Лицевые счета сотрудников - - - - - - - - - Поиск: - - - - - - - - - - - - Qt::Vertical - - - - QAbstractScrollArea::AdjustToContents - - - true - - - - - QAbstractScrollArea::AdjustToContents - - - true - - - - - - - - - - 0 - 0 - 647 - 20 - - - - - Действия - - - - - - - - - - - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - - - toolBar_2 - - - TopToolBarArea - - - false - - - - - - - - - :/ico/add.png:/ico/add.png - - - Добавить сотрудника - - - - - - :/ico/delete.png:/ico/delete.png - - - Удалить сотрудника - - - - - - :/ico/save.png:/ico/save.png - - - Сохранить всех сотрудников - - - - - - :/ico/add_dop.png:/ico/add_dop.png - - - Добавить лицевой счет - - - - - - :/ico/delete_dop.png:/ico/delete_dop.png - - - Удалить лицевой счет - - - - - - :/ico/save.png:/ico/save.png - - - Сохранить все лицевые счета - - - - - Выход - - - - - - - - + + + PersonForm + + + Qt::WindowModal + + + + 0 + 0 + 647 + 423 + + + + Лицевые счета сотрудников + + + + + + + + + Поиск: + + + + + + + + + + + + Qt::Vertical + + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + + + + + + 0 + 0 + 647 + 20 + + + + + Действия + + + + + + + + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + + + toolBar_2 + + + TopToolBarArea + + + false + + + + + + + + + :/ico/add.png:/ico/add.png + + + Добавить сотрудника + + + + + + :/ico/delete.png:/ico/delete.png + + + Удалить сотрудника + + + + + + :/ico/save.png:/ico/save.png + + + Сохранить всех сотрудников + + + + + + :/ico/add_dop.png:/ico/add_dop.png + + + Добавить лицевой счет + + + + + + :/ico/delete_dop.png:/ico/delete_dop.png + + + Удалить лицевой счет + + + + + + :/ico/save.png:/ico/save.png + + + Сохранить все лицевые счета + + + + + Выход + + + + + + + + diff --git a/selectimportform.cpp b/selectimportform.cpp index 36c86df..8ab92e5 100644 --- a/selectimportform.cpp +++ b/selectimportform.cpp @@ -1,24 +1,24 @@ -#include "selectimportform.h" -#include "ui_selectimportform.h" - -SelectImportForm::SelectImportForm(QWidget *parent) : - QDialog(parent), - ui(new Ui::SelectImportForm) -{ - ui->setupUi(this); -} - -SelectImportForm::~SelectImportForm() -{ - delete ui; -} - -void SelectImportForm::on_pushButton_2_clicked() -{ - this->done(0); -} - -void SelectImportForm::on_pushButton_clicked() -{ - this->done(ui->comboBox->currentIndex()+1); -} +#include "selectimportform.h" +#include "ui_selectimportform.h" + +SelectImportForm::SelectImportForm(QWidget *parent) : + QDialog(parent), + ui(new Ui::SelectImportForm) +{ + ui->setupUi(this); +} + +SelectImportForm::~SelectImportForm() +{ + delete ui; +} + +void SelectImportForm::on_pushButton_2_clicked() +{ + this->done(0); +} + +void SelectImportForm::on_pushButton_clicked() +{ + this->done(ui->comboBox->currentIndex()+1); +} diff --git a/selectimportform.h b/selectimportform.h index 344d271..a8a50aa 100644 --- a/selectimportform.h +++ b/selectimportform.h @@ -1,27 +1,27 @@ -#ifndef SELECTIMPORTFORM_H -#define SELECTIMPORTFORM_H - -#include - -namespace Ui { -class SelectImportForm; -} - -class SelectImportForm : public QDialog -{ - Q_OBJECT - -public: - explicit SelectImportForm(QWidget *parent = 0); - ~SelectImportForm(); - -private slots: - void on_pushButton_2_clicked(); - - void on_pushButton_clicked(); - -private: - Ui::SelectImportForm *ui; -}; - -#endif // SELECTIMPORTFORM_H +#ifndef SELECTIMPORTFORM_H +#define SELECTIMPORTFORM_H + +#include + +namespace Ui { +class SelectImportForm; +} + +class SelectImportForm : public QDialog +{ + Q_OBJECT + +public: + explicit SelectImportForm(QWidget *parent = 0); + ~SelectImportForm(); + +private slots: + void on_pushButton_2_clicked(); + + void on_pushButton_clicked(); + +private: + Ui::SelectImportForm *ui; +}; + +#endif // SELECTIMPORTFORM_H diff --git a/selectimportform.ui b/selectimportform.ui index 233fd9f..f6c5764 100644 --- a/selectimportform.ui +++ b/selectimportform.ui @@ -1,106 +1,106 @@ - - - SelectImportForm - - - - 0 - 0 - 304 - 114 - - - - Выбор банка - - - - - 10 - 10 - 281 - 41 - - - - - - - Для какого банка формируеться список: - - - - - - - - БеларусБанк - - - - - БелАгроПромБанк - - - - - ПриорБанк - - - - - Минимальная ЗП БеларусБанк - - - - - Минимальная ЗП БелАгроПромБанк - - - - - - - - - - 40 - 70 - 204 - 25 - - - - - - - OK - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Отмена - - - - - - - - - + + + SelectImportForm + + + + 0 + 0 + 304 + 114 + + + + Выбор банка + + + + + 10 + 10 + 281 + 41 + + + + + + + Для какого банка формируеться список: + + + + + + + + БеларусБанк + + + + + БелАгроПромБанк + + + + + ПриорБанк + + + + + Минимальная ЗП БеларусБанк + + + + + Минимальная ЗП БелАгроПромБанк + + + + + + + + + + 40 + 70 + 204 + 25 + + + + + + + OK + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Отмена + + + + + + + + + diff --git a/version.txt b/version.txt index 9401cf2..b9bbb62 100644 --- a/version.txt +++ b/version.txt @@ -1,25 +1,31 @@ -======================================================================= -v1.0.1 -- ; -- , ; -- . - -======================================================================= -v1.0.2 -- (); -- ; -- ; -- (). - -======================================================================= -v1.0.3 -- ; -- (); -- " ". - -======================================================================= -v1.0.4 -- ; -- ; -- ; -- , . +======================================================================= +v1.0.1 +- ; +- , ; +- . + +======================================================================= +v1.0.2 +- (); +- ; +- ; +- (). + +======================================================================= +v1.0.3 +- ; +- (); +- " ". + +======================================================================= +v1.0.4 +- ; +- ; +- ; +- , . +======================================================================= +v1.0.5 +- , 2 ; +- database.mdb; +- archiv, summa - double; +- archive_data, summa - double.