#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSqlDatabase>
#include <stdio.h>
#include <QTextStream>
#include <QMessageBox>
#include <QSqlRelationalTableModel>
#include <QSqlQuery>
#include <entry.h>
#include <QRegExpValidator>
#include <QLineEdit>
#include <QValidator>
#include <QComboBox>
#include <qdebug.h>
#include <QRegExp>
#include <QValidator>
#include <QRegExpValidator>
#include <QPixmap>
#include <QPalette>
#include <QProcess>
#include <QFile>
#include <Q_INT32>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui
->lineEditpassword
->setEchoMode
(QLineEdit::Password);
ui->lineEditUsername->setMaxLength(15);
ui->lineEditpassword->setMaxLength(15);
setAutoFillBackground(true);
setPalette(p);
setWindowFlags(Qt::FramelessWindowHint);
}
void MainWindow
::changeEvent(QEvent *e
) {
db.setDatabaseName("/mnt/jffs2/venus.sqlite");
if (!db.open()) {
tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
}
bool checkquery=query.exec("create table apmc (id INTEGER PRIMARY KEY AUTOINCREMENT,username varchar(20), password password, apmc varchar(20))");
qDebug()<<checkquery;
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
db.close();
}
}
void MainWindow::on_pushButtonLogin_clicked()
{
QString UserName
= ui
->lineEditUsername
->displayText
();
QString Password
= ui
->lineEditpassword
->text
();
QString apmc
=ui
->comboBoxApmc
->currentText
();
qDebug()<<UserName.isEmpty();
qDebug()<<Password.isEmpty();
if(UserName.isEmpty())
{
}
else if(UserName.length()>=4)
{
QString s
= ui
->lineEditUsername
->displayText
();
QString s1
= s.
mid(s.
length()-4, s.
length());
qDebug()<<s1.toStdString().c_str() << "What is the value of s1";
qDebug()<<"The Value of s1 is : "<<s1;
bool ok = false;
qulonglong Integer = s1.toULongLong(&ok);
qDebug()<<"Print for me"<<Integer;
if(ok)
{
qDebug()<<"True";
}
else
{
qDebug()<<"False";
tr
("Please Enter the UserName in right format"),
QMessageBox::Cancel);
ui->lineEditUsername->clear();
ui->lineEditpassword->clear();
}
}
else if(Password.isEmpty())
{
}
else if(apmc=="None")
{
}
else
{
qDebug()<<ui->lineEditUsername->displayText();
bool check=query.exec("insert into apmc (username,password,apmc) values('" + ui->lineEditUsername->displayText() + "','" + ui->lineEditpassword->text() + "' ,'" + ui->comboBoxApmc->currentText()+"')");
qDebug()<<"insertino chekc-----------------"<<check;
msgR->setText("Inserted Successfully");
QPixmap bg
("/home/venugopal/MyQTProjects/G2G/images/G2G.jpg");
setAutoFillBackground(true);
msgR->setPalette(p);
msgR->exec();
this->close();
Entry* e=new Entry();
e->show();
}
}
void MainWindow::on_Delete_clicked()
{
system("rm -Rf /home/venugopal/sample/venu.xml");
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSqlDatabase>
#include <stdio.h>
#include <QTextStream>
#include <QMessageBox>
#include <QSqlRelationalTableModel>
#include <QSqlQuery>
#include <entry.h>
#include <QRegExpValidator>
#include <QLineEdit>
#include <QValidator>
#include <QComboBox>
#include <qdebug.h>
#include <QRegExp>
#include <QValidator>
#include <QRegExpValidator>
#include <QPixmap>
#include <QPalette>
#include <QProcess>
#include <QFile>
#include <Q_INT32>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->lineEditpassword->setEchoMode(QLineEdit::Password);
ui->lineEditUsername->setMaxLength(15);
ui->lineEditpassword->setMaxLength(15);
QPixmap bg(":/images/G2G.jpg");
QPalette p(palette());
p.setBrush(QPalette::Background, bg);
setAutoFillBackground(true);
setPalette(p);
setWindowFlags(Qt::FramelessWindowHint);
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("/mnt/jffs2/venus.sqlite");
if (!db.open()) {
QMessageBox::critical(0, tr("Cannot open database"),
tr("Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it."), QMessageBox::Cancel);
}
QSqlQuery query;
bool checkquery=query.exec("create table apmc (id INTEGER PRIMARY KEY AUTOINCREMENT,username varchar(20), password password, apmc varchar(20))");
qDebug()<<checkquery;
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
db.close();
}
}
void MainWindow::on_pushButtonLogin_clicked()
{
QSqlQuery query;
QMessageBox* msgR=new QMessageBox(this);
QString UserName = ui->lineEditUsername->displayText();
QString Password = ui->lineEditpassword->text();
QString apmc=ui->comboBoxApmc->currentText();
qDebug()<<UserName.isEmpty();
qDebug()<<Password.isEmpty();
if(UserName.isEmpty())
{
QMessageBox::critical(0, tr("UserName"),
tr("Please Enter the UserName"), QMessageBox::Cancel);
}
else if(UserName.length()>=4)
{
QString s = ui->lineEditUsername->displayText();
QString s1 = s.mid(s.length()-4, s.length());
qDebug()<<s1.toStdString().c_str() << "What is the value of s1";
qDebug()<<"The Value of s1 is : "<<s1;
bool ok = false;
qulonglong Integer = s1.toULongLong(&ok);
qDebug()<<"Print for me"<<Integer;
if(ok)
{
qDebug()<<"True";
}
else
{
qDebug()<<"False";
QMessageBox::critical(0, tr("UserName"),
tr("Please Enter the UserName in right format"), QMessageBox::Cancel);
ui->lineEditUsername->clear();
ui->lineEditpassword->clear();
}
}
else if(Password.isEmpty())
{
QMessageBox::critical(0, tr("Password"),
tr("Please Enter the Password"), QMessageBox::Cancel);
}
else if(apmc=="None")
{
QMessageBox::critical(0, tr("Apmc"),
tr("Please Enter the Apmc"), QMessageBox::Cancel);
}
else
{
qDebug()<<ui->lineEditUsername->displayText();
bool check=query.exec("insert into apmc (username,password,apmc) values('" + ui->lineEditUsername->displayText() + "','" + ui->lineEditpassword->text() + "' ,'" + ui->comboBoxApmc->currentText()+"')");
qDebug()<<"insertino chekc-----------------"<<check;
msgR->setText("Inserted Successfully");
QPixmap bg("/home/venugopal/MyQTProjects/G2G/images/G2G.jpg");
QPalette p(palette());
p.setBrush(QPalette::Background, bg);
setAutoFillBackground(true);
msgR->setPalette(p);
msgR->exec();
this->close();
Entry* e=new Entry();
e->show();
}
}
void MainWindow::on_Delete_clicked()
{
system("rm -Rf /home/venugopal/sample/venu.xml");
}
To copy to clipboard, switch view to plain text mode
Bookmarks