Subversion Repositories OpenInventory

Rev

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

/************************************************************************************
** Êëàññ MySQL ñîäåðæèò ìåòîäû äëÿ ðàáîòû ñ áàçàìè äàííûõ
** MySQL class contains methods for working with databases
**
**
*************************************************************************************/







#ifndef MYSQL_H
#define MYSQL_H

#include "settingsdialog.h"
#include "tablefield.h"
#include "sqltable.h"

#include <QObject>
#include <QtGui>
#include <QMainWindow>
#include <QString>
#include <QtSql>
#include <QSqlTableModel>
#include <QTableView>
#include <QSqlDriverPlugin>
#include <QIcon>
#include <QVariant>
#include <QProcess>
#include <QByteArray>
#include <QSqlQuery>


class MySql : public QObject
{
Q_OBJECT
public:
    explicit MySql(QObject *parent = 0);
 ~MySql();
    bool connect(); // ñîåäèíåíèå ñ áàçîé äàííûõ
    bool createDataBase(); // ñîçäàåò íåîáõîäèìûå òàáëèöû â þàçå äàííûõ äëÿ õðàíåíèÿ íàçâàíèÿ è îïèñàíèÿ êëàññîâ (Òàáëèöà ListOfClasses è Òàáëèöà DescriptionOfClasses)
    bool createListOfClassesTable(); // ñîçäàåò íåîáõîäèìóþ òàáëèöó â áàçå äàííûõ äëÿ õðàíåíèÿ íàçâàíèÿ è êëàññîâ (Òàáëèöà ListOfClasses)
    bool createDescriptionOfClassesTable(); // ñîçäàåò íåîáõîäèìóþ òàáëèöó â áàçå äàííûõ äëÿ õðàíåíèÿ îïèñàíèÿ êëàññîâ (Òàáëèöà DescriptionOfClasses)
    bool createListModelsTable(); // ñîçäàåò íåîáõîäèìóþ òàáëèöó â áàçå äàííûõ äëÿ õðàíåíèÿ ìîäåëåé (Òàáëèöà ListOfModels)
signals:

public slots:

private:
    QString sqlDatabaseName; // ïåðåìåííàÿ ñîäåðæèò èìÿ áàçû äàííûõ, ñ êîòîðîé áóäåì óñòàíàâëèâàòü ñîåäèíåíèå
    QString sqlUserName; // ïåðåìåííàÿ ñîäåðæèò èìÿ ïîëüçîâàòåëÿ áàçû äàííûõ
    QString sqlPassword; // ïåðåìåííàÿ ñîäåðæèò ïàðîëü ê áàçå äàííûõ
    QString sqlHostName; // ïåðåìåííàÿ ñîäåðæèò èìÿ õîñòà, íà êîòîðîì íàõîäèòñÿ áàçà äàííûõ
    QSqlDatabase db;
    QString mysqlLastError;

protected:

public:
    void setDatabaseName(QString dbname);
    void setUserName(QString uname);
    void setPassword(QString passwrd);
    void setHostName(QString hname);
    bool createTable(SqlTable* table); // ñîçäàåò â áàçå äàííûõ òàáëèöó
    void close(); // çàêîûâàåì ñîåäèíåíèå ñ áàçîé

    QString lasError();
    QSqlError dbLastError(); // ôóíêöèÿ ôîçâðàùàåò ïîñëåäíþþ îøèáêó áàçû äàííûõ


};

#endif // MYSQL_H