ChangPassword::ChangPassword(QString username,QWidget *parent) : QDialog(parent), ui(new Ui::ChangPassword) { ui->setupUi(this); Username=username; connOpen(); }
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()); } } }
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); }
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(); }
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 }
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 } } }
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(); } }
studentinfo::studentinfo(QString Name,QWidget *parent) : QDialog(parent), ui(new Ui::studentinfo) { ui->setupUi(this); Username=Name; if(!connOpen()) ui->label_stu_status->setText("Failed to open the database!"); else ui->label_stu_status->setText("Connected....."); // show the name of student ui->label_name->setText(Name); // display the status of booking displaysBookingStatus(); // display the date that is available for book display_main(); }
void Settings::on_changepass_clicked() { connOpen(); QString Login, Loginf, Password, Password2, Passwordf; Login=ui->lineEdit_log->text(); Loginf=ui->lineEdit_ylog->text(); Password=ui->lineEdit_pass->text(); Password2=ui->lineEdit_pass_2->text(); Passwordf=ui->lineEdit_ypass->text(); connOpen(); if(!prtf.isOpen()) { qDebug()<<"Failed to open the database"; } // Change user page if(Login.size() < 1) { ui->label_mesch->setText("Enter your new login"); } if(Loginf.size() < 1) { ui->label_mesch->setText("Enter your primary login"); } else if(Password.size() < 1) { ui->label_mesch->setText("Enter your new password"); } else if(Password2.size() < 1) { ui->label_mesch->setText("Enter your new password again"); } else if(Passwordf.size() < 1) { ui->label_mesch->setText("Enter your primary password"); } else { QSqlQuery qry; qry.prepare("select * from prtf where Login='******' and Password='******'"); if(qry.exec()) { if(Password2 == Password) { QSqlQuery qry; qry.prepare("update prtf set Login = '******', Password = '******' where Login = '******' and Password = '******'"); if(qry.exec()) { ui->label_mesch->setText("Your login and password successfully changed"); } else { QMessageBox::critical(this, tr("Error::"), qry.lastError().text()); } } else { ui->label_mesch->setText("Incorrect password"); } } else { ui->label_mesch->setText("Your primary login or primary password is not correct"); } } }
void MainWindow::on_pushButton_clicked() { /*LOGIN*/ customerLog logFile; QString usernameIn, passwordIn; usernameIn = ui->lineEdit->text(); passwordIn = ui->lineEdit_2->text(); /*Store user input*/ connOpen(); QSqlQuery qry; qry.prepare("Select * from BANKING_CREDENTIALS where UserName='******' and Password='******'"); if(qry.exec()){ while(qry.next()){ //Initialize client client.manager = qry.value(3).toInt(); client.name = qry.value(0).toString(); client.ID = qry.value(1).toString(); client.savBal = qry.value(5).toDouble(); client.cheqBal = qry.value(4).toDouble(); client.passWord = qry.value(2).toDouble(); client.isTrail = qry.value(8).toInt(); client.maintPers = qry.value(9).toInt(); client.hasCheq = qry.value(7).toInt(); client.hasSav = qry.value(6).toInt(); qDebug()<<(qry.record()); } /*Check to see if client is a manager, customer, or maintance role and display correct view*/ MaintanenceView mv; if(client.name=="" && client.passWord =="") { ui->label->setText("Incorrect login information, try again"); //Username is wrong, password is wrong, both are wrong, and user doesn't exist.. }else if(client.manager == 0 && client.maintPers == 0){ QString action = "MAINWINDOW: CLIENT LOGGED IN"; QString role = "CLIENT"; mv.isTrail(client.isTrail, action); logFile.addClientToLog(client.name, client.ID, role); this->hide(); clientView customerLogin; customerLogin.setModal(true); customerLogin.exec(); } else if(client.maintPers == 1){ QString action = "MAINWINDOW: MAINTANECE LOGGED IN"; QString role = "MAINTANCE"; mv.isTrail(client.isTrail, action); logFile.addClientToLog(client.name, client.ID, role); this->hide(); MaintanenceView maintanceLogin; maintanceLogin.setModal(true); maintanceLogin.exec(); }else if(client.manager == 1){ QString action = "MAINWINDOW: MANAGER LOGGED IN"; QString role = "MANAGER"; mv.isTrail(client.isTrail, action); logFile.addClientToLog(client.name, client.ID, role); this->hide(); managerLogin managerlogin; managerlogin.setModal(true); managerlogin.exec(); } } }