コード例 #1
0
ファイル: studentinfo.cpp プロジェクト: ruxuebu/bookingsystem
// change password
void studentinfo::on_pushButton_resetPW_clicked()
{
    connClose();
    ChangPassword changpassword(Username);
    changpassword.setModal(true);
    changpassword.exec();
}
コード例 #2
0
void Settings::on_Delete_page_clicked()
{
    QString login, password, logcompar, pascompar, search = "1";
    login=ui->lineEdit_logdel->text();
    password=ui->lineEdit_passdel->text();

    if(!prtf.isOpen())
    {
        qDebug()<<"Failed to open the database";
    }
    connOpen();

    QSqlQuery query ("SELECT * FROM prtf where Search = '"+search+"'");

         while (query.next())
         {
         logcompar = query.value(3).toString();
         pascompar = query.value(4).toString();
         }


   if(password != pascompar)
   {
       ui->label_mesdel->setText("Password is not correct");
   }
   else if(login != logcompar)
   {
       ui->label_mesch->setText("Login is not correct");
   }
   else if(login.size() < 1)
   {
       ui->label_mesdel->setText("Enter your login");
   }
   else if(password.size() < 1)
   {
       ui->label_mesdel->setText("Enter your password");
   }
   else
   {
       QSqlQuery qry;
       qry.prepare("Delete from prtf where Login='******' and Password='******'");
        if(qry.exec())
        {
            close();
            connClose();
            //open mainwindow

        }
        else
        {
            QMessageBox::critical(this, tr("Error::"), qry.lastError().text());
        }
   }


}
コード例 #3
0
ファイル: serverskt.cpp プロジェクト: sdlylshl/sokit
void ServerSkt::setCookie(const QString& k, void* v)
{
	void* o = m_conns.value(k);
	if (o)
	{
		if (close(o))
			emit connClose(k);
	}

	m_conns.insert(k, v);
	emit connOpen(k);
}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: drasoulm/CS3307
void MainWindow::createDBFileThenTable(){ //Create Tables, if they don't exist
    QFile file("database.db");
     file.open(QIODevice::ReadWrite);
     file.close();
     connOpen();
     QSqlQuery query;
     query.exec("CREATE TABLE 'BANKING_CREDENTIALS' ('Name' TEXT, 'UserName' TEXT, 'Password' TEXT, 'Manager' INT, 'Cheq' DOUBLE, 'Sav' DOUBLE, 'SavAcct' INT, 'CheqAcct' INT, 'execTrace' INT, 'maintainence' INT)");
     query.exec("INSERT INTO BANKING_CREDENTIALS (Name,UserName,Password,Manager,Cheq,Sav,SavAcct,CheqAcct,execTrace, maintainence) VALUES ('Manager Credentials','ManagerCred','Welcome1234',1,0,0,0,0,1,0)");
     query.exec("INSERT INTO BANKING_CREDENTIALS (Name,UserName,Password,Manager,Cheq,Sav,SavAcct,CheqAcct,execTrace, maintainence) VALUES ('Client Credentials','FirstClient','Welcome1234',0,1,1,5000,5000,1,0)");
     query.exec("INSERT INTO BANKING_CREDENTIALS (Name,UserName,Password,Manager,Cheq,Sav,SavAcct,CheqAcct,execTrace, maintainence) VALUES ('Maintanence Credentials','MantanenceCred','Welcome1234',1,0,0,0,0,1,1)");
     qDebug()<<(query.lastQuery());
     query.exec("CREATE TABLE 'CLIENT_REQUEST' ('name' TEXT, 'openSav' INT, 'openCheq' INT, 'done' INT, 'date' TEXT)");
     connClose();
}
コード例 #5
0
void MainWindow::on_SearchButton_clicked()
{
    QString product;
        product = ui->searchWidget->text();

        if (!connOpen())
        {
            qDebug () << "Failed to open Database.";
        }

        bool connOpen();//open the connection with database


        QSqlQuery qry;

        qry.prepare("select * from tb_product where name = '"+product+"'");

        if (qry.exec())
        {
                int count = 0;
                while (qry.next())
                    {
                        count++;
                    }
                if (count == 1)
                {
                    qDebug () << " Product found.";

                    QSqlQueryModel * modal = new QSqlQueryModel ();
                    QSqlQuery * qry3 = new QSqlQuery(db);
                    qry3->prepare("select * from tb_product where name='"+product+"'");

                    qry3->exec();
                    modal->setQuery(*qry3);
                    ui->productTable->setModel(modal);



                }

                else
                    QMessageBox::critical(this,tr ("Error!"),tr ("Product not found."));

         }
            connClose();//close the connection with database


}
コード例 #6
0
void MainWindow::on_addButton_clicked()
{
    connOpen();//open the connection with database


        QString product;
        product = ui->searchWidget->text();

        QSqlQuery qry3;
        qry3.prepare("insert into tb_product_cart (product_fk) select id from tb_product where name='"+product+"'");
        if(qry3.exec())
        {   qDebug () <<"done1";}

        QSqlQuery qry1;
        qry1.prepare("select)");
        if(qry1.exec())
        {   qDebug () <<"done41";}

        QSqlQuery qry4;
        qry4.prepare("update tb_product_cart set quant = quant +1 order by id desc limit 1");

        if(qry4.exec())
        {   qDebug () <<"done";
            int count = 0;
            while (qry4.next())
                {
                    count++;
                }
            if (count == 1)
            {

                QSqlQuery qry5;
                qry5.prepare("select * from tb_product_cart order by id desc limit 1");
                qry5.exec();

                QSqlQueryModel * modal = new QSqlQueryModel ();
                QSqlQuery * qry7 = new QSqlQuery(db);
                qry7->prepare("select * from tb_product_cart");

                qry7->exec();
                modal->setQuery(*qry7);
                ui->orderTable->setModel(modal);

                connClose();//close the connection with database
             }
        }
}
コード例 #7
0
void Settings::on_pushButton_clicked()
{
    connOpen();
    QString searchf = "1";
    QString search = "0";

    QSqlQuery qry;
    qry.prepare("update prtf set Search = '"+search+"' where Search = '"+searchf+"'");

    if(qry.exec())
    {
        connClose();
        close();
        MainWindow signin;
        signin.show();
    }
}
コード例 #8
0
ファイル: serverskt.cpp プロジェクト: sdlylshl/sokit
void ServerSkt::stop()
{
	if (!m_started)
		return;

	OBJMAP::const_iterator i;
	for (i = m_conns.constBegin(); i != m_conns.constEnd(); ++i)
	{
		QString k = i.key();
		void* v = i.value();

		if (close(v))
			emit connClose(k);
	}

	m_conns.clear();

	close();

	show(QString("stop %1 server!").arg(name()));

	m_started = false;
}
コード例 #9
0
ファイル: serverskt.cpp プロジェクト: sdlylshl/sokit
void ServerSkt::unsetCookie(const QString& k)
{
	m_conns.remove(k);
	emit connClose(k);
}