Beispiel #1
0
bool Registration::checkLogin()
{
    QSqlQuery zapytanie("SELECT login FROM users WHERE login = '******';");
    if(zapytanie.numRowsAffected() != 0 || ui->edit_login->text().length() == 0 )
    {
        ui->edit_login->setStyleSheet("QLineEdit{ background-color: qlineargradient(spread:repeat, x1:0.346, y1:0, x2:0.359, y2:1, stop:0 rgba(255, 0, 0, 183), stop:1 rgba(255, 255, 255, 255));}");
        return false;
    }
    else
    {
        ui->edit_login->setStyleSheet("QLineEdit{ background-color: qlineargradient(spread:repeat, x1:0.346, y1:0, x2:0.359, y2:1, stop:0 rgba(138, 255, 0, 183), stop:1 rgba(255, 255, 255, 255));}");
        return true;
    }   
}
Beispiel #2
0
void OknoLogowania::ustawDane()
{
    ui->wyborProfilu->clear();
    QSqlDatabase bazaDanych = QSqlDatabase::addDatabase("QSQLITE");
    bazaDanych.setDatabaseName(this->nazwaBazy);

    bazaDanych.open();
    {
        QSqlQuery zapytanie("select ID, nazwa from profil order by nazwa asc");
        while(zapytanie.next())
        {
            ui->wyborProfilu->addItem(zapytanie.value(1).toString(), QVariant(zapytanie.value(0).toString()));
        }
    }
    bazaDanych.close();
}
Beispiel #3
0
void Registration::rejestruj()
{
    if(checkLogin() && checkEmail() && passwdCmp())
    {
        QByteArray haslo = ui->edit_haslo->text().toUtf8();
        QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Md5);
        hash->addData(haslo);
        QSqlQuery zapytanie("INSERT INTO users(login, password, email) VALUES ('"+ ui->edit_login->text()+"','"+hash->result().toHex()+"','"+ui->edit_email->text()+"');");
        this->close();
        if(zapytanie.numRowsAffected()!=0)
        {
            QMessageBox::information(0,"rejestracja","dodano nowego uzytkownika\n zalogowano automatycznie");
            Wydatnik::getInstance()->zaloguj(ui->edit_login->text(),hash->result().toHex());
        }
        else
        {
            QMessageBox::warning(0,"rejestracja","rejestracja nie powiodla sie");
        }
    }
    else
        Wydatnik::getInstance()->Error("Podano niepoprawne dane");
}